    :root {
      --bg: #f9f8f5;
      --surface: #ffffff;
      --line: #e5e2d9;
      --text: #2c2c34;
      --text-soft: #2c2c34;
      --accent: #5b6abf;
      --accent-ink: #2c2c34;
      --shadow: 0 18px 40px rgba(0,0,0,0.06);
      --motion-smooth: cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    * { box-sizing: border-box; }

    html, body {
      margin: 0;
      min-height: 100%;
      background: radial-gradient(1300px 700px at 50% -200px, #f4f3ee 0%, #f9f8f5 45%, #f9f8f5 100%);
      color: var(--text);
      font-family: "Inter", "Segoe UI", sans-serif;
    }

    .app {
      width: 100%;
      margin: 0 auto;
      min-height: calc(100vh - 20px);
      display: grid;
      grid-template-columns: 1fr;
      gap: 10px;
    }

    .panel {
      border: 1px solid var(--line);
      border-radius: 20px;
      background: #ffffff;
      box-shadow: var(--shadow);
      overflow: hidden;
      backdrop-filter: blur(4px);
    }

    .left {
      display: grid;
      grid-template-rows: auto 1fr auto;
      min-height: 0;
    }

    .left-head {
      padding: 12px;
      border-bottom: 1px solid var(--line);
      display: grid;
      gap: 8px;
      background: rgba(0,0,0,0.02);
    }

    .brand {
      margin: 0;
      font-family: "Instrument Serif", sans-serif;
      font-size: 20px;
      letter-spacing: 0.02em;
    }

    .sub {
      font-size: 12px;
      color: var(--text-soft);
    }

    .search {
      width: 100%;
      border: 1px solid #c0bfba;
      border-radius: 11px;
      background: #ffffff;
      color: #2c2c34;
      padding: 10px 12px;
      outline: none;
    }

    .search:focus {
      border-color: #2c2c34;
      box-shadow: 0 0 0 3px rgba(96, 141, 207, 0.25);
    }

    .list {
      padding: 8px;
      overflow: auto;
      display: grid;
      gap: 8px;
      align-content: start;
    }

    .entry {
      border: 1px solid #f4f3ee;
      border-radius: 14px;
      background: #ffffff;
      padding: 10px;
      display: grid;
      gap: 7px;
      transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    }

    .entry:hover {
      border-color: #c0bfba;
      transform: translateY(-1px);
      box-shadow: 0 10px 18px rgba(8, 17, 30, 0.08);
    }

    .entry strong {
      font-size: 14px;
      line-height: 1.28;
      color: #2c2c34;
    }

    .entry.stagger-in {
      animation: cardIn 0.24s var(--motion-smooth) both;
      animation-delay: calc(var(--stagger, 0) * 14ms);
    }

    .small {
      font-size: 12px;
      color: var(--text-soft);
    }

    .row {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      align-items: center;
    }

    .chip {
      border: 1px solid #c0bfba;
      background: #ffffff;
      color: #2c2c34;
      border-radius: 999px;
      font-size: 11px;
      
      padding: 4px 8px;
      display: inline-block;
    }

    .pick {
      width: 18px;
      height: 18px;
      accent-color: var(--accent);
    }

    button,
    input,
    select {
      font: inherit;
    }

    button {
      border: 1px solid #c0bfba;
      border-radius: 10px;
      background: #ffffff;
      color: #2c2c34;
      
      padding: 8px 10px;
      cursor: pointer;
    }

    button:hover {
      background: #f4f3ee;
      border-color: #2c2c34;
    }

    button.primary {
      background: var(--accent);
      border-color: var(--accent);
      color: var(--accent-ink);
      
    }

    button.primary:hover {
      background: #5b6abf;
    }

    .left-foot {
      border-top: 1px solid #f4f3ee;
      background: #f4f3ee;
      flex-shrink: 0;
    }

    .nav {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
    }

    .nav .logo { grid-column: 1 / -1; justify-content: center; }

    .nav a {
      text-decoration: none;
      color: #2c2c34;
      border: none;
      border-top: 2px solid transparent;
      border-right: 1px solid #f4f3ee;
      text-align: center;
      padding: 10px 6px;
      font-size: 11.5px;
      
      background: transparent;
      transition: color 0.12s, background 0.12s;
      white-space: nowrap;
    }

    .nav a:last-child { border-right: none; }
    .nav a:hover { color: #2c2c34; background: rgba(0,0,0,0.03); }
    .nav a.active {
      color: #5b6abf;
      border-top-color: #5b6abf;
      background: rgba(91,106,191,.05);
    }

    .right {
      display: grid;
      grid-template-rows: auto 1fr;
      min-height: 0;
    }

    .right-head {
      border-bottom: 1px solid var(--line);
      padding: 10px 12px;
      background: rgba(0,0,0,0.02);
      display: grid;
      gap: 10px;
    }

    .right-head h1 {
      margin: 0;
      font-family: "Instrument Serif", sans-serif;
      font-size: 18px;
      letter-spacing: -0.01em;
    }

    .controls {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      align-items: center;
    }

    .controls input,
    .controls select {
      border: 1px solid #c0bfba;
      border-radius: 10px;
      background: #ffffff;
      color: #2c2c34;
      padding: 8px 10px;
      outline: none;
      min-width: 120px;
    }

    .status {
      font-size: 12px;
      color: #2c2c34;
    }

    .workspace {
      padding: 14px;
      overflow: auto;
      background-color: #f9f8f5;
      background-image:
        radial-gradient(rgba(91,106,191,0.04) 1px, transparent 1px),
        linear-gradient(180deg, rgba(91,106,191,0.03), transparent);
      background-size: 22px 22px, 100% 100%;
      display: grid;
      gap: 10px;
      align-content: start;
    }

    .sheet {
      background: #ffffff;
      color: #2c2c34;
      border: 1px solid #f4f3ee;
      border-radius: 16px;
      padding: 14px;
      box-shadow: 0 10px 24px rgba(8, 20, 36, 0.22);
      display: grid;
      gap: 8px;
    }

    .problem {
      margin-top: 8px;
      padding-top: 8px;
      border-top: 1px dashed #f4f3ee;
      display: grid;
      gap: 5px;
    }

    .problem.stagger-in {
      animation: sheetIn 0.22s var(--motion-smooth) both;
      animation-delay: calc(var(--stagger, 0) * 20ms);
    }

    .expr {
      border: 1px solid #f4f3ee;
      border-radius: 9px;
      background: #f8fbff;
      padding: 8px;
      overflow-x: auto;
      white-space: nowrap;
      font-size: 13px;
      color: #2c2c34;
    }

    @keyframes cardIn {
      from {
        opacity: 0;
        transform: translateY(4px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    @keyframes sheetIn {
      from {
        opacity: 0;
        transform: translateY(4px) scale(0.997);
      }
      to {
        opacity: 1;
        transform: translateY(0) scale(1);
      }
    }

    @media (prefers-reduced-motion: reduce) {
      .entry,
      .problem {
        animation: none !important;
        transition: none !important;
      }
    }

    @media print {
      body {
        background: #fff;
      }

      .app {
        width: 100%;
        margin: 0;
        display: block;
      }

      .left,
      .right-head {
        display: none !important;
      }

      .right,
      .panel,
      .workspace {
        border: 0 !important;
        box-shadow: none !important;
        background: #fff !important;
        padding: 0 !important;
      }

      .sheet {
        box-shadow: none;
        border: 0;
        border-radius: 0;
      }

      /* Hand out the problems; keep the key on its own page. */
      .answer-key {
        page-break-before: always;
        break-before: page;
      }
    }

    /* Desktop (1021px+) */
    @media (min-width: 1021px) {
      .app {
        width: min(1240px, calc(100vw - 18px));
        height: calc(100vh - 20px);
        grid-template-columns: 370px minmax(0, 1fr);
        margin: 10px auto;
      }
    }

    /* ── Mobile improvements ────────────────────────────────── */
    .left {
      max-height: 45vh;
    }

    .left-head {
      padding: 12px;
    }

    .right-head {
      padding: 12px;
    }

    @media (min-width: 1021px) {
      .left {
        max-height: none;
      }
    }

    /* Bottom nav: safe area + touch targets */
    .left-foot {
      padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .nav a {
      min-height: 44px;
      display: inline-flex;
      align-items: center;
      padding: 8px 12px;
    }
  

    /* Stacked layout (<1021px): app-style fixed bottom nav, matches /play/ */
    @media (max-width: 1020px) {
      .left .left-foot {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 60;
        background: #ffffff;
        border-top: 1px solid var(--line, #e5e2d9);
        padding-bottom: env(safe-area-inset-bottom, 0px);
      }
      .left .nav { grid-template-columns: repeat(6, 1fr); }
      .left .nav .logo { display: none !important; }
      .panel { backdrop-filter: none; }
      .left .nav a {
        font-size: 10.5px;
        padding: 12px 2px;
        border-right: none;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
      }
      .app { padding-bottom: 62px; align-content: start; }
    }
