:root {
  color-scheme: dark;
  --page: #111519;
  --page-deep: #0c1013;
  --surface: rgba(25, 31, 35, .9);
  --surface-solid: #1a2024;
  --surface-raised: #22292e;
  --surface-soft: #20272b;
  --line: rgba(226, 235, 231, .09);
  --line-strong: rgba(226, 235, 231, .15);
  --text: #f1f5f2;
  --text-soft: #b8c0bc;
  --muted: #838d88;
  --accent: #a3e2c5;
  --accent-deep: #79c6a2;
  --accent-ink: #18251e;
  --blue: #a2c2d8;
  --warm: #dbc7a5;
  --danger: #f1a59d;
  --screen: linear-gradient(145deg, rgba(31, 43, 39, .97), rgba(25, 33, 33, .96));
  --key-shadow: 0 3px 0 rgba(0, 0, 0, .21), 0 8px 20px rgba(0, 0, 0, .12);
  --card-shadow: 0 24px 80px rgba(0, 0, 0, .23), 0 2px 8px rgba(0, 0, 0, .12);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --focus: #a3e2c5;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

:root[data-theme="light"] {
  color-scheme: light;
  --page: #f2f2ed;
  --page-deep: #e9eae4;
  --surface: rgba(255, 255, 252, .91);
  --surface-solid: #fffefa;
  --surface-raised: #f6f6f0;
  --surface-soft: #f1f2eb;
  --line: rgba(31, 48, 41, .09);
  --line-strong: rgba(31, 48, 41, .16);
  --text: #26312c;
  --text-soft: #59645e;
  --muted: #828b84;
  --accent: #438866;
  --accent-deep: #347554;
  --accent-ink: #f7fff9;
  --blue: #527c96;
  --warm: #927445;
  --danger: #b84c41;
  --screen: linear-gradient(145deg, #e8f0e8, #f1f2e9);
  --key-shadow: 0 2px 0 rgba(40, 57, 47, .08), 0 8px 18px rgba(41, 54, 46, .06);
  --card-shadow: 0 24px 70px rgba(43, 58, 48, .09), 0 2px 8px rgba(43, 58, 48, .04);
  --focus: #347554;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--page); }
body { margin: 0; min-height: 100vh; overflow-x: hidden; color: var(--text); background: radial-gradient(ellipse at 12% 0%, rgba(95, 139, 117, .09), transparent 36%), linear-gradient(145deg, var(--page), var(--page-deep)); }
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
button:disabled { cursor: not-allowed; opacity: .45; }
.ambient { position: fixed; z-index: -1; width: 420px; height: 420px; border-radius: 50%; pointer-events: none; filter: blur(100px); opacity: .1; }
.ambient-one { top: 15%; right: -245px; background: #82c0a2; }
.ambient-two { bottom: -280px; left: -190px; background: #506e91; opacity: .08; }
.app-shell { width: min(1140px, calc(100% - 72px)); min-height: 100vh; margin-inline: auto; padding: 26px 0 24px; display: flex; flex-direction: column; }
.app-header { min-height: 68px; margin-bottom: 32px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; }
.brand-mark { display: grid; width: 43px; height: 43px; padding: 2px; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: 0 6px 16px rgba(0, 0, 0, .12); }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }
.brand-copy { display: grid; gap: 3px; }
.brand-copy strong { font-size: 16px; font-weight: 650; letter-spacing: -.045em; }
.brand-copy small, .eyebrow { color: var(--muted); font-size: 9px; font-weight: 730; letter-spacing: .14em; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.icon-button, .history-trigger { border: 1px solid var(--line); background: var(--surface); color: var(--text-soft); transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease; }
.icon-button { display: grid; width: 42px; height: 42px; padding: 0; place-items: center; border-radius: 14px; cursor: pointer; }
.icon-button:hover, .history-trigger:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface-raised); transform: translateY(-1px); }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: block; }
.history-trigger { display: flex; height: 42px; align-items: center; gap: 9px; padding: 0 12px; border-radius: 14px; cursor: pointer; font-size: 12px; font-weight: 600; }
.history-trigger svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.history-count { display: grid; min-width: 20px; height: 20px; padding-inline: 5px; place-items: center; color: var(--accent); border-radius: 7px; background: color-mix(in srgb, var(--accent) 12%, transparent); font-size: 10px; font-weight: 700; }

.main-layout { display: grid; grid-template-columns: minmax(430px, 1fr) 310px; align-items: start; gap: 26px; margin: auto 0; }
.calculator-card, .quick-tools-card, .tip-card { border: 1px solid var(--line); background: var(--surface); box-shadow: var(--card-shadow); backdrop-filter: blur(24px); }
.calculator-card { overflow: hidden; max-width: 780px; width: 100%; justify-self: center; padding: 24px; border-radius: var(--radius-xl); }
.programmer-panel { margin: -4px 0 19px; padding: 0 0 18px; border-bottom: 1px solid var(--line); }
.programmer-heading { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 10px; }
.programmer-heading h2 { margin: 4px 0 0; font-size: 16px; font-weight: 600; letter-spacing: -.035em; }
.programmer-badge { padding: 5px 7px; border: 1px solid color-mix(in srgb, var(--blue) 22%, var(--line)); border-radius: 7px; color: var(--blue); font-size: 8px; font-weight: 720; letter-spacing: .12em; }
.programmer-screen { overflow: hidden; padding: 10px 12px 8px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--surface-solid) 78%, var(--page)); }
.base-switch { display: flex; align-items: center; gap: 4px; }
.base-switch button { min-width: 40px; height: 23px; padding: 0 7px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 8px; font-weight: 750; letter-spacing: .09em; }
.base-switch button:hover { color: var(--text); }
.base-switch button.active { border-color: color-mix(in srgb, var(--accent) 25%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }
.programmer-expression { min-height: 17px; overflow: hidden; margin-top: 5px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.programmer-value { display: block; overflow: hidden; margin: 0 0 6px; color: var(--text); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: clamp(21px, 4vw, 29px); letter-spacing: .025em; line-height: 1.2; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.base-values { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; padding-top: 7px; border-top: 1px solid var(--line); }
.base-value { min-width: 0; color: var(--text-soft); text-align: center; }
.base-value strong { display: block; margin-bottom: 3px; color: var(--muted); font-size: 7px; font-weight: 750; letter-spacing: .1em; }
.base-value span { display: block; overflow: hidden; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.programmer-error { min-height: 12px; margin: 4px 0 0; color: var(--danger); font-size: 9px; text-align: right; }
.programmer-keypad { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; margin-top: 8px; }
.program-key { display: grid; min-width: 0; height: 34px; padding: 0 2px; place-items: center; border: 1px solid var(--line-strong); border-radius: 8px; background: color-mix(in srgb, var(--text) 2%, var(--surface-raised)); color: var(--text); cursor: pointer; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; font-weight: 600; box-shadow: 0 2px 0 rgba(0, 0, 0, .12); transition: background .14s ease, transform .12s ease, border-color .14s ease; }
.program-key:hover:not(:disabled) { border-color: color-mix(in srgb, var(--blue) 38%, var(--line)); background: color-mix(in srgb, var(--blue) 10%, var(--surface-raised)); }
.program-key:active:not(:disabled) { transform: translateY(1px) scale(.97); }
.program-key:disabled { opacity: .25; }
.program-shift, .program-memory { color: var(--accent); }
.program-shift.shift-active { background: color-mix(in srgb, var(--accent) 22%, var(--surface-raised)); }
.program-delete { background: color-mix(in srgb, var(--blue) 19%, var(--surface-raised)); color: var(--blue); }
.program-clear { background: color-mix(in srgb, var(--danger) 14%, var(--surface-raised)); color: var(--danger); }
.program-equals { background: color-mix(in srgb, var(--accent) 20%, var(--surface-raised)); color: var(--accent); font-size: 14px; }
.program-equals:not(.program-equals-wide) { grid-column: span 2; }
.program-equals-wide { grid-column: span 2; display: none; }
.screen-card { position: relative; display: flex; min-height: 166px; flex-direction: column; justify-content: space-between; overflow: hidden; padding: 17px 20px 20px; border: 1px solid rgba(230, 242, 235, .09); border-radius: 19px; background: var(--screen); }
.screen-card::after { position: absolute; top: -80px; right: -72px; width: 240px; height: 240px; border: 1px solid rgba(163, 226, 197, .07); border-radius: 50%; box-shadow: 0 0 0 22px rgba(163, 226, 197, .018), 0 0 0 48px rgba(163, 226, 197, .014); content: ""; pointer-events: none; }
.screen-meta, .screen-indicators { display: flex; align-items: center; }
.screen-meta { position: relative; z-index: 1; justify-content: space-between; }
.screen-mode { display: inline-flex; align-items: center; gap: 8px; color: var(--text-soft); font-size: 10px; font-weight: 600; letter-spacing: .035em; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 11%, transparent); }
.screen-indicators { gap: 8px; }
.memory-indicator, .angle-indicator { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); font-size: 9px; font-weight: 720; letter-spacing: .09em; }
.memory-indicator[hidden], .angle-indicator[hidden] { display: none; }
.memory-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.expression-line { position: relative; z-index: 1; min-height: 24px; margin-top: 17px; overflow: hidden; color: var(--muted); font-size: clamp(15px, 2vw, 19px); font-variant-numeric: tabular-nums; letter-spacing: .01em; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.result-row { position: relative; z-index: 1; display: flex; align-items: end; justify-content: space-between; gap: 14px; }
.result-wrap { min-width: 0; }
.result-caption { display: block; margin-bottom: 4px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }
.result-value { display: block; max-width: 100%; overflow: hidden; color: var(--text); font-size: clamp(36px, 6vw, 52px); font-weight: 450; font-variant-numeric: tabular-nums; letter-spacing: -.055em; line-height: 1; text-overflow: ellipsis; white-space: nowrap; transition: opacity .2s ease, transform .2s ease; }
.result-value.updated { animation: result-arrive .24s ease-out; }
@keyframes result-arrive { from { opacity: .36; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.copy-button { display: grid; width: 35px; height: 35px; flex: 0 0 auto; margin-bottom: 1px; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .035); color: var(--text-soft); cursor: pointer; transition: .18s ease; }
.copy-button:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 48%, var(--line)); color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.copy-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.error-message { min-height: 14px; margin: 5px 0 -7px; color: var(--danger); font-size: 11px; text-align: right; }

.control-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 19px 0 14px; }
.memory-keys { display: flex; align-items: center; gap: 5px; }
.memory-key { min-width: 39px; min-height: 34px; padding: 0 7px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; font-size: 10px; font-weight: 720; letter-spacing: .04em; transition: .16s ease; }
.memory-key:hover { border-color: var(--line); background: var(--surface-raised); color: var(--accent); }
.memory-store { color: var(--accent); }
.scientific-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 35px; padding: 0 11px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-raised); color: var(--text-soft); cursor: pointer; font-size: 10px; font-weight: 730; letter-spacing: .08em; transition: .18s ease; }
.scientific-toggle:hover, .scientific-toggle[aria-expanded="true"] { border-color: color-mix(in srgb, var(--accent) 34%, var(--line)); color: var(--accent); }
.scientific-glyph { display: grid; width: 19px; height: 19px; place-items: center; border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 6px; color: var(--accent); font-family: Georgia, serif; font-size: 13px; font-style: italic; }
.toggle-chevron { margin-left: 1px; color: var(--muted); font-size: 14px; transition: transform .18s ease; }
.scientific-toggle[aria-expanded="true"] .toggle-chevron { transform: rotate(180deg); }
.scientific-panel { margin-bottom: 14px; padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: color-mix(in srgb, var(--surface-solid) 62%, transparent); animation: panel-appear .18s ease-out; }
.scientific-panel[hidden] { display: none; }
@keyframes panel-appear { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.scientific-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; }
.scientific-key { min-width: 0; min-height: 38px; padding: 3px 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-raised); color: var(--blue); cursor: pointer; font-size: 11px; font-weight: 620; transition: transform .12s ease, background .16s ease, border-color .16s ease; }
.scientific-key:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--blue) 30%, var(--line)); background: color-mix(in srgb, var(--blue) 9%, var(--surface-raised)); }
.scientific-key:active { transform: scale(.96); }
.angle-key { display: flex; align-items: center; justify-content: center; gap: 5px; color: var(--accent); }
.angle-key span { font-weight: 750; }
.angle-key small { color: var(--muted); font-size: 8px; }

