/* ==========================================================================
   PoliNetwork Studio — Design System v4.0 (Apple / Craft / Things 3 Edition)
   Cool Neutral Grouped Canvas · Borderless Elevated Cards · iOS/macOS Craft
   Light (#F2F2F7 / #FFFFFF / #0071E3) & True OLED Dark (#000000 / #1C1C1E)
   ========================================================================== */

:root {
  /* Light Theme — Apple iOS / macOS System Grouped Palette */
  --bg-canvas: #f2f2f7;
  --bg-surface: #ffffff;
  --bg-subtle: #efeff4;
  --bg-hover: #e5e5ea;
  --bg-elevated: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.86);
  --bg-glass-nav: rgba(255, 255, 255, 0.90);

  --sep: rgba(60, 60, 67, 0.12);
  --sep-strong: rgba(60, 60, 67, 0.22);
  --field-border: #8a8a93;
  --track-empty: rgba(60, 60, 67, 0.12);
  --scrim-bg: var(--bg-canvas);

  --ink-primary: #1c1c1e;
  --ink-secondary: #5c5c62;
  --ink-tertiary: #59595e;

  /* Apple Blue (4.81:1 with white, 5.53:1 text on white) */
  --accent: #0071e3;
  --accent-hover: #0062c4;
  --accent-text: #005ec4;
  --accent-ink: #ffffff;
  --accent-soft: #e6f2ff;
  --accent-soft-text: #004394;

  /* Apple System Semantics (All >= 8.0:1 AAA on pastel tints) */
  --red: #ff3b30;
  --cal-red: #c81e1e;
  --red-text: #8f1414;
  --red-soft: #fdeaea;

  --orange: #ff9500;
  --orange-text: #7a3600;
  --orange-soft: #fdf0dd;

  --green: #34c759;
  --green-text: #115423;
  --green-soft: #e3f6e8;

  --indigo: #5856d6;
  --indigo-text: #3e3bb8;
  --indigo-soft: rgba(88, 86, 214, 0.12);

  /* Typography — Pure Modern Sans (Zero Serif, Zero Monospace on UI) */
  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', sans-serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, sans-serif;
  --font-code: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --reader-scale: 1;

  /* Apple Radii & Soft Ambient Shadows */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 26px;

  --shadow-card: 0 2px 14px rgba(0, 0, 0, 0.045);
  --shadow-float: 0 8px 28px rgba(0, 0, 0, 0.09);
  --shadow-deck: 0 12px 32px rgba(0, 0, 0, 0.065);
  --shadow-modal: 0 24px 64px rgba(0, 0, 0, 0.18);

  --topbar-h: 56px;
  --fnav-h: 72px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  /* True Apple OLED Dark Mode (Graphite & Pure Black, zero blue-slate) */
  --bg-canvas: #000000;
  --bg-surface: #1c1c1e;
  --bg-subtle: #2c2c2e;
  --bg-hover: #3a3a3c;
  --bg-elevated: #2c2c2e;
  --bg-glass: rgba(28, 28, 30, 0.88);
  --bg-glass-nav: rgba(34, 34, 38, 0.92);

  --sep: rgba(255, 255, 255, 0.12);
  --sep-strong: rgba(255, 255, 255, 0.22);
  --field-border: #63636a;
  --track-empty: rgba(255, 255, 255, 0.16);

  --ink-primary: #ffffff;
  --ink-secondary: #b8b8bf;
  --ink-tertiary: #a6a6ae;

  --accent: #0071e3;
  --accent-hover: #0a84ff;
  --accent-text: #64b5ff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(10, 132, 255, 0.22);
  --accent-soft-text: #8cc8ff;

  --red: #ff453a;
  --cal-red: #c81e1e;
  --red-text: #ff8980;
  --red-soft: rgba(255, 69, 58, 0.22);

  --orange: #ff9f0a;
  --orange-text: #ffc978;
  --orange-soft: rgba(255, 159, 10, 0.22);

  --green: #30d158;
  --green-text: #72ea92;
  --green-soft: rgba(48, 209, 88, 0.22);

  --indigo: #5e5ce6;
  --indigo-text: #a5a3ff;
  --indigo-soft: rgba(94, 92, 230, 0.22);

  --shadow-card: 0 2px 14px rgba(0, 0, 0, 0.45);
  --shadow-float: 0 10px 30px rgba(0, 0, 0, 0.72);
  --shadow-deck: 0 14px 36px rgba(0, 0, 0, 0.55);
  --shadow-modal: 0 26px 70px rgba(0, 0, 0, 0.78);
}

body[data-view="reader"] { --scrim-bg: var(--bg-surface); }

/* ==================== RESET & BASE ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  background: var(--bg-canvas);
}

body {
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  color: var(--ink-primary);
  line-height: 1.55;
  min-height: 100dvh;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 2.5px solid var(--accent-text);
  outline-offset: 2px;
}

.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;
}

.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 300;
  background: var(--accent); color: var(--accent-ink);
  padding: 0.6rem 1.1rem; border-radius: 999px; font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 0.75rem; }

.hidden { display: none !important; }
.muted { color: var(--ink-secondary); }
.small { font-size: 0.875rem; }
body.modal-open { overflow: hidden; }

.ic {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0;
}
.ic.sm { width: 17px; height: 17px; }
.ic.xs { width: 15px; height: 15px; }

/* ==================== DESKTOP TOP BAR ==================== */
.topbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--topbar-h);
  background: var(--bg-glass);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border-bottom: 0.5px solid var(--sep);
}

.topbar-inner {
  max-width: none; height: 100%; margin: 0 auto;
  padding: 0 1.5rem;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem;
}

.brand {
  justify-self: start;
  display: inline-flex; align-items: center; gap: 0.55rem;
  background: none; border: none; cursor: pointer; padding: 0.2rem 0;
  border-radius: var(--r-xs); flex-shrink: 0;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: #fff;
  font-family: var(--font-display); font-weight: 800; font-size: 0.78rem;
  display: grid; place-items: center; letter-spacing: -0.02em;
}
.brand-title {
  font-family: var(--font-display); font-weight: 800; font-size: 1.02rem;
  letter-spacing: -0.025em; color: var(--ink-primary);
}

/* Desktop Segmented Primary Nav */
.primary-nav {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--bg-subtle); padding: 3px; border-radius: 12px;
}
.nav-tab {
  border: none; background: transparent; color: var(--ink-secondary);
  font-size: 0.86rem; font-weight: 600;
  height: 32px; padding: 0 0.9rem; border-radius: 9px;
  display: inline-flex; align-items: center; gap: 0.42rem;
  cursor: pointer; white-space: nowrap; transition: all 0.16s var(--ease);
}
.nav-tab .ic { width: 16px; height: 16px; opacity: 0.82; }
.nav-tab:hover { color: var(--ink-primary); }
.nav-tab.active {
  background: var(--bg-surface); color: var(--ink-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.nav-tab.active .ic { color: var(--accent-text); opacity: 1; }

.nav-count {
  font-size: 0.7rem; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--accent); color: #fff;
  padding: 0.05rem 0.42rem; border-radius: 999px;
}

.topbar-utilities { justify-self: end; display: flex; align-items: center; gap: 0.45rem; }

.search-pill {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  min-width: 184px; height: 34px; padding: 0 0.5rem 0 0.8rem; border-radius: 999px;
  border: none; background: var(--bg-subtle); color: var(--ink-secondary);
  font-size: 0.84rem; font-weight: 500; cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.search-pill-left { display: inline-flex; align-items: center; gap: 0.45rem; }
.search-pill:hover { background: var(--bg-hover); color: var(--ink-primary); }
.search-pill-kbd {
  display: inline-flex; align-items: center; gap: 2px;
  font-family: var(--font-sans); font-size: 0.72rem; font-weight: 600;
  color: var(--ink-secondary); background: var(--bg-surface);
  border: 0.5px solid var(--sep);
  padding: 0.08rem 0.42rem; border-radius: 6px;
}
[data-theme="dark"] .search-pill-kbd {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--ink-secondary);
}

.circle-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: none; background: var(--bg-surface); color: var(--ink-primary);
  display: grid; place-items: center; cursor: pointer; flex-shrink: 0;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  transition: background 0.14s, transform 0.12s;
}
.topbar .circle-btn { background: var(--bg-subtle); box-shadow: none; }
.circle-btn.accent { color: var(--accent-text); }
.circle-btn.sm { width: 34px; height: 34px; }
@media (hover: hover) {
  .circle-btn:hover { background: var(--bg-hover); }
}
.circle-btn[aria-expanded="true"] {
  background: var(--accent-soft); color: var(--accent-text);
}

