/* ==========================================================================
   Advanced Scientific Calculator v2
   Palette (teal + navy only):
     --mycalc-navy-900  deep navy    frame / headers
     --mycalc-navy-700  mid navy     panels / toolbar
     --mycalc-navy-500  soft navy    default key surface
     --mycalc-navy-300  pale navy    subtle borders / dividers
     --mycalc-teal-600  core teal    primary actions
     --mycalc-teal-400  bright teal  hover / highlight / accents
     --mycalc-teal-100  pale teal    display background
   ========================================================================== */

.mycalc-wrapper {
	--mycalc-navy-900: #091B2E;
	--mycalc-navy-700: #123054;
	--mycalc-navy-500: #1D4B76;
	--mycalc-navy-300: #2D6491;
	--mycalc-teal-600: #0E7C7B;
	--mycalc-teal-400: #2CC4BB;
	--mycalc-teal-100: #EAF7F5;

	--mycalc-radius-lg: 20px;
	--mycalc-radius-md: 12px;
	--mycalc-radius-sm: 8px;

	width: 100%;
	max-width: 900px;
	margin: 1.5rem auto;
	overflow-x: hidden;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	box-sizing: border-box;
}

.mycalc-wrapper *,
.mycalc-wrapper *::before,
.mycalc-wrapper *::after {
	box-sizing: border-box;
}

.mycalc-title {
	color: var(--mycalc-navy-900);
	font-weight: 600;
	font-size: 1.05rem;
	margin: 0 0 0.75rem;
	letter-spacing: 0.01em;
}

/* Layout: calculator + history card side by side when there's room, wrapping
   history below automatically when there isn't — via flex-wrap, not a media-query
   flex-direction switch. This is deliberate: some WordPress themes ship CSS with
   enough specificity to override a plain "display: flex" declaration (breaking a
   direction-based layout entirely), so every layout-critical property here is
   !important to guarantee it can't be silently overridden. flex-wrap doesn't
   need a breakpoint to "know" when to stack — it just wraps when the row runs
   out of space, which is more robust than depending on a direction switch. */

.mycalc-layout {
	display: flex !important;
	flex-wrap: wrap !important;
	align-items: flex-start !important;
	gap: 16px !important;
	width: 100% !important;
}

.mycalc-calculator {
	position: relative;
	flex: 1 1 320px !important;
	min-width: 280px !important;
	max-width: 100%;
	background: var(--mycalc-navy-900);
	border-radius: var(--mycalc-radius-lg);
	padding: 0;
	overflow: hidden;
	box-shadow: 0 20px 45px -12px rgba(9, 27, 46, 0.45), 0 2px 8px rgba(9, 27, 46, 0.25);
}

/* ---------- History card ---------- */

.mycalc-history-card {
	flex: 1 1 240px !important;
	min-width: 240px !important;
	max-width: 100%;
	display: flex !important;
	flex-direction: column !important;
	background: var(--mycalc-navy-900);
	border-radius: var(--mycalc-radius-lg);
	overflow: hidden;
	box-shadow: 0 20px 45px -12px rgba(9, 27, 46, 0.45), 0 2px 8px rgba(9, 27, 46, 0.25);
}

.mycalc-history-header {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	color: var(--mycalc-teal-100);
	font-size: 0.72rem;
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	padding: 14px 16px 8px;
}

.mycalc-history-header span {
	opacity: 0.65;
}

.mycalc-history-export {
	background: transparent;
	border: 1px solid rgba(234, 247, 245, 0.3);
	color: rgba(234, 247, 245, 0.75);
	font-size: 0.65rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: none;
	padding: 4px 9px;
	border-radius: 999px;
	cursor: pointer;
}

.mycalc-history-export:hover:not(:disabled) {
	border-color: var(--mycalc-teal-400);
	color: var(--mycalc-teal-400);
}

.mycalc-history-export:disabled {
	opacity: 0.3;
	cursor: default;
}

.mycalc-export-wrap {
	position: relative;
}

