/* Dream Journal — Gold + Turquoise. Lifted from design/styles.css and extended. */
:root {
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-2: #e9efed;
  --ink: #172321;
  --ink-2: #465350;
  --muted: #71807c;
  --line: #d8e1de;
  --gold: #a87936;
  --gold-soft: #efe7d8;
  --gold-deep: #7d5726;
  --turq: #167c80;
  --turq-soft: #dceeed;
  --turq-deep: #0e5f63;
  --danger: #a64242;
  --shadow-sm: 0 1px 0 rgba(26,24,20,.04);
  --shadow-md: 0 1px 2px rgba(23,35,33,.03), 0 12px 32px rgba(23,35,33,.07);
  --serif: "Fraunces", "Source Serif Pro", Georgia, serif;
  --sans: "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="nocturnal"] {
  --bg: #0f1418;
  --surface: #161c22;
  --surface-2: #1d242b;
  --ink: #ece6d6;
  --ink-2: #c0bbac;
  --muted: #7a7568;
  --line: #2a3038;
  --gold: #d9a955;
  --gold-soft: #3a2f1a;
  --gold-deep: #f0c87a;
  --turq: #5dc8c0;
  --turq-soft: #1a3a3a;
  --turq-deep: #8de2d9;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; }

.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
.mono  { font-family: var(--mono); font-size: 11px; letter-spacing: 0.02em; }

.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

/* ── Boot / Sign-in ─────────────────────────────────── */
.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 24px;
  background: var(--bg);
}
.boot-inner {
  max-width: 420px;
  text-align: center;
}
.boot-inner h1 {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 14px 0 8px;
}
.boot-inner h1 em {
  color: var(--gold-deep);
  font-style: italic;
}
.boot-msg {
  color: var(--muted);
  margin: 6px 0 28px;
  font-size: 15px;
}
.boot-error {
  margin: 16px 0 24px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--danger);
  border-radius: 8px;
  text-align: left;
  font-size: 13.5px;
  color: var(--ink-2);
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: opacity 180ms;
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}

/* ── App layout ─────────────────────────────────────── */
.app-shell {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}
.app-header {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 32px 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
}
.app-header h1 {
  font-family: var(--serif);
  font-size: 42px;
  font-weight: 400;
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.app-header h1 em {
  color: var(--gold-deep);
  font-style: italic;
}
.app-header p {
  color: var(--muted);
  margin: 10px 0 0;
  max-width: 540px;
}

/* Loader card */
.loader-card {
  max-width: 600px;
  margin: 24px auto;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.loader-card .progress {
  margin-top: 12px;
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.loader-card .progress > span {
  display: block;
  height: 100%;
  background: var(--gold);
  transition: width 240ms ease;
}

.header-actions { display: flex; gap: 8px; align-items: center; }

/* ── KPI strip (header) ──────────────────────────────── */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
  margin-top: 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.kpi {
  padding: 16px 14px 14px 0;
  border-right: 1px solid var(--line);
  min-width: 0;
}
.kpi:last-child { border-right: none; }
.kpi-num {
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi .eyebrow { margin-top: 6px; }

/* ── Tabs ─────────────────────────────────────────────── */
.tabs {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 32px 6px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.tab {
  background: transparent;
  border: none;
  padding: 10px 16px;
  border-radius: 9px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  transition: color 180ms;
}
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--ink); font-weight: 500; }
.tab.active::after {
  content: "";
  position: absolute;
  left: 16px; right: 16px; bottom: 4px;
  height: 2px;
  background: var(--gold);
  border-radius: 2px;
}

/* ── Panel area ──────────────────────────────────────── */
.panel-area {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 32px 120px;
}
.panel-h2 {
  font-size: 28px;
  font-weight: 400;
  margin: 0 0 24px;
  letter-spacing: -0.02em;
}
.panel-h2 em { color: var(--gold-deep); font-style: italic; }
.muted { color: var(--muted); }

/* ── Search bar ───────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 18px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  transition: border-color 160ms;
}
.search-bar:focus-within { border-color: var(--gold); }
.search-input {
  flex: 1;
  min-width: 0; /* let the field shrink so the button never overflows the bar */
  border: none;
  background: transparent;
  outline: none;
  padding: 14px 0;
  font-size: 15px;
  color: var(--ink);
  font-family: var(--sans);
}
.search-input::placeholder { color: var(--muted); }

/* ── Filters ─────────────────────────────────────────── */
.filters { margin-bottom: 22px; }
.filter-label { margin-bottom: 8px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-family: var(--mono);
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-2);
  cursor: pointer;
  transition: all 140ms;
}
.filter-chip:hover { border-color: var(--ink-2); color: var(--ink); }
.filter-chip.active {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold-deep);
}

