    :root {
      color-scheme: light;
      --page: #f7f7f4;
      --ink: #1c1d1b;
      --muted: #858783;
      --key: #ffffff;
      --key-border: #eceee9;
      --active-ring: #afb4ac;
      --accent: #30342e;
      --hairline: #e3e5df;
    }
    * { box-sizing: border-box; }
    html {
      width: 100%;
      height: 100%;
      overflow: hidden;
      overscroll-behavior: none;
      -webkit-text-size-adjust: 100%;
    }
    body {
      width: 100%;
      height: 100%;
      margin: 0;
      overflow: hidden;
      overscroll-behavior: none;
      background: var(--page);
      color: var(--ink);
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
      -webkit-font-smoothing: antialiased;
    }
    button { font: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
    button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
    .app {
      width: 100%;
      max-width: 480px;
      height: 100vh;
      height: 100svh;
      min-height: 0;
      margin: 0 auto;
      padding: max(18px, env(safe-area-inset-top)) 18px max(12px, env(safe-area-inset-bottom));
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    .masthead { display: flex; align-items: center; justify-content: space-between; flex: 0 0 auto; }
    .brand {
      display: flex;
      align-items: center;
      width: max-content;
      user-select: none;
    }
    .brand-word { font-size: 24px; font-weight: 650; letter-spacing: -1.45px; line-height: 1; }
    .brand-word { margin: 0; }
    .brand-dot { color: var(--accent); }
    .theme-toggle {
      display: grid;
      place-items: center;
      width: 44px;
      height: 44px;
      border: 0;
      border-radius: 50%;
      background: transparent;
      color: var(--muted);
      cursor: pointer;
    }
    .theme-toggle svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    .theme-toggle:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
    .theme-toggle [hidden] { display: none; }
    .stage {
      flex: 1 1 0;
      min-height: 0;
      display: flex;
      flex-direction: column;
      align-items: stretch;
      justify-content: flex-end;
      text-align: right;
      padding: clamp(4px, 2.4svh, 22px) 7px clamp(5px, 2.4svh, 24px);
      overflow: hidden;
      font-variant-numeric: tabular-nums lining-nums;
    }
    .expression {
      height: clamp(17px, 3svh, 27px);
      flex: 0 0 auto;
      margin-bottom: clamp(2px, .8svh, 7px);
      color: var(--muted);
      font-size: 17px;
      font-weight: 480;
      letter-spacing: -.2px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .result {
      appearance: none;
      -webkit-appearance: none;
      display: block;
      width: 100%;
      min-width: 0;
      flex: 0 0 auto;
      margin: 0;
      font-size: clamp(56px, 15.5vw, 92px);
      line-height: 1.14;
      font-weight: 465;
      letter-spacing: -.06em;
      white-space: nowrap;
      overflow: visible;
      text-align: right;
      font-feature-settings: "tnum" 1;
      padding: 0;
      border: 0;
      background: transparent;
      color: var(--ink);
      cursor: copy;
    }
    .divider { height: 1px; background: var(--hairline); margin: 0 5px clamp(6px, 1.8svh, 17px); flex: 0 0 auto; }
    .keys {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      grid-template-rows: repeat(5, clamp(44px, calc((100svh - 220px) / 5), 86px));
      gap: clamp(4px, 1.15svh, 12px);
      flex: 0 0 auto;
    }
    .key {
      display: flex;
      align-items: center;
      justify-content: center;
      min-width: 0;
      min-height: 0;
      padding: 0;
      border: 1px solid var(--key-border);
      border-radius: clamp(14px, 4.5vw, 22px);
      background: var(--key);
      color: var(--ink);
      font-size: clamp(25px, 7vw, 32px);
      font-weight: 490;
      line-height: 1;
      cursor: pointer;
      transition: transform .13s ease;
      user-select: none;
    }
    .key:active { transform: scale(.956); }
    @media (hover: hover) and (pointer: fine) {
      .key:hover:not(:active) { filter: brightness(.985); }
    }
    .key.function { font-size: clamp(21px, 6vw, 26px); font-weight: 470; }
    .key.operation { font-size: clamp(28px, 7.6vw, 35px); font-weight: 480; }
    .key.operation.selected { box-shadow: inset 0 0 0 1px var(--active-ring); }
    .key.equals { font-size: 34px; font-weight: 650; }
    .key.backspace svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 1.9; fill: none; stroke-linecap: round; stroke-linejoin: round; }
    .copy-helper { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
    .noscript { color: var(--muted); text-align: center; font-size: 14px; }
    .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
    @media (min-width: 600px) and (min-height: 600px) {
      body { display: grid; place-items: center; }
      .app { height: min(760px, 96svh); padding: 35px 20px 24px; }
      .keys { grid-template-rows: repeat(5, min(83px, max(50px, calc((96svh - 240px) / 5)))); gap: 11px; }
    }
    @media (max-height: 610px) and (orientation: portrait) {
      .app { padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
      .brand-word { font-size: 21px; }
      .stage { padding: 4px 6px 7px; }
      .expression { height: 22px; font-size: 15px; margin-bottom: 2px; }
      .divider { margin-bottom: 10px; }
      .keys { gap: clamp(4px, 1.15svh, 7px); }
      .key { border-radius: 18px; }
    }
    @media (max-width: 360px) {
      .app { padding-left: 12px; padding-right: 12px; }
    }
    @media (max-height: 400px) and (orientation: portrait) {
      .app { padding-top: max(7px, env(safe-area-inset-top)); padding-bottom: max(7px, env(safe-area-inset-bottom)); }
      .brand-word { font-size: 19px; }
      .expression { height: 16px; font-size: 12px; }
      .divider { margin-bottom: 5px; }
      .key { border-radius: 13px; font-size: 23px; }
    }
    @media (orientation: landscape) and (max-height: 540px) {
      .app {
        max-width: 900px;
        height: 100svh;
        min-height: 0;
        padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
        display: grid;
        grid-template-columns: minmax(0, .84fr) minmax(0, 1.16fr);
        grid-template-rows: auto 1fr;
        column-gap: 20px;
      }
      .masthead { grid-column: 1; grid-row: 1; }
      .stage { grid-column: 1; grid-row: 2; min-height: 0; padding: 10px 0 12px; }
      .result { font-size: clamp(42px, 7vw, 78px); }
      .divider { display: none; }
      .keys { grid-column: 2; grid-row: 1 / 3; align-self: stretch; grid-template-rows: repeat(5, minmax(0, 1fr)); gap: 6px; }
      .key { border-radius: 14px; font-size: 25px; }
      .key.function { font-size: 20px; }
    }
    @media (orientation: landscape) and (max-height: 350px) {
      .app { padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: max(4px, env(safe-area-inset-bottom)); }
      .keys { gap: 4px; }
    }
    :root[data-theme="dark"] {
        color-scheme: dark;
        --page: #171917;
        --ink: #f2f2ed;
        --muted: #a0a39e;
        --key: #292c29;
        --key-border: #343834;
        --active-ring: #848a80;
        --accent: #e8ebe6;
        --hairline: #353934;
    }
    @media (prefers-color-scheme: dark) {
      :root:not([data-theme]) {
        color-scheme: dark;
        --page: #171917;
        --ink: #f2f2ed;
        --muted: #a0a39e;
        --key: #292c29;
        --key-border: #343834;
        --active-ring: #848a80;
        --accent: #e8ebe6;
        --hairline: #353934;
      }
    }
    @media (prefers-contrast: more) {
      :root { --muted: #666b6a; --hairline: #aeb2b1; }
      .key { outline: 1px solid var(--hairline); outline-offset: -1px; }
      .key:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
    }
    @media (prefers-contrast: more) and (prefers-color-scheme: dark) {
      :root:not([data-theme="light"]) { --muted: #c3c8c7; --hairline: #757a7b; }
    }
    @media (prefers-contrast: more) {
      :root[data-theme="dark"] { --muted: #c3c8c7; --hairline: #757a7b; }
    }
    @media (prefers-reduced-motion: reduce) { .key { transition: none; } }