/* ==================== SHARED APPLE PRIMITIVES ==================== */
.main-shell { min-height: calc(100dvh - var(--topbar-h)); }
.view { display: none; }
.view.active { display: block; animation: appleFade 0.12s var(--ease); }
@keyframes appleFade { from { opacity: 0; } to { opacity: 1; } }

.ios-container {
  max-width: 980px; margin: 0 auto;
  padding: 2rem 1.5rem 3.5rem;
  display: flex; flex-direction: column; gap: 1.5rem;
}

.view-large-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.large-title {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 3vw, 2.25rem);
  font-weight: 800; letter-spacing: -0.018em; line-height: 1.12;
  color: var(--ink-primary);
}
.mobile-head-actions { display: none; align-items: center; gap: 0.5rem; }

/* Borderless Elevated Apple Card */
.apple-card {
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-card);
}

/* Tactile Apple Buttons */
.btn-apple {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 44px; padding: 0.6rem 1.2rem; border-radius: 14px;
  border: none; font-size: 0.94rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background 0.14s, transform 0.1s, opacity 0.14s;
}
.btn-apple:active:not(:disabled) { transform: scale(0.985); }
.btn-apple:disabled { opacity: 0.38; cursor: not-allowed; }
.btn-apple.full { width: 100%; }
.btn-apple.sm { min-height: 36px; padding: 0.4rem 0.85rem; border-radius: 10px; font-size: 0.83rem; }
.btn-apple.icon-only { min-width: 36px; padding: 0; }
.btn-apple.primary { background: var(--accent); color: var(--accent-ink); }
@media (hover: hover) {
  .btn-apple.primary:hover:not(:disabled) { background: var(--accent-hover); }
}
.btn-apple.soft { background: var(--bg-subtle); color: var(--ink-primary); }
@media (hover: hover) {
  .btn-apple.soft:hover:not(:disabled) { background: var(--bg-hover); }
}
.btn-apple.danger-soft { background: var(--red-soft); color: var(--red-text); }
.btn-apple.danger { background: var(--red); color: #fff; }

.text-action {
  background: none; border: none; padding: 0.25rem 0;
  color: var(--accent-text); font-size: 0.88rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.text-action:hover { opacity: 0.78; }

/* Apple iOS Segmented Control */
.ios-seg {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--bg-subtle); padding: 3px; border-radius: 11px;
}
.ios-seg-btn {
  border: none; background: transparent; color: var(--ink-secondary);
  font-size: 0.84rem; font-weight: 600;
  min-height: 30px; padding: 0.25rem 0.85rem; border-radius: 8px;
  cursor: pointer; white-space: nowrap; transition: all 0.15s var(--ease);
}
.ios-seg.compact .ios-seg-btn { min-height: 28px; padding: 0.2rem 0.78rem; font-size: 0.81rem; }
.ios-seg-btn.active {
  background: var(--bg-surface); color: var(--ink-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.10);
}
[data-theme="dark"] .ios-seg-btn { color: #b4b4bc; }
[data-theme="dark"] .ios-seg-btn.active {
  background: #3c3c42; color: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45), inset 0 0 0 0.5px rgba(255, 255, 255, 0.14);
}
.ios-seg-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Apple Inputs & Selects */
.ios-field {
  min-height: 40px; padding: 0.5rem 0.85rem; width: 100%;
  border-radius: var(--r-sm); border: 1px solid var(--field-border);
  background: var(--bg-surface); color: var(--ink-primary);
  font-size: 0.9rem; transition: border-color 0.15s, box-shadow 0.15s;
}
.ios-field.sm { min-height: 36px; padding: 0.35rem 0.75rem; font-size: 0.84rem; border-radius: 10px; }
.ios-field::placeholder { color: var(--ink-tertiary); opacity: 1; }
.ios-field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

select.ios-field,
select.ios-field.sm {
  appearance: none; -webkit-appearance: none;
  padding-right: 2.15rem; text-overflow: ellipsis; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2359595e' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  background-size: 14px 14px;
}
[data-theme="dark"] select.ios-field,
[data-theme="dark"] select.ios-field.sm {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b8b8bf' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
select.ios-field option { background: var(--bg-surface); color: var(--ink-primary); }

.ios-search-wrap { position: relative; display: flex; align-items: center; width: 100%; }
.ios-search-wrap .search-ic { position: absolute; left: 0.75rem; color: var(--ink-tertiary); pointer-events: none; }
.ios-field.has-ic { padding-left: 2.25rem; }
.ios-field.has-clear { padding-right: 2.35rem; }
.clear-ic-btn {
  position: absolute; right: 0.4rem; width: 28px; height: 28px;
  border-radius: 50%; border: none; background: transparent;
  color: var(--ink-tertiary); display: grid; place-items: center; cursor: pointer;
  opacity: 0.72; transition: opacity 0.14s;
}
.clear-ic-btn:hover { opacity: 1; }
.ic-clear { width: 17px; height: 17px; display: block; }

.pill-track {
  height: 5px; width: 100%; border-radius: 999px;
  background: var(--track-empty); overflow: hidden; display: flex;
}
.pill-track-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 999px; transition: width 0.28s var(--ease); }
.pill-track-rev { height: 100%; width: 0%; background: var(--orange); transition: width 0.28s var(--ease); }

/* ==================== 1. STUDIO (HOME) ==================== */
.home-bento {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 1.15rem;
  align-items: stretch;
}

.hero-card {
  display: flex; flex-direction: column; gap: 1.15rem;
  padding: 1.4rem 1.5rem;
}
.hero-actions {
  margin-top: auto; display: flex; flex-direction: column; gap: 0.65rem;
}
.hero-card-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.hero-copy { min-width: 0; }
.hero-kicker { display: block; font-size: 0.78rem; font-weight: 600; color: var(--accent-text); margin-bottom: 0.2rem; }
.hero-title {
  font-family: var(--font-display); font-size: clamp(1.12rem, 3.8vw, 1.38rem); font-weight: 700;
  letter-spacing: -0.025em; line-height: 1.22; color: var(--ink-primary);
}
.hero-meta { font-size: 0.86rem; color: var(--ink-secondary); margin-top: 0.2rem; }

.mini-ring-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 0.22rem; flex-shrink: 0;
}
.mini-ring { position: relative; width: 54px; height: 54px; flex-shrink: 0; }
.mini-ring svg { width: 54px; height: 54px; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--track-empty); stroke-width: 5; }
.ring-fill { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset 0.45s var(--ease); }
.mini-ring-val {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 0.78rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.mini-ring-cap {
  font-size: 0.68rem; font-weight: 600; color: var(--ink-secondary); letter-spacing: 0.01em;
}

.hero-quick-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }

.home-side-stack { display: flex; flex-direction: column; gap: 1.15rem; }

/* Apple iOS Calendar Event Card */
.event-card-box {
  padding: 0; overflow: hidden; display: flex; flex-direction: column; flex: 1;
}
.event-card-main {
  border: none; background: transparent; text-align: left; cursor: pointer; width: 100%;
  display: flex; align-items: center; gap: 0.95rem;
  padding: 1rem 1.2rem; flex: 1;
  transition: background 0.14s;
}
@media (hover: hover) {
  .event-card-main:hover { background: var(--bg-subtle); }
}
.ios-cal {
  width: 48px; height: 50px; border-radius: 12px; background: var(--bg-subtle);
  overflow: hidden; display: flex; flex-direction: column; align-items: center; flex-shrink: 0;
}
.ios-cal-month {
  width: 100%; background: var(--cal-red); color: #fff;
  font-size: 0.62rem; font-weight: 700; text-align: center;
  padding: 2px 0; letter-spacing: 0.05em; text-transform: uppercase;
}
.ios-cal-day {
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 800;
  line-height: 30px; color: var(--ink-primary); font-variant-numeric: tabular-nums;
}
.event-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.22rem; }
.event-title { font-size: 0.95rem; font-weight: 600; color: var(--ink-primary); line-height: 1.28; }
.event-meta-chips {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 0.4rem;
  font-size: 0.81rem; color: var(--ink-secondary);
}
.event-sep { color: var(--ink-tertiary); opacity: 0.7; }
.event-countdown { font-weight: 600; color: var(--ink-secondary); }
.event-origin { color: var(--ink-tertiary); }
.event-card-foot {
  border-top: 0.5px solid var(--sep);
  padding: 0.55rem 1.2rem;
}
.event-ref-btn {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 0.5rem; width: 100%;
  border: none; background: transparent; padding: 0.1rem 0; text-align: left;
  color: var(--accent-text); font-size: 0.82rem; font-weight: 600; cursor: pointer;
}
.event-ref-btn:hover { opacity: 0.78; }
.chev-right { width: 17px; height: 17px; color: var(--ink-tertiary); opacity: 0.7; flex-shrink: 0; }