/* ── Entry list ──────────────────────────────────────── */
.result-count {
  margin: 14px 0 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.entry-list {
  display: flex;
  flex-direction: column;
}
.entry-row {
  padding: 18px 0 16px;
  border-top: 1px solid var(--line);
  color: var(--ink);
}
.entry-list > .entry-row:last-child {
  border-bottom: 1px solid var(--line);
}
.entry-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}
.entry-meta {
  display: flex;
  gap: 6px;
  align-items: baseline;
  flex-wrap: wrap;
  min-width: 0;
}
.entry-source {
  font-size: 12px;
  font-style: italic;
}
.emotion-tag {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--turq-deep);
  white-space: nowrap;
}
.entry-body {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0 0 10px;
  cursor: pointer;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
}
.entry-body.expanded {
  -webkit-line-clamp: unset;
  display: block;
  overflow: visible;
}
.entry-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.entry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
}
.chip-symbol { color: var(--gold-deep); border-color: var(--gold-soft); }
.chip-person { color: var(--turq-deep); border-color: var(--turq-soft); }
.drive-link {
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.drive-link:hover { color: var(--ink-2); }

/* ── Insights panel ──────────────────────────────────── */
.insights-intro {
  max-width: 540px;
  font-size: 15px;
  line-height: 1.55;
  margin: 0 0 28px;
}
.insights-card {
  max-width: 720px;
  margin: 0 auto;
}
.insights-empty {
  padding: 40px 32px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.insights-empty-line {
  font-size: 19px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--ink-2);
  margin: 0 0 22px;
  font-style: italic;
}
.insights-loading {
  padding: 50px 32px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  display: grid;
  place-items: center;
}
.insights-reading {
  padding: 32px 36px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 2px solid var(--gold);
  border-radius: 0 14px 14px 0;
}
.insights-reading p {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.72;
  color: var(--ink);
  margin: 0 0 18px;
}
.insights-reading p:last-child { margin-bottom: 0; }
.insights-reading .insights-quote {
  font-style: italic;
  color: var(--ink-2);
  border-left: 2px solid var(--gold-soft);
  padding-left: 16px;
  margin-left: 4px;
}
.insights-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding: 0 4px;
  flex-wrap: wrap;
  gap: 12px;
}
.insights-timestamp {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
@media (max-width: 720px) {
  .insights-reading { padding: 24px 20px; border-radius: 0 12px 12px 0; }
  .insights-reading p { font-size: 16px; line-height: 1.65; }
}

/* ── Search & Ask panel ──────────────────────────────── */
.search-modes {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.mode-btn {
  padding: 8px 16px;
  border-radius: 9px;
  font-size: 13px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 140ms;
}
.mode-btn:hover { border-color: var(--ink-2); color: var(--ink); }
.mode-btn.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.search-bar-lg {
  padding: 4px 6px 4px 18px;
  margin-bottom: 8px;
}
.search-bar-lg .search-input { padding: 16px 0; font-size: 16px; }
.search-go {
  flex-shrink: 0;
  padding: 11px 22px;
  border-radius: 10px;
}
.search-loading {
  display: grid;
  place-items: center;
  padding: 44px 20px;
}
.match-badge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--turq-deep);
  background: var(--turq-soft);
  padding: 3px 9px;
  border-radius: 6px;
  white-space: nowrap;
}

/* ── PWA install banner ──────────────────────────────── */
.install-banner {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 14px;
  box-shadow: 0 12px 34px rgba(26,24,20,.30);
  font-size: 13.5px;
  max-width: 540px;
  margin: 0 auto;
  animation: slideUpIn .4s ease-out;
}
@keyframes slideUpIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.install-banner .brand-dot { flex-shrink: 0; }
.install-text { flex: 1; line-height: 1.3; }
.install-go {
  flex-shrink: 0;
  background: var(--gold);
  color: var(--ink);
  border: none;
  border-radius: 10px;
  padding: 7px 16px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.install-ios { flex-shrink: 0; font-family: var(--mono); font-size: 11px; color: var(--gold-soft); }
.install-x { background: transparent; border: none; color: rgba(255,255,255,.6); font-size: 20px; cursor: pointer; padding: 0 4px; line-height: 1; }

/* ── Capture-first shell: top bar ────────────────────── */
.topbar {
  position: sticky;
  top: calc(env(safe-area-inset-top, 0px));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-soft), var(--gold) 70%);
}
.brand-name { font-size: 17px; letter-spacing: -0.01em; }
.topnav { display: flex; gap: 2px; margin-left: 8px; }
.navbtn {
  background: transparent;
  border: none;
  padding: 8px 16px;
  border-radius: 9px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  transition: color 160ms, background 160ms;
}
.navbtn:hover { color: var(--ink-2); }
.navbtn.active { color: var(--ink); font-weight: 500; background: var(--surface-2); }
.topbar-signout { margin-left: auto; }

/* ── Screen container ────────────────────────────────── */
.screen {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 24px 120px;
}
.screen-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.screen-title { font-size: 30px; font-weight: 400; letter-spacing: -0.02em; margin: 0; }
.screen-sub { margin: 0 0 22px; max-width: 560px; font-size: 15px; line-height: 1.55; }
.rescan-link {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}
.rescan-link:hover { color: var(--ink-2); border-color: var(--ink-2); }
.screen-loading { display: grid; place-items: center; padding: 60px 20px; text-align: center; }
.empty-state { display: grid; place-items: center; gap: 12px; padding: 60px 20px; text-align: center; }
.empty-state .serif { font-size: 20px; }