.keypad { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.key { display: grid; min-width: 0; height: clamp(53px, 7vw, 66px); padding: 0; place-items: center; border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--key-shadow); cursor: pointer; font-size: 19px; font-weight: 540; transition: transform .12s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease; -webkit-tap-highlight-color: transparent; }
.key:active { transform: translateY(2px) scale(.975); box-shadow: 0 1px 0 rgba(0,0,0,.13); }
.key-number { background: var(--surface-raised); color: var(--text); }
.key-number:hover { border-color: var(--line-strong); background: color-mix(in srgb, var(--text) 5%, var(--surface-raised)); }
.key-utility { background: color-mix(in srgb, var(--accent) 8%, var(--surface-solid)); color: var(--accent); font-size: 15px; font-weight: 650; }
.key-utility:hover { border-color: color-mix(in srgb, var(--accent) 32%, var(--line)); background: color-mix(in srgb, var(--accent) 14%, var(--surface-solid)); }
.key-utility svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.key-operator { background: color-mix(in srgb, var(--blue) 10%, var(--surface-solid)); color: var(--blue); font-size: 23px; font-weight: 470; }
.key-operator:hover { border-color: color-mix(in srgb, var(--blue) 34%, var(--line)); background: color-mix(in srgb, var(--blue) 16%, var(--surface-solid)); }
.key-sign { font-size: 16px; }
.key-equals { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent); box-shadow: 0 4px 0 color-mix(in srgb, var(--accent-deep) 60%, transparent), 0 11px 25px color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-ink); font-size: 24px; font-weight: 650; }
.key-equals:hover { filter: brightness(1.05); transform: translateY(-1px); }
.key-equals:active { transform: translateY(2px) scale(.975); }
.keyboard-hint { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 17px; color: var(--muted); font-size: 9px; }
.keyboard-icon { margin-right: 2px; font-size: 13px; }
kbd { padding: 2px 5px; border: 1px solid var(--line); border-radius: 5px; color: var(--text-soft); background: var(--surface-raised); font: inherit; font-size: 8px; }
.hint-divider { margin-inline: 3px; opacity: .5; }