/* Mini 3-stat Card */
.stats-mini-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 0.4rem; gap: 0.25rem;
}
.mini-stat {
  border: none; background: transparent; border-radius: 14px;
  padding: 0.7rem 0.5rem; cursor: pointer; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
  transition: background 0.14s;
}
@media (hover: hover) {
  .mini-stat:hover { background: var(--bg-subtle); }
}
.mini-stat-val {
  font-family: var(--font-display); font-size: 1.08rem; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--ink-primary);
}
.mini-stat-lbl { font-size: 0.76rem; font-weight: 500; color: var(--ink-secondary); }

/* Apple Inset Grouped Document List */
.ios-section { display: flex; flex-direction: column; gap: 0.6rem; }
.ios-section-head { display: flex; justify-content: space-between; align-items: center; padding: 0 0.4rem; }
.ios-section-label { font-size: 0.86rem; font-weight: 600; color: var(--ink-secondary); }

.apple-group {
  background: var(--bg-surface); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--shadow-card);
}
.doc-item {
  width: 100%; border: none; background: transparent; text-align: left;
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.95rem 1.15rem; cursor: pointer; position: relative;
  transition: background 0.13s;
}
.doc-item + .doc-item::before {
  content: ""; position: absolute; top: 0; left: 4.15rem; right: 0;
  height: 0.5px; background: var(--sep);
}
@media (hover: hover) {
  .doc-item:hover { background: var(--bg-subtle); }
}
.doc-sq {
  width: 36px; height: 36px; border-radius: 10px; color: #fff;
  display: grid; place-items: center; flex-shrink: 0;
}
.doc-sq.blue { background: #0071e3; }
.doc-sq.indigo { background: #5856d6; }
.doc-sq.green { background: #198744; }
.doc-info { flex: 1; min-width: 0; }
.doc-name { font-size: 0.98rem; font-weight: 600; color: var(--ink-primary); letter-spacing: -0.01em; }
.doc-sub { font-size: 0.81rem; color: var(--ink-secondary); margin-top: 1px; }
.doc-right { display: flex; align-items: center; gap: 0.65rem; flex-shrink: 0; }
.doc-pct {
  font-size: 0.82rem; font-weight: 600; color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}

/* Collapsible Method Row */
.apple-disclosure {
  background: var(--bg-surface); border-radius: var(--r-lg);
  padding: 0.95rem 1.2rem; box-shadow: var(--shadow-card);
}
.apple-disclosure summary {
  list-style: none; cursor: pointer; font-size: 0.92rem; font-weight: 600;
  color: var(--ink-primary); display: flex; justify-content: space-between; align-items: center;
}
.apple-disclosure .chev-down { color: var(--ink-secondary); transition: transform 0.2s var(--ease); }
.apple-disclosure summary::-webkit-details-marker { display: none; }
.apple-disclosure[open] summary { color: var(--ink-primary); margin-bottom: 0.9rem; }
.apple-disclosure[open] .chev-down { transform: rotate(180deg); }
.guide-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.85rem; }
.guide-item {
  background: var(--bg-subtle); border-radius: var(--r-sm); padding: 0.8rem 0.9rem;
  display: flex; flex-direction: column; gap: 0.25rem;
}
.guide-item strong { font-size: 0.85rem; color: var(--ink-primary); }
.guide-item span { font-size: 0.8rem; color: var(--ink-secondary); line-height: 1.45; }

/* ==================== 2. NORME (FULL-BLEED CRAFT / APPLE BOOKS READER) ==================== */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 75;
  background: rgba(0, 0, 0, 0.42); backdrop-filter: blur(4px);
}

.reader-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  min-height: calc(100dvh - var(--topbar-h));
}

.toc-sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100dvh - var(--topbar-h));
  display: flex; flex-direction: column;
  background: var(--bg-canvas);
  border-right: 0.5px solid var(--sep);
}
.toc-head-mobile { display: none; }
.toc-controls {
  padding: 0.85rem 0.9rem; display: flex; flex-direction: column; gap: 0.55rem;
  border-bottom: 0.5px solid var(--sep);
}
.toc-controls .ios-seg { width: 100%; display: flex; }
.toc-controls .ios-seg-btn { flex: 1 1 auto; padding: 0.22rem 0.35rem; font-size: 0.76rem; }
.toc-filter-row { display: flex; align-items: center; gap: 0.5rem; }
.toc-filter-row select { flex: 1; }
.toc-count { font-size: 0.78rem; font-weight: 600; color: var(--ink-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }

.toc-list {
  flex: 1; overflow-y: auto; padding: 0.45rem 0.55rem 2.5rem; scrollbar-width: thin;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent);
}
.toc-doc-header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.71rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--ink-tertiary); padding: 0.75rem 0.35rem 0.3rem;
}
.toc-doc-header:first-child { padding-top: 0.3rem; }
.toc-item {
  display: flex; align-items: center; gap: 0.5rem;
  width: 100%; text-align: left; border: none; background: transparent;
  color: var(--ink-secondary); font-size: 0.84rem; font-weight: 500;
  padding: 0.48rem 0.6rem; border-radius: 10px; cursor: pointer;
  margin-bottom: 1px; transition: background 0.12s, color 0.12s;
}
@media (hover: hover) {
  .toc-item:hover { background: var(--bg-hover); color: var(--ink-primary); }
}
.toc-item.active {
  background: var(--accent-soft); color: var(--accent-soft-text); font-weight: 600;
}
.toc-item.is-group { font-weight: 700; color: var(--ink-primary); font-size: 0.79rem; margin-top: 0.4rem; }
.toc-item.lvl-2 { padding-left: 1.05rem; }
.toc-item.lvl-3 { padding-left: 1.5rem; font-size: 0.81rem; }
.toc-item.lvl-4 { padding-left: 1.9rem; font-size: 0.79rem; }
.toc-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--sep-strong); }
.toc-item.active .toc-dot.s0 { background: transparent; border: 1.6px solid var(--accent-soft-text); }
.toc-dot.s1 { background: var(--orange); }
.toc-dot.s2 { background: var(--green); }
.toc-dot.s3 { background: var(--accent); }
.toc-item.is-group .toc-dot { visibility: hidden; width: 2px; }
.toc-code { font-size: 0.78rem; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 2.3ch; text-align: right; color: var(--ink-tertiary); flex-shrink: 0; }
.toc-item.active .toc-code { color: var(--accent-soft-text); }
.toc-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.toc-star { color: var(--orange); font-size: 0.76rem; flex-shrink: 0; }

/* Pure White Full-Bleed Reading Canvas */
.reader-canvas {
  background: var(--bg-surface);
  min-width: 0;
  display: flex; flex-direction: column;
}

.reader-nav-bar {
  position: sticky; top: var(--topbar-h); z-index: 30;
  height: 52px; padding: 0 1.5rem;
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 0.5px solid var(--sep);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 0.5rem;
}
.reader-nav-left { display: flex; align-items: center; min-width: 0; }
.reader-nav-right { display: flex; align-items: center; justify-content: flex-end; gap: 0.35rem; }