/* ── Search bar (large) ──────────────────────────────── */
.search-bar-lg { padding: 4px 6px 4px 18px; margin-bottom: 10px; gap: 12px; }
.search-bar-lg .search-input { padding: 15px 0; font-size: 16px; }
.meaning-btn, .search-bar-lg .btn-primary { flex-shrink: 0; }

/* ── Archive-not-loaded banner ───────────────────────── */
.archive-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  margin-bottom: 18px;
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: 12px;
  flex-wrap: wrap;
}

/* ── Patterns: the constellation ─────────────────────── */
.cat-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.cat-chip {
  padding: 7px 15px;
  border-radius: 9px;
  font-size: 13px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 150ms;
}
.cat-chip:hover { color: var(--ink-2); border-color: var(--ink-2); }
.cat-chip.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.constellation {
  position: relative;
  width: 100%;
  margin-top: 6px;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--gold-soft) 40%, transparent), transparent 60%),
    var(--surface-2);
  border: 1px solid var(--line);
}

@keyframes orbIn { from { opacity: 0; } to { opacity: 1; } }
/* Drift + a minimal breathing scale, sharing one slow cycle so each node feels alive. */
@keyframes orbDrift { from { transform: translate(0, 0) scale(1); } to { transform: translate(var(--dx), var(--dy)) scale(1.035); } }
@keyframes orbBreath { 0%,100% { opacity: .92; } 50% { opacity: 1; } }

/* ── Connecting mesh (shared-dream links behind the orbs) ── */
.mesh {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
}
@keyframes meshPulse {
  0%, 100% { stroke-opacity: calc(var(--op, .3) * .45); }
  50%      { stroke-opacity: var(--op, .3); }
}
.mesh-link {
  stroke: var(--gold-deep);
  stroke-width: 1.1;
  stroke-linecap: round;
  stroke-opacity: var(--op, .3);
  animation: meshPulse var(--pdur, 7s) ease-in-out infinite;
  animation-delay: var(--pdelay, 0s);
}