.utility-column { display: flex; flex-direction: column; gap: 15px; }
.welcome-card { position: relative; min-height: 222px; overflow: hidden; padding: 23px 22px 17px; border: 1px solid var(--line); border-radius: var(--radius-xl); background: linear-gradient(145deg, #293a35, #1a2929 72%, #202c31); box-shadow: var(--card-shadow); color: #f2f6f1; }
.welcome-card::after { position: absolute; right: 18px; bottom: 32px; width: 88px; height: 88px; border: 1px solid rgba(186, 228, 203, .24); border-radius: 50%; content: ""; box-shadow: 0 0 0 10px rgba(186, 228, 203, .045), 0 0 0 22px rgba(186, 228, 203, .035); }
.welcome-card .eyebrow { color: #aabdb2; }
.welcome-card h1 { position: relative; z-index: 1; margin: 15px 0 9px; font-size: 25px; font-weight: 500; letter-spacing: -.05em; line-height: 1.16; }
.welcome-card p { position: relative; z-index: 1; max-width: 230px; margin: 0; color: #b4c1b9; font-size: 11px; line-height: 1.6; }
.welcome-foot { position: relative; z-index: 1; display: flex; align-items: center; gap: 7px; margin-top: 21px; color: #c6d4cc; font-size: 9px; }
.sparkle { color: #b6dbbf; font-size: 13px; }
.welcome-orbit { position: absolute; border: 1px solid rgba(186, 228, 203, .11); border-radius: 50%; }
.orbit-one { right: -58px; top: -104px; width: 210px; height: 210px; }
.orbit-two { right: -20px; top: -77px; width: 158px; height: 158px; }
.quick-tools-card { padding: 20px 17px 9px; border-radius: var(--radius-lg); }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin: 0 3px 10px; }
.section-heading h2 { margin: 4px 0 0; font-size: 15px; font-weight: 600; letter-spacing: -.03em; }
.section-index { color: var(--muted); font-size: 9px; letter-spacing: .08em; }
.tool-link { display: flex; width: 100%; align-items: center; gap: 11px; padding: 12px 3px; border: 0; border-top: 1px solid var(--line); background: transparent; cursor: pointer; text-align: left; transition: padding .16s ease; }
.tool-link:hover { padding-inline: 7px 1px; }
.tool-icon { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border-radius: 11px; background: color-mix(in srgb, var(--accent) 10%, var(--surface-raised)); color: var(--accent); font-size: 17px; }
.finance-icon { color: var(--blue); background: color-mix(in srgb, var(--blue) 11%, var(--surface-raised)); }
.date-icon { color: var(--warm); background: color-mix(in srgb, var(--warm) 11%, var(--surface-raised)); }
.equation-icon { color: var(--accent); background: color-mix(in srgb, var(--accent) 11%, var(--surface-raised)); font-family: Georgia, serif; font-size: 15px; font-style: italic; }
.tool-link > span:nth-child(2) { display: grid; gap: 3px; min-width: 0; }
.tool-link strong { font-size: 11px; font-weight: 620; }
.tool-link small { color: var(--muted); font-size: 9px; }
.tool-arrow { margin-left: auto; color: var(--muted); font-size: 14px; transition: transform .16s ease, color .16s ease; }
.tool-link:hover .tool-arrow { transform: translate(2px, -2px); color: var(--accent); }
.tip-card { display: flex; align-items: flex-start; gap: 11px; padding: 16px; border-radius: var(--radius-lg); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); box-shadow: none; }
.tip-star { color: var(--accent); font-size: 16px; }
.tip-card .eyebrow { font-size: 8px; }
.tip-card p { margin: 6px 0 0; color: var(--text-soft); font-size: 10px; line-height: 1.5; }
.tip-card strong { color: var(--text); font-weight: 650; }
.app-footer { display: flex; align-items: center; gap: 9px; margin-top: 1px; color: var(--muted); font-size: 8px; font-weight: 650; letter-spacing: .13em; }
.footer-line { width: 25px; height: 1px; background: var(--line-strong); }

dialog { color: var(--text); }
.side-dialog, .tools-dialog { width: min(435px, 100vw); max-width: none; height: 100dvh; max-height: none; margin: 0 0 0 auto; padding: 27px 24px; border: 1px solid var(--line); border-radius: 22px 0 0 22px; background: var(--surface-solid); box-shadow: -24px 0 80px rgba(0, 0, 0, .18); overflow-y: auto; }
.side-dialog::backdrop, .settings-dialog::backdrop, .tools-dialog::backdrop { background: rgba(7, 11, 10, .5); backdrop-filter: blur(5px); }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dialog-header h2 { margin: 5px 0 0; font-size: 24px; font-weight: 550; letter-spacing: -.045em; }
.dialog-close { width: 36px; height: 36px; font-size: 22px; font-weight: 350; }
.history-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 27px 0 12px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.history-toolbar > span { color: var(--muted); font-size: 10px; }
.text-button { padding: 6px 0 6px 8px; border: 0; background: transparent; color: var(--danger); cursor: pointer; font-size: 10px; font-weight: 650; }
.text-button:hover { text-decoration: underline; }
.history-list { display: grid; gap: 9px; }
.history-item { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 32px; gap: 0 8px; padding: 13px 13px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-raised); text-align: left; transition: border-color .16s ease, transform .16s ease; }
.history-item:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.history-expression { overflow: hidden; color: var(--text-soft); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.history-result { margin-top: 8px; color: var(--text); font-size: 20px; font-weight: 520; letter-spacing: -.04em; }
.history-time { margin-top: 5px; color: var(--muted); font-size: 9px; }
.history-reuse { grid-column: 2; grid-row: 1 / span 3; align-self: center; width: 31px; height: 31px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--accent); cursor: pointer; }
.history-reuse:hover { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.empty-state { display: grid; justify-items: center; padding: 95px 15px; color: var(--muted); text-align: center; }
.empty-state[hidden] { display: none; }
.empty-symbol { display: grid; width: 50px; height: 50px; margin-bottom: 15px; place-items: center; border: 1px solid var(--line); border-radius: 17px; color: var(--accent); font-size: 22px; }
.empty-state strong { color: var(--text-soft); font-size: 13px; font-weight: 620; }
.empty-state p { margin: 7px 0 0; font-size: 10px; }
.settings-dialog { width: min(470px, calc(100vw - 28px)); max-width: none; margin: auto; padding: 24px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface-solid); box-shadow: var(--card-shadow); }
.settings-content { margin-top: 22px; }
.setting-row { display: flex; min-height: 64px; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); cursor: pointer; }
.setting-row > span { display: grid; gap: 4px; }
.setting-row strong { color: var(--text); font-size: 11px; font-weight: 620; }
.setting-row small { color: var(--muted); font-size: 9px; }
.setting-row select, .field-control { min-height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 10px; outline: 0; background: var(--surface-raised); color: var(--text); font-size: 10px; }
.setting-row select { max-width: 130px; }
.switch-input { position: relative; width: 35px; height: 20px; flex: 0 0 auto; appearance: none; border: 1px solid var(--line-strong); border-radius: 20px; background: var(--surface-raised); cursor: pointer; transition: .18s ease; }
.switch-input::after { position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); content: ""; transition: .18s ease; }
.switch-input:checked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 30%, var(--surface-raised)); }
.switch-input:checked::after { left: 18px; background: var(--accent); }
.settings-done, .primary-action { display: flex; width: 100%; min-height: 43px; align-items: center; justify-content: space-between; margin-top: 20px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); cursor: pointer; font-size: 11px; font-weight: 700; }
.settings-done span, .primary-action span { font-size: 16px; }
.settings-done:hover, .primary-action:hover { filter: brightness(1.06); }
.tools-dialog { width: min(530px, calc(100vw - 28px)); height: min(720px, calc(100dvh - 42px)); margin: auto; padding: 24px; border-radius: 22px; }
.tools-dialog > .dialog-header { position: sticky; top: 0; z-index: 2; padding-block: 4px; background: var(--surface-solid); }
.tool-tabs { display: flex; gap: 5px; margin: 23px 0 20px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-raised); }
.tool-tabs button { flex: 1; min-height: 33px; padding: 0 7px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; font-size: 10px; font-weight: 630; transition: .16s ease; }
.tool-tabs button:hover { color: var(--text); }
.tool-tabs button.active { background: var(--surface-solid); color: var(--accent); box-shadow: 0 2px 7px rgba(0, 0, 0, .1); }
.tool-pane[hidden] { display: none; }
.field-label { display: grid; gap: 7px; margin-bottom: 14px; color: var(--text-soft); font-size: 10px; font-weight: 620; }
.field-control { width: 100%; font-size: 12px; font-weight: 450; }
.field-control:focus { border-color: var(--accent); }
.converter-fields { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; margin-top: 14px; }
.converter-fields .field-label:nth-child(3) { margin-top: 1px; }
.swap-units { position: absolute; top: 92px; left: calc(50% - 15px); z-index: 1; display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface-solid); color: var(--accent); cursor: pointer; font-size: 15px; }
.swap-units:hover { transform: rotate(180deg); }
.tool-result { display: grid; gap: 8px; margin-top: 13px; padding: 15px; border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line)); border-radius: 13px; background: color-mix(in srgb, var(--accent) 6%, var(--surface-raised)); }
.tool-result > span { color: var(--muted); font-size: 8px; font-weight: 750; letter-spacing: .12em; }
.tool-result output { color: var(--text); font-size: 23px; font-variant-numeric: tabular-nums; font-weight: 520; letter-spacing: -.04em; }
.finance-fields, .date-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; margin-top: 14px; }
.finance-fields .field-label:last-child { grid-column: 1 / -1; }
.finance-fields .field-label { margin-bottom: 11px; }
.primary-action { margin-top: 4px; }
.date-fields { grid-template-columns: 1fr; margin-top: 15px; }
.equation-input { text-align: left; }
.equation-domain { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.equation-domain[hidden], .field-label[hidden] { display: none; }
.equation-help { margin: -3px 0 14px; color: var(--muted); font-size: 9px; line-height: 1.55; }
.equation-result output { font-size: 17px; line-height: 1.5; letter-spacing: -.015em; white-space: pre-line; }
.equation-steps { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-raised); color: var(--text); }
.equation-steps[hidden] { display: none; }
.equation-steps summary { padding: 12px 14px; color: var(--accent); cursor: pointer; font-size: 11px; font-weight: 700; }
.equation-steps pre { max-height: 310px; margin: 0; overflow: auto; padding: 12px; border-top: 1px solid var(--line); color: var(--text-soft); font: 10px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre; }
#gauss-pane .field-label { gap: 5px; margin-bottom: 8px; }
#gauss-pane .equation-help { margin-block: 0 8px; padding-block: 9px; }
.toast { position: fixed; z-index: 10; right: 24px; bottom: 24px; max-width: calc(100vw - 32px); padding: 11px 15px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface-solid); box-shadow: var(--card-shadow); color: var(--text); font-size: 11px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  .app-shell { width: min(760px, calc(100% - 48px)); }
  .main-layout { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 18px; margin: 0; }
  .calculator-card { max-width: 660px; }
  .utility-column { width: 100%; max-width: 660px; display: grid; grid-template-columns: 1fr 1fr; align-items: stretch; }
  .welcome-card { grid-row: span 2; min-height: 100%; }
  .quick-tools-card { padding-top: 16px; }
  .tip-card { align-self: end; }
  .app-footer { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .app-shell { width: 100%; min-height: 100svh; padding: max(14px, env(safe-area-inset-top)) 14px max(15px, env(safe-area-inset-bottom)); }
  .field-control { font-size: 16px; }
  .app-header { min-height: 48px; margin-bottom: 18px; }
  .brand-mark { width: 39px; height: 39px; border-radius: 13px; }
  .brand-copy strong { font-size: 14px; }
  .brand-copy small { font-size: 8px; }
  .header-actions { gap: 6px; }
  .icon-button { width: 38px; height: 38px; border-radius: 12px; }
  .history-trigger { width: 38px; height: 38px; justify-content: center; padding: 0; border-radius: 12px; }
  .history-trigger > span:not(.history-count) { display: none; }
  .history-count { position: absolute; min-width: 15px; height: 15px; margin: -26px 0 0 24px; padding: 0 3px; border: 1px solid var(--page); border-radius: 6px; font-size: 8px; }
  .main-layout { gap: 14px; }
  .calculator-card { padding: 12px; border-radius: 23px; }
  .programmer-panel { margin-top: 0; margin-bottom: 7px; padding-bottom: 7px; }
  .programmer-heading { margin-bottom: 4px; }
  .programmer-heading h2 { font-size: 13px; }
  .programmer-screen { padding: 4px 6px 3px; border-radius: 10px; }
  .programmer-expression { min-height: 11px; margin-top: 1px; font-size: 8px; }
  .programmer-value { margin-bottom: 2px; font-size: 18px; }
  .base-switch button { min-width: 29px; height: 18px; padding-inline: 5px; font-size: 7px; }
  .base-values { gap: 2px; padding-top: 3px; }
  .base-value strong { margin-bottom: 1px; font-size: 6px; }
  .base-value span { font-size: 7px; }
  .programmer-keypad { gap: 1px; margin-top: 3px; }
  .program-key { height: 20px; border-radius: 6px; font-size: 8px; }
  .screen-card { min-height: 95px; padding: 6px 11px 8px; border-radius: 16px; }
  .expression-line { min-height: 13px; margin-top: 4px; font-size: 12px; }
  .result-value { font-size: clamp(32px, 8.7vw, 40px); }
  .error-message { min-height: 8px; margin: 2px 0 -7px; font-size: 9px; }
  .control-row { margin: 2px 0; }
  .memory-keys { gap: 1px; }
  .memory-key { min-width: 29px; min-height: 25px; padding: 0 3px; font-size: 8px; }
  .scientific-toggle { min-height: 27px; gap: 5px; padding-inline: 7px; font-size: 9px; }
  .scientific-glyph { width: 15px; height: 15px; }
  .scientific-panel { margin-bottom: 4px; padding: 2px; }
  .scientific-grid { gap: 1px; }
  .scientific-key { min-height: 21px; font-size: 8px; }
  .angle-key { flex-direction: column; gap: 0; }
  .angle-key small { font-size: 7px; }
  .keypad { gap: 3px; }
  .key { height: clamp(39px, 10.2vw, 41px); border-radius: 12px; font-size: 17px; }
  .key-utility { font-size: 14px; }
  .key-sign { font-size: 15px; }
  .keyboard-hint { display: none; }
  .utility-column { grid-template-columns: 1fr; gap: 11px; }
  .welcome-card { grid-row: auto; min-height: 173px; padding: 18px 18px 14px; }
  .welcome-card h1 { margin: 11px 0 6px; font-size: 23px; }
  .welcome-foot { margin-top: 13px; }
  .welcome-card::after { right: 29px; bottom: 28px; }
  .quick-tools-card { padding: 15px 14px 6px; }
  .tip-card { min-height: 70px; }
  .app-footer { margin: 2px 2px 8px; }
  .side-dialog { top: auto; right: 0; bottom: 0; left: 0; width: 100vw; height: min(84dvh, 680px); padding: 23px 20px max(20px, env(safe-area-inset-bottom)); border-radius: 23px 23px 0 0; }
  .settings-dialog, .tools-dialog { width: calc(100vw - 20px); }
  .tools-dialog { height: min(820px, calc(100dvh - 28px)); padding: 21px 18px; }
  .toast { right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); }
}

