/* Apple-flavoured theme: one token set for light, one for dark.
   The header uses vibrancy (translucent + blurred) like a macOS toolbar. */

:root,
[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --panel: #ffffff;
  --panel-2: #fafafa;
  --sidebar: #f0f0f2;
  --line: rgba(0, 0, 0, 0.10);
  --line-strong: rgba(0, 0, 0, 0.18);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.10);
  /* Small text on a tinted pill needs a deeper ink than a link or a big
     heading, or it lands just under the readable contrast floor. */
  --accent-ink: #0058b0;
  --good: #248a3d;
  --good-soft: rgba(52, 199, 89, 0.14);
  --good-ink: #1f7a35;
  --warn: #9a5b00;
  --warn-soft: rgba(255, 149, 0, 0.16);
  --bad: #d70015;
  --bad-soft: rgba(255, 59, 48, 0.12);
  --header: rgba(255, 255, 255, 0.72);
  --seg-bg: rgba(120, 120, 128, 0.12);
  --seg-active: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.07);
  --radius: 16px;
  --radius-sm: 10px;
  --glass-bg: rgba(255, 255, 255, 0.66);
  --glass-line: rgba(255, 255, 255, 0.75);
  --glass-highlight: rgba(255, 255, 255, 0.95);
  --glass-blur: saturate(180%) blur(22px);
  --glow-a: rgba(0, 113, 227, 0.16);
  --glow-b: rgba(122, 106, 255, 0.13);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --panel: #1c1c1e;
  --panel-2: #2c2c2e;
  --sidebar: #161618;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f5f5f7;
  --muted: #98989d;
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.18);
  --accent-ink: #0a84ff;
  --good: #30d158;
  --good-soft: rgba(48, 209, 88, 0.16);
  --good-ink: #30d158;
  --warn: #ffd60a;
  --warn-soft: rgba(255, 214, 10, 0.16);
  --bad: #ff453a;
  --bad-soft: rgba(255, 69, 58, 0.18);
  --header: rgba(28, 28, 30, 0.72);
  --seg-bg: rgba(120, 120, 128, 0.24);
  --seg-active: #636366;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  /* The glass surfaces are declared once for light mode, so they have to be
     restated here. Without this the cards paint 66% white on a black page and
     light text sits on a light panel. */
  --glass-bg: rgba(30, 30, 32, 0.72);
  --glass-line: rgba(255, 255, 255, 0.14);
  --glass-highlight: rgba(255, 255, 255, 0.10);
  color-scheme: dark;
}

* { box-sizing: border-box; }

:root {
  /* Apple's spring feel: fast out, gentle settle, then a small overshoot. */
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 620px at 8% -12%, var(--glow-a), transparent 62%),
    radial-gradient(900px 520px at 104% -4%, var(--glow-b), transparent 58%),
    var(--bg);
  /* No background-attachment: fixed. Pinning a two-layer gradient to the
     viewport forces a full-page repaint on every scroll frame, which is the
     single worst thing you can do to a phone. The gradient sits on the body
     box instead, which scrolls with the content for free. */
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.wrap {
  width: min(1080px, calc(100% - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  margin: 0 auto;
}

/* ---------- toolbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--header);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  /* Clear of the Dynamic Island / notch when opened from the home screen. */
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.topbar .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 10px;
}

.topbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}

.tagline {
  margin: 1px 0 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.sub { margin: 1px 0 0; color: var(--muted); font-size: 12.5px; }

.dot {
  width: 11px;
  height: 11px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(180deg, #4ea8de, var(--accent));
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}

/* ---------- appearance switch ---------- */

.switch {
  position: relative;
  width: 56px;
  height: 30px;
  flex: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--seg-bg);
  cursor: pointer;
  transition: background-color 0.25s ease;
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--seg-active);
  box-shadow: var(--shadow-sm);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

[data-theme="dark"] .switch-thumb { transform: translateX(26px); }

.switch-glyph {
  position: absolute;
  top: 50%;
  display: flex;
  align-items: center;
  transform: translateY(-50%);
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  pointer-events: none;
}
.switch-glyph svg { display: block; }
.switch-glyph.sun { left: 7px; }
.switch-glyph.moon { right: 7px; }

/* ---------- segmented tab control ---------- */

/* The six tabs wrap onto a second line rather than scrolling sideways. A
   scrolled-away tab is a tab nobody knows is there. */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-sm);
  background: var(--seg-bg);
  min-width: 0;
  max-width: 100%;
}