.mycalc-header-controls {
	display: flex;
	align-items: center;
	gap: 6px;
}

.mycalc-currency {
	background: transparent;
	border: 1px solid rgba(234, 247, 245, 0.3);
	color: rgba(234, 247, 245, 0.75);
	font-size: 0.65rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	text-transform: none;
	padding: 4px 6px;
	border-radius: 999px;
	cursor: pointer;
	max-width: 110px;
	appearance: auto;
}

.mycalc-currency:hover {
	border-color: var(--mycalc-teal-400);
	color: var(--mycalc-teal-400);
}

.mycalc-currency option {
	background: var(--mycalc-navy-700);
	color: var(--mycalc-teal-100);
}

.mycalc-export-menu {
	position: absolute;
	top: calc(100% + 6px);
	right: 0;
	z-index: 20;
	min-width: 130px;
	background: var(--mycalc-navy-500);
	border-radius: var(--mycalc-radius-sm);
	box-shadow: 0 12px 28px rgba(9, 27, 46, 0.45);
	padding: 4px;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.mycalc-export-menu[hidden] {
	display: none;
}

.mycalc-export-menu button {
	background: transparent;
	border: none;
	color: var(--mycalc-teal-100);
	font-size: 0.75rem;
	font-weight: 600;
	text-align: left;
	padding: 7px 10px;
	border-radius: var(--mycalc-radius-sm);
	cursor: pointer;
	white-space: nowrap;
}

.mycalc-export-menu button:hover,
.mycalc-export-menu button:focus-visible {
	background: var(--mycalc-teal-600);
	color: #fff;
}

button {
	font-family: inherit;
	-webkit-tap-highlight-color: transparent;
}

/* ---------- Display ---------- */

.mycalc-display {
	position: relative;
	background: var(--mycalc-teal-100);
	padding: 16px 18px 14px;
	display: flex;
	flex-direction: column;
	height: 185px; /* fixed, not min-height — the display can no longer grow/shrink
	                  based on content, which is what caused everything below it
	                  (tabs, keypad) to shift position while typing. Content that's
	                  too tall scrolls inside .mycalc-input-row instead. */
	overflow: hidden;
}

/* Desktop: a genuinely spacious working area, not just a cramped single input line. */
@media (min-width: 617px) {
	.mycalc-display {
		height: 248px;
	}
}

.mycalc-display-top {
	display: flex;
	align-items: center;
	gap: 8px;
}

.mycalc-mem-indicator {
	font-size: 0.68rem;
	font-weight: 800;
	color: var(--mycalc-teal-600);
	min-width: 18px;
	height: 18px;
	line-height: 15px;
	padding: 0 5px;
	text-align: center;
	border-radius: 999px;
	border: 1.5px solid var(--mycalc-teal-600);
	opacity: 0;
	transform: scale(0.8);
	transition: opacity 0.15s ease, transform 0.15s ease;
}

.mycalc-mem-indicator[data-visible="true"] {
	opacity: 1;
	transform: scale(1);
}

.mycalc-help-btn {
	width: 20px;
	height: 20px;
	min-width: 20px;
	line-height: 18px;
	text-align: center;
	padding: 0;
	border: 1.5px solid var(--mycalc-teal-600);
	border-radius: 50%;
	background: transparent;
	color: var(--mycalc-teal-600);
	font-size: 0.7rem;
	font-weight: 800;
	cursor: pointer;
}

.mycalc-help-btn:hover {
	background: var(--mycalc-teal-600);
	color: #fff;
}

.mycalc-mode-toggle {
	margin-left: auto;
	display: flex;
	background: rgba(9, 27, 46, 0.08);
	border-radius: 999px;
	padding: 2px;
}

.mycalc-mode-btn {
	border: none;
	background: transparent;
	color: var(--mycalc-navy-700);
	opacity: 0.55;
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.03em;
	padding: 5px 10px;
	border-radius: 999px;
	cursor: pointer;
}

.mycalc-mode-btn.is-active {
	background: var(--mycalc-teal-600);
	color: #fff;
	opacity: 1;
}

/* History list — lives inside the navy history card. !important is used deliberately
   on every layout-critical property here: some WordPress themes ship CSS specific
   enough to silently override plain declarations (as confirmed by devtools showing
   "display: flex" struck through), which breaks scrolling/sizing and makes this box
   grow the whole page or overlap other content instead of scrolling internally.
   overscroll-behavior:contain stops scrolling inside this box from "leaking" into
   scrolling the whole page once it hits an edge. */

.mycalc-history {
	display: block !important;
	box-sizing: border-box !important;
	flex: 1 1 auto !important;
	min-height: 90px !important;
	max-height: 220px !important;
	overflow-y: auto !important;
	overflow-x: hidden !important;
	overscroll-behavior: contain !important;
	-webkit-overflow-scrolling: touch;
	padding: 0 10px 12px;
	scrollbar-width: thin;
	scrollbar-color: rgba(234, 247, 245, 0.25) transparent;
}

.mycalc-history-list {
	display: block !important;
	height: auto !important;
}

.mycalc-history::-webkit-scrollbar {
	width: 5px;
}
.mycalc-history::-webkit-scrollbar-thumb {
	background: rgba(234, 247, 245, 0.2);
	border-radius: 3px;
}
.mycalc-history::-webkit-scrollbar-track {
	background: transparent;
}

.mycalc-history-empty {
	color: rgba(234, 247, 245, 0.4);
	font-size: 0.78rem;
	font-style: italic;
	padding: 4px 4px 8px;
}

.mycalc-history-list .mycalc-history-item {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 1px;
	padding: 8px 6px;
	border-radius: var(--mycalc-radius-sm);
	cursor: pointer;
	position: relative;
}

.mycalc-history-num {
	position: absolute;
	top: 8px;
	right: 6px;
	color: rgba(234, 247, 245, 0.3);
	font-size: 0.68rem;
	font-weight: 700;
}

.mycalc-history-list .mycalc-history-item:hover,
.mycalc-history-list .mycalc-history-item:focus-visible {
	background: rgba(44, 196, 187, 0.12);
}

.mycalc-history-list .mycalc-history-expr {
	color: rgba(234, 247, 245, 0.55);
	font-size: 0.78rem;
	white-space: normal;
	overflow-wrap: anywhere;
	width: 100%;
}

.mycalc-history-list .mycalc-history-result {
	font-weight: 700;
	font-size: 0.92rem;
	color: var(--mycalc-teal-400);
	white-space: normal;
	overflow-wrap: anywhere;
	width: 100%;
}

/* Input + live preview. The preview is deliberately its OWN block below the input,
   not sharing a row with it — when the input grows tall (wrapped/long expressions,
   internal scroll), a side-by-side layout could visually collide with it. Stacking
   them removes that possibility entirely regardless of how tall the input gets. */

/* Input + syntax-highlight overlay + live preview.
   The input row has a flexible but bounded height (fills whatever's left inside the
   now fixed-height .mycalc-display) with its own internal scroll — content that's too
   tall scrolls inside this row instead of growing the row itself, which is what used
   to push the tabs/keypad up and down while typing.
   The highlight div sits behind an otherwise-identical, text-transparent textarea:
   both are perfectly overlaid (same font/padding/line-height) so the highlighted text
   appears to BE the textarea's text, while the real (invisible) textarea on top still
   handles typing, selection, and the cursor. */

.mycalc-input-row {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	overflow: hidden;
	margin-top: 6px;
	background: transparent !important;
}

.mycalc-input-highlight,
.mycalc-input {
	position: absolute !important;
	inset: 0 !important;
	margin: 0 !important;
	width: 100% !important;
	height: 100% !important;
	box-sizing: border-box !important;
	border: 0 !important;
	padding: 6px 2px 2px;
	font-size: clamp(1.35rem, 6vw, 1.75rem) !important;
	font-family: "Cambria Math", Cambria, Georgia, serif !important;
	line-height: 1.3 !important;
	overflow-wrap: anywhere;
	word-break: break-word;
	white-space: pre-wrap !important;
	text-align: right !important; /* calculator convention: entry starts from the right */
}

.mycalc-input-highlight {
	overflow: auto;
	scrollbar-width: none;
	background: transparent !important;
	color: var(--mycalc-navy-900);
	pointer-events: none;
	z-index: 1;
	-webkit-tap-highlight-color: transparent;
}

.mycalc-input-highlight::-webkit-scrollbar {
	display: none;
}

.mycalc-fn-token {
	color: var(--mycalc-teal-600);
	font-weight: 700;
}

.mycalc-op-token {
	/* navy-300: clearly lighter than the near-black navy-900 digits, clearly
	   different from the teal-600 function names, still within the palette */
	color: var(--mycalc-navy-300);
	font-weight: 700;
}

/* Measuring wrapper inside the highlight overlay. Its offsetHeight reports the
   TRUE rendered height of the content (a textarea's scrollHeight can't — it is
   clamped to the box height), which is what makes bottom-alignment computable. */
.mycalc-highlight-inner {
	display: block;
	width: 100%;
}

.mycalc-input {
	z-index: 2;
	resize: none;
	outline: none;
	background: transparent !important;
	color: transparent !important; /* real text is invisible — the highlight div behind it is what's seen.
	                                   !important because this theme's CSS has repeatedly needed it to
	                                   override plain declarations on form elements specifically. */
	caret-color: var(--mycalc-navy-900);
	overflow-y: auto;
	-webkit-tap-highlight-color: transparent;
}

.mycalc-input::placeholder {
	/* Both properties needed: the JS hardening sets -webkit-text-fill-color:
	   transparent on the input to hide its real text, and that value inherits
	   into the placeholder pseudo-element — without an explicit override here
	   the "0" placeholder becomes invisible too. */
	color: rgba(9, 27, 46, 0.3) !important;
	-webkit-text-fill-color: rgba(9, 27, 46, 0.3) !important;
	opacity: 1;
}

.mycalc-live-preview {
	flex: 0 0 auto;
	min-height: 1.7em; /* always reserved, whether populated or not, so its presence
	                       never shifts the layout */
	color: var(--mycalc-teal-600);
	font-size: clamp(0.95rem, 4vw, 1.2rem);
	font-weight: 700;
	text-align: right;
	padding: 4px 2px 2px;
	opacity: 0.9;
	overflow-wrap: anywhere;
	border-top: 1px solid rgba(9, 27, 46, 0.08);
	margin-top: 4px;
}

.mycalc-error {
	flex: 0 0 auto;
	min-height: 1.4em;
	color: #b3331d;
	font-size: 0.78rem;
	background: var(--mycalc-teal-100);
	padding: 0 14px 8px;
}

/* ---------- Toolbar: two dedicated full-width rows ---------- */
/* Tabs get their own row, toolbar actions get their own row below. With only
   4 items in each, every button fits and is always fully visible — no
   horizontal scrolling, so nothing can get scrolled out of reach. */

.mycalc-tabs {
	display: flex;
	gap: 4px;
	background: var(--mycalc-navy-700);
	padding: 8px 10px 4px;
	border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.mycalc-tab {
	flex: 1 1 0;
	background: transparent;
	border: none;
	color: rgba(234, 247, 245, 0.6);
	font-weight: 600;
	font-size: 0.82rem;
	padding: 7px 4px;
	border-radius: 999px;
	cursor: pointer;
	white-space: nowrap;
	transition: background 0.15s ease, color 0.15s ease;
}

.mycalc-tab:hover {
	color: var(--mycalc-teal-100);
}

.mycalc-tab.is-active {
	background: var(--mycalc-teal-600);
	color: #fff;
}

.mycalc-toolbar-actions {
	display: flex;
	gap: 4px;
	background: var(--mycalc-navy-700);
	padding: 0 10px 8px;
}

.mycalc-toolbar-actions .mycalc-icon-btn,
.mycalc-toolbar-actions .mycalc-clear-all {
	flex: 1 1 0;
	margin-left: 0;
}

.mycalc-icon-btn {
	background: transparent;
	border: 1px solid transparent;
	color: rgba(234, 247, 245, 0.7);
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	line-height: 1;
	width: auto;
	height: auto;
	min-width: auto;
	padding: 6px 9px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	white-space: nowrap;
	border-radius: 999px;
	cursor: pointer;
}

.mycalc-icon-btn:hover {
	background: rgba(44, 196, 187, 0.18);
	color: var(--mycalc-teal-100);
}

.mycalc-icon-btn:disabled {
	opacity: 0.3;
	cursor: default;
}
.mycalc-icon-btn:disabled:hover {
	background: transparent;
}

.mycalc-clear-all {
	background: transparent;
	border: 1px solid var(--mycalc-navy-300);
	color: rgba(234, 247, 245, 0.75);
	font-size: 0.72rem;
	font-weight: 600;
	padding: 6px 11px;
	border-radius: 999px;
	cursor: pointer;
	margin-left: 4px;
	white-space: nowrap;
}

.mycalc-clear-all:hover {
	border-color: var(--mycalc-teal-400);
	color: var(--mycalc-teal-400);
}

/* ---------- Memory row ---------- */

.mycalc-mem-row {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 6px;
	background: var(--mycalc-navy-700);
	padding: 0 10px 8px;
}

.mycalc-mem-btn {
	background: rgba(9, 27, 46, 0.35);
	border: none;
	color: rgba(234, 247, 245, 0.75);
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	padding: 6px 4px;
	border-radius: var(--mycalc-radius-sm);
	cursor: pointer;
}

.mycalc-mem-btn:hover {
	background: var(--mycalc-teal-600);
	color: #fff;
}

.mycalc-mem-btn:active {
	transform: scale(0.96);
}

/* Last-used memory operation stays highlighted so it's visible at a glance */
.mycalc-mem-btn.is-active {
	background: var(--mycalc-teal-600);
	color: #fff;
}

/* Thin, unobtrusive scrollbar for the input when content genuinely overflows
   (JS keeps overflow hidden entirely when content fits) */
.mycalc-input {
	scrollbar-width: thin;
	scrollbar-color: rgba(9, 27, 46, 0.25) transparent;
}
.mycalc-input::-webkit-scrollbar {
	width: 6px;
}
.mycalc-input::-webkit-scrollbar-thumb {
	background: rgba(9, 27, 46, 0.2);
	border-radius: 3px;
}
.mycalc-input::-webkit-scrollbar-track {
	background: transparent;
}

/* ---------- Panels / keypad ---------- */

.mycalc-panels {
	background: var(--mycalc-navy-700);
	padding: 8px 8px 10px;
}

.mycalc-panel {
	display: none;
}

.mycalc-panel.is-active {
	display: block;
	animation: mycalc-fade-in 0.12s ease;
}

@keyframes mycalc-fade-in {
	from { opacity: 0; transform: translateY(2px); }
	to { opacity: 1; transform: translateY(0); }
}

.mycalc-grid {
	display: grid;
	gap: 6px;
}

.mycalc-grid-6 {
	grid-template-columns: repeat(6, 1fr);
}

.mycalc-grid-10 {
	grid-template-columns: repeat(10, 1fr);
}

.mycalc-key {
	background: var(--mycalc-navy-500);
	color: var(--mycalc-teal-100);
	border: none;
	border-radius: var(--mycalc-radius-sm);
	font-size: clamp(0.82rem, 3.6vw, 0.98rem);
	min-height: 44px;
	padding: 8px 2px;
	cursor: pointer;
	transition: background 0.12s ease, transform 0.05s ease;
	line-height: 1;
	touch-action: manipulation;
}

.mycalc-key sup {
	font-size: 0.65em;
}

.mycalc-key:hover {
	background: var(--mycalc-teal-600);
	color: #fff;
}

.mycalc-key:active {
	transform: scale(0.94);
	background: var(--mycalc-teal-600);
}

.mycalc-key-op {
	background: var(--mycalc-navy-900);
	color: var(--mycalc-teal-400);
}

.mycalc-key-op:hover {
	background: var(--mycalc-teal-600);
	color: #fff;
}

.mycalc-key-equals {
	background: linear-gradient(135deg, var(--mycalc-teal-600), #0A5F5E);
	color: #fff;
	font-weight: 700;
	font-size: clamp(1rem, 4vw, 1.2rem);
	min-height: 46px;
}

.mycalc-key-equals:hover {
	background: var(--mycalc-teal-400);
	color: var(--mycalc-navy-900);
}

.mycalc-key-pct {
	color: var(--mycalc-teal-400);
}

.mycalc-frac {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	font-size: 0.8em;
	line-height: 1.05;
}
.mycalc-frac i:first-child {
	border-bottom: 1.5px solid currentColor;
	padding: 0 2px 1px;
	font-style: normal;
}
.mycalc-frac i:last-child {
	padding-top: 1px;
	font-style: normal;
}

.mycalc-key-letter {
	font-size: clamp(0.75rem, 3.2vw, 0.88rem);
	padding: 8px 2px;
	min-height: 40px;
}

.mycalc-grid-qwerty .mycalc-row-offset {
	grid-column-start: 1;
}

/* ---------- Responsive ---------- */

/* When the history card wraps below the calculator (not enough room to sit beside
   it), cap it to a compact height instead of letting it grow tall and push the
   keypad further down. min-width on .mycalc-layout children (set above) is what
   actually triggers the wrap — this just tunes how the wrapped card looks. */
/* Desktop: fully rigid, fixed-width columns. flex-grow:0 and flex-shrink:0 (the "0 0"
   in flex:0 0 Npx) mean these boxes are locked at exactly this pixel width no matter
   what — they cannot expand to fit long typed content and cannot shrink either. Content
   that's too long to fit wraps inside the box instead (see .mycalc-input's overflow-wrap). */
@media (min-width: 617px) {
	.mycalc-layout {
		align-items: stretch !important;
	}
	.mycalc-calculator {
		flex: 0 0 500px !important;
		width: 500px !important;
		max-width: 500px !important;
	}
	.mycalc-history-card {
		flex: 0 0 340px !important;
		width: 340px !important;
		max-width: 340px !important;
	}
	.mycalc-history {
		max-height: none !important;
	}
}

@media (max-width: 616px) {
	.mycalc-history-card {
		max-height: 245px;
	}
	.mycalc-history {
		max-height: 205px !important;
	}
	.mycalc-history-header {
		padding: 10px 14px 4px;
	}
}

@media (max-width: 480px) {
	.mycalc-wrapper {
		max-width: 100%;
		margin: 0.75rem auto;
	}
	.mycalc-calculator,
	.mycalc-history-card {
		border-radius: var(--mycalc-radius-md);
	}
	.mycalc-layout {
		gap: 10px !important;
	}
	.mycalc-history-card {
		max-height: 225px;
	}
	.mycalc-history {
		max-height: 185px !important;
	}
	.mycalc-grid-6,
	.mycalc-grid-10 {
		gap: 5px;
	}
	.mycalc-mem-row {
		padding: 0 8px 8px;
	}
	.mycalc-icon-btn {
		font-size: 0.68rem;
		padding: 6px 4px;
	}
	.mycalc-clear-all {
		font-size: 0.68rem;
		padding: 6px 6px;
	}
}

@media (max-width: 360px) {
	.mycalc-key {
		min-height: 40px;
	}
	.mycalc-mem-btn {
		font-size: 0.68rem;
		padding: 5px 2px;
	}
	.mycalc-tab {
		padding: 6px 10px;
		font-size: 0.78rem;
	}
	.mycalc-icon-btn {
		font-size: 0.66rem;
		padding: 5px 6px;
	}
	.mycalc-clear-all {
		padding: 5px 8px;
		font-size: 0.68rem;
	}
}

/* Shorter phone screens generally (covers small portrait phones too, not just landscape) */
@media (max-height: 700px) {
	.mycalc-display {
		padding: 8px 12px 6px;
	}
	.mycalc-tabs {
		padding: 6px 10px;
	}
	.mycalc-mem-row {
		padding: 0 8px 6px;
		gap: 4px;
	}
	.mycalc-panels {
		padding: 6px 6px 8px;
	}
	.mycalc-key {
		min-height: 38px;
		padding: 6px 2px;
	}
	.mycalc-key-equals {
		min-height: 40px;
	}
	.mycalc-grid {
		gap: 4px;
	}
}

/* Landscape phones: shrink further so keypad still fits on-screen */
@media (max-height: 480px) and (orientation: landscape) {
	.mycalc-history-card {
		max-height: 90px;
	}
	.mycalc-history {
		max-height: 68px !important;
	}
	.mycalc-history-header {
		padding: 6px 12px 2px;
	}
	.mycalc-display {
		padding: 8px 12px 6px;
	}
	.mycalc-key {
		min-height: 34px;
		padding: 4px 2px;
	}
	.mycalc-mem-row {
		padding: 0 8px 6px;
	}
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	.mycalc-key,
	.mycalc-panel.is-active {
		transition: none;
		animation: none;
	}
}

/* Visible keyboard focus for accessibility */
.mycalc-wrapper button:focus-visible,
.mycalc-wrapper textarea:focus-visible {
	outline: 2px solid var(--mycalc-teal-400);
	outline-offset: 2px;
}

/* ---------- Help modal ---------- */

.mycalc-help-modal[hidden] {
	display: none;
}

.mycalc-help-modal {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.mycalc-help-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(9, 27, 46, 0.6);
}

.mycalc-help-panel {
	position: relative;
	background: var(--mycalc-teal-100);
	color: var(--mycalc-navy-900);
	width: 100%;
	max-width: 480px;
	max-height: min(600px, 85vh);
	border-radius: var(--mycalc-radius-lg);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	box-shadow: 0 24px 60px rgba(9, 27, 46, 0.5);
}

.mycalc-help-panel-header {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	background: var(--mycalc-navy-900);
	padding: 16px 18px;
}

.mycalc-help-panel-header h4 {
	margin: 0;
	color: #fff;
	font-size: 1rem;
	font-weight: 700;
}

.mycalc-help-close {
	flex: 0 0 auto;
	width: 28px;
	height: 28px;
	border: none;
	border-radius: 50%;
	background: rgba(234, 247, 245, 0.12);
	color: var(--mycalc-teal-100);
	font-size: 1.1rem;
	line-height: 1;
	cursor: pointer;
}

.mycalc-help-close:hover {
	background: var(--mycalc-teal-600);
	color: #fff;
}

.mycalc-help-body {
	overflow-y: auto;
	padding: 16px 20px 22px;
}

.mycalc-help-body section {
	margin-bottom: 16px;
}

.mycalc-help-body section:last-child {
	margin-bottom: 0;
}

.mycalc-help-body h5 {
	margin: 0 0 4px;
	font-size: 0.78rem;
	font-weight: 800;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--mycalc-teal-600);
}

.mycalc-help-body p {
	margin: 0;
	font-size: 0.86rem;
	line-height: 1.55;
	color: var(--mycalc-navy-700);
}

.mycalc-help-body code {
	background: rgba(9, 27, 46, 0.08);
	color: var(--mycalc-navy-900);
	padding: 1px 5px;
	border-radius: 4px;
	font-size: 0.82em;
	font-family: "Cambria Math", Cambria, Georgia, serif;
}