.ios-back-btn {
  display: none; align-items: center; gap: 0.1rem;
  border: none; background: transparent; color: var(--accent-text);
  font-size: 0.94rem; font-weight: 500; cursor: pointer; padding: 0.35rem 0.2rem;
}
.breadcrumb {
  font-size: 0.82rem; font-weight: 500; color: var(--ink-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.text-icon-btn {
  min-width: 36px; height: 36px; padding: 0 0.5rem;
  border: none; background: transparent; color: var(--ink-secondary);
  font-size: 0.92rem; font-weight: 600; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
@media (hover: hover) {
  .text-icon-btn:hover { background: var(--bg-subtle); color: var(--ink-primary); }
}
.text-icon-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-text); }
.text-icon-btn[aria-pressed="true"] { color: var(--accent-text); }
.text-icon-btn[aria-pressed="true"] svg { fill: currentColor; }

.font-menu-wrap { position: relative; }
.font-popover {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 45;
  display: flex; align-items: center; gap: 0.25rem;
  background: var(--bg-surface); border: 0.5px solid var(--sep-strong);
  border-radius: 14px; padding: 0.35rem; box-shadow: var(--shadow-float);
}
.fp-btn {
  width: 36px; height: 34px; border: none; border-radius: 10px;
  background: var(--bg-subtle); color: var(--ink-primary);
  font-size: 0.82rem; font-weight: 700; cursor: pointer;
}
@media (hover: hover) {
  .fp-btn:hover { background: var(--bg-hover); }
}
.fp-val {
  min-width: 46px; text-align: center; font-size: 0.78rem; font-weight: 600;
  color: var(--ink-secondary); font-variant-numeric: tabular-nums;
}

.reader-inner {
  width: 100%; max-width: 720px; margin: 0 auto;
  padding: 2rem 1.75rem 4rem;
}

.return-pill {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;
  background: var(--accent-soft); color: var(--ink-primary);
  border-radius: var(--r-sm); padding: 0.55rem 0.9rem; margin-bottom: 1.25rem; font-size: 0.84rem;
}

.art-header { margin-bottom: 1.65rem; }
.art-kicker {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem;
  font-size: 0.84rem; font-weight: 600; color: var(--accent-text); margin-bottom: 0.25rem;
}
.art-meta-muted { color: var(--ink-secondary); font-weight: 500; }
.art-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 2.8vw, 2.1rem);
  font-weight: 800; letter-spacing: -0.018em; line-height: 1.15;
  color: var(--ink-primary); margin-bottom: 0.9rem;
}

.art-tools-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0.55rem; }

.ios-pill-select {
  appearance: none; -webkit-appearance: none;
  min-height: 34px; padding: 0.25rem 1.9rem 0.25rem 0.82rem;
  border-radius: 999px; border: 1px solid var(--sep);
  background: var(--bg-subtle); color: var(--ink-primary);
  font-size: 0.81rem; font-weight: 600; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2359595e' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.62rem center; background-size: 12px 12px;
}
[data-theme="dark"] .ios-pill-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23b8b8bf' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
.ios-pill-select[data-mastery="1"] { background-color: var(--orange-soft); color: var(--orange-text); border-color: transparent; }
.ios-pill-select[data-mastery="2"] { background-color: var(--green-soft); color: var(--green-text); border-color: transparent; }
.ios-pill-select[data-mastery="3"] { background-color: var(--accent-soft); color: var(--accent-soft-text); border-color: transparent; }
.ios-pill-select option { background: var(--bg-surface); color: var(--ink-primary); }

.pill-toggle {
  display: inline-flex; align-items: center; gap: 0.42rem;
  min-height: 34px; padding: 0.25rem 0.85rem; border-radius: 999px;
  border: 1px solid var(--sep); background: var(--bg-subtle); color: var(--ink-secondary);
  font-size: 0.81rem; font-weight: 600; cursor: pointer; transition: all 0.14s;
}
.pill-toggle .pill-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ink-tertiary); opacity: 0.45;
  transition: background 0.14s, opacity 0.14s;
}
.pill-toggle.active {
  border-color: transparent; background: var(--accent-soft); color: var(--accent-soft-text);
}
.pill-toggle.active .pill-dot { background: var(--accent-text); opacity: 1; }

/* Comfortable Apple Books Legal Prose */
.legal-prose {
  font-size: calc(1.03rem * var(--reader-scale));
  line-height: 1.74;
  color: var(--ink-primary);
  display: flex; flex-direction: column; gap: 0.95rem;
}
.prose-block { white-space: pre-line; }
.prose-sublist {
  padding-left: 1rem;
  border-left: 2px solid var(--sep-strong);
  margin-left: 0.25rem;
  display: flex; flex-direction: column; gap: 0.65rem;
}
.prose-block.subitem {
  padding-left: 0; border-left: none; margin-left: 0;
}
.prose-block.code-block {
  font-family: var(--font-code); font-size: 0.8rem; line-height: 1.5;
  background: var(--bg-subtle); border-radius: var(--r-md);
  padding: 1rem 1.1rem; white-space: pre-wrap; overflow-x: auto;
}
.prose-child-link {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  width: 100%; text-align: left; border: none; background: var(--bg-subtle);
  padding: 0.85rem 1rem; border-radius: var(--r-md); cursor: pointer;
  transition: background 0.14s;
}
@media (hover: hover) {
  .prose-child-link:hover { background: var(--bg-hover); }
}

.num-hl {
  background: var(--accent-soft); color: var(--accent-soft-text);
  font-weight: 600; padding: 0.04rem 0.36rem; border-radius: 6px;
  white-space: nowrap; -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.xref-link {
  color: var(--accent-text); background: none; border: none; padding: 0;
  font-weight: 600; cursor: pointer; text-decoration: none;
}
.xref-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.pdf-gallery {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem; margin-top: 1.5rem;
}
.pdf-card {
  border: none; background: var(--bg-subtle); border-radius: var(--r-lg);
  overflow: hidden; cursor: zoom-in; text-align: left; padding: 0;
  transition: transform 0.15s var(--ease);
}
@media (hover: hover) {
  .pdf-card:hover { transform: translateY(-2px); }
}
.pdf-card img { width: 100%; display: block; background: #fff; }
.pdf-card-cap { padding: 0.65rem 0.9rem; font-size: 0.81rem; font-weight: 600; color: var(--ink-secondary); }

/* Inline Cloze Bar & Prose */
.cloze-bar {
  background: var(--bg-subtle); border-radius: var(--r-md);
  padding: 0.85rem; margin-bottom: 1.25rem;
  display: flex; flex-direction: column; gap: 0.65rem;
}
.cloze-selects-card {
  background: var(--bg-subtle); border-radius: var(--r-md);
  padding: 0.7rem; margin-bottom: 0.45rem;
}
.cloze-sticky-strip {
  position: sticky; top: calc(var(--topbar-h) + 52px); z-index: 20;
  background: var(--bg-surface);
  margin: 0 0 1.35rem;
  padding: 0.55rem 0 0.5rem;
  display: flex; flex-direction: column; gap: 0.55rem;
  transition: box-shadow 0.15s var(--ease);
}
.cloze-sticky-strip.is-stuck {
  border-bottom: 0.5px solid var(--sep-strong);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.045);
  padding-bottom: 0.65rem;
}
[data-theme="dark"] .cloze-sticky-strip.is-stuck {
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.45);
}
.cloze-bar .ios-field, .cloze-selects-card .ios-field { background: var(--bg-surface); }
.cloze-bar .btn-apple.soft { background: var(--bg-surface); }
.cloze-bar-selects { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; }
.cloze-bar-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.cloze-counter { font-size: 0.82rem; font-weight: 600; color: var(--ink-secondary); font-variant-numeric: tabular-nums; }
.cloze-btn-group { display: flex; align-items: center; gap: 0.4rem; }

.inline-notice {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.65rem;
  padding: 0.85rem 1rem; border-radius: var(--r-md);
  background: var(--orange-soft); color: var(--ink-primary); margin-bottom: 1rem; font-size: 0.87rem;
}
.inline-notice.ok { background: var(--green-soft); }
.notice-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; }

