:root {
      color-scheme: dark;
      --page: #071c25;
      --surface: #0a2530;
      --surface-raised: #14333c;
      --surface-input: #102d37;
      --ink: #f2e7cf;
      --muted: #9aa9a8;
      --accent: #d7ae68;
      --accent-ink: #182a2d;
      --line: rgba(215, 174, 104, .25);
      --danger: #f1a39c;
      --shadow: 0 24px 75px #0004;
      font-family: Heebo, "Segoe UI", Arial, sans-serif;
      font-synthesis: none;
    }

    * { box-sizing: border-box; }
    html { width: 100%; height: 100%; min-width: 320px; min-height: 0; overflow: hidden; background: var(--page); }
    body {
      margin: 0;
      min-width: 320px;
      width: 100%;
      height: 100%;
      min-height: 0;
      overflow: hidden;
      background:
        radial-gradient(900px 700px at 48% 50%, rgba(68,112,105,.16), transparent 62%),
        radial-gradient(650px 600px at 8% 92%, rgba(187,135,58,.12), transparent 62%),
        radial-gradient(600px 500px at 92% 15%, rgba(40,92,103,.18), transparent 68%),
        linear-gradient(125deg, #061821, #0a2530 48%, #061923);
      color: var(--ink);
    }
    body::before {
      position: fixed;
      z-index: 0;
      inset: 0;
      background:
        linear-gradient(30deg, transparent 48%, rgba(214,177,108,.15) 49%, transparent 50%) 0 0 / 110px 110px,
        linear-gradient(150deg, transparent 48%, rgba(214,177,108,.09) 49%, transparent 50%) 0 0 / 110px 110px;
      content: "";
      opacity: .18;
      pointer-events: none;
    }
    body::after {
      position: fixed;
      z-index: 0;
      bottom: 0;
      left: -100px;
      width: 650px;
      height: 420px;
      color: rgba(215,174,104,.055);
      content: "א ב ג ד ה ו ז ח ט י כ ל מ נ ס ע פ צ ק ר ש ת";
      font: 32px/2.7 "Frank Ruhl Libre", Georgia, serif;
      pointer-events: none;
      transform: rotate(-20deg);
      word-spacing: 18px;
    }
    button, input { font: inherit; }
    button { color: inherit; }
    button:focus-visible, input:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 3px;
    }
    .app {
      position: relative;
      z-index: 1;
      width: 100%;
      height: 100vh;
      height: 100dvh;
      min-height: 0;
      margin: 0;
      display: flex;
      flex-direction: column;
      padding: 0 clamp(14px, 2vw, 30px);
    }
    .topbar {
      height: 82px;
      min-height: 82px;
      flex: 0 0 82px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 28px;
      border-bottom: 1px solid var(--line);
    }
    .brand {
      display: flex;
      align-items: center;
      gap: 12px;
      flex: 0 0 auto;
      color: var(--ink);
      text-decoration: none;
    }
    .brand-mark {
      position: relative;
      width: 46px;
      height: 46px;
      display: grid;
      place-items: center;
      border: 1px solid var(--accent);
      border-radius: 50%;
      color: var(--accent);
      font: 34px/1 "Frank Ruhl Libre", Georgia, serif;
      box-shadow: 0 0 0 10px rgba(215,174,104,.035);
    }
    .brand-mark::before, .brand-mark::after {
      position: absolute;
      border: 1px solid rgba(215,174,104,.17);
      border-radius: 50%;
      content: "";
    }
    .brand-mark::before { inset: -9px; }
    .brand-mark::after { inset: 9px; }
    .brand-text { display: grid; text-align: left; }
    .brand-text .brand-title {
      color: #f1dca9;
      font: 27px/1 "Frank Ruhl Libre", Georgia, serif;
      letter-spacing: .08em;
    }
    .brand-subtitle {
      margin-top: 7px;
      color: #c3b79e;
      font: 13px/1 "Frank Ruhl Libre", Georgia, serif;
      letter-spacing: .48em;
    }
    .app-shell {
      display: grid;
      grid-template-columns: 232px minmax(0, 1fr);
      gap: clamp(18px, 2vw, 30px);
      height: calc(100% - 82px);
      min-height: 0;
      flex: 1 1 auto;
    }
    .rail {
      position: sticky;
      top: 12px;
      align-self: start;
      display: flex;
      flex-direction: column;
      min-width: 0;
      height: 100%;
      max-height: 100%;
      overflow: hidden;
      padding: 20px 10px 14px 0;
      border-right: 1px solid var(--line);
    }
    .workspace-nav { display: flex; flex-direction: column; gap: 5px; }
    .nav-button {
      position: relative;
      width: 100%;
      min-width: 0;
      min-height: 46px;
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 6px 9px;
      border: 0;
      border-radius: 14px;
      background: transparent;
      color: var(--muted);
      cursor: pointer;
      text-align: left;
      font: 17px "Frank Ruhl Libre", Georgia, serif;
      font-weight: 600;
    }
    .nav-button:hover, .nav-button[aria-current="page"] { color: var(--ink); }
    .nav-button[aria-current="page"] { background: linear-gradient(90deg, rgba(215,174,104,.15), rgba(215,174,104,.035)); }
    .nav-button[aria-current="page"]::before {
      position: absolute;
      top: 10px;
      bottom: 10px;
      left: 0;
      width: 3px;
      border-radius: 3px;
      background: var(--accent);
      content: "";
    }
    .nav-icon {
      display: grid;
      place-items: center;
      width: 30px;
      height: 30px;
      flex: 0 0 auto;
      border: 1px solid var(--line);
      border-radius: 50%;
      color: var(--accent);
      font: 14px Arial, sans-serif;
    }
    .nav-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
    .nav-label { min-width: 0; }
    .header-actions { display: flex; flex: 0 0 auto; gap: 8px; }
    .icon-button, .button, .nav-button { transition: background .16s ease, border-color .16s ease, color .16s ease; }
    .icon-button {
      min-width: 42px;
      min-height: 42px;
      display: inline-grid;
      place-items: center;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: var(--surface);
      color: var(--ink);
      cursor: pointer;
    }
    .icon-button:hover, .button:hover { border-color: var(--accent); }
    main {
      min-width: 0;
      height: 100%;
      min-height: 0;
      display: flex;
      overflow: hidden;
      padding: 14px 0;
    }
    .workspace[hidden] { display: none; }
    .workspace {
      width: 100%;
      min-width: 0;
      height: 100%;
      min-height: 0;
      display: flex;
      flex-direction: column;
      margin: 0;
      overflow-y: auto;
    }
    .workspace-heading { margin: 0 0 24px; }
    .eyebrow {
      margin: 0 0 8px;
      color: var(--accent);
      font-size: 11px;
      font-weight: 700;
      letter-spacing: .14em;
      text-transform: uppercase;
    }
    h1, h2, p { overflow-wrap: anywhere; }
    h1 {
      margin: 0;
      font: 500 clamp(23px, 3vw, 32px)/1.15 "Frank Ruhl Libre", Georgia, serif;
    }
    .subtitle { margin: 8px 0 0; color: var(--muted); line-height: 1.55; }
    .panel {
      min-width: 0;
      border: 1px solid var(--line);
      border-radius: 26px;
      background:
        radial-gradient(500px 350px at 45% 42%, rgba(166,126,65,.15), transparent 70%),
        linear-gradient(140deg, rgba(20,49,54,.96), rgba(7,30,39,.98));
      box-shadow: var(--shadow);
    }
    .calculate-panel { width: 100%; min-height: 0; flex: 1 1 auto; padding: clamp(12px, 1.5vw, 20px); }
    #workspace-calculate { overflow: hidden; }
    #workspace-calculate .calculate-panel { overflow-y: auto; }
    #workspace-dictionary { overflow: hidden; }
    #workspace-dictionary .calculate-panel { display: flex; min-height: 0; flex-direction: column; overflow: hidden; }
    #dictionaryForm, #workspace-dictionary .dictionary-method, #workspace-dictionary .dictionary-status { flex: 0 0 auto; }
    .word-form { width: min(100%, 720px); margin: 0 auto; }
    .yahrzeit-notice {
      width: min(100%, 720px);
      min-height: 1.4em;
      margin: 7px auto 0;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.4;
      text-align: center;
    }
    .field-label {
      display: block;
      margin: 0 0 9px;
      color: var(--muted);
      font-size: 13px;
      font-weight: 600;
    }
    .word-entry {
      display: flex;
      width: 100%;
      min-height: 60px;
      overflow: hidden;
      border: 1px solid rgba(225,213,188,.42);
      border-radius: 45px;
      background: linear-gradient(100deg, rgba(236,229,214,.94), rgba(195,196,187,.9));
      box-shadow: 0 14px 35px #0003, inset 0 1px #ffffffbf;
    }
    .word-entry:focus-within { border-color: var(--accent); }
    .word-input, .search-input {
      min-width: 0;
      border: 0;
      background: transparent;
      color: var(--ink);
    }
    .word-input {
      width: 100%;
      padding: 10px 18px;
      direction: rtl;
      text-align: right;
      color: #142b31;
      font: 27px/1.3 "Frank Ruhl Libre", Georgia, serif;
    }
    .word-input::placeholder { color: #667270; }
    .word-entry-actions { display: flex; gap: 5px; padding: 8px; }
    .entry-action {
      min-width: 43px;
      border: 0;
      border-radius: 10px;
      background: transparent;
      color: var(--muted);
      cursor: pointer;
      font-size: 18px;
    }
    .entry-action { color: #17363c; }
    .entry-action:hover { background: rgba(14,43,51,.12); color: #17363c; }
    .entry-action svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
    .entry-action.listening { background: rgba(165,61,53,.18); color: var(--danger); animation: voice-pulse 1.2s ease-in-out infinite alternate; }
    @keyframes voice-pulse { to { box-shadow: 0 0 0 5px rgba(165,61,53,.12); } }
    .method-bar {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: 8px;
      margin: 9px 0 2px;
    }
    .method-button {
      min-height: 35px;
      padding: 6px 16px;
      border: 1px solid rgba(215,174,104,.32);
      border-radius: 999px;
      background: rgba(6,27,35,.18);
      color: #ddd4c3;
      cursor: pointer;
      font: 15px "Frank Ruhl Libre", Georgia, serif;
    }
    .method-button:hover, .method-button.active {
      border-color: var(--accent);
      background: rgba(215,174,104,.09);
      color: #f0d59d;
    }
    .dictionary-method {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 8px 14px;
      margin-top: 18px;
    }
    .dictionary-method .field-label { margin: 0; }
    .dictionary-method .method-bar {
      flex-wrap: nowrap;
      justify-content: flex-start;
      margin: 0;
    }
    .flow-label {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 9px;
      margin: 10px 0 5px;
      color: var(--muted);
      font-size: 12px;
      font-weight: 600;
    }
    .flow-label span { color: var(--accent); }
    .letter-breakdown {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 5px;
      min-height: 58px;
      min-width: 0;
      direction: rtl;
    }
    .letter-word-row {
      display: flex;
      flex-wrap: nowrap;
      justify-content: center;
      gap: 8px;
      width: 100%;
      min-width: 0;
      direction: rtl;
    }
    .letter-word-row.wrap-long-word { flex-wrap: wrap; gap: 5px; }
    .letter-item {
      width: 62px;
      min-width: 0;
      flex: 0 1 62px;
      min-height: 56px;
      display: grid;
      align-content: center;
      justify-items: center;
      gap: 2px;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: var(--surface-raised);
    }
    .wrap-long-word .letter-item { width: 42px; flex-basis: 42px; }
    .letter-char { color: var(--ink);     font: 29px/1.15 "Frank Ruhl Libre", Georgia, serif; }
    .letter-value { color: var(--accent); font-size: 12px; font-weight: 700; }
    .empty-breakdown {
      align-self: center;
      padding: 20px 0;
      color: var(--muted);
      font-size: 13px;
    }
    .result {
      margin: 8px auto 0;
      padding: 6px 8px;
      border-top: 1px solid var(--line);
      border-bottom: 1px solid var(--line);
      text-align: center;
    }
    .result-word {
      min-height: 46px;
      color: var(--ink);
      direction: rtl;
      font: 500 clamp(42px, 5vw, 60px)/1.1 "Frank Ruhl Libre", Georgia, serif;
      overflow-wrap: anywhere;
    }
    .result-value {
      margin-top: 2px;
      color: var(--accent);
      font: 600 clamp(44px, 5vw, 56px)/1.1 "Frank Ruhl Libre", Georgia, serif;
      font-variant-numeric: tabular-nums;
    }
    .result-label { color: #c6beb0; font: 15px "Frank Ruhl Libre", Georgia, serif; }
    .metrics {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px;
      margin-top: 7px;
    }
    .metric {
      min-width: 0;
      padding: 9px 7px;
      border: 1px solid var(--line);
      border-radius: 16px;
      background: rgba(20,51,60,.55);
      text-align: center;
    }
    .metric-label { color: var(--muted); font-size: 12px; }
    .metric-value { margin-top: 2px; color: #f1e1be; font: 22px "Frank Ruhl Libre", Georgia, serif; font-variant-numeric: tabular-nums; }
    .action-row {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: 9px;
      margin-top: 8px;
    }
    .mobile-action-label { display: none; }
    .button {
      min-height: 43px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 9px 14px;
      border: 1px solid var(--line);
      border-radius: 11px;
      background: var(--surface-raised);
      color: var(--ink);
      cursor: pointer;
      font-size: 13px;
      font-weight: 600;
    }
    .button.primary { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
    .button.danger { color: var(--danger); }
    .button:disabled { cursor: not-allowed; opacity: .55; }
    .keyboard {
      position: fixed;
      z-index: 10;
      right: max(0px, env(safe-area-inset-right));
      bottom: 0;
      left: max(0px, env(safe-area-inset-left));
      width: auto;
      max-height: min(68vh, 430px);
      max-height: min(68dvh, 430px);
      overflow: auto;
      margin: 0;
      padding: 14px 14px max(14px, env(safe-area-inset-bottom));
      border: 1px solid rgba(215,174,104,.62);
      border-radius: 18px 18px 0 0;
      background: linear-gradient(145deg, #102c36f5, #071b25f7);
      box-shadow: 0 22px 90px #000b, 0 0 34px rgba(215,174,104,.15);
    }
    .keyboard[hidden] { display: none; }
    .number-keyboard { right: auto; left: 50%; width: min(calc(100vw - 28px), 360px); transform: translateX(-50%); }
    .keyboard-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 9px;
      color: var(--muted);
      font-size: 12px;
      font-weight: 600;
    }
    .keyboard-close {
      min-height: 32px;
      padding: 5px 11px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: transparent;
      color: var(--ink);
      cursor: pointer;
      font-size: 12px;
    }
    .keyboard-close:hover { border-color: var(--accent); color: var(--accent); }
    .key-row { display: flex; width: 100%; justify-content: center; gap: 5px; margin: 5px 0; direction: ltr; }
    .key {
      min-width: 0;
      min-height: 44px;
      flex: 1 1 0;
      padding: 4px 7px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--surface-raised);
      color: var(--ink);
      cursor: pointer;
      font: 18px/1.2 Georgia, serif;
    }
    .key:hover { border-color: var(--accent); color: var(--accent); }
    .key.utility { flex: 1.5 1 0; font: 12px/1.2 "Segoe UI", Arial, sans-serif; }
    .key.space { flex: 5 1 0; }
    .parshah-panel { display: flex; min-height: 0; flex-direction: column; gap: 12px; overflow: hidden; }
    .parshah-panel > [hidden] { display: none; }
    .parshah-home, .parshah-aliyot, .parshah-reading, .parshah-dvar { display: flex; min-width: 0; min-height: 0; flex: 1 1 auto; flex-direction: column; gap: 12px; }
    .parshah-home { justify-content: center; align-items: center; }
    .parshah-choice { width: min(100%, 480px); min-height: 62px; font-family: "Frank Ruhl Libre", Georgia, serif; font-size: 20px; }
    .parshah-back { flex: 0 0 auto; align-self: flex-start; padding: 6px; border-radius: 50%; color: var(--accent); }
    .parshah-back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
    .parshah-section-title { flex: 0 0 auto; margin: 0; padding-top: 5px; border-top: 1px solid var(--line); color: var(--accent); font: 500 19px/1.4 "Frank Ruhl Libre", Georgia, serif; }
    .parshah-dvar-content h3 { margin: 0 0 8px; font-size: 17px; }
    .parshah-hint, .parshah-status { flex: 0 0 auto; margin: 0; color: var(--muted); font-size: 13px; }
    .parshah-choice-list { display: grid; min-height: 0; gap: 8px; overflow: auto; padding: 2px; }
    .parshah-aliyah-choice { min-height: 48px; font: 600 17px/1.3 "Frank Ruhl Libre", Georgia, serif; }
    .parshah-verses { flex: 1 1 auto; min-width: 0; min-height: 0; overflow: auto; margin: 0; padding: 0 8px 0 0; list-style: none; }
    .parshah-verse { padding: 8px 0; border-bottom: 1px solid var(--line); }
    .parshah-verse-toggle { display: grid; width: 100%; grid-template-columns: 2.1rem minmax(0, 1fr); gap: 10px; align-items: start; padding: 0; border: 0; background: transparent; color: inherit; text-align: start; cursor: pointer; }
    .parshah-verse-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
    .parshah-verse-number { color: var(--accent); font: 600 13px/2 "Frank Ruhl Libre", Georgia, serif; }
    .parshah-verse-text { min-width: 0; color: var(--ink); direction: rtl; text-align: right; overflow-wrap: anywhere; font: 400 clamp(19px, 2.1vw, 25px)/1.9 "Frank Ruhl Libre", Georgia, serif; }
    .parshah-translation { display: block; margin: 5px 0 0 calc(2.1rem + 10px); padding: 8px 11px; border-inline-start: 2px solid var(--accent); color: var(--muted); font-size: 14px; line-height: 1.6; text-align: left; }
    .parshah-translation[hidden] { display: none; }
    .parshah-dvar-content { flex: 1 1 auto; min-height: 0; overflow: auto; color: var(--ink); font-size: 16px; line-height: 1.75; }
    .parshah-dvar-entry { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
    .parshah-dvar-entry + .parshah-dvar-entry { padding-top: 8px; }
    .parshah-dvar-entry h3 { margin: 0 0 8px; font-size: 17px; }
    .parshah-dvar-entry p { margin: 0 0 6px; }
    .parshah-dvar-source { margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 1.5; }
    .parshah-dvar-source a { color: var(--accent); overflow-wrap: anywhere; }
    .parshah-dvar-placeholder { margin: 0; color: var(--muted); }
    .search-form { display: flex; gap: 9px; }
    .dictionary-input-mode { flex: 0 0 auto; min-width: 48px; padding: 8px; font-size: 15px; }
    .search-input {
      flex: 1 1 auto;
      min-height: 52px;
      padding: 10px 14px;
      border: 1px solid var(--line);
      border-radius: 11px;
      background: var(--surface-input);
      font-size: 16px;
    }
    .search-input[dir="auto"] { text-align: start; }
    .dictionary-status { min-height: 22px; margin: 14px 0 0; color: var(--muted); font-size: 13px; }
    .result-list { display: grid; min-height: 0; flex: 1 1 auto; align-content: start; gap: 8px; overflow-y: auto; margin-top: 15px; overscroll-behavior: contain; }
    .dictionary-load-more { justify-self: center; margin: 4px 0; }
    .dictionary-result {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
      min-width: 0;
      padding: 14px 16px;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: var(--surface-raised);
      text-align: start;
      cursor: pointer;
    }
    .dictionary-result:hover { border-color: var(--accent); }
    .dictionary-word {
      min-width: 0;
      flex: 0 1 auto;
      max-width: 45%;
      overflow: hidden;
      direction: rtl;
      font: 25px/1.3 Georgia, serif;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .dictionary-meta {
      min-width: 0;
      max-width: 55%;
      flex: 0 1 auto;
      overflow: hidden;
      color: var(--muted);
      font-size: 12px;
      text-align: end;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .dictionary-meta strong { color: var(--accent); font-size: 1.15em; }
    .history-list { display: grid; gap: 8px; }
    .history-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      min-width: 0;
      padding: 12px 14px;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: var(--surface-raised);
    }
    .history-open {
      min-width: 0;
      flex: 1 1 auto;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 2px 0;
      border: 0;
      background: transparent;
      text-align: start;
      cursor: pointer;
    }
    .history-word { min-width: 0; direction: rtl; font: 23px/1.3 Georgia, serif; overflow-wrap: anywhere; }
    .history-value { color: var(--accent); font-size: 18px; font-variant-numeric: tabular-nums; }
    .history-copy { flex: 0 0 auto; }
    #workspace-tanach .workspace-heading { text-align: right; }
    .tanach-panel { display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
    .tanach-controls {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      align-items: start;
      justify-items: center;
      gap: 12px;
    }
    .tanach-choice-stage { width: 100%; min-width: 0; }
    .tanach-choice-stage .field-label { margin-bottom: 9px; }
    .tanach-category-choices {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 10px;
      width: min(100%, 600px);
      margin-inline: auto;
      justify-items: center;
    }
    .tanach-category-choice { width: min(100%, 600px); min-width: 0; min-height: 68px; font-size: 19px; }
    .tanach-choice-grid {
      display: flex;
      flex-direction: column;
      gap: 9px;
      width: min(100%, 740px);
      margin-inline: auto;
      max-height: min(56vh, 460px);
      overflow-y: auto;
      overscroll-behavior: contain;
      padding: 2px 3px 4px;
    }
    .tanach-option {
      display: flex;
      align-items: center;
      justify-content: center;
      min-width: 0;
      width: 100%;
      min-height: 50px;
      padding: 10px 12px;
      overflow-wrap: anywhere;
      line-height: 1.35;
      text-align: center;
    }
    .tanach-chapter-choices {
      display: flex;
      flex-direction: column;
      gap: 8px;
      width: min(100%, 740px);
      margin-inline: auto;
      max-height: min(56vh, 460px);
      overflow-y: auto;
      overscroll-behavior: contain;
      padding: 2px 3px 4px;
    }
    .tanach-chapter-choices .tanach-option { min-height: 46px; padding: 8px; }
    .tanach-panel [hidden] { display: none !important; }
    .tanach-back {
      width: 32px;
      min-width: 32px;
      height: 32px;
      min-height: 32px;
      justify-self: start;
      align-self: flex-start;
      padding: 6px;
      border-radius: 50%;
      color: var(--accent);
    }
    .tanach-back:active { transform: scale(.94); }
    .tanach-back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
    .tanach-reading { display: flex; flex: 1 1 auto; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; }
    .tanach-next-chapter { flex: 0 0 auto; align-self: flex-end; min-width: 120px; }
    .tanach-chapter-title {
      flex: 0 0 auto;
      margin: 0;
      padding-top: 5px;
      border-top: 1px solid var(--line);
      color: var(--accent);
      font: 500 19px/1.4 "Frank Ruhl Libre", Georgia, serif;
    }
    .tanach-status { flex: 0 0 auto; margin: 0; color: var(--muted); font-size: 13px; }
    .tanach-verses {
      flex: 1 1 auto;
      min-width: 0;
      min-height: 0;
      overflow: auto;
      margin: 0;
      padding: 0 8px 0 0;
      list-style: none;
    }
    .tanach-verse {
      padding: 8px 0;
      border-bottom: 1px solid var(--line);
    }
    .tanach-verse-toggle {
      display: grid;
      width: 100%;
      grid-template-columns: 2.1rem minmax(0, 1fr);
      gap: 10px;
      align-items: start;
      padding: 0;
      border: 0;
      background: transparent;
      color: inherit;
      text-align: start;
      cursor: pointer;
    }
    .tanach-verse-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
    .tanach-verse-number { color: var(--accent); font: 600 13px/2 "Frank Ruhl Libre", Georgia, serif; }
    .tanach-verse-text {
      min-width: 0;
      color: var(--ink);
      font: 400 clamp(19px, 2.1vw, 25px)/1.9 "Frank Ruhl Libre", Georgia, serif;
      overflow-wrap: anywhere;
      direction: rtl;
      text-align: right;
    }
    .tanach-translation {
      display: block;
      margin: 5px 0 0 calc(2.1rem + 10px);
      padding: 8px 11px;
      border-inline-start: 2px solid var(--accent);
      color: var(--muted);
      font-size: 14px;
      line-height: 1.6;
      text-align: left;
    }
    .tanach-translation[hidden] { display: none; }
    .tanach-attribution { flex: 0 0 auto; margin: 0; color: var(--muted); font-size: 10px; line-height: 1.4; text-align: center; }
    .tanach-attribution a { color: var(--accent); }
    .tanach-verses:empty { display: none; }
    .empty-state {
      padding: 28px 16px;
      border: 1px dashed var(--line);
      border-radius: 12px;
      color: var(--muted);
      text-align: center;
      line-height: 1.6;
    }
    .settings-list { display: grid; gap: 0; }
    .setting {
      display: flex;
      align-items: center;
      justify-content: space-between;
      min-width: 0;
      gap: 18px;
      padding: 18px 0;
      border-bottom: 1px solid var(--line);
    }
    .setting > div:first-child { min-width: 0; flex: 1 1 0; }
    .setting:last-child { border-bottom: 0; }
    .setting-title { font-size: 15px; font-weight: 600; }
    .setting-description { margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.45; }
    .setting-value { min-width: 0; max-width: 46%; flex: 0 1 46%; color: var(--muted); font-size: 13px; text-align: end; overflow-wrap: anywhere; }
    .setting-checkbox { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--accent); cursor: pointer; }
    .setting-select { min-height: 40px; max-width: 46%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-input); color: var(--ink); font: inherit; }
    .letter-breakdown[hidden], .metrics[hidden] { display: none; }
    #workspace-settings .calculate-panel { overflow-x: hidden; overflow-y: auto; }
    .toast {
      position: fixed;
      z-index: 5;
      right: 16px;
      bottom: 16px;
      max-width: calc(100vw - 32px);
      padding: 12px 16px;
      border: 1px solid var(--accent);
      border-radius: 11px;
      background: var(--surface-raised);
      color: var(--ink);
      box-shadow: var(--shadow);
      opacity: 0;
      pointer-events: none;
      transform: translateY(8px);
      transition: opacity .18s ease, transform .18s ease;
    }
    .toast.show { opacity: 1; transform: translateY(0); }
    body.light {
      color-scheme: light;
      --page: #b9d3e2;
      --surface: #c9dfeb;
      --surface-raised: #b9d5e4;
      --surface-input: #a9c9da;
      --ink: #193746;
      --muted: #466575;
      --accent: #9a6b24;
      --accent-ink: #173442;
      --line: rgba(39,83,111,.28);
      --danger: #a53d35;
      --shadow: 0 18px 50px rgba(24,57,78,.2);
      background:
        radial-gradient(900px 700px at 48% 50%, rgba(71,137,177,.22), transparent 62%),
        radial-gradient(650px 600px at 8% 92%, rgba(181,133,55,.13), transparent 62%),
        radial-gradient(600px 500px at 92% 15%, rgba(58,119,158,.2), transparent 68%),
        linear-gradient(125deg, #b5d0e0, #c7dce8 48%, #b2cee0);
    }
    body.light .panel {
      background:
        radial-gradient(500px 350px at 45% 42%, rgba(184,137,58,.12), transparent 70%),
        linear-gradient(140deg, var(--surface), #bdd6e4);
    }
    body.light::before {
      background:
        linear-gradient(30deg, transparent 48%, rgba(147,111,50,.16) 49%, transparent 50%) 0 0 / 110px 110px,
        linear-gradient(150deg, transparent 48%, rgba(42,108,101,.1) 49%, transparent 50%) 0 0 / 110px 110px;
    }
    body.light::after { color: rgba(155,111,38,.12); }
    body.light .brand-mark { color: #9a6b24; }
    body.light .brand-mark::before, body.light .brand-mark::after { border-color: rgba(154,107,36,.24); }
    body.light .brand-text .brand-title { color: #79551f; }
    body.light .brand-subtitle { color: #466575; }
    body.light .nav-button[aria-current="page"] { background: linear-gradient(90deg, rgba(154,107,36,.18), rgba(53,112,153,.12)); }
    body.light .word-entry { background: linear-gradient(100deg, #c8deea, #aecddd); }
    body.light .word-input { color: #193746; }
    body.light .word-input::placeholder { color: #557182; }
    body.light .entry-action { color: #28516a; }
    body.light .entry-action:hover { background: rgba(41,91,123,.14); color: #193746; }
    body.light .method-button {
      border-color: rgba(168,120,40,.34);
      background: rgba(49,105,145,.1);
      color: #31586d;
    }
    body.light .method-button:hover, body.light .method-button.active {
      border-color: var(--accent);
      background: rgba(182,133,53,.18);
      color: #755017;
    }
    body.light .metric { background: #bfd8e5; }
    body.light .metric-value { color: #254b61; }
    body.light .result-label { color: #466575; }
    body.light .keyboard {
      border-color: rgba(154,107,36,.58);
      background: linear-gradient(145deg, #bdd8e7f5, #9fbed1f7);
      box-shadow: 0 22px 70px rgba(24,57,78,.28), 0 0 34px rgba(154,107,36,.12);
    }
    body.light .keyboard-header { color: #466575; }
    body.light .keyboard-close { color: #193746; }

    @media (max-width: 860px) {
      .app { padding-right: 14px; padding-left: 14px; }
      .topbar { height: 72px; min-height: 72px; flex-basis: 72px; gap: 12px; }
      .brand-mark { width: 40px; height: 40px; font-size: 25px; }
      .brand-text .brand-title { font-size: 22px; }
      .brand-subtitle { font-size: 10px; }
      .app-shell { grid-template-columns: 68px minmax(0, 1fr); gap: 14px; height: calc(100% - 72px); min-height: 0; }
      .rail { padding: 14px 5px 10px 0; }
      .workspace-nav { gap: 4px; }
      .nav-button { min-height: 40px; justify-content: center; padding: 4px; }
      .nav-icon { width: 27px; height: 27px; }
      .nav-label { display: none; }
      main { min-height: 0; padding: 12px 0; }
      .workspace { min-height: 0; }
      .workspace-heading { margin-bottom: 12px; }
    }
    @media (max-width: 480px) {
      .tanach-panel { gap: 9px; padding: 13px 11px; }
      .tanach-controls { gap: 9px; }
      .tanach-category-choices { gap: 8px; }
      .tanach-category-choice { min-height: 58px; padding: 10px; font-size: 17px; }
      .tanach-choice-grid { gap: 7px; max-height: min(56vh, 460px); }
      .tanach-option { min-height: 46px; padding: 8px 10px; font-size: 14px; }
      .tanach-chapter-choices { gap: 6px; max-height: min(56vh, 460px); }
      .tanach-chapter-title { font-size: 17px; }
      .tanach-verse-toggle { grid-template-columns: 1.6rem minmax(0, 1fr); gap: 7px; }
      .tanach-translation { margin-left: calc(1.6rem + 7px); font-size: 13px; }
      .tanach-verse-text { font-size: clamp(18px, 5vw, 22px); line-height: 1.85; }
      .app-shell { grid-template-columns: 50px minmax(0, 1fr); gap: 8px; height: calc(100% - 64px); min-height: 0; }
      .topbar { height: 64px; min-height: 64px; flex-basis: 64px; }
      .brand { gap: 10px; }
      .brand-mark { width: 36px; height: 36px; font-size: 23px; }
      .brand-text .brand-title { font-size: 19px; }
      .brand-subtitle { margin-top: 5px; font-size: 8px; letter-spacing: .36em; }
      .header-actions { gap: 6px; }
      .icon-button { min-width: 38px; min-height: 38px; }
      .rail { padding: 9px 3px 8px 0; }
      .workspace-nav { gap: 3px; }
      .nav-button { min-height: 36px; padding: 3px; }
      .nav-icon { width: 25px; height: 25px; font-size: 13px; }
      main { min-height: 0; padding: 9px 0; }
      .workspace-heading { margin-bottom: 8px; }
      .workspace-heading h1 { font-size: 22px; }
      .workspace-heading .subtitle { margin-top: 5px; font-size: 14px; line-height: 1.4; }
      .calculate-panel { padding: 15px 12px; border-radius: 16px; }
      .word-input { padding-right: 10px; padding-left: 8px; font-size: 28px; }
      .word-entry { min-height: 60px; }
      .method-bar { gap: 7px; margin-top: 9px; }
      .method-button { min-height: 38px; padding: 6px 11px; font-size: 14px; }
      .flow-label { gap: 7px; margin: 10px 0 6px; font-size: 12px; }
      .letter-breakdown { min-height: 58px; gap: 7px; }
      .letter-item { width: 52px; flex-basis: 52px; min-height: 57px; }
      .letter-char { font-size: 27px; }
      .letter-value { font-size: 12px; }
      .result { margin-top: 10px; padding: 9px 8px; }
      .result-word { min-height: 47px; font-size: 46px; }
      .result-value { margin-top: 1px; font-size: 55px; }
      .result-label { font-size: 14px; }
      .metrics { gap: 7px; margin-top: 8px; }
      .metric { padding: 10px 5px; border-radius: 12px; }
      .metric-label { font-size: 11px; }
      .metric-value { margin-top: 2px; font-size: 21px; }
      .action-row { gap: 7px; margin-top: 10px; }
      .action-row .button { min-height: 42px; padding: 8px 9px; font-size: 12px; }
      #workspace-calculate #findNumber { font-size: 11px; }
      .entry-action { min-width: 38px; }
      .key-row { gap: 3px; }
      .key { min-height: 44px; padding: 3px 2px; font-size: 16px; }
      .key.utility { font-size: 10px; }
      .keyboard { max-height: 60dvh; padding: 9px 9px max(9px, env(safe-area-inset-bottom)); border-radius: 14px 14px 0 0; }
      .search-form { gap: 6px; }
      .dictionary-result { padding: 12px; }
      .dictionary-meta { font-size: 10px; }
      .setting { align-items: flex-start; padding: 15px 0; }
      .setting-value { max-width: 46%; }
      .parshah-verse-toggle { grid-template-columns: 1.6rem minmax(0, 1fr); gap: 7px; }
      .parshah-verse-text { font-size: clamp(18px, 5vw, 22px); line-height: 1.85; }
      .parshah-translation { margin-left: calc(1.6rem + 7px); font-size: 13px; }
    }
    @media (max-width: 600px) {
      #workspace-settings .setting { flex-direction: column; align-items: stretch; gap: 8px; }
      #workspace-settings .setting-value { max-width: 100%; flex-basis: auto; text-align: start; }
      #workspace-settings .setting > .button { align-self: flex-start; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
      #workspace-settings .setting-select { max-width: 100%; align-self: flex-start; }
    }
    @media (max-width: 480px) {
      .action-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: stretch;
      }
      .action-row .button { width: 100%; white-space: nowrap; }
      .mobile-action-label { display: inline; }
      .desktop-action-label { display: none; }
    }
    @media (max-height: 500px) {
      #workspace-tanach .workspace-heading .subtitle { display: none; }
      .tanach-panel { gap: 7px; padding: 10px; }
      .tanach-verse { padding: 5px 0; }
      .tanach-verse-text { line-height: 1.65; }
      .app-shell { grid-template-columns: 44px minmax(0, 1fr); gap: 8px; }
      .rail { padding: 4px 3px 4px 0; }
      .workspace-nav { gap: 1px; }
      .nav-button { min-height: 34px; justify-content: center; padding: 2px; }
      .nav-label { display: none; }
      .nav-icon { width: 22px; height: 22px; font-size: 12px; }
      .nav-icon svg { width: 15px; height: 15px; }
      .workspace-heading { margin-bottom: 8px; }
      .workspace-heading h1 { font-size: 20px; }
      .workspace-heading .eyebrow { margin-bottom: 4px; }
      #workspace-calculate .workspace-heading .subtitle { display: none; }
      #workspace-calculate .calculate-panel { padding: 10px; }
      #workspace-calculate .field-label { margin-bottom: 5px; }
      #workspace-calculate .word-entry { min-height: 50px; }
      #workspace-calculate .word-input { font-size: 24px; }
      #workspace-calculate .method-bar { gap: 4px; margin-top: 8px; }
      #workspace-calculate .method-button { min-height: 32px; padding: 4px 7px; font-size: 12px; }
      #workspace-calculate .flow-label { margin: 8px 0 5px; }
      #workspace-calculate .letter-breakdown { min-height: 45px; }
      #workspace-calculate .letter-item { width: 42px; flex-basis: 42px; min-height: 43px; }
      #workspace-calculate .letter-char { font-size: 21px; }
      #workspace-calculate .result { margin-top: 8px; padding: 6px; }
      #workspace-calculate .result-word { min-height: 32px; font-size: 32px; }
      #workspace-calculate .result-value { font-size: 40px; }
      #workspace-calculate .metric-label { font-size: 10px; }
      #workspace-calculate .metric-value { font-size: 18px; }
      #workspace-calculate .action-row { gap: 5px; margin-top: 8px; }
      #workspace-calculate .action-row .button { min-height: 38px; padding: 6px; font-size: 11px; }
    }
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
    }