@media (max-width: 360px) {
  .app-shell { padding-inline: 10px; }
  .calculator-card { padding: 11px; }
  .keypad { gap: 5px; }
  .key { height: 40px; border-radius: 11px; }
  .programmer-keypad { gap: 3px; }
  .program-key { font-size: 8px; }
  .memory-key { min-width: 29px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Calculator-first visual system */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --page: #eef0ed;
  --page-deep: #e7eae6;
  --surface: #ffffff;
  --surface-solid: #ffffff;
  --surface-raised: #f6f8f6;
  --surface-soft: #edf1ee;
  --line: #e1e6e2;
  --line-strong: #cbd4ce;
  --text: #202923;
  --text-soft: #59645d;
  --muted: #7b857f;
  --accent: #123754;
  --accent-deep: #0a2942;
  --accent-ink: #ffffff;
  --blue: #356c88;
  --warm: #d96722;
  --action: #ec7028;
  --action-deep: #c95716;
  --danger: #b5433b;
  --screen: #fbfcfb;
  --key-shadow: 0 2px 0 rgba(34, 48, 39, .08);
  --card-shadow: 0 12px 32px rgba(31, 48, 37, .09), 0 2px 6px rgba(31, 48, 37, .04);
  --radius-xl: 20px;
  --radius-lg: 15px;
  --radius-md: 11px;
  --focus: #ec7028;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #172026;
  --page-deep: #11181d;
  --surface: #202a30;
  --surface-solid: #202a30;
  --surface-raised: #28343a;
  --surface-soft: #253138;
  --line: rgba(230, 239, 234, .1);
  --line-strong: rgba(230, 239, 234, .18);
  --text: #edf3ef;
  --text-soft: #bdc9c2;
  --muted: #91a098;
  --accent: #f08b48;
  --accent-deep: #cc6727;
  --accent-ink: #17232d;
  --blue: #8bbbd3;
  --warm: #f0b46f;
  --action: #f08b48;
  --action-deep: #c85d1d;
  --danger: #ed9d93;
  --screen: #202b30;
  --key-shadow: 0 2px 0 rgba(0, 0, 0, .22);
  --card-shadow: 0 18px 50px rgba(0, 0, 0, .22);
  --focus: #ffad70;
}

html { background: var(--page); }
body { min-height: 100vh; background: linear-gradient(135deg, var(--page), var(--page-deep)); }
.ambient { display: none; }
.app-shell { width: min(1000px, calc(100% - 40px)); padding: 18px 0 28px; }
.app-header { order: -2; min-height: 42px; margin: 0 2px 8px; padding: 0 0 8px; border-bottom: 1px solid var(--line); }
.brand { gap: 10px; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: var(--surface); box-shadow: none; }
.brand-mark img { width: 29px; height: 29px; }
.brand-copy { gap: 2px; }
.brand-copy strong { font-size: 15px; letter-spacing: -.025em; }
.brand-copy small { font-size: 8px; letter-spacing: .1em; }
.header-actions { gap: 7px; }
.icon-button, .history-trigger { background: var(--surface); border-color: var(--line); color: var(--text-soft); box-shadow: 0 1px 2px rgba(25, 40, 30, .04); }
.icon-button { width: 38px; height: 38px; border-radius: 11px; }
.history-trigger { height: 38px; border-radius: 11px; font-size: 11px; }
.equation-shortcut { display: flex; width: auto; min-width: 38px; align-items: center; justify-content: center; gap: 6px; padding: 0 10px; border-color: #d1dce4; background: #edf3f7; color: var(--accent); font-size: 10px; font-weight: 700; }
.equation-shortcut span:first-child { font-family: Georgia, serif; font-size: 13px; font-style: italic; }

.main-layout { grid-template-columns: minmax(0, 650px); justify-content: center; gap: 0; margin: 0; }
.calculator-card { display: flex; max-width: 610px; flex-direction: column; padding: 10px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--card-shadow); backdrop-filter: none; }
[hidden] { display: none !important; }
.mode-switch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; margin: 1px 0 5px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-raised); }
.mode-switch button { min-width: 0; min-height: 33px; padding: 0 5px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--text-soft); cursor: pointer; font-size: 10px; font-weight: 650; transition: background .15s ease, color .15s ease, box-shadow .15s ease; }
.mode-switch button:hover { color: var(--accent); }
.mode-switch button.active { border-color: color-mix(in srgb, var(--accent) 36%, var(--line)); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); color: var(--accent); box-shadow: 0 1px 3px rgba(27, 41, 32, .08); }
.mode-switch button:focus { outline: none; }
.mode-switch button:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.programmer-panel { margin: 0 0 9px; padding: 14px 13px 12px; border: 1px solid #29383e; border-radius: 13px; background: linear-gradient(155deg, #29363c, #202b30); color: #eef4f0; }
.programmer-heading { margin: 0 1px 9px; }
.programmer-heading .eyebrow { color: #aab9b2; font-size: 8px; letter-spacing: .1em; }
.programmer-heading h2 { margin: 2px 0 0; color: #f3f7f4; font-size: 14px; font-weight: 600; letter-spacing: -.02em; }
.programmer-badge { padding: 4px 6px; border-color: rgba(179, 218, 195, .22); border-radius: 5px; color: #b9e1c8; font-size: 7px; }
.programmer-screen { padding: 7px 9px 6px; border-color: #d4ddd8; border-radius: 7px; background: #edf1ee; color: #23312b; }
.base-switch { gap: 2px; }
.base-switch button { min-width: 34px; height: 21px; border-radius: 5px; color: #64726a; font-size: 8px; }
.base-switch button.active { border-color: #238457; background: #238457; color: #fff; }
.programmer-expression { min-height: 14px; margin-top: 3px; color: #6f7d75; font-size: 9px; }
.programmer-value { margin-bottom: 4px; color: #1f2d26; font-size: clamp(20px, 3vw, 27px); }
.base-values { gap: 3px; padding-top: 5px; border-color: #d4ddd8; }
.base-value { color: #44534a; }
.base-value strong { margin-bottom: 2px; color: #78847d; font-size: 7px; }
.base-value span { font-size: 8px; }
.programmer-error { min-height: 9px; margin: 2px 0 0; color: #a43b35; font-size: 8px; }
.programmer-keypad { gap: 4px; margin-top: 7px; }
.program-key { height: clamp(28px, 3.4vw, 35px); border-color: #536168; border-radius: 6px; background: #3a474d; box-shadow: 0 2px 0 #172126; color: #f0f4f1; font-size: 9px; }
.program-key:hover:not(:disabled) { background: #46565d; }
.program-shift { border-color: var(--accent-deep); background: var(--accent); color: var(--accent-ink); }
.program-shift:hover:not(:disabled) { filter: brightness(1.06); }
.program-memory { color: #9ee0b6; }
.program-delete { border-color: #387591; background: #356c88; color: #fff; }
.program-clear { border-color: #2f718d; background: #2c7899; color: #fff; }
.program-equals { background: #d3e9d9; color: #20553a; }

.screen-card { order: -1; min-height: 118px; margin-bottom: 9px; padding: 12px 15px 13px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--screen); box-shadow: inset 0 2px 5px rgba(32, 46, 37, .035); }
.screen-card::after { display: none; }
.screen-mode { color: var(--text-soft); font-size: 9px; }
.screen-indicators { gap: 7px; }
.standard-readout[hidden], .programmer-readout[hidden] { display: none; }
.status-dot { width: 5px; height: 5px; box-shadow: none; }
.expression-line { min-height: 22px; margin-top: 13px; color: var(--muted); font-size: clamp(14px, 2vw, 18px); }
.result-caption { margin-bottom: 3px; color: var(--muted); font-size: 8px; letter-spacing: .1em; }
.result-value { color: var(--text); font-size: clamp(34px, 5vw, 46px); }
.copy-button { width: 29px; height: 29px; margin: 0; border-radius: 8px; border-color: var(--line); background: var(--surface-raised); color: var(--text-soft); }
.programmer-display-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.programmer-base-label { color: var(--muted); font-size: 9px; }
.programmer-display-head .base-switch button { min-width: 38px; }
.programmer-readout .programmer-expression { min-height: 19px; margin-top: 7px; color: var(--muted); font-size: 12px; }
.programmer-readout .programmer-value { margin: 0 0 7px; color: var(--text); font-size: clamp(34px, 5vw, 45px); }
.programmer-readout .base-values { padding-top: 6px; }
.programmer-readout .base-value strong { font-size: 7px; }
.programmer-readout .base-value span { color: var(--text-soft); font-size: 9px; }
.programmer-readout .programmer-error { min-height: 10px; margin-top: 3px; }
.control-row { margin: 10px 2px 8px; }
.memory-keys { gap: 1px; }
.memory-key { min-width: 34px; min-height: 29px; padding: 0 5px; border-radius: 7px; color: var(--muted); font-size: 9px; }
.memory-key:hover { background: var(--surface-soft); }
.memory-store { color: var(--accent); }
.scientific-toggle { min-height: 31px; gap: 6px; padding-inline: 8px; border-color: var(--line); border-radius: 8px; background: var(--surface-raised); color: var(--text-soft); font-size: 9px; }
.scientific-toggle[aria-expanded="true"] { color: var(--accent); }
.scientific-glyph { width: 17px; height: 17px; border-radius: 5px; }
.scientific-panel { margin-bottom: 9px; padding: 6px; border-color: var(--line); border-radius: 10px; background: var(--surface-raised); }
.scientific-grid { gap: 4px; }
.scientific-key { min-height: 32px; border-color: var(--line); border-radius: 6px; background: var(--surface); color: var(--blue); font-size: 10px; font-weight: 600; box-shadow: 0 1px 0 rgba(27, 41, 32, .04); }
.scientific-key:hover { background: color-mix(in srgb, var(--blue) 7%, var(--surface)); }
.angle-key { color: var(--accent); }
.angle-key small { color: var(--muted); font-size: 7px; }
.keypad { gap: 6px; }
.key { height: clamp(45px, 5vw, 54px); border-color: var(--line); border-radius: 9px; box-shadow: 0 2px 0 rgba(33, 47, 38, .07); font-size: 18px; }
.key-number { background: var(--surface); color: var(--text); }
.key-number:hover { background: #f2f5f2; }
.key-utility { background: #f0f3f5; color: #53616b; font-size: 14px; }
.key-operator { background: #eaf0f2; color: #356c88; font-size: 22px; }
.key-equals { border-color: var(--action); background: var(--action); box-shadow: 0 2px 0 var(--action-deep); color: #fff; }
.keyboard-hint { margin-top: 10px; font-size: 8px; }

.utility-column { gap: 10px; }
.welcome-card, .tip-card, .app-footer { display: none; }
.quick-tools-card { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 10px; padding: 10px 2px 1px; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; box-shadow: none; backdrop-filter: none; }
.section-heading { grid-column: 1 / -1; align-items: center; margin: 0 1px 3px; }
.section-heading .eyebrow { font-size: 8px; }
.section-heading h2 { margin-top: 3px; font-size: 15px; }
.section-index { font-size: 8px; }
.tool-link { min-height: 40px; gap: 7px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-raised); }
.tool-link:hover { padding-inline: 7px 5px; }
.tool-icon { width: 31px; height: 31px; border-radius: 9px; background: #edf3f7; color: var(--accent); }
.finance-icon { background: #eef3f5; color: var(--blue); }
.date-icon { background: #f6f1e9; color: var(--warm); }
.equation-icon { background: #edf3f7; color: var(--accent); }
.tool-link strong { color: var(--text); font-size: 9px; }
.tool-link small { font-size: 7px; }
.tool-arrow { font-size: 11px; }

.side-dialog, .settings-dialog, .tools-dialog { border-color: var(--line); background: var(--surface-solid); color: var(--text); box-shadow: var(--card-shadow); }
.side-dialog { border-radius: 16px 0 0 16px; }
.settings-dialog, .tools-dialog { border-radius: 17px; }
.dialog-header h2 { font-size: 22px; }
.tool-tabs { border-color: var(--line); border-radius: 9px; background: var(--surface-raised); }
.tool-tabs button { font-size: 9px; }
.tool-tabs button.active { background: var(--surface); box-shadow: 0 1px 3px rgba(27, 41, 32, .08); }
.field-control { border-color: var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--text); }
.tool-result { border-radius: 10px; background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.primary-action, .settings-done { border-radius: 9px; background: var(--action); color: #fff; }
.setting-row select { background: var(--surface); color: var(--text); }
.history-item { border-radius: 10px; background: var(--surface); }
.toast { border-radius: 9px; background: var(--surface-solid); }

@media (max-width: 820px) {
  .app-shell { width: min(620px, calc(100% - 32px)); }
  .main-layout { grid-template-columns: minmax(0, 1fr); justify-items: stretch; gap: 0; }
  .calculator-card { max-width: none; }
  .utility-column { width: 100%; max-width: none; display: block; }
  .quick-tools-card { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 8px; margin-top: 8px; padding-top: 8px; }
  .section-heading { grid-column: 1 / -1; }
  .tool-link { min-height: 42px; border-top: 1px solid var(--line); }
}

@media (max-width: 620px) {
  .app-shell { width: 100%; padding: max(10px, env(safe-area-inset-top)) 11px max(14px, env(safe-area-inset-bottom)); }
  .app-header { min-height: 37px; margin: 0 1px 6px; padding-bottom: 6px; }
  .brand-mark { width: 39px; height: 39px; border-radius: 11px; }
  .brand-mark img { width: 31px; height: 31px; }
  .brand-copy strong { font-size: 13px; }
  .brand-copy small { font-size: 7px; }
  .header-actions { gap: 5px; }
  .icon-button { width: 34px; height: 34px; border-radius: 9px; }
  .equation-shortcut { width: 34px; min-width: 34px; padding: 0; }
  .equation-shortcut span:last-child { display: none; }
  .history-trigger { width: 34px; height: 34px; padding: 0; border-radius: 9px; justify-content: center; }
  .history-trigger > span:not(.history-count) { display: none; }
  .history-count { min-width: 14px; height: 14px; margin: -24px 0 0 22px; font-size: 7px; }
  .calculator-card { padding: 7px; border-radius: 14px; }
  .mode-switch { margin-bottom: 4px; padding: 2px; }
  .mode-switch button { min-height: 30px; font-size: 9px; }
  .programmer-panel { margin-bottom: 7px; padding: 10px 9px 9px; border-radius: 10px; }
  .programmer-heading { margin-bottom: 7px; }
  .programmer-heading h2 { font-size: 12px; }
  .programmer-screen { padding: 5px 6px 4px; }
  .base-switch button { min-width: 29px; height: 18px; padding-inline: 4px; font-size: 7px; }
  .programmer-expression { min-height: 12px; font-size: 8px; }
  .programmer-value { margin-bottom: 3px; font-size: 20px; }
  .base-values { padding-top: 4px; }
  .base-value strong { font-size: 6px; }
  .base-value span { font-size: 7px; }
  .programmer-keypad { gap: 3px; margin-top: 6px; }
  .program-key { height: 27px; border-radius: 5px; font-size: 8px; }
  .screen-card { min-height: 94px; padding: 8px 10px 9px; border-radius: 9px; }
  .screen-card { margin-bottom: 7px; }
  .programmer-display-head { margin-top: 4px; }
  .programmer-display-head .base-switch button { min-width: 33px; height: 20px; font-size: 7px; }
  .programmer-readout .programmer-expression { min-height: 15px; margin-top: 5px; font-size: 10px; }
  .programmer-readout .programmer-value { margin-bottom: 4px; font-size: clamp(30px, 8vw, 38px); }
  .programmer-readout .base-values { padding-top: 4px; }
  .programmer-readout .base-value strong { font-size: 6px; }
  .programmer-readout .base-value span { font-size: 7px; }
  .programmer-readout .programmer-error { min-height: 8px; margin-top: 2px; font-size: 7px; }
  .expression-line { min-height: 17px; margin-top: 8px; font-size: 13px; }
  .result-value { font-size: clamp(30px, 8vw, 38px); }
  .error-message { min-height: 10px; margin: 3px 0 -5px; font-size: 8px; }
  .control-row { margin: 7px 1px 6px; }
  .memory-keys { gap: 0; }
  .memory-key { min-width: 29px; min-height: 25px; padding: 0 3px; font-size: 8px; }
  .scientific-toggle { min-height: 27px; gap: 4px; padding-inline: 6px; font-size: 8px; }
  .scientific-glyph { width: 15px; height: 15px; }
  .scientific-panel { margin-bottom: 7px; padding: 4px; border-radius: 8px; }
  .scientific-grid { gap: 3px; }
  .scientific-key { min-height: 28px; border-radius: 5px; font-size: 8px; }
  .keypad { gap: 4px; }
  .key { height: clamp(40px, 11vw, 46px); border-radius: 8px; font-size: 17px; }
  .key-utility { font-size: 13px; }
  .key-sign { font-size: 14px; }
  .keyboard-hint { display: none; }
  .quick-tools-card { margin-bottom: 0; padding: 8px 1px 1px; gap: 4px; }
  .section-heading { margin-bottom: 7px; }
  .tool-link { min-height: 44px; gap: 7px; padding: 5px 1px; }
  .tool-icon { width: 27px; height: 27px; border-radius: 8px; font-size: 14px; }
  .tool-link strong { font-size: 9px; }
  .tool-link small { font-size: 7px; }
  .side-dialog { width: 100vw; height: min(84dvh, 680px); padding: 20px 17px max(18px, env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; }
  .settings-dialog, .tools-dialog { width: calc(100vw - 18px); }
  .tools-dialog { height: min(820px, calc(100dvh - 24px)); padding: 18px 15px; }
  .tool-tabs { margin: 16px 0; }
}

@media (max-width: 360px) {
  .app-shell { padding-inline: 8px; }
  .calculator-card { padding: 6px; }
  .programmer-panel { padding-inline: 7px; }
  .program-key { height: 25px; font-size: 7px; }
  .memory-key { min-width: 26px; }
  .scientific-key { font-size: 7px; }
}

/* Keep the calculator stationary inside the available screen area. */
html, body { width: 100%; height: 100%; min-height: 0; overflow: hidden; overscroll-behavior: none; }
body { height: 100vh; height: 100dvh; }
.app-shell { width: min(1000px, calc(100% - 20px)); height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; margin: 0 auto; padding: max(6px, env(safe-area-inset-top)) 0 max(6px, env(safe-area-inset-bottom)); }
.main-layout { display: flex; flex: 1; width: 100%; min-height: 0; align-items: center; justify-content: center; margin: 0; }
.calculator-card { display: grid; grid-template-rows: auto auto auto auto auto auto auto; align-content: center; row-gap: clamp(3px, 1vh, 8px); width: min(100%, 610px); height: auto; max-width: 610px; max-height: 100%; min-height: 0; overflow: hidden; }
.app-header { grid-row: 1; min-height: 38px; margin: 0 2px 4px; padding-bottom: 4px; }
.screen-card { grid-row: 2; }
.mode-switch { grid-row: 3; }
.control-row { grid-row: 4; }
.programmer-panel, .scientific-panel { grid-row: 5; }
.keypad { grid-row: 6; }
.keyboard-hint { display: none; }
.tools-open-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.tools-open-button:hover { color: var(--accent); }
.side-dialog, .settings-dialog, .tools-dialog { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); overflow: auto; overscroll-behavior: contain; }

@media (max-width: 820px) {
  .app-shell { width: 100%; padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right)); }
  .calculator-card { width: 100%; max-width: 610px; }
}

@media (max-width: 620px) {
  .app-header { min-height: 34px; margin-bottom: 3px; padding-bottom: 3px; }
  .brand { gap: 7px; }
  .brand-copy small { font-size: 7px; letter-spacing: .07em; }
  .header-actions { gap: 4px; }
  .icon-button, .history-trigger { width: 32px; min-width: 32px; height: 32px; }
  .history-count { margin-top: -23px; }
  .calculator-card { padding: 7px; }
  .screen-card { min-height: 86px; margin-bottom: 4px; padding: 7px 9px 8px; }
  .expression-line { min-height: 15px; margin-top: 6px; }
  .result-value, .programmer-readout .programmer-value { font-size: clamp(28px, 8vw, 36px); }
  .mode-switch { margin: 0 0 2px; }
  .mode-switch button { min-height: 27px; }
  .control-row { margin: 3px 1px; }
  .keypad { gap: 4px; }
  .key { height: clamp(36px, 8vh, 46px); }
  .scientific-panel { margin-bottom: 0; padding: 4px; }
  .scientific-grid { gap: 3px; }
  .scientific-key { min-height: clamp(24px, 3.2vh, 28px); }
  .programmer-panel { margin-bottom: 0; padding: 8px; }
  .programmer-heading { margin-bottom: 5px; }
  .programmer-keypad { gap: 3px; margin-top: 5px; }
  .program-key { height: clamp(24px, 4vh, 29px); }
}

@media (max-width: 360px) {
  .brand-copy small { display: none; }
  .header-actions { gap: 3px; }
  .icon-button, .history-trigger { width: 29px; min-width: 29px; height: 29px; }
  .calculator-card { padding: 6px; }
}

@media (max-height: 560px) {
  .app-shell { padding-block: max(3px, env(safe-area-inset-top)) max(3px, env(safe-area-inset-bottom)); }
  .calculator-card { padding: 5px; }
  .app-header { min-height: 27px; margin-bottom: 1px; padding-bottom: 1px; }
  .brand-mark { width: 26px; height: 26px; border-radius: 7px; }
  .brand-mark img { width: 20px; height: 20px; }
  .brand-copy strong { font-size: 11px; }
  .brand-copy small { font-size: 6px; }
  .icon-button, .history-trigger { width: 26px; min-width: 26px; height: 26px; }
  .icon-button svg, .history-trigger svg { width: 14px; height: 14px; }
  .screen-card { min-height: 64px; margin-bottom: 2px; padding: 5px 7px; }
  .expression-line { min-height: 12px; margin-top: 3px; font-size: 11px; }
  .result-caption { font-size: 7px; }
  .result-value, .programmer-readout .programmer-value { font-size: 25px; }
  .programmer-readout .programmer-expression { min-height: 12px; margin-top: 2px; font-size: 9px; }
  .programmer-display-head { margin-top: 1px; }
  .programmer-display-head .base-switch button { min-width: 28px; height: 16px; padding-inline: 3px; font-size: 6px; }
  .mode-switch { margin: 0; padding: 1px; }
  .mode-switch button { min-height: 22px; padding-inline: 2px; font-size: 8px; }
  .control-row { margin: 1px 0; }
  .memory-key { min-width: 24px; min-height: 19px; font-size: 7px; }
  .keypad { gap: 2px; }
  .key { height: clamp(21px, calc((100dvh - 270px) / 5), 28px); border-radius: 5px; font-size: 14px; }
  .scientific-panel { padding: 2px; }
  .scientific-grid { gap: 2px; }
  .scientific-key { min-height: clamp(17px, calc((100dvh - 330px) / 4), 21px); padding: 1px; font-size: 7px; }
  .programmer-panel { padding: 5px; }
  .programmer-heading h2 { font-size: 10px; }
  .programmer-heading .eyebrow, .programmer-badge { font-size: 6px; }
  .programmer-keypad { gap: 2px; margin-top: 2px; }
  .program-key { height: clamp(19px, calc((100dvh - 240px) / 7), 24px); border-radius: 4px; font-size: 7px; }
}

/* Larger key legends stay readable on touchscreens without changing the keypad grid. */
.mode-switch button { font-size: clamp(10px, 2.2vw, 11px); }
.base-switch button, .programmer-display-head .base-switch button { font-size: 9px; }
.programmer-readout .base-value strong { font-size: 8px; }
.memory-key { font-size: 10px; }
.key-number { font-size: clamp(19px, 4.5vw, 23px); font-weight: 600; }
.key-utility { font-size: 16px; }
.key-operator { font-size: clamp(20px, 4.8vw, 24px); }
.key-sign { font-size: 17px; }
.scientific-key { font-size: clamp(10px, 2.4vw, 12px); }
.angle-key small { font-size: 9px; }
.program-key { font-size: clamp(9px, 2.2vw, 11px); }

@media (max-width: 360px) {
  .mode-switch button { font-size: 10px; }
  .base-switch button, .programmer-display-head .base-switch button { font-size: 8px; }
  .memory-key { font-size: 9px; }
  .scientific-key { font-size: 10px; }
  .program-key { font-size: 9px; }
}

@media (max-height: 560px) {
  .mode-switch button { font-size: 9px; }
  .base-switch button, .programmer-display-head .base-switch button { font-size: 8px; }
  .key-number { font-size: clamp(15px, 4.5vh, 18px); }
  .key-utility { font-size: 14px; }
  .key-operator { font-size: clamp(17px, 4.8vh, 19px); }
  .scientific-key { font-size: 9px; }
  .program-key { font-size: 9px; }
}

/* ITSSCM premium finish: one calm, branded surface for web, laptop and APK. */
:root {
  --page: #081421;
  --page-deep: #050d17;
  --surface: rgba(15, 29, 44, .96);
  --surface-solid: #0f1d2c;
  --surface-raised: #16283a;
  --surface-soft: #1b3043;
  --line: rgba(183, 211, 235, .12);
  --line-strong: rgba(183, 211, 235, .2);
  --text: #f4f7fa;
  --text-soft: #b9c9d8;
  --muted: #8498aa;
  --accent: #f18a48;
  --accent-deep: #d5672c;
  --accent-ink: #21140c;
  --blue: #63b5df;
  --warm: #f6bd7e;
  --danger: #f0978d;
  --action: #ff9148;
  --action-deep: #d96827;
  --screen: linear-gradient(145deg, #14283b, #102033);
  --key-shadow: 0 3px 0 rgba(0, 0, 0, .24), 0 8px 18px rgba(0, 0, 0, .12);
  --card-shadow: 0 28px 80px rgba(0, 0, 0, .34), 0 4px 16px rgba(0, 0, 0, .18);
  --focus: #ffc078;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  --page: #eef3f8;
  --page-deep: #e3ebf3;
  --surface: rgba(255, 255, 255, .96);
  --surface-solid: #ffffff;
  --surface-raised: #f4f7fa;
  --surface-soft: #eaf0f5;
  --line: rgba(21, 48, 72, .1);
  --line-strong: rgba(21, 48, 72, .17);
  --text: #172b3d;
  --text-soft: #4e6578;
  --muted: #71869a;
  --accent: #bd4d17;
  --accent-deep: #963a0f;
  --accent-ink: #ffffff;
  --blue: #286d98;
  --warm: #94612b;
  --danger: #b43e38;
  --action: #c65319;
  --action-deep: #9e3f12;
  --screen: linear-gradient(145deg, #ffffff, #f1f6fa);
  --key-shadow: 0 2px 0 rgba(29, 53, 73, .08), 0 6px 16px rgba(29, 53, 73, .055);
  --card-shadow: 0 24px 66px rgba(23, 47, 68, .13), 0 3px 10px rgba(23, 47, 68, .05);
  --focus: #a64113;
}

html { background: var(--page); }
body {
  background:
    radial-gradient(ellipse at 12% 5%, rgba(46, 125, 177, .2), transparent 34%),
    radial-gradient(ellipse at 90% 96%, rgba(225, 105, 41, .12), transparent 32%),
    linear-gradient(145deg, var(--page), var(--page-deep));
}
:root[data-theme="light"] body {
  background:
    radial-gradient(ellipse at 11% 4%, rgba(63, 133, 178, .11), transparent 34%),
    radial-gradient(ellipse at 91% 98%, rgba(221, 116, 56, .08), transparent 30%),
    linear-gradient(145deg, var(--page), var(--page-deep));
}

.app-shell { width: min(1040px, calc(100% - 20px)); }
.calculator-card {
  width: min(100%, clamp(600px, 56vw, 760px));
  max-width: 760px;
  padding: clamp(7px, 1.5vw, 14px);
  border: 1px solid var(--line-strong);
  border-radius: clamp(18px, 2.4vw, 27px);
  background: linear-gradient(148deg, color-mix(in srgb, var(--surface-solid) 96%, white 4%), var(--surface-solid));
  box-shadow: var(--card-shadow), inset 0 1px 0 rgba(255, 255, 255, .075);
}
:root[data-theme="light"] .calculator-card { box-shadow: var(--card-shadow), inset 0 1px 0 #fff; }

.app-header {
  min-height: 44px;
  margin: 0 2px 3px;
  padding-bottom: 8px;
  border-color: var(--line);
}
.brand { gap: 10px; }
.brand-mark {
  width: 41px;
  height: 41px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  clip-path: circle(42.1% at 50% 50%);
}
.brand-copy strong { font-size: 16px; letter-spacing: .015em; }
.brand-copy small { color: var(--muted); font-size: 8px; letter-spacing: .14em; }
.header-actions { gap: 6px; }
.icon-button, .history-trigger {
  border-color: var(--line);
  background: color-mix(in srgb, var(--surface-raised) 76%, transparent);
  color: var(--text-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035);
}
.icon-button { width: 38px; height: 38px; border-radius: 12px; }
.history-trigger { height: 38px; border-radius: 12px; }

.screen-card {
  min-height: 118px;
  margin-bottom: 6px;
  padding: 12px 15px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 17px;
  background: var(--screen);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .055), inset 0 -1px 0 rgba(0, 0, 0, .08);
}
.screen-mode { color: var(--text-soft); font-size: 10px; }
.status-dot { width: 7px; height: 7px; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
.expression-line { min-height: 24px; color: var(--muted); font-size: clamp(15px, 2.1vw, 19px); }
.result-caption { color: var(--muted); font-size: 9px; }
.result-value, .programmer-readout .programmer-value { color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -.045em; }
.copy-button { border-color: var(--line); background: var(--surface-raised); color: var(--text-soft); }

.mode-switch {
  gap: 4px;
  padding: 4px;
  border-color: var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-raised) 82%, transparent);
}
.mode-switch button { min-height: 36px; border-radius: 9px; color: var(--text-soft); font-size: 11px; font-weight: 700; }
.mode-switch button.active {
  border-color: var(--action);
  background: var(--action);
  color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 3px 8px rgba(0, 0, 0, .12);
}

.control-row { margin: 7px 2px 5px; }
.memory-key { min-height: 30px; border-radius: 8px; color: var(--text-soft); font-size: 11px; font-weight: 650; }
.memory-store { color: var(--accent); }
.scientific-toggle { min-height: 32px; border-radius: 9px; background: var(--surface-raised); color: var(--text-soft); }
.scientific-toggle[aria-expanded="true"] { border-color: color-mix(in srgb, var(--accent) 36%, var(--line)); background: color-mix(in srgb, var(--accent) 10%, var(--surface-raised)); color: var(--accent); }
.scientific-glyph { background: color-mix(in srgb, var(--blue) 18%, var(--surface)); color: var(--blue); }
.scientific-panel { border-color: var(--line); border-radius: 13px; background: color-mix(in srgb, var(--surface-raised) 82%, transparent); }
.scientific-key {
  min-height: 33px;
  border-color: var(--line);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--blue);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 2px 0 rgba(0, 0, 0, .08);
}
.angle-key { color: var(--accent); }

.keypad { gap: clamp(4px, .8vw, 7px); }
.key {
  border-color: var(--line);
  border-radius: 11px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .075), var(--key-shadow);
  font-weight: 560;
  transition: transform .12s ease, filter .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.key-number {
  background: var(--surface-raised);
  color: var(--text);
}
.key-utility {
  background: #263a4d;
  border-color: #385166;
  color: #d3e3ee;
}
.key-operator {
  background: #203c50;
  border-color: #35556c;
  color: #9bd8f0;
  font-weight: 650;
}
.key-equals {
  border-color: var(--action);
  background: linear-gradient(145deg, color-mix(in srgb, var(--action) 90%, white 10%), var(--action));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 3px 0 var(--action-deep), 0 8px 18px color-mix(in srgb, var(--action) 19%, transparent);
  color: var(--accent-ink);
  font-size: 22px;
  font-weight: 750;
}
:root[data-theme="light"] .mode-switch button.active { color: #fff; }
:root[data-theme="light"] .key-number { border-color: #dce5ed; background: #fff; color: #162d42; }
:root[data-theme="light"] .key-utility { border-color: #d7e2eb; background: #edf3f7; color: #315670; }
:root[data-theme="light"] .key-utility[data-action="clear"] { border-color: #f2cdb8; background: #fff0e8; color: #9b3e16; }
:root[data-theme="light"] .key-operator { border-color: #cbdde9; background: #e5eff6; color: #225f88; }
:root[data-theme="dark"] .key-utility[data-action="clear"] { border-color: #755044; background: #49342f; color: #ffd0b7; }

.programmer-panel {
  border-color: rgba(112, 164, 197, .24);
  border-radius: 15px;
  background: linear-gradient(145deg, #132638, #0d1b2a);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
}
.programmer-heading .eyebrow { color: #8eabc0; }
.programmer-badge { border-color: rgba(99, 181, 223, .32); color: #8dd1f1; }
.programmer-screen { border-color: rgba(91, 130, 154, .26); background: linear-gradient(145deg, #e8f1f4, #dce8ed); }
.program-key { border-color: #354d60; border-radius: 8px; background: #203548; box-shadow: 0 2px 0 #081421; }
.program-key:hover:not(:disabled) { background: #2a465b; }
.program-shift { border-color: var(--action); background: var(--action); color: var(--accent-ink); }
.program-delete, .program-clear { border-color: #367fa2; background: #286d8b; color: #fff; }
.program-equals { border-color: #6dbb9b; background: #c9f0dc; color: #154d37; }

.key:focus-visible, .mode-switch button:focus-visible, .scientific-key:focus-visible,
.program-key:focus-visible, .icon-button:focus-visible, .history-trigger:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
@media (hover: hover) and (pointer: fine) {
  .key:hover { filter: brightness(1.07); transform: translateY(-1px); }
  .scientific-key:hover { border-color: color-mix(in srgb, var(--blue) 35%, var(--line)); filter: brightness(1.04); }
  .icon-button:hover, .history-trigger:hover { border-color: var(--line-strong); background: var(--surface-soft); color: var(--text); }
}
.key:active, .scientific-key:active, .program-key:active { transform: translateY(1px); filter: brightness(.97); }

@media (max-width: 620px) {
  .app-shell { width: 100%; padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right)); }
  .calculator-card { width: 100%; max-width: 760px; border-radius: 20px; }
  .brand-mark { width: 37px; height: 37px; }
  .screen-card { min-height: 86px; padding: 7px 10px 8px; }
  .key { border-radius: 9px; }
}
@media (max-height: 560px) {
  .calculator-card { padding: 5px; border-radius: 15px; }
  .app-header { min-height: 27px; padding-bottom: 2px; }
  .brand-mark { width: 26px; height: 26px; }
  .screen-card { min-height: 64px; margin-bottom: 2px; padding: 5px 7px; border-radius: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

.equation-help {
  margin: 4px 0 14px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 11px;
  background: var(--surface-raised);
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.55;
}