.tabs button {
  flex: none;
  border: 0;
  border-radius: 8px;
  padding: 6px 13px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.tabs button:hover { color: var(--text); }
.tabs button.active {
  background: var(--seg-active);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ---------- layout ---------- */

main { padding: 22px 0 56px; }

h2,
.sub-head {
  margin: 30px 0 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}
h2:first-child { margin-top: 4px; }
.sub-head:first-child { margin-top: 4px; }

/* ---------- scoreboard ---------- */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.kpi .label {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kpi .value { margin: 5px 0 2px; font-size: 28px; font-weight: 600; letter-spacing: -0.03em; }
.kpi .note { color: var(--muted); font-size: 12.5px; }

/* ---------- cards ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px 18px;
  margin-bottom: 12px;
}
.card h3 { margin: 14px 0 3px; font-size: 15.5px; font-weight: 600; letter-spacing: -0.02em; }
.card .meta { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.card ul { margin: 6px 0 14px; padding-left: 20px; }
.card li { margin: 3px 0; }
.card > p:last-child { margin-bottom: 14px; }

/* ---------- pills ---------- */

.pill {
  display: inline-block;
  margin: 0 6px 5px 0;
  padding: 3px 9px;
  border: 0;
  border-radius: 999px;
  background: var(--seg-bg);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}
.pill.good { background: var(--good-soft); color: var(--good-ink); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--accent-soft); color: var(--accent-ink); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- tables ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--panel-2); }
td .meta { margin-top: 4px; color: var(--muted); font-size: 12.5px; }

/* ---------- controls ---------- */

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

/* The checkbox inside the "Strong Fits Only" label is an input in .controls
   too, so it is excluded here — otherwise it picks up appearance:none, loses
   its tick, and stretches to 240px. */
.controls input:not([type="checkbox"]),
.controls select {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  box-shadow: var(--shadow-sm);
  appearance: none;
}
.controls input:not([type="checkbox"]) { flex: 1 1 240px; }
.controls input:not([type="checkbox"]):focus,
.controls select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-size: 13.5px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.check input[type="checkbox"] {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.controls select {
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* ---------- phase rows ---------- */

.phase {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.phase:last-child { border-bottom: 0; }
.phase .id { flex: none; width: 26px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.phase .name { font-weight: 600; }
.phase .detail { color: var(--muted); font-size: 13px; }

/* ---------- notices ---------- */

.empty,
.warnbar {
  padding: 13px 16px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  font-size: 13.5px;
  box-shadow: var(--shadow);
}
.warnbar strong { color: var(--text); }

/* The one-line "what is this tab" note that sits under every heading. */
.view-note {
  margin: -6px 0 14px;
  max-width: 68ch;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

/* "Show All N Openings" at the foot of a clipped board. */
.more-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 12px 0 4px;
}

.foot {
  padding: 14px 0 calc(44px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.foot .road {
  margin: 8px 0 0;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.8;
}

.foot-note {
  margin: 6px 0 0;
  max-width: 76ch;
  opacity: 0.85;
}

/* ---------- small screens, including every iPhone ---------- */

@media (max-width: 640px) {
  .topbar .wrap { padding-bottom: 8px; }
  .topbar-controls { width: 100%; gap: 10px; flex-wrap: nowrap; }
  .tabs { flex: 1 1 auto; min-width: 0; }
  .switch { flex: none; }
  .brand h1 { font-size: 16px; }
  .sub { font-size: 12px; }
  main { padding-top: 18px; }
  h2 { margin-top: 24px; }
  .kpi .value { font-size: 25px; }
  .card { padding: 4px 14px; }
  .verse { padding: 16px 18px; }
  .verse blockquote { font-size: 17px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  th, td { padding: 9px 10px; font-size: 13px; }
  /* Comfortable tap targets on a phone. */
  .tabs button { padding: 8px 12px; }
  .seg-btn { padding: 9px 12px; }
  .btn { padding: 9px 14px; font-size: 13px; }
  .controls input:not([type="checkbox"]), .controls select, .vault-row input[type="text"] { font-size: 16px; }
}

/* Landscape phones: keep the sticky toolbar from eating the viewport. */
@media (max-height: 480px) and (orientation: landscape) {
  .topbar { position: static; }
}

/* ---------- log ---------- */

.log-item { display: flex; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.log-item:last-child { border-bottom: 0; }
.log-item time {
  flex: none;
  width: 84px;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

/* ---------- verse of the day ---------- */

.verse {
  margin-bottom: 20px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.verse-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}
.verse-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.verse-head .verse-label { margin-bottom: 0; }
.verse blockquote {
  margin: 8px 0 0;
  font-size: 19px;
  line-height: 1.5;
  letter-spacing: -0.01em;
}
.verse-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}
.verse-ref {
  margin-top: 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- work-arrangement segmented control ---------- */

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  margin-bottom: 12px;
  border-radius: 12px;
  background: var(--seg-bg);
}

.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 9px;
  padding: 8px 15px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: var(--seg-active);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.seg-count {
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- resume vault ---------- */

.btn {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}
.btn:hover { border-color: var(--line-strong); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.danger { color: var(--bad); }

.vault-drop {
  margin: 12px 0 14px;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  transition: border-color 0.18s ease, background-color 0.18s ease;
}
.vault-drop.dragging { border-color: var(--accent); background: var(--accent-soft); }
.vault-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.vault-row:last-child { margin-bottom: 0; }
.vault-row input[type="text"] {
  flex: 1 1 200px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.vault-list { margin-top: 6px; }
.vault-item { padding: 11px 0; border-bottom: 1px solid var(--line); }
.vault-item:last-child { border-bottom: 0; }
.vault-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.vault-actions { display: flex; gap: 6px; }
.vault-preview { margin-top: 10px; }
.vault-preview iframe {
  width: 100%;
  height: 480px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}


/* ============================================================================
   Apple-style motion and liquid glass
   ========================================================================== */

/* ---------- glass surfaces ---------- */

.card,
.kpi,
.verse,
.table-wrap,
.seg {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-line);
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-highlight);
}

/* The toolbar reads as the thickest piece of glass, so it gets an extra sheen
   and a hairline along the bottom edge. */
.topbar {
  background: var(--header);
  -webkit-backdrop-filter: saturate(180%) blur(26px);
  backdrop-filter: saturate(180%) blur(26px);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 1px 0 var(--line);
}

/* A translucent pill that sits on top of the glass, not a flat grey box. */
.tabs,
.switch {
  background: var(--seg-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}

.controls input:not([type="checkbox"]),
.controls select,
.vault-row input[type="text"] {
  /* background-color, not the shorthand: the shorthand would wipe the chevron
     drawn on the selects and leave them looking like plain boxes. */
  background-color: var(--glass-bg);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  transition: border-color 0.22s var(--ease), box-shadow 0.22s var(--ease), transform 0.22s var(--spring);
}
.controls input:not([type="checkbox"]):focus,
.controls select:focus {
  transform: translateY(-1px);
  box-shadow: 0 0 0 3px var(--accent-soft), inset 0 1px 0 var(--glass-highlight);
}

/* Column headings stay put and stay glassy while a long table scrolls. */
.table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--line);
}

/* ---------- springs on every interactive thing ---------- */

.tabs button,
.seg-btn,
.btn,
.pill,
.kpi,
.card,
.verse {
  transition: background-color 0.24s var(--ease), color 0.24s var(--ease),
              border-color 0.24s var(--ease), box-shadow 0.24s var(--ease),
              transform 0.34s var(--spring);
}

.tabs button:hover,
.seg-btn:hover { transform: translateY(-1px); }
.tabs button.active,
.seg-btn.active { animation: settle 0.42s var(--bounce) both; }

.btn:hover { transform: translateY(-2px) scale(1.02); }
/* Press states: the whole point of an iOS button is that it gives under a finger. */
.btn:active,
.tabs button:active,
.seg-btn:active,
.switch:active { transform: scale(0.955); }

/* Every "lifts on hover" effect is behind a real pointer check. On a touch
   screen a hover style sticks to whatever was tapped last, so the row that was
   just pressed stays lifted for the rest of the session. */
@media (hover: hover) and (pointer: fine) {
  .card:hover,
  .kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow), inset 0 1px 0 var(--glass-highlight), 0 14px 34px rgba(0, 0, 0, 0.10); }
  .btn:hover { transform: translateY(-2px) scale(1.02); }
}

.switch-thumb { transition: transform 0.42s var(--bounce); }

/* Pills used to pop in on every render. Because a filter change re-renders
   every row, typing one letter in the search box replayed that animation on
   hundreds of pills at once. They now only animate as part of a view change. */
.view-enter .pill { animation: pop 0.4s var(--bounce) both; }

a { transition: color 0.2s var(--ease), opacity 0.2s var(--ease); }
a:active { opacity: 0.6; }

/* ---------- view changes and staggered entrances ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
@keyframes pop {
  0%   { opacity: 0; transform: scale(0.8); }
  70%  { transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes settle {
  0%   { transform: scale(0.94); }
  60%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}
@keyframes verseIn {
  from { opacity: 0; transform: translateY(10px); filter: blur(4px); }
  to   { opacity: 1; transform: none; filter: none; }
}

/* Only animate when the tab actually changes, so typing in the search box does
   not re-trigger every entrance. */
/* Only the first screenful cascades in. Animating fifty rows at once is a
   stutter nobody sees the end of. */
.view-enter { animation: rise 0.5s var(--spring) both; }
.view-enter .verse  { animation: rise 0.55s var(--spring) both; }
.view-enter .card   { animation: rise 0.5s var(--spring) both; }
.view-enter .kpi    { animation: rise 0.5s var(--spring) both; }
.view-enter tbody tr:nth-child(-n+12) { animation: rise 0.36s var(--spring) both; }

/* Stagger children so the entrance cascades instead of snapping in together. */
.view-enter .card:nth-child(1), .view-enter tbody tr:nth-child(1), .view-enter .kpi:nth-child(1) { animation-delay: 0.00s; }
.view-enter .card:nth-child(2), .view-enter tbody tr:nth-child(2), .view-enter .kpi:nth-child(2) { animation-delay: 0.035s; }
.view-enter .card:nth-child(3), .view-enter tbody tr:nth-child(3), .view-enter .kpi:nth-child(3) { animation-delay: 0.07s; }
.view-enter .card:nth-child(4), .view-enter tbody tr:nth-child(4), .view-enter .kpi:nth-child(4) { animation-delay: 0.105s; }
.view-enter .card:nth-child(5), .view-enter tbody tr:nth-child(5), .view-enter .kpi:nth-child(5) { animation-delay: 0.14s; }
.view-enter .card:nth-child(6), .view-enter tbody tr:nth-child(6), .view-enter .kpi:nth-child(6) { animation-delay: 0.175s; }
.view-enter .card:nth-child(n+7), .view-enter tbody tr:nth-child(n+7), .view-enter .kpi:nth-child(n+7) { animation-delay: 0.21s; }

/* Swapping to another verse blurs the new one in, like a content transition. */
.verse-swap { animation: verseIn 0.5s var(--spring) both; }

/* ---------- nothing bleeds off a phone ---------- */

.wrap,
.card,
.kpi,
.verse,
.phase,
.vault-item,
.log-item { min-width: 0; }

.meta, .detail, .note, .sub, .verse-ref, .verse blockquote, td, th,
.vault-head strong, .name {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.table-wrap { max-width: 100%; }
.vault-preview iframe { max-width: 100%; }
.vault-actions { flex-wrap: wrap; }
img, iframe, svg { max-width: 100%; }

/* ---------- reduced motion wins over all of it ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
}

/* ---------- phones: the wide table becomes stacked glass cards ---------- */

@media (max-width: 700px) {
  .table-wrap {
    overflow: visible;
    border: 0;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: none;
    border-radius: 0;
  }
  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }

  /* Solid cards, not glass. A blur behind every row means one compositing
     layer per row, and a phone pays for all of them on every scroll frame.
     One layer for the whole list is not worth that. */
  .table-wrap tbody tr {
    margin-bottom: 12px;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
  }
  .table-wrap tbody tr:hover { background: var(--panel); }
  /* The row cascade is a desktop nicety; on a phone the list is long and the
     animation is the first thing to drop. */
  .view-enter tbody tr:nth-child(-n+12) { animation: none; }
  .table-wrap td {
    padding: 5px 0;
    border: 0;
    font-size: 13.5px;
  }
  /* Each cell names itself, so nothing needs a column heading. */
  .table-wrap td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 1px;
  }
  .table-wrap td[data-label="Company"] { font-size: 15.5px; font-weight: 600; }
  .table-wrap td[data-label="Role"] { padding-top: 8px; }
  .table-wrap td[data-label="Apply"] { padding-top: 8px; }
  .table-wrap td[data-label="Apply"] a {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    font-weight: 500;
  }
  .table-wrap td .meta { font-size: 12.5px; }
}

/* ============================================================================
   iOS segmented control: rounded thumb, spring snap, drag with the finger
   ========================================================================== */

.seg {
  position: relative;
  border-radius: 13px;
  padding: 3px;
  touch-action: none;          /* let the thumb swallow the drag on a phone */
  -webkit-user-select: none;
  user-select: none;
}

.seg-thumb {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-radius: 10px;
  background: var(--seg-active);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-highlight);
  pointer-events: none;
  will-change: transform, width;
  /* A touch of overshoot on the way in, and a hair of resistance in the size. */
  transition: transform 0.46s var(--bounce), width 0.42s var(--bounce), height 0.28s var(--ease);
}

.seg-btn {
  position: relative;
  z-index: 1;
  background: none;
  border-radius: 10px;
}
/* The thumb is the highlight now, so the button itself never paints one. */
.seg-btn.active,
.seg-btn.active:hover {
  background: none;
  box-shadow: none;
  color: var(--text);
}
.seg-btn:active { transform: none; }
.seg-label { position: relative; }

/* Apple rounding throughout: cards, sheets, pills, fields. */
:root, [data-theme="light"] { --radius: 20px; --radius-sm: 13px; }
[data-theme="dark"] { --radius: 20px; --radius-sm: 13px; }

.tabs { border-radius: 13px; }
.tabs button { border-radius: 10px; }
.pill { border-radius: 999px; }
.btn { border-radius: 999px; }
.verse, .card, .kpi, .table-wrap, .warnbar, .empty { border-radius: var(--radius); }
.vault-drop { border-radius: 16px; }
.vault-preview iframe { border-radius: 14px; }
.controls input, .controls select, .vault-row input[type="text"], .switch { border-radius: var(--radius-sm); }
.switch { border-radius: 999px; }

/* ---------- today panel ---------- */

.today {
  margin-bottom: 20px;
  padding: 18px 22px;
  border: 1px solid var(--glass-line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-highlight);
}
.today-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.today-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}
.today-date { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.today-grid { display: grid; gap: 18px; grid-template-columns: 1.4fr 1fr 1fr; }
.today-block { min-width: 0; }
.today-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}
ul.plain.tight { list-style: none; margin: 0; padding: 0; }
ul.plain.tight li {
  padding: 6px 0 6px 18px;
  position: relative;
  font-size: 14.5px;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
ul.plain.tight li:last-child { border-bottom: 0; }
ul.plain.tight li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 14px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.today-numbers { display: flex; gap: 18px; flex-wrap: wrap; }
.today-num { display: block; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.today-cap { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

@media (max-width: 760px) {
  .today-grid { grid-template-columns: 1fr; gap: 16px; }
  .today { padding: 16px 18px; }
}

/* ---------- today row actions ---------- */

.row-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: 8px; vertical-align: middle; }
.mini {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.3s var(--spring), background-color 0.2s var(--ease);
}
.mini:hover { background: var(--accent); color: #fff; border-color: transparent; }
.mini:active { transform: scale(0.94); }
.mini.danger { background: var(--bad-soft); color: var(--bad); }
.mini.danger:hover { background: var(--bad); color: #fff; }

.today-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
@media (max-width: 760px) {
  .row-actions { display: flex; margin: 6px 0 0; }
  .today-foot { flex-direction: column; align-items: flex-start; }
}

/* ---------- cover note box ---------- */

.note-box {
  margin: 10px 0 4px;
  padding: 12px 14px;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
}
.note-box textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  resize: vertical;
}
.note-box .row-actions { margin: 8px 0 0; }