.cloze-prose {
  font-size: calc(1.02rem * var(--reader-scale)); line-height: 2.3;
  display: flex; flex-direction: column; gap: 0.95rem;
}
.cloze-blank {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 50px; min-height: 32px; padding: 0.1rem 0.62rem; margin: 2px 3px;
  border-radius: 8px; border: 1.5px dashed var(--accent-text);
  background: var(--accent-soft); color: var(--accent-soft-text);
  font-size: 0.9rem; font-weight: 600; cursor: pointer; line-height: 1.25;
  vertical-align: middle;
  transition: background 0.14s, color 0.14s;
}
@media (hover: hover) {
  .cloze-blank:hover { background: var(--accent); color: #fff; }
}
.cloze-blank.revealed, .cloze-chip-ok {
  display: inline-flex; align-items: center; height: 28px; vertical-align: baseline;
  border: none; background: var(--green-soft); color: var(--green-text);
  font-weight: 600; font-size: 0.92rem; padding: 0 0.5rem; margin: 0 2px; border-radius: 7px; line-height: 1.2;
}
.cloze-blank.peeked, .cloze-chip-peeked {
  display: inline-flex; align-items: center; height: 28px; vertical-align: baseline;
  border: 1px dashed var(--orange); background: var(--orange-soft); color: var(--orange-text);
  font-weight: 600; font-style: italic; font-size: 0.92rem; padding: 0 0.5rem; margin: 0 2px; border-radius: 7px; line-height: 1.2;
}

.cloze-token-group { display: inline; white-space: nowrap; }
.cloze-input-wrap {
  display: inline-flex; align-items: stretch; gap: 0;
  height: 28px; margin: 0 3px;
  border-radius: 7px; border: 1px solid var(--field-border);
  background: #f7f8fa; overflow: hidden;
  white-space: nowrap; vertical-align: baseline;
  transition: border-color 0.14s, box-shadow 0.14s, background 0.14s;
}
[data-theme="dark"] .cloze-input-wrap { background: #26262a; }
.cloze-input-wrap.has-trail { margin-right: 3px; }
.cloze-input-wrap:focus-within {
  border-color: var(--accent);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.cloze-input-wrap.is-bad {
  border-color: var(--red);
  background: var(--red-soft);
}
.cloze-trail { margin-left: 1px; }
.cloze-input {
  height: 100%; min-width: 72px; padding: 0 0.48rem; border: none;
  background: transparent; color: var(--ink-primary); font-size: 0.9rem; line-height: 1.2;
}
.cloze-input::placeholder { color: #52525b; opacity: 1; }
[data-theme="dark"] .cloze-input::placeholder { color: #b4b4bc; opacity: 1; }
.cloze-input:focus { outline: none; }
.cloze-peek {
  width: 30px; min-width: 30px; height: 100%; flex-shrink: 0;
  border: none; border-left: 1px solid var(--field-border);
  background: #e9ebf0; color: var(--ink-primary);
  font-size: 0.78rem; font-weight: 700; cursor: pointer; display: inline-grid; place-items: center;
  transition: background 0.12s, color 0.12s;
}
[data-theme="dark"] .cloze-peek { background: #34343a; color: var(--ink-primary); }
@media (hover: hover) {
  .cloze-peek:hover { background: var(--bg-hover); color: var(--ink-primary); }
}

.art-connect {
  margin-top: 2rem; display: flex; flex-wrap: wrap; gap: 0.55rem;
}
.art-pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;
  margin-top: 1.75rem; padding-top: 1.5rem; border-top: 0.5px solid var(--sep);
}
.pager-card {
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 0.85rem 1rem; border-radius: var(--r-md);
  border: none; background: var(--bg-subtle); text-align: left; cursor: pointer; min-width: 0;
  transition: background 0.14s;
}
.pager-card.next { text-align: right; }
@media (hover: hover) {
  .pager-card:hover:not(:disabled) { background: var(--bg-hover); }
}
.pager-card:disabled { opacity: 0.35; cursor: not-allowed; }
.pager-dir { font-size: 0.76rem; font-weight: 600; color: var(--accent-text); }
.pager-title { font-size: 0.88rem; font-weight: 600; color: var(--ink-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==================== 3. PRATICA (FLASHCARD DECK, QUIZ & CLOZE) ==================== */
.practice-container { max-width: 720px; }
.practice-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.85rem;
}

.deck-top-bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.deck-top-left { display: flex; align-items: center; gap: 0.4rem; }
.deck-top-right { display: flex; align-items: center; justify-content: flex-end; gap: 0.4rem; }
.status-pill {
  font-size: 0.82rem; font-weight: 600; color: var(--ink-secondary);
  background: var(--bg-surface); padding: 0.32rem 0.85rem; border-radius: 999px;
  box-shadow: var(--shadow-card); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.focus-chip {
  border: none; background: var(--accent-soft); color: var(--accent-soft-text);
  font-size: 0.78rem; font-weight: 600; padding: 0.3rem 0.7rem; border-radius: 999px; cursor: pointer;
}
.warn-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  border: none; background: var(--orange-soft); color: var(--orange-text);
  font-size: 0.78rem; font-weight: 600; padding: 0.36rem 0.78rem; border-radius: 999px; cursor: pointer;
  white-space: nowrap; transition: filter 0.14s;
}
.warn-chip:hover { filter: brightness(0.95); }
.score-ok { color: var(--green-text); }
.score-bad { color: var(--red-text); }

.filter-panel {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem;
  margin-bottom: 0.9rem; padding: 1rem 1.1rem;
}
.filter-field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.filter-field.span-2 { grid-column: span 2; }
.filter-field.align-end { justify-content: flex-end; }
.filter-field > label { font-size: 0.76rem; font-weight: 600; color: var(--ink-secondary); }

/* Apple iOS Toggle Switch Row */
.ios-switch-row {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  min-height: 36px; padding: 0 0.75rem; border-radius: 10px;
  border: 1px solid var(--field-border); background: var(--bg-surface);
  cursor: pointer; user-select: none;
}
.ios-switch-label { font-size: 0.84rem; font-weight: 400; color: var(--ink-primary); }
.ios-switch-input {
  position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none;
}
.ios-switch-track {
  position: relative; width: 38px; height: 22px; border-radius: 999px; flex-shrink: 0;
  background: #7c7c85; transition: background 0.18s var(--ease);
}
[data-theme="dark"] .ios-switch-track { background: #63636a; }
.ios-switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.30); transition: transform 0.18s var(--ease);
}
.ios-switch-input:checked + .ios-switch-track { background: #198744; }
.ios-switch-input:checked + .ios-switch-track::after { transform: translateX(16px); }
.ios-switch-input:focus-visible + .ios-switch-track { outline: 2.5px solid var(--accent-text); outline-offset: 2px; }

.deck-track { margin-bottom: 0.9rem; }

/* Floating Apple Card Deck */
.deck-stage { display: flex; flex-direction: column; }
.flashcard-deck-card {
  background: var(--bg-surface); border-radius: var(--r-xl);
  padding: 1.65rem 1.6rem; min-height: 270px;
  box-shadow: var(--shadow-deck); cursor: pointer;
  display: flex; flex-direction: column; gap: 1rem;
}
.fc-card-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.fc-meta-kicker { font-size: 0.82rem; font-weight: 600; color: var(--accent-text); }
.fc-card-state { font-size: 0.78rem; font-weight: 600; color: var(--ink-tertiary); font-variant-numeric: tabular-nums; }
.soft-pill {
  font-size: 0.74rem; font-weight: 600; padding: 0.18rem 0.6rem; border-radius: 999px;
  background: var(--orange-soft); color: var(--orange-text);
}
.fc-question {
  font-family: var(--font-display); font-size: clamp(1.18rem, 2.2vw, 1.42rem);
  font-weight: 700; letter-spacing: -0.025em; line-height: 1.35; color: var(--ink-primary);
}
.fc-divider { height: 0.5px; background: var(--sep); margin-bottom: 1rem; }
.fc-back { display: flex; flex-direction: column; flex: 1; }
.fc-answer { font-size: 0.96rem; line-height: 1.68; color: var(--ink-primary); white-space: pre-line; }
.fc-src-btn { margin-top: 1.15rem; align-self: flex-start; }

/* Thumb-Zone Reveal / SM-2 Rating Dock */
.thumb-dock { margin-top: 1rem; }
.sm2-dock { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.55rem; }
.sm2-pill {
  border: none; border-radius: var(--r-md); padding: 0.75rem 0.35rem;
  min-height: 58px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem;
  transition: transform 0.1s, filter 0.14s;
}
.sm2-pill:active { transform: scale(0.97); }
.sm2-pill strong { font-size: 0.86rem; font-weight: 700; }
.sm2-pill small { font-size: 0.74rem; font-weight: 600; opacity: 1; font-variant-numeric: tabular-nums; }
.sm2-pill.r1 { background: var(--red-soft); color: var(--red-text); }
.sm2-pill.r2 { background: var(--orange-soft); color: var(--orange-text); }
.sm2-pill.r3 { background: var(--accent-soft); color: var(--accent-soft-text); }
.sm2-pill.r4 { background: var(--green-soft); color: var(--green-text); }

.kbd-hint { display: block; text-align: center; font-size: 0.76rem; color: var(--ink-tertiary); margin-top: 0.7rem; }

/* Quiz Card */
.quiz-card { padding: 1.3rem 1.45rem; border-radius: var(--r-xl); box-shadow: var(--shadow-deck); }
.quiz-question {
  font-family: var(--font-display); font-size: clamp(0.98rem, 3.6vw, 1.22rem);
  font-weight: 700; letter-spacing: -0.012em; line-height: 1.36; margin: 0.5rem 0 0.9rem;
}
.quiz-opts { display: flex; flex-direction: column; gap: 0.5rem; }
.quiz-opt {
  display: flex; align-items: flex-start; gap: 0.75rem;
  text-align: left; border: none; border-radius: 14px;
  background: var(--bg-subtle); color: var(--ink-primary);
  padding: 0.72rem 0.95rem; min-height: 46px;
  font-size: 0.91rem; line-height: 1.42; cursor: pointer;
  transition: background 0.14s, transform 0.1s;
}
@media (hover: hover) {
  .quiz-opt:hover:not(:disabled) { background: var(--bg-hover); }
}
.opt-key {
  width: 24px; height: 24px; border-radius: 8px;
  background: var(--bg-surface); color: var(--ink-secondary);
  font-size: 0.76rem; font-weight: 700; display: grid; place-items: center; flex-shrink: 0; margin-top: 1px;
}
.opt-text { flex: 1; min-width: 0; }
.opt-status { margin-left: auto; font-weight: 800; font-size: 0.95rem; flex-shrink: 0; padding-left: 0.35rem; }
.quiz-opt.correct { background: var(--green-soft); color: var(--green-text); font-weight: 600; }
.quiz-opt.correct .opt-key { background: #15803d; color: #fff; }
.quiz-opt.wrong { background: var(--red-soft); color: var(--red-text); font-weight: 500; }
.quiz-opt.wrong .opt-key { background: #c81e1e; color: #fff; }

.quiz-fb {
  margin-top: 1.1rem; padding: 1rem 1.1rem; border-radius: var(--r-md);
  background: var(--bg-subtle); border: 1px solid var(--sep);
}
.quiz-fb.ok { background: #f2fbf5; border-color: rgba(21, 128, 61, 0.26); }
.quiz-fb.ok strong { color: var(--green-text); }
.quiz-fb.bad { background: #fef5f5; border-color: rgba(200, 30, 30, 0.24); }
.quiz-fb.bad strong { color: var(--red-text); }
[data-theme="dark"] .quiz-fb.ok { background: rgba(48, 209, 88, 0.10); border-color: rgba(48, 209, 88, 0.28); }
[data-theme="dark"] .quiz-fb.bad { background: rgba(255, 69, 58, 0.10); border-color: rgba(255, 69, 58, 0.28); }
.quiz-fb-head { display: inline-flex; align-items: center; gap: 0.45rem; }
.fb-badge-ic {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  display: inline-grid; place-items: center;
  font-size: 0.72rem; font-weight: 800; color: #fff; background: #c81e1e;
}
.quiz-fb.ok .fb-badge-ic, .quiz-mobile-dock.ok .fb-badge-ic { background: #15803d; }
.quiz-fb.bad .fb-badge-ic, .quiz-mobile-dock.bad .fb-badge-ic { background: #c81e1e; }
.quiz-fb strong { font-size: 0.92rem; }
.quiz-fb p { font-size: 0.88rem; color: var(--ink-primary); margin-top: 0.4rem; line-height: 1.52; }
.quiz-fb-foot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.65rem; margin-top: 0.85rem; }
.show-xs { display: none; }

.quiz-expand-opts {
  display: none; align-items: center; gap: 0.35rem;
  margin-top: 0.55rem; min-height: 36px; padding: 0.25rem 0.75rem;
  border: none; border-radius: 999px; background: var(--bg-subtle); color: var(--ink-primary);
  font-size: 0.79rem; font-weight: 600; cursor: pointer;
  transition: background 0.14s;
}
.quiz-expand-opts:hover { background: var(--bg-hover); }
.quiz-expand-opts .expand-chev { color: var(--ink-secondary); transition: transform 0.18s var(--ease); }
.quiz-expand-opts[aria-expanded="true"] .expand-chev { transform: rotate(180deg); }
.quiz-mobile-dock { display: none; }

.empty-card { text-align: center; padding: 2.2rem 1.5rem; }
.empty-card h2 { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; margin-bottom: 0.35rem; }
.empty-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.15rem; }
.summary-score { font-family: var(--font-display); font-size: 2.4rem; font-weight: 800; color: var(--accent-text); margin: 0.35rem 0; }
.missed-list { text-align: left; margin-top: 1.15rem; display: flex; flex-direction: column; gap: 0.5rem; }
.missed-row {
  background: var(--bg-subtle); border-radius: var(--r-sm); padding: 0.75rem 0.95rem;
  font-size: 0.85rem; display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap;
}

.practice-cloze-card { padding: 1.35rem 1.4rem; border-radius: var(--r-xl); }
.pcloze-head { display: flex; flex-direction: column; gap: 0.1rem; }
.pcloze-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; }
.pcloze-foot {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.65rem;
  margin-top: 1.25rem; padding-top: 1rem; border-top: 0.5px solid var(--sep);
}

/* ==================== 4. SINOSSI ==================== */
.ref-pills-rail {
  display: flex; gap: 0.45rem; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; padding-bottom: 0.15rem;
}
.ref-pills-rail::-webkit-scrollbar { display: none; }
.ref-pill {
  border: none; background: var(--bg-surface); color: var(--ink-secondary);
  font-size: 0.85rem; font-weight: 600; padding: 0.5rem 0.95rem;
  border-radius: 999px; white-space: nowrap; cursor: pointer; flex-shrink: 0;
  box-shadow: var(--shadow-card); transition: all 0.14s;
}
.ref-pill.active { background: var(--accent); color: #fff; }

.ref-filter-row { display: flex; }
.ref-search { max-width: 340px; }
.ref-search .ios-field { background: #ffffff; border: 1px solid var(--field-border); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04); }
[data-theme="dark"] .ref-search .ios-field { background: var(--bg-surface); }

.ref-table-wrap {
  background: var(--bg-surface); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--shadow-card);
}
table.ref-table { width: 100%; border-collapse: collapse; font-size: 0.89rem; }
table.ref-table th, table.ref-table td {
  padding: 0.9rem 1.05rem; text-align: left; vertical-align: top;
  border-bottom: 0.5px solid var(--sep);
}
table.ref-table tr:last-child td { border-bottom: none; }
table.ref-table th {
  font-size: 0.74rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--ink-tertiary); background: var(--bg-subtle);
}
table.ref-table th:first-child, table.ref-table td:first-child { min-width: 225px; width: 25%; }
table.ref-table th.col-source, table.ref-table td.col-source { white-space: nowrap; text-align: right; width: 1%; }
table.ref-table td.col-source .text-action { padding: 0; line-height: 1.55; vertical-align: baseline; }
.q-organ { display: block; font-weight: 700; color: var(--ink-primary); line-height: 1.35; }
.q-sub { display: block; font-size: 0.81rem; font-weight: 500; color: var(--ink-secondary); margin-top: 2px; line-height: 1.35; }
.q-num { font-weight: 600; color: var(--ink-primary); }
table.ref-table tr.tl-past td { opacity: 0.56; }
table.ref-table tr.tl-next td { background: var(--accent-soft); }
table.ref-table tr.tl-election td { background: var(--orange-soft); }

.stv-box {
  background: var(--bg-surface); border-radius: var(--r-lg);
  padding: 1.35rem 1.5rem; margin-top: 1rem; box-shadow: var(--shadow-card);
}
.stv-box h3 { font-family: var(--font-display); font-size: 1.08rem; font-weight: 700; margin-bottom: 0.65rem; }
.stv-formula {
  font-family: var(--font-code); background: var(--bg-subtle);
  border-radius: var(--r-sm); padding: 0.8rem 1rem; margin: 0.65rem 0 0.85rem;
  color: var(--accent-soft-text); font-weight: 600; font-size: 0.88rem; overflow-x: auto;
}

/* ==================== FLOATING iOS PILL TAB BAR ==================== */
.floating-nav-wrap {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 65;
  padding: 20px 1rem calc(0.65rem + env(safe-area-inset-bottom));
  background: linear-gradient(
    to top,
    var(--scrim-bg) 62%,
    color-mix(in srgb, var(--scrim-bg) 82%, transparent) 84%,
    transparent 100%
  );
  pointer-events: none;
}
.floating-nav {
  pointer-events: auto;
  max-width: 400px; margin: 0 auto; height: 58px;
  border-radius: 29px;
  background: var(--bg-glass-nav);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: var(--shadow-float), 0 0 0 0.5px var(--sep-strong);
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 0 0.35rem;
}
[data-theme="dark"] .floating-nav {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.fnav-btn {
  border: none; background: transparent; color: var(--ink-tertiary);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.14rem; font-size: 0.68rem; font-weight: 600; cursor: pointer; border-radius: 22px;
}
[data-theme="dark"] .fnav-btn { color: #b4b4bc; }
.fnav-btn .ic { width: 20px; height: 20px; }
.fnav-btn.active { color: var(--accent-text); }
.fnav-ic-wrap { position: relative; display: inline-flex; }
.fnav-dot {
  position: absolute; top: -1px; right: -4px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--red);
  box-shadow: 0 0 0 2px var(--bg-surface);
}

/* ==================== MODALS & TOAST ==================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.48); backdrop-filter: blur(8px);
  display: grid; place-items: center; padding: 1rem;
}
.modal-sheet {
  background: var(--bg-surface); border-radius: var(--r-xl);
  padding: 1.35rem 1.45rem; width: 100%; max-width: 600px; max-height: 82vh;
  display: flex; flex-direction: column; gap: 0.9rem; box-shadow: var(--shadow-modal);
}
.modal-sheet.compact { max-width: 440px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { font-family: var(--font-display); font-size: 1.12rem; font-weight: 700; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 0.55rem; }

.backup-summary {
  background: var(--bg-subtle); border-radius: var(--r-sm); padding: 0.75rem 0.9rem;
  font-size: 0.82rem; color: var(--ink-secondary); font-variant-numeric: tabular-nums;
}
.confirm-box {
  background: var(--red-soft); border-radius: var(--r-md); padding: 0.9rem 1rem;
  display: flex; flex-direction: column; gap: 0.65rem; font-size: 0.85rem;
}

/* ==================== FIREBASE GOOGLE CLOUD SYNC UI ==================== */
.cloud-btn { position: relative; overflow: visible; }
.cloud-btn-avatar {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block;
}
.cloud-dot {
  position: absolute; bottom: -1px; right: -1px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #198744; border: 2px solid var(--bg-surface);
}
.cloud-dot.syncing { background: var(--accent); animation: cloudPulse 1s infinite ease-in-out; }
.cloud-dot.pending { background: var(--orange); }
.cloud-dot.error { background: var(--cal-red); }
@keyframes cloudPulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.25); opacity: 0.7; } }

.cloud-home-card { padding: 0.95rem 1.2rem; }
.cloud-home-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.85rem;
}
.cloud-home-left { display: flex; align-items: center; gap: 0.85rem; min-width: 0; flex: 1; }
.google-sq {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--bg-subtle); border: 0.5px solid var(--sep);
  display: grid; place-items: center; flex-shrink: 0;
}
[data-theme="dark"] .google-sq { background: #2c2c2e; }
.google-g-ic { width: 18px; height: 18px; flex-shrink: 0; }
.cloud-home-copy { display: flex; flex-direction: column; min-width: 0; }
.cloud-home-title {
  font-size: 0.93rem; font-weight: 600; color: var(--ink-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cloud-home-sub {
  font-size: 0.79rem; color: var(--ink-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cloud-user-avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  background: var(--accent-soft); flex-shrink: 0; border: 0.5px solid var(--sep);
}
.cloud-user-avatar.lg { width: 42px; height: 42px; }

.cloud-modal-box {
  background: var(--bg-subtle); border-radius: var(--r-md);
  padding: 1rem 1.05rem; display: flex; flex-direction: column; gap: 0.85rem;
}
.cloud-modal-out, .cloud-modal-in { display: flex; flex-direction: column; gap: 0.8rem; }
.cloud-modal-head { display: flex; align-items: flex-start; gap: 0.8rem; }
.cloud-modal-head strong { display: block; font-size: 0.94rem; margin-bottom: 0.15rem; }

.btn-google-signin {
  width: 100%; min-height: 44px; padding: 0.55rem 1.1rem;
  border-radius: 12px; border: 1px solid var(--field-border);
  background: var(--bg-surface); color: var(--ink-primary);
  font-size: 0.92rem; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.6rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: background 0.14s, transform 0.1s;
}
.btn-google-signin:hover { background: var(--bg-hover); }
.btn-google-signin:active { transform: scale(0.988); }

.cloud-profile-row {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
}
.cloud-profile-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cloud-profile-info strong { font-size: 0.94rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cloud-profile-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cloud-pill-status {
  font-size: 0.74rem; font-weight: 700; padding: 0.22rem 0.62rem; border-radius: 999px;
  background: var(--green-soft); color: var(--green-text); white-space: nowrap;
}
.cloud-pill-status.syncing { background: var(--accent-soft); color: var(--accent-soft-text); }
.cloud-pill-status.pending { background: var(--orange-soft); color: var(--orange-text); }
.cloud-pill-status.error { background: var(--red-soft); color: var(--red-text); }

.cloud-sync-meta {
  font-size: 0.79rem; color: var(--ink-secondary);
  background: var(--bg-surface); padding: 0.55rem 0.75rem; border-radius: 10px;
  font-variant-numeric: tabular-nums;
}
.cloud-notice {
  font-size: 0.79rem; line-height: 1.45;
  padding: 0.65rem 0.8rem; border-radius: 10px;
  background: var(--orange-soft); color: var(--orange-text);
}
.modal-divider-label {
  font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--ink-tertiary); margin-top: 0.15rem; margin-bottom: -0.35rem;
}

.search-results { overflow-y: auto; display: flex; flex-direction: column; gap: 0.45rem; max-height: 56vh; }
.sr-item {
  width: 100%; text-align: left; border: none; background: var(--bg-subtle);
  border-radius: var(--r-md); padding: 0.78rem 0.95rem; cursor: pointer;
  transition: background 0.12s;
}
.sr-item:hover, .sr-item.active { background: var(--accent-soft); }
.sr-item-meta { font-size: 0.75rem; font-weight: 600; color: var(--accent-soft-text); margin-bottom: 0.15rem; }
.sr-item-title { font-weight: 600; font-size: 0.9rem; color: var(--ink-primary); margin-bottom: 0.2rem; }
.sr-item-snip { font-size: 0.8rem; color: var(--ink-secondary); line-height: 1.45; }
mark.search-hit {
  background: var(--orange-soft); color: var(--orange-text);
  font-weight: 700; padding: 0 1px; border-radius: 3px;
}
.search-modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding-top: 0.6rem; border-top: 0.5px solid var(--sep);
  font-size: 0.76rem; font-weight: 500; color: var(--ink-tertiary);
}

.lightbox-panel { width: min(94vw, 940px); max-height: 92vh; display: flex; flex-direction: column; gap: 0.65rem; }
.lightbox-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  background: var(--bg-surface); border-radius: var(--r-md); padding: 0.55rem 0.9rem;
}
.lightbox-cap { font-size: 0.86rem; font-weight: 600; }
.lightbox-controls { display: flex; gap: 0.35rem; }
.lightbox-panel img {
  width: 100%; max-height: calc(92vh - 78px); object-fit: contain;
  border-radius: var(--r-md); background: #fff; box-shadow: var(--shadow-modal);
}

.toast-region {
  position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 120;
  display: flex; flex-direction: column; gap: 0.45rem; pointer-events: none;
}
.toast {
  pointer-events: auto; background: var(--ink-primary); color: var(--bg-surface);
  border-radius: 999px; padding: 0.62rem 1.1rem;
  font-size: 0.84rem; font-weight: 600; box-shadow: var(--shadow-float); max-width: 320px;
}

/* ==================== RESPONSIVE (900px MOBILE iOS MODE) ==================== */
@media (max-width: 900px) {
  .topbar { display: none; }
  .desktop-only { display: none !important; }
  .mobile-head-actions { display: flex; }
  .mobile-head-actions .circle-btn { width: 44px; height: 44px; }
  .floating-nav-wrap { display: block; }
  .ios-back-btn { display: inline-flex; }

  .main-shell { min-height: 100dvh; }
  .ios-container {
    padding: max(18px, env(safe-area-inset-top)) 1.05rem calc(var(--fnav-h) + 2.5rem + env(safe-area-inset-bottom));
    gap: 1.05rem;
  }
  .home-bento { grid-template-columns: 1fr; gap: 1rem; }
  .home-side-stack { gap: 1rem; }
  .event-card-main { align-items: flex-start; }
  .event-card-main .ios-cal { margin-top: 2px; }
  .event-card-main .chev-right { align-self: center; }
  .guide-grid { grid-template-columns: 1fr; }

  /* Full-Screen Slide-Over TOC Sheet */
  .reader-layout { grid-template-columns: 1fr; min-height: 100dvh; }
  .reader-nav-bar { top: 0; padding: 0 0.85rem; }
  .reader-inner { padding: 1.35rem 1.15rem calc(var(--fnav-h) + 2.5rem + env(safe-area-inset-bottom)); }
  .ios-pill-select, .pill-toggle { min-height: 40px; }
  .cloze-sticky-strip {
    top: 52px; margin: 0 0 1.05rem; padding: 0.5rem 0 0.5rem;
  }
  .cloze-sticky-strip.is-stuck {
    margin: 0 -1.15rem 1.05rem; padding: 0.5rem 1.15rem 0.65rem;
  }
  .toc-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 85;
    width: min(86vw, 330px); height: 100dvh; border-right: none; border-radius: 0;
    transform: translateX(-105%);
    box-shadow: none; visibility: hidden;
    transition: transform 0.24s var(--ease), visibility 0s linear 0.24s;
  }
  .toc-sidebar.open {
    transform: translateX(0); box-shadow: var(--shadow-modal); visibility: visible;
    transition: transform 0.24s var(--ease), visibility 0s;
  }
  .toc-head-mobile {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.9rem 1rem; border-bottom: 0.5px solid var(--sep);
  }
  .toc-head-mobile strong { font-family: var(--font-display); font-size: 1.08rem; }
  .toc-item { min-height: 44px; padding-top: 0.55rem; padding-bottom: 0.55rem; }

  /* Practice: Focus Mode + Sticky Thumb-Zone Dock on Mobile! */
  .practice-header { gap: 0.6rem; }
  .compact-title { font-size: 1.65rem; }
  .practice-header .ios-seg { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
  .practice-header .ios-seg-btn { padding: 0.35rem 0.25rem; }
  .deck-top-bar .circle-btn { width: 44px; height: 44px; }
  .deck-top-right { gap: 0.6rem; }
  .warn-chip, .focus-chip { min-height: 40px; padding: 0.42rem 0.85rem; font-size: 0.8rem; }
  .filter-panel { grid-template-columns: 1fr; }
  .filter-field.span-2 { grid-column: span 1; }
  .flashcard-deck-card {
    padding: 1.25rem 1.2rem; min-height: 205px;
    max-height: calc(100dvh - 332px); overflow-y: auto;
  }
  .thumb-dock {
    position: sticky;
    bottom: calc(var(--fnav-h) + 12px + env(safe-area-inset-bottom));
    z-index: 25;
    background: linear-gradient(to bottom, transparent 0%, var(--bg-canvas) 22px, var(--bg-canvas) 100%);
    margin: 0.15rem -1.05rem 0;
    padding: 1.15rem 1.05rem 0.45rem;
  }

  .quiz-card { padding: 1.05rem 1rem; }
  .quiz-opt { padding: 0.62rem 0.82rem; font-size: 0.87rem; line-height: 1.36; min-height: 44px; }
  #pane-quiz.has-answer:not(.show-all-opts) .quiz-opt:not(.correct):not(.wrong) { display: none; }
  #pane-quiz.has-answer .quiz-expand-opts { display: inline-flex; }
  .quiz-fb { display: none !important; }
  .quiz-mobile-dock {
    margin-top: 0.75rem;
    scroll-margin-bottom: calc(var(--fnav-h) + 24px);
    background: var(--bg-surface);
    border-radius: var(--r-lg); padding: 0.9rem 1rem;
    border: 1px solid var(--sep);
    box-shadow: var(--shadow-card);
    display: flex; flex-direction: column; gap: 0.45rem;
  }
  .quiz-mobile-dock.ok { background: #f2fbf5; border-color: rgba(21, 128, 61, 0.26); }
  .quiz-mobile-dock.bad { background: #fef5f5; border-color: rgba(200, 30, 30, 0.24); }
  [data-theme="dark"] .quiz-mobile-dock.ok { background: rgba(48, 209, 88, 0.10); border-color: rgba(48, 209, 88, 0.28); }
  [data-theme="dark"] .quiz-mobile-dock.bad { background: rgba(255, 69, 58, 0.10); border-color: rgba(255, 69, 58, 0.28); }
  .qmd-top { display: flex; align-items: center; justify-content: space-between; gap: 0.65rem; }
  .qmd-verdict { font-size: 0.9rem; font-weight: 700; line-height: 1.2; }
  .qmd-verdict.ok { color: var(--green-text); }
  .qmd-verdict.bad { color: var(--red-text); }
  .qmd-explain { font-size: 0.84rem; line-height: 1.48; color: var(--ink-primary); }
  .qmd-src {
    border: none; background: transparent; padding: 0.1rem 0; text-align: left; align-self: flex-start;
    color: var(--accent-soft-text); font-size: 0.82rem; font-weight: 600; cursor: pointer;
  }

  .ref-pills-rail {
    padding: 2px 28px 6px 2px;
    -webkit-mask-image: linear-gradient(to right, #000 0%, #000 86%, transparent 100%);
    mask-image: linear-gradient(to right, #000 0%, #000 86%, transparent 100%);
  }
  .ref-search { max-width: 100%; }
  .toast-region { bottom: calc(var(--fnav-h) + 0.75rem); left: 1rem; right: 1rem; align-items: center; }

  /* Responsive Sinossi Tables -> Clean Borderless Apple Cards */
  .ref-table-wrap { background: transparent; box-shadow: none; overflow: visible; border-radius: 0; }
  table.ref-table { border-collapse: separate; border-spacing: 0; }
  table.ref-table thead { display: none; }
  table.ref-table, table.ref-table tbody, table.ref-table tr, table.ref-table td { display: block; width: 100%; }
  table.ref-table tr {
    background: var(--bg-surface); border-radius: var(--r-lg);
    padding: 0.95rem 1.1rem; margin-bottom: 0.75rem; box-shadow: var(--shadow-card);
  }
  table.ref-table tr:last-child { margin-bottom: 0; }
  table.ref-table td { padding: 0.28rem 0; border-bottom: none; }
  table.ref-table td:first-child {
    padding-top: 0; padding-bottom: 0.55rem; margin-bottom: 0.42rem;
    border-bottom: 0.5px solid var(--sep);
  }
  table.ref-table td:first-child::before,
  table.ref-table td.col-source::before { display: none; }
  table.ref-table td.col-source {
    text-align: left; width: 100%;
    padding-top: 0.55rem; margin-top: 0.45rem; border-top: 0.5px solid var(--sep);
  }
  table.ref-table td::before {
    content: attr(data-label); display: block;
    font-size: 0.69rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--ink-tertiary); margin-bottom: 0.08rem;
  }
}

@media (max-width: 480px) {
  .hide-xs { display: none; }
  .show-xs { display: inline; }
}

@media (max-width: 380px), (max-height: 700px) and (max-width: 900px) {
  .ios-container {
    padding-top: max(10px, env(safe-area-inset-top));
    padding-inline: 0.85rem;
    gap: 0.5rem;
  }
  .large-title { font-size: 1.46rem; }
  .compact-title { font-size: 1.3rem; }
  .practice-header { gap: 0.35rem; }
  .deck-top-bar { margin-bottom: 0.32rem; }
  .deck-track { margin-bottom: 0.42rem; }
  .event-sep { display: none; }
  .warn-chip { min-height: 36px; padding: 0.32rem 0.68rem; font-size: 0.75rem; }
  .mobile-head-actions .circle-btn { width: 42px; height: 42px; }
  .deck-top-bar .circle-btn { width: 38px; height: 38px; }
  .quiz-card { padding: 0.72rem 0.85rem; }
  .quiz-question { font-size: 0.88rem; line-height: 1.28; margin: 0.24rem 0 0.48rem; }
  .quiz-opts { gap: 0.3rem; }
  .quiz-opt { padding: 0.42rem 0.68rem; min-height: 36px; font-size: 0.81rem; line-height: 1.3; }
  .quiz-expand-opts { margin-top: 0.35rem; min-height: 32px; font-size: 0.74rem; padding: 0.18rem 0.65rem; }
  .quiz-mobile-dock { margin-top: 0.42rem; padding: 0.62rem 0.82rem; gap: 0.3rem; }
  .qmd-verdict { font-size: 0.84rem; }
  .qmd-explain { font-size: 0.78rem; line-height: 1.38; }
  .qmd-src { font-size: 0.77rem; }
  .sm2-dock { gap: 0.35rem; }
  .sm2-pill { padding: 0.62rem 0.2rem; }
  .sm2-pill strong { font-size: 0.78rem; }
  .cloze-bar-selects { grid-template-columns: 1fr; }
  .art-pager { grid-template-columns: 1fr; }
  .pager-card.next { text-align: left; }
}

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