.orb {
  position: absolute;
  z-index: 1;
  border: none;
  background: transparent;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  animation: orbIn .8s ease-out forwards;
  transition: transform .32s cubic-bezier(.34, 1.56, .64, 1), filter .3s;
  display: grid;
  place-items: center;
}
.orb:hover, .orb:focus-visible { transform: scale(1.13); z-index: 30; filter: brightness(1.06); outline: none; }
.orb-body {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  animation: orbDrift var(--dur, 6s) ease-in-out infinite alternate, orbBreath 7s ease-in-out infinite;
  box-shadow: 0 8px 26px rgba(26,24,20,.10), inset 0 2px 8px rgba(255,255,255,.35);
}
.orb-symbol .orb-body { background: radial-gradient(circle at 36% 30%, #f6e8c6, var(--gold) 62%, var(--gold-deep)); }
.orb-eck    .orb-body { background: radial-gradient(circle at 36% 30%, #f3e0bf, var(--gold-deep) 66%, #6f4e16); }
.orb-person .orb-body { background: radial-gradient(circle at 36% 30%, #cdeee9, var(--turq) 62%, var(--turq-deep)); }
.orb-place  .orb-body { background: radial-gradient(circle at 36% 30%, #d6ece3, #3aa089 64%, var(--turq-deep)); }
.orb-text {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  pointer-events: none;
  text-align: center;
  padding: 0 8px;
  line-height: 1.1;
}
.orb-name { color: #fff; text-shadow: 0 1px 5px rgba(60,40,10,.5); letter-spacing: -0.01em; }
.orb-count { color: rgba(255,255,255,.85); font-family: var(--mono); font-size: 10px; }

/* ── Pattern detail overlay ──────────────────────────── */
.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  background: rgba(26,24,20,.42);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .26s ease;
}
.detail-overlay.open { opacity: 1; }
.detail-panel {
  width: min(560px, 94vw);
  height: 100%;
  overflow-y: auto;
  background: var(--bg);
  box-shadow: -24px 0 70px rgba(26,24,20,.22);
  transform: translateX(48px);
  transition: transform .32s cubic-bezier(.22, 1, .36, 1);
  padding: 26px 30px 90px;
}
.detail-overlay.open .detail-panel { transform: translateX(0); }
.detail-head { position: relative; margin-bottom: 22px; }
.detail-close {
  position: absolute; top: -4px; right: -6px;
  background: transparent; border: none; cursor: pointer;
  font-size: 26px; line-height: 1; color: var(--muted); padding: 6px;
}
.detail-close:hover { color: var(--ink); }
.detail-cat {
  display: inline-block;
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 6px; margin-bottom: 12px; color: #fff;
}
.detail-cat.orb-symbol, .detail-cat.orb-eck { background: var(--gold-deep); }
.detail-cat.orb-person, .detail-cat.orb-place { background: var(--turq-deep); }
.detail-title { font-size: 32px; font-weight: 400; letter-spacing: -0.02em; margin: 0 0 4px; }
.detail-count { font-size: 13px; }

.timeline-wrap { margin: 18px 0 6px; padding: 16px 16px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.timeline { display: flex; gap: 3px; align-items: flex-end; height: 84px; }
.tl-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; flex: 1; min-width: 0; }
.tl-bar { width: 72%; max-width: 16px; background: linear-gradient(var(--gold), var(--gold-deep)); border-radius: 3px 3px 0 0; transition: height .4s ease; }
.tl-bar.empty { background: var(--line); }
.tl-year { font-family: var(--mono); font-size: 9px; color: var(--muted); }

.meaning-cta { margin-top: 16px; font-size: 13.5px; }
.meaning-card {
  margin-top: 16px;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 2px solid var(--gold);
  border-radius: 0 12px 12px 0;
}
.meaning-card p { font-family: var(--serif); font-size: 15.5px; line-height: 1.68; margin: 0 0 14px; }
.meaning-card p:last-child { margin-bottom: 0; }

/* Highlighted pattern words inside entry bodies */
mark.hl {
  background: var(--gold-soft);
  color: var(--gold-deep);
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 500;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

@media (max-width: 640px) {
  .detail-panel { width: 100vw; padding: 22px 18px 90px; }
  .detail-title { font-size: 27px; }
  .orb-name { font-size: 12px !important; }
}

/* ── Result cards ────────────────────────────────────── */
.result-count { margin: 6px 2px 10px; font-size: 13px; }
.result-list { display: flex; flex-direction: column; gap: 0; }
.result-card {
  padding: 18px 0 16px;
  border-top: 1px solid var(--line);
}
.result-list > .result-card:last-child { border-bottom: 1px solid var(--line); }
.result-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}
.result-date { font-size: 17px; color: var(--ink); }
.result-body {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.62;
  color: var(--ink-2);
  margin: 0 0 10px;
  cursor: pointer;
  white-space: pre-wrap;
}
.result-body.open { cursor: default; }
.entry-context {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 0 0 6px;
  padding-left: 12px;
  border-left: 2px solid var(--turq-soft);
}
.entry-context .ctx-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--turq-deep);
  margin-right: 8px;
}
.result-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.result-source {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  font-style: italic;
}

/* ── Mobile ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 12px 14px; flex-wrap: wrap; }
  .topnav { margin-left: 0; order: 3; width: 100%; justify-content: space-between; }
  .navbtn { flex: 1; padding: 9px 6px; }
  .topbar-signout { font-size: 12px; padding: 7px 11px; }
  .screen { padding: 20px 16px 110px; }
  .screen-title { font-size: 25px; }
}

/* ── FAB (+ New dream) ───────────────────────────────── */
.fab {
  position: fixed;
  z-index: 50;
  right: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 30px rgba(26,24,20,.25), 0 2px 0 rgba(255,255,255,.12) inset;
  cursor: pointer;
  transition: transform 160ms ease;
}
.fab:hover { transform: translateY(-1px); }
.fab-plus {
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
}

/* ── Capture screen ──────────────────────────────────── */
.capture-view {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: 120px;
}
.capture-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 8px;
  max-width: 600px;
  margin: 0 auto;
}
.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--ink-2);
  font-size: 14px;
  padding: 8px;
  margin-left: -8px;
  cursor: pointer;
}
.back-btn:hover { color: var(--ink); }

.capture-stage {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 20px 28px;
  display: grid;
  place-items: center;
  text-align: center;
}
.capture-h1 {
  font-size: 32px;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 12px 0 6px;
}
.capture-sub {
  margin: 0 0 28px;
  font-size: 14px;
  max-width: 320px;
}

/* ── Ink Bloom mic button — animated SVG halo, lifted from design. ── */
.mic-bloom {
  position: relative;
  width: 240px;
  height: 240px;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  outline: none;
}
.mic-bloom:focus-visible { outline: 2px solid var(--gold); outline-offset: 8px; border-radius: 50%; }
.mic-bloom:hover .bloom-svg { filter: brightness(1.04); }
.bloom-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.bloom-label {
  position: relative;
  z-index: 1;
  color: rgba(255,255,255,0.98);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-shadow: 0 1px 6px rgba(138,100,34,0.7);
  mix-blend-mode: screen;
  pointer-events: none;
  user-select: none;
}

.live-preview {
  margin: 24px auto 0;
  padding: 0 8px;
  max-width: 460px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-2);
  text-align: center;
  min-height: 40px;
  transition: color .3s ease;
}
.live-preview.empty { color: var(--muted); opacity: .85; }
.live-quote { opacity: 0.5; }
.live-cursor {
  display: inline-block;
  width: 6px; height: 14px;
  background: var(--gold);
  vertical-align: -1px;
  margin-left: 3px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.transcribing { display: grid; place-items: center; gap: 14px; padding: 24px 0; }
.spinner {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--gold);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.type-instead {
  margin-top: 22px;
  background: transparent;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 4px;
  font-size: 13px;
  cursor: pointer;
}

/* Discard an in-progress recording — discreet, warms to danger on hover. */
.cancel-recording {
  margin-top: 22px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font: 500 13px/1 var(--sans);
  padding: 9px 16px 9px 13px;
  border-radius: 10px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.cancel-recording:hover,
.cancel-recording:focus-visible {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  background: color-mix(in srgb, var(--danger) 7%, transparent);
  outline: none;
}
.cancel-recording svg { display: block; }

.saved-check { margin: 24px auto 12px; }

/* Capture form sections */
.capture-section {
  max-width: 600px;
  margin: 0 auto;
  padding: 8px 20px 22px;
}
.capture-textarea {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 16px;
  line-height: 1.55;
  font-family: var(--serif);
  outline: none;
  resize: vertical;
}
.capture-textarea:focus { border-color: var(--gold); }
.charcount-row {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 12px;
}
.capture-field { margin-bottom: 16px; }
.capture-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 500;
}
.capture-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  font-family: var(--sans);
  outline: none;
  transition: border-color 140ms;
}
.capture-input:focus { border-color: var(--gold); }
.capture-input-multi { resize: vertical; min-height: 60px; line-height: 1.5; }

.tag-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 48px;
}
.tag-input:focus-within { border-color: var(--gold); }
.tag-input-field {
  flex: 1;
  min-width: 90px;
  border: none;
  background: transparent;
  outline: none;
  color: var(--ink);
  font-size: 14px;
  padding: 5px 4px;
  font-family: var(--sans);
}
.chip-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 11px;
}
.chip-x {
  background: transparent;
  border: none;
  padding: 0 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.chip-x:hover { color: var(--ink); }

.capture-savebar {
  position: sticky;
  bottom: 0;
  left: 0; right: 0;
  padding: 14px 20px;
  background: linear-gradient(180deg, transparent 0%, var(--bg) 30%);
  backdrop-filter: blur(8px);
}
.btn-save {
  display: block;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 18px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: opacity 200ms, background 200ms;
}
.btn-save:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-save.saved { background: var(--turq); color: #fff; }

/* ── Captures list (on the Capture screen) ───────────── */
.captures-panel {
  max-width: 600px;
  margin: 8px auto 0;
  padding: 0 20px;
}
.captures-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 10px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.captures-sync { font-size: 12.5px; }
.captures-allsynced { font-size: 12px; color: var(--turq-deep); font-family: var(--mono); letter-spacing: .04em; }
.captures-list { display: flex; flex-direction: column; }
.capture-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
}
.capture-date { color: var(--muted); flex-shrink: 0; width: 86px; }
.capture-snippet {
  flex: 1;
  color: var(--ink-2);
  font-family: var(--serif);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.capture-badge {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .04em;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-synced { color: var(--turq-deep); background: var(--turq-soft); }
.badge-pending { color: var(--muted); background: var(--surface-2); }
.badge-failed { color: var(--danger); background: #f3dede; }

/* ── Mobile breakpoint ───────────────────────────────── */
@media (max-width: 900px) {
  .kpi-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:nth-child(3n) { border-right: none; }
  .kpi:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 720px) {
  .app-header { padding: 24px 20px 12px; flex-direction: column; align-items: flex-start; }
  .app-header h1 { font-size: 30px; }
  .tabs { padding: 12px 20px 4px; overflow-x: auto; flex-wrap: nowrap; }
  .tab { white-space: nowrap; flex-shrink: 0; }
  .panel-area { padding: 20px 20px 100px; }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(odd) { border-right: 1px solid var(--line); }
  .kpi:nth-child(even) { border-right: none; }
  .kpi:nth-child(-n+4) { border-bottom: 1px solid var(--line); }
  .kpi-num { font-size: 22px; }
  .fab {
    right: 50%; transform: translateX(50%);
    bottom: 18px;
  }
  .fab:hover { transform: translateX(50%) translateY(-1px); }
  .mic-bloom { width: 200px; height: 200px; }
}

/* ── Email/password sign-in form ─────────────────────────────────────────── */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 26px;
  text-align: left;
}
.auth-label {
  font: 600 11px/1 var(--sans);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 8px;
}
.auth-input {
  font: 400 16px/1.3 var(--sans);   /* 16px so iOS Safari never zooms on focus */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.auth-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.auth-submit {
  margin-top: 18px;
  width: 100%;
}
.auth-alt {
  margin-top: 14px;
  font: 500 13px/1.3 var(--sans);
  color: var(--turq-deep);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.auth-alt:hover:not(:disabled) { color: var(--turq); }
.auth-alt:disabled { opacity: .5; cursor: default; }
.auth-note {
  font: 400 13px/1.5 var(--sans);
  color: var(--turq-deep);
  background: var(--turq-soft);
  border-left: 3px solid var(--turq);
  border-radius: 8px;
  padding: 12px 14px;
  text-align: left;
}

/* ── Capture mode toggle (Dream | Thought) ───────────────────────────────── */
.mode-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 20px;
}
.mode-pill {
  font: 500 13px/1 var(--sans);
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 9px 22px;
  border-radius: 8px;
  cursor: pointer;
  transition: color .15s ease, background .2s ease, box-shadow .2s ease;
}
.mode-pill.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* Recent-thoughts rows on the capture idle screen */
.thought-row { padding: 12px 0; border-bottom: 1px solid var(--line); text-align: left; }
.thought-row-title { font-size: 15px; color: var(--ink); line-height: 1.35; }
.thought-row-topics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.muted-faint { color: var(--muted); opacity: .7; }

/* ── Notes screen ─────────────────────────────────────────────────────────── */
.topic-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.topic-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font: 500 13px/1 var(--sans);
  color: var(--turq-deep);
  background: var(--turq-soft);
  border: 1px solid transparent;
  padding: 8px 13px;
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.topic-chip:hover { border-color: var(--turq); }
.topic-chip.active { background: var(--turq); color: #fff; }
.topic-chip-n { font: 500 11px/1 var(--mono); opacity: .7; }
.topic-chip.active .topic-chip-n { opacity: .9; }
.topic-chip-sm {
  display: inline-block;
  font: 500 11px/1.2 var(--sans);
  color: var(--turq-deep);
  background: var(--turq-soft);
  padding: 4px 9px;
  border-radius: 8px;
}

.notes-list { display: flex; flex-direction: column; gap: 14px; }
.note-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.note-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.note-title { font-size: 18px; font-weight: 400; color: var(--ink); margin: 0; line-height: 1.3; }
.note-date { font-size: 12px; color: var(--muted); white-space: nowrap; }
.note-topics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.note-pending { font-size: 12px; margin-top: 8px; }
.note-body { margin: 12px 0 0; color: var(--ink-2); font-size: 15px; line-height: 1.65; white-space: pre-wrap; }
.note-expand {
  margin-top: 10px; background: none; border: none; padding: 0;
  color: var(--turq-deep); font: 500 13px/1 var(--sans); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}

/* ── Notes write-assistant ───────────────────────────────────────────────── */
.write-box { margin: 8px 0 4px; }
.write-results { margin-top: 6px; }
.notes-divider {
  display: flex; align-items: center; gap: 14px;
  margin: 26px 0 18px;
  color: var(--muted);
  font: 500 11px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase;
}
.notes-divider::before, .notes-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.outline-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--turq);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}
.outline-card .md-h { font-family: var(--serif); color: var(--ink); margin: 18px 0 8px; line-height: 1.3; font-weight: 400; }
.outline-card h3.md-h { font-size: 22px; margin-top: 2px; }
.outline-card h4.md-h { font-size: 17px; color: var(--turq-deep); }
.outline-card h5.md-h { font-size: 13px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-family: var(--sans); font-weight: 600; }
.outline-card .md-p { margin: 8px 0; color: var(--ink-2); line-height: 1.65; font-size: 15px; }
.outline-card .md-ul, .outline-card .md-ol { margin: 8px 0 8px 2px; padding-left: 20px; color: var(--ink-2); line-height: 1.6; font-size: 15px; }
.outline-card .md-ul li, .outline-card .md-ol li { margin: 5px 0; }
.outline-card strong { color: var(--ink); font-weight: 600; }

/* ── v3 mobile-first refinement ─────────────────────────────────────────── */
body { min-height: 100vh; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--turq);
  outline-offset: 3px;
}

.topbar {
  min-height: 64px;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(18px) saturate(1.1);
}
.brand-dot { width: 9px; height: 9px; }
.navbtn, .btn-ghost, .btn-primary, .cat-chip { min-height: 42px; }
.navbtn.active { color: var(--turq-deep); background: var(--turq-soft); }
.screen { width: 100%; max-width: 800px; min-width: 0; overflow-x: clip; }
.screen-title { line-height: 1.15; }

.capture-stage { padding-top: 18px; }
.capture-h1 { font-size: clamp(30px, 6vw, 38px); }
.capture-sub { margin-bottom: 18px; }
.mic-bloom { width: 220px; height: 220px; }
.capture-textarea,
.capture-input,
.tag-input {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border-color: color-mix(in srgb, var(--line) 82%, var(--ink));
  box-shadow: 0 1px 0 rgba(23,35,33,.02);
}
.capture-field,
.capture-section,
.capture-view { width: 100%; max-width: 100%; min-width: 0; }
.date-input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  border-radius: 12px;
}
.date-input-wrap .capture-input[type="date"] {
  display: block;
  width: 100%;
  inline-size: 100%;
  min-width: 0;
  min-inline-size: 0;
  max-width: 100%;
  max-inline-size: 100%;
  overflow: hidden;
  -webkit-appearance: none;
  appearance: none;
}
.date-input-wrap .capture-input[type="date"]::-webkit-date-and-time-value {
  min-width: 0;
  text-align: left;
}
.date-input-wrap .capture-input[type="date"]::-webkit-calendar-picker-indicator {
  flex: 0 0 auto;
  margin: 0;
  padding: 4px;
}
.capture-textarea:focus,
.capture-input:focus,
.tag-input:focus-within {
  border-color: var(--turq);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--turq-soft) 72%, transparent);
}
.draft-status { color: var(--turq-deep); min-height: 1em; }
.btn-save {
  background: var(--ink);
  min-height: 54px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(23,35,33,.16);
}
.btn-save:not(:disabled):active { transform: translateY(1px); }

.result-list { gap: 10px; }
.result-card {
  padding: 16px 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.result-list > .result-card:last-child { border-bottom: 1px solid var(--line); }
.result-toggle {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}
.result-toggle .result-body { display: block; cursor: pointer; }
.result-toggle:focus-visible { outline-offset: 5px; border-radius: 6px; }
.result-body { margin-bottom: 8px; }
.result-source { padding-top: 4px; }
.overlay-open { overflow: hidden; }
.detail-close { min-width: 44px; min-height: 44px; }
.detail-panel { overscroll-behavior: contain; }

.mode-toggle { padding: 4px; }
.mode-pill { min-height: 40px; padding-inline: 22px; }
.mode-pill.active { color: var(--turq-deep); }
.cat-chip.active { background: var(--turq-deep); border-color: var(--turq-deep); }
.topic-chip.active { background: var(--turq-deep); }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .topbar {
    position: sticky;
    top: 0;
    min-height: 58px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .brand { min-width: 0; }
  .brand-name { font-size: 16px; white-space: nowrap; }
  .topbar-signout {
    margin-left: auto;
    min-height: 40px;
    padding: 8px 11px;
    font-size: 12px;
  }
  .topnav {
    position: static;
    order: 3;
    width: 100%;
    margin: 0;
    padding: 4px 0 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
  }
  .navbtn {
    min-height: 48px;
    padding: 8px 4px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
  }
  .navbtn.active { font-weight: 600; }
  .screen { padding: 20px 16px calc(32px + env(safe-area-inset-bottom, 0px)); }
  .screen-head { margin-bottom: 14px; }
  .screen-title { font-size: 28px; }

  .capture-view { min-height: auto; padding-bottom: 18px; }
  .capture-stage { padding: 10px 8px 18px; }
  .capture-h1 { margin-top: 10px; font-size: 32px; }
  .capture-sub { max-width: 290px; font-size: 14px; }
  .mic-bloom { width: min(190px, 58vw); height: min(190px, 58vw); }
  .type-instead { min-height: 44px; margin-top: 10px; padding: 10px 18px; }
  .capture-section { padding-inline: 0; }
  .capture-field { margin-bottom: 18px; }
  .capture-textarea { min-height: 150px; border-radius: 14px; padding: 15px; }
  .capture-input { min-height: 50px; border-radius: 12px; font-size: 16px; }
  .date-input-wrap .capture-input[type="date"] {
    width: -webkit-fill-available;
    inline-size: -webkit-fill-available;
  }
  .capture-input-multi { min-height: 82px; }
  .tag-input { min-height: 50px; }
  .tag-input-field { min-width: 0; width: 100%; font-size: 16px; }
  .capture-savebar {
    bottom: 0;
    width: 100%;
    margin-inline: 0;
    padding: 18px 0 calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .captures-panel { padding-inline: 0; }
  .capture-row { min-height: 48px; align-items: center; }

  .search-bar-lg { padding: 8px 10px 10px 14px; flex-wrap: wrap; }
  .search-bar-lg .search-input { min-height: 46px; }
  .search-bar-lg .meaning-btn,
  .search-bar-lg > .btn-primary {
    width: 100%;
    justify-content: center;
    min-height: 46px;
  }
  .result-card { padding: 15px; }
  .result-body { font-size: 16px; line-height: 1.58; }
  .result-source { align-items: flex-start; flex-direction: column; gap: 5px; }
  .cat-row { flex-wrap: nowrap; overflow-x: auto; margin-inline: -16px; padding: 2px 16px 8px; scrollbar-width: none; }
  .cat-row::-webkit-scrollbar { display: none; }
  .cat-chip { flex: 0 0 auto; min-height: 42px; }
  .constellation { margin-top: 2px; border-radius: 16px; }
  .detail-panel { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .install-banner { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
}

/* ── Patterns v3: Atlas + Dream River ──────────────────────────────────── */
.pattern-view-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  margin: 2px 0 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.pattern-view-btn {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}
.pattern-view-btn.active {
  background: var(--surface);
  color: var(--turq-deep);
  box-shadow: var(--shadow-sm);
}
.patterns-visual { margin-top: 10px; min-width: 0; }
.patterns-view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin: 18px 0 14px;
}
.patterns-view-title { margin: 0 0 3px; font-size: 25px; font-weight: 400; }
.patterns-view-copy { margin: 0; font-size: 13.5px; line-height: 1.45; max-width: 500px; }
.pattern-count-badge {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--turq-soft);
  color: var(--turq-deep);
  font: 500 11px/1 var(--mono);
}

.atlas-scroll {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  scrollbar-width: thin;
}
.atlas-scroll:focus-visible { outline: 2px solid var(--turq); outline-offset: 3px; }
.atlas-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 4px;
  padding: 6px;
}
.atlas-table th, .atlas-table td { padding: 0; }
.atlas-corner,
.atlas-theme-cell {
  position: sticky;
  left: 0;
  z-index: 4;
  min-width: 108px;
  max-width: 108px;
  background: var(--surface);
  box-shadow: 8px 0 12px -12px rgba(23,35,33,.35);
}
.atlas-corner {
  height: 34px;
  padding-left: 8px !important;
  color: var(--muted);
  text-align: left;
  font: 500 10px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .1em;
}
.atlas-year {
  min-width: 34px;
  height: 34px;
  color: var(--muted);
  text-align: center;
  font: 500 10px/1 var(--mono);
}
.atlas-theme-btn {
  width: 100%;
  min-height: 38px;
  padding: 4px 7px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  text-align: left;
}
.atlas-theme-btn:hover { background: var(--surface-2); }
.atlas-theme-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.atlas-theme-total { color: var(--muted); font: 500 10px/1 var(--mono); }
.heat-cell {
  display: block;
  width: 34px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: var(--surface-2);
}
.heat-cell.has-dreams {
  background: color-mix(in srgb, var(--turq) calc(14% + var(--heat) * 76%), var(--surface));
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.heat-cell.has-dreams:hover,
.heat-cell.has-dreams:focus-visible { transform: scale(.9); box-shadow: 0 0 0 2px var(--gold); }
.atlas-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin: 8px 2px 18px;
  color: var(--muted);
  font-size: 11px;
}
.legend-swatch {
  width: 17px;
  height: 8px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--turq) calc(14% + var(--heat) * 76%), var(--surface));
}

.ranked-patterns {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}
.ranked-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 15px 16px 10px;
}
.ranked-head h3 { margin: 0; font-size: 20px; font-weight: 400; }
.ranked-head span { font-size: 11px; }
.ranked-pattern {
  width: 100%;
  min-height: 68px;
  padding: 11px 14px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto 72px;
  align-items: center;
  gap: 10px;
  text-align: left;
}
.ranked-pattern:hover { background: color-mix(in srgb, var(--turq-soft) 40%, transparent); }
.rank-number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold-deep);
  font: 500 11px/1 var(--mono);
}
.rank-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rank-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 400; }
.rank-main .muted { font-size: 11px; }
.rank-count { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.rank-count strong { font-size: 16px; }
.rank-count span { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.pattern-spark { width: 72px; height: 30px; color: var(--turq); overflow: visible; }
.pattern-change-card {
  position: relative;
  width: 100%;
  margin-top: 12px;
  padding: 16px 46px 16px 17px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
}
.pattern-change-card strong { font-size: 18px; font-weight: 400; }
.pattern-change-card .muted { font-size: 12.5px; }
.change-arrow { position: absolute; right: 17px; top: 50%; transform: translateY(-50%); color: var(--gold-deep); font-size: 22px; }

.river-chart-wrap {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: radial-gradient(100% 75% at 50% 0%, color-mix(in srgb, var(--turq-soft) 36%, transparent), transparent 70%), var(--surface);
}
.river-chart { display: block; width: 100%; height: auto; min-height: 380px; }
.river-gridline { stroke: var(--line); stroke-width: 1; }
.river-year-label { fill: var(--muted); font: 500 9px var(--mono); }
.river-ribbon {
  cursor: pointer;
  opacity: .62;
  stroke: color-mix(in srgb, currentColor 60%, transparent);
  stroke-width: .8;
  transition: opacity 180ms ease, filter 180ms ease;
}
.river-ribbon.river-symbol { color: var(--turq-deep); fill: var(--turq); }
.river-ribbon.river-eck { color: var(--gold-deep); fill: var(--gold); }
.river-ribbon.river-person { color: #567b72; fill: #84aaa0; }
.river-ribbon.river-place { color: #637a82; fill: #9ab0b7; }
.river-ribbon.selected { opacity: .88; filter: drop-shadow(0 0 4px color-mix(in srgb, var(--turq) 35%, transparent)); }
.river-ribbon.dimmed { opacity: .16; }
.river-ribbon:focus-visible { outline: none; stroke: var(--ink); stroke-width: 2; opacity: 1; }
.river-legend { display: flex; gap: 6px; overflow-x: auto; padding: 10px 2px 8px; scrollbar-width: none; }
.river-legend::-webkit-scrollbar { display: none; }
.river-legend-btn {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.river-legend-btn.selected { background: var(--surface); border-color: var(--turq); color: var(--turq-deep); }
.river-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--turq); }
.river-legend-btn.river-eck .river-dot { background: var(--gold); }
.river-legend-btn.river-person .river-dot { background: #84aaa0; }
.river-legend-btn.river-place .river-dot { background: #9ab0b7; }
.river-detail { margin-top: 2px; }
.river-detail-card {
  position: relative;
  width: 100%;
  min-height: 92px;
  padding: 15px 46px 15px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px;
  gap: 8px 12px;
  align-items: center;
  text-align: left;
}
.river-detail-main { display: flex; flex-direction: column; gap: 2px; }
.river-detail-main strong { font-size: 21px; font-weight: 400; }
.river-detail-main .muted { font-size: 12px; }
.river-detail-card .pattern-spark { width: 90px; }
.river-insight { grid-column: 1 / -1; padding-top: 8px; border-top: 1px solid var(--line); color: var(--turq-deep); font-size: 12px; }

@media (max-width: 520px) {
  .patterns-view-head { margin-top: 14px; }
  .patterns-view-title { font-size: 23px; }
  .pattern-count-badge { display: none; }
  .atlas-corner, .atlas-theme-cell { min-width: 96px; max-width: 96px; }
  .ranked-pattern { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 8px; }
  .ranked-pattern .pattern-spark { display: none; }
  .rank-count strong { font-size: 15px; }
  .river-chart { min-height: 360px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .orb-body, .mesh-link { animation: none !important; }
}
