/* Nikko — design system */

@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,300;0,6..72,400;0,6..72,500;1,6..72,400&family=Geist:wght@300;400;500;600&family=Geist+Mono:wght@400;500&family=Sniglet:wght@400;800&family=Belgrano&display=swap');

:root {
  --font-display: "Newsreader", Georgia, serif;
  --font-body: "Geist", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, Menlo, monospace;
  --font-brand: "Sniglet", "Geist", ui-rounded, sans-serif;
  --font-chat: "Belgrano", "Newsreader", Georgia, serif;

  --gap: 18px;
  --bubble-pad-y: 14px;
  --bubble-pad-x: 18px;
  --thread-gap: 22px;

  /* Light theme */
  --bg: #EAE7DF;
  --bg-2: #e1ddd2;
  --bg-3: #FFFFFF;
  --surface: #FFFFFF;
  --ink: #1a1a1a;
  --ink-2: #3a3a3a;
  --muted: #5d5d5d;
  --faint: #846a6a;
  --line: #d4cfc1;
  --line-soft: #ddd8c9;

  --bubble-assist: #FFFFFF;
  --bubble-assist-line: #d8d2c2;
  --bubble-user: #1a1a1a;
  --bubble-user-ink: #EAE7DF;

  --accent: #279af1;        /* secondary blue */
  --accent-2: #846a6a;      /* secondary mauve */
  --accent-soft: #d8eaff;
  --sun: #CE844C;            /* avatar sun */
  --sun-soft: #f1d9c2;

  --crisis: #b85450;
  --crisis-soft: #f5dad9;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --shadow-soft: 0 1px 2px rgba(26,26,26,.04), 0 8px 24px -12px rgba(26,26,26,.10);
  --shadow-card: 0 1px 3px rgba(26,26,26,.06), 0 24px 48px -24px rgba(26,26,26,.20);

  --t-fast: 160ms cubic-bezier(.3,.7,.4,1);
  --t-med: 280ms cubic-bezier(.3,.7,.4,1);
  --t-slow: 520ms cubic-bezier(.22,.61,.36,1);
}

[data-theme="dark"] {
  --bg: #1A2B5F;
  --bg-2: #1f3170;
  --bg-3: #274290;
  --surface: #274290;
  --ink: #eae7df;
  --ink-2: #cac3b3;
  --muted: #9aa6c4;
  --faint: #7a87a8;
  --line: #354f9a;
  --line-soft: #2c3f80;

  --bubble-assist: #274290;
  --bubble-assist-line: #3a559e;
  --bubble-user: #eae7df;
  --bubble-user-ink: #1A2B5F;

  --accent: #42858c;
  --accent-2: #397367;
  --accent-soft: #2a4a86;
  --sun: #CE844C;
  --sun-soft: #3a4a8a;

  --crisis: #e7a39f;
  --crisis-soft: #3a3163;

  --shadow-soft: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  --shadow-card: 0 1px 3px rgba(0,0,0,.5), 0 24px 48px -24px rgba(0,0,0,.8);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color var(--t-med), color var(--t-med);
}
button { font-family: inherit; }
::selection { background: color-mix(in oklch, var(--accent) 32%, transparent); }

body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .25;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .04 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: multiply;
}
[data-theme="dark"] body::before { mix-blend-mode: screen; opacity: .15; }

.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in oklch, var(--bg) 92%, transparent);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .brand {
  display: flex; align-items: center; gap: 10px;
}
.topbar .brand .wordmark {
  font-family: var(--font-brand);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.topbar .pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  white-space: nowrap;
}
.topbar .pill .dot {
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  vertical-align: middle;
  background: var(--sun);
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--sun) 28%, transparent);
}
.topbar .spacer { flex: 1; }

.iconbtn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--ink-2);
  width: 34px; height: 34px;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--t-fast);
}
.iconbtn:hover { background: var(--bg-2); color: var(--ink); border-color: color-mix(in oklch, var(--ink) 18%, var(--line)); }
.iconbtn.danger { color: var(--crisis); border-color: color-mix(in oklch, var(--crisis) 35%, var(--line)); }
.iconbtn.danger:hover { background: var(--crisis-soft); }
.iconbtn.active {
  background: color-mix(in oklch, var(--sun) 18%, var(--bg-3));
  border-color: var(--sun);
  color: var(--sun);
}
.iconbtn svg { width: 16px; height: 16px; }

.ghostbtn {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all var(--t-fast);
}
.ghostbtn:hover { background: var(--bg-3); color: var(--ink); }
.ghostbtn svg { width: 13px; height: 13px; }
.ghostbtn.danger {
  border-color: color-mix(in oklch, var(--crisis) 50%, var(--line));
  color: var(--crisis);
}
.ghostbtn.danger:hover { background: var(--crisis-soft); border-color: var(--crisis); }

/* Memory indicator */
.mem-indicator {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-2);
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in oklch, var(--accent) 8%, var(--bg-3));
  border: 1px solid color-mix(in oklch, var(--accent) 30%, var(--line));
}
.mem-indicator .pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 28%, transparent);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Gate */
.gate {
  position: fixed; inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 40px 20px;
  overflow-y: auto;
}
.gate::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 600px at 50% -10%, color-mix(in oklch, var(--sun-soft) 50%, transparent) 0%, transparent 60%),
    radial-gradient(700px 500px at 50% 120%, color-mix(in oklch, var(--accent-soft) 50%, transparent) 0%, transparent 65%);
}
.gate-card {
  position: relative;
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
  padding: 38px 36px 30px;
  z-index: 1;
}
.gate-mark { display: flex; justify-content: center; margin-bottom: 18px; }
.gate-title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 38px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-align: center;
  margin: 0 0 8px;
  color: var(--ink);
}
.gate-title em {
  font-family: var(--font-brand);
  font-style: normal;
  font-weight: 400;
  color: var(--ink); /* black per request */
  letter-spacing: -0.005em;
}
.gate-sub {
  text-align: center;
  color: var(--muted);
  font-size: 14.5px;
  margin: 0 0 28px;
  text-wrap: balance;
}
.gate-list {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 22px;
}
.gate-item {
  display: grid; grid-template-columns: 24px 1fr; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--bg);
  border: 1px solid var(--line-soft);
}
[data-theme="dark"] .gate-item { background: var(--bg-2); }
.gate-item .glyph {
  width: 22px; height: 22px;
  border-radius: 999px;
  background: color-mix(in oklch, var(--accent-2) 14%, var(--bg));
  color: var(--accent-2);
  display: grid; place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.gate-item .glyph svg { width: 12px; height: 12px; }
.gate-item h4 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.gate-item p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
}
.gate-attest {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  background: var(--bg);
  cursor: pointer;
  transition: all var(--t-fast);
  margin-bottom: 18px;
  user-select: none;
}
[data-theme="dark"] .gate-attest { background: var(--bg-2); }
.gate-attest:hover { border-color: color-mix(in oklch, var(--accent) 35%, var(--line)); }
.gate-attest.checked {
  border-color: var(--accent);
  background: color-mix(in oklch, var(--accent-soft) 50%, var(--bg));
}
.gate-attest .check {
  width: 20px; height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
  margin-top: 1px;
  display: grid; place-items: center;
  transition: all var(--t-fast);
}
.gate-attest.checked .check {
  background: var(--accent);
  border-color: var(--accent);
}
.gate-attest.checked .check svg { opacity: 1; transform: scale(1); }
.gate-attest .check svg {
  width: 12px; height: 12px;
  color: #fff;
  opacity: 0;
  transform: scale(.6);
  transition: all var(--t-fast);
}
.gate-attest .label { font-size: 13.5px; color: var(--ink); }
.gate-attest .label strong { font-weight: 500; }
.gate-attest .label small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}
.gate-cta {
  appearance: none;
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.gate-cta:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 32px -12px color-mix(in oklch, var(--ink) 50%, transparent);
}
.gate-cta:disabled { opacity: 0.35; cursor: not-allowed; }
.gate-foot {
  margin-top: 18px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.gate-foot a {
  color: var(--faint);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.gate-foot a:hover { color: var(--muted); }

/* Chat layout — panels left/right */
.chat {
  flex: 1;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  position: relative;
  min-height: 0;
}
.chat[data-left="open"]  { grid-template-columns: 320px 1fr 44px; }
.chat[data-right="open"] { grid-template-columns: 44px 1fr 360px; }
.chat[data-left="open"][data-right="open"] { grid-template-columns: 320px 1fr 360px; }
@media (max-width: 980px) {
  .chat,
  .chat[data-left="open"],
  .chat[data-right="open"],
  .chat[data-left="open"][data-right="open"] { grid-template-columns: 44px 1fr 44px; }
  .chat[data-left="open"]  .panel.left  { width: 84vw; max-width: 360px; position: absolute; z-index: 5; height: 100%; left: 0; }
  .chat[data-right="open"] .panel.right { width: 84vw; max-width: 360px; position: absolute; z-index: 5; height: 100%; right: 0; }
}

.tabrail {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border-right: 1px solid var(--line-soft);
  background: var(--bg);
}
.tabrail.right { border-right: 0; border-left: 1px solid var(--line-soft); }
.tabrail .tabbtn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 14px 0;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: all var(--t-fast);
  border-bottom: 1px solid var(--line-soft);
}
.tabrail .tabbtn:hover { background: var(--bg-2); color: var(--ink); }
.tabrail .tabbtn[aria-pressed="true"] {
  color: var(--accent-2);
  background: color-mix(in oklch, var(--accent-2) 8%, var(--bg));
}
.tabrail.right .tabbtn[aria-pressed="true"] {
  color: var(--sun);
  background: color-mix(in oklch, var(--sun) 10%, var(--bg));
}
.tabrail .tabbtn svg { width: 16px; height: 16px; }
.tabrail .tabbtn .lbl {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}
.panel.left { border-right: 1px solid var(--line-soft); }
.panel.right { border-left: 1px solid var(--line-soft); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.panel-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.panel-head .meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}
.panel-body {
  flex: 1;          /* fill remaining panel height so overflow-y:auto is bounded */
  min-height: 0;    /* flex default min-height:auto prevents shrink → scroll */
  overflow-y: auto;
  padding: 14px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Sources cards */
.source-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.source-card.active {
  border-color: var(--sun);
  background: color-mix(in oklch, var(--sun-soft) 35%, var(--surface));
}
.source-card .row {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.source-card .num {
  width: 18px; height: 18px;
  border-radius: 5px;
  background: color-mix(in oklch, var(--sun) 20%, transparent);
  color: var(--sun);
  display: grid; place-items: center;
  font-size: 10px; font-weight: 600;
}
.source-card .title {
  font-size: 13px; font-weight: 500; color: var(--ink); line-height: 1.4;
}
.source-card a.linkrow {
  font-size: 11.5px;
  color: var(--accent);
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
  word-break: break-word;
}
.source-card a.linkrow:hover { text-decoration: underline; }
.source-card .blurb {
  font-size: 12.5px; color: var(--ink-2); line-height: 1.5;
}
.source-card .apa {
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 11px;
  font-style: italic;
  color: var(--faint);
  line-height: 1.45;
  padding-top: 6px;
  border-top: 1px dashed var(--line-soft);
}

/* Mood diary */
.mood-day {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
  cursor: pointer;
  transition: border-color var(--t-fast);
}
.mood-day:hover { border-color: color-mix(in oklch, var(--accent-2) 35%, var(--line)); }
.mood-day.active { border-color: var(--accent-2); background: color-mix(in oklch, var(--accent-2) 10%, var(--surface)); }
.mood-day .top {
  display: flex; justify-content: space-between; align-items: baseline;
}
.mood-day .date {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-transform: uppercase;
}
.mood-day .scale {
  display: inline-flex; gap: 2px;
}
.mood-day .scale i {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--line);
  display: inline-block;
}
.mood-day .scale i.on { background: var(--accent-2); }
.mood-day .note {
  font-size: 12.5px; color: var(--ink-2); line-height: 1.5;
}
.mood-day .note.empty { color: var(--faint); font-style: italic; }

.mood-add {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.mood-pick {
  appearance: none;
  width: 38px; height: 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
  font-size: 14px;
}
.mood-pick:hover { background: var(--bg-2); }
.mood-pick.on {
  background: var(--accent-2);
  color: var(--bubble-user-ink);
  border-color: var(--accent-2);
}
.mood-add textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-3);
  color: var(--ink);
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.4;
  resize: vertical;
  min-height: 60px;
  outline: none;
}
.mood-add textarea:focus { border-color: var(--accent-2); }
.mood-add .actions {
  display: flex; gap: 6px; justify-content: flex-end; width: 100%;
}

.thread-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.thread {
  flex: 1;
  overflow-y: auto;
  padding: 36px 22px 24px;
  scroll-behavior: smooth;
}
.thread-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--thread-gap);
}

.session-stamp {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: -8px 0 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
.session-stamp::before, .session-stamp::after {
  content: "";
  flex: 1;
  border-top: 1px dashed var(--line);
}

.msg {
  display: flex;
  gap: 14px;
  animation: msg-in var(--t-slow) both;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg.user { flex-direction: row-reverse; }
.msg .avatar-slot {
  flex: 0 0 auto;
  width: 44px;
  display: flex;
  justify-content: center;
  padding-top: 2px;
}
.msg.user .avatar-slot { display: none; }
.msg .body { min-width: 0; max-width: 100%; flex: 1; }
.msg.user .body { display: flex; justify-content: flex-end; }

.bubble {
  display: inline-block;
  max-width: 100%;
  padding: var(--bubble-pad-y) var(--bubble-pad-x);
  border-radius: var(--r-lg);
  border: 1px solid var(--bubble-assist-line);
  background: var(--bubble-assist);
  color: var(--ink);
  font-family: var(--font-chat);
  font-size: 15px;
  line-height: 1.65;
  letter-spacing: 0.003em;
  box-shadow: var(--shadow-soft);
  position: relative;
}
.msg.assistant .bubble { border-bottom-left-radius: 6px; }
.msg.user .bubble {
  background: var(--bubble-user);
  color: var(--bubble-user-ink);
  border-color: var(--bubble-user);
  border-bottom-right-radius: 6px;
}
.bubble p { margin: 0 0 0.6em; }
.bubble p:last-child { margin-bottom: 0; }
.bubble strong { font-weight: 500; }

.cite-sup {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin: 0 1px 0 2px;
  border-radius: 4px;
  background: color-mix(in oklch, var(--sun) 18%, transparent);
  color: var(--sun);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  vertical-align: 4px;
  cursor: pointer;
  border: 0;
  transition: all var(--t-fast);
  line-height: 1;
}
.cite-sup:hover {
  background: var(--sun);
  color: #fff;
}

/* Sources badge — "N sources used" button below GUIDANCE mode responses */
.sources-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  padding: 3px 10px 3px 7px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--t-fast);
  line-height: 1.4;
}
.sources-badge svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: 0.7;
}
.sources-badge:hover {
  border-color: var(--sun);
  color: var(--sun);
  background: color-mix(in oklch, var(--sun-soft) 20%, var(--surface));
}
.sources-badge:hover svg { opacity: 1; }

/* Composer */
.composer-wrap {
  border-top: 1px solid var(--line-soft);
  padding: 14px 22px 20px;
  background: color-mix(in oklch, var(--bg) 92%, transparent);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}
.composer-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.safety-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: color-mix(in oklch, var(--crisis) 10%, var(--bg-3));
  border: 1px solid color-mix(in oklch, var(--crisis) 40%, var(--line));
  font-size: 13px;
  color: var(--ink);
  animation: msg-in var(--t-med) both;
}
.safety-banner .icon {
  width: 22px; height: 22px; border-radius: 999px;
  background: color-mix(in oklch, var(--crisis) 22%, transparent);
  color: var(--crisis);
  display: grid; place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.safety-banner .icon svg { width: 12px; height: 12px; }
.safety-banner .body { flex: 1; min-width: 0; }
.safety-banner .body strong { font-weight: 500; display: block; margin-bottom: 2px; }
.safety-banner .body p { margin: 0; color: var(--ink-2); line-height: 1.5; }
.safety-banner .body p a {
  color: var(--crisis);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.safety-banner .dismiss {
  appearance: none;
  border: 0; background: transparent;
  color: var(--muted);
  width: 22px; height: 22px;
  border-radius: 6px;
  cursor: pointer;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.safety-banner .dismiss:hover { background: color-mix(in oklch, var(--ink) 6%, transparent); color: var(--ink); }
.safety-banner .dismiss svg { width: 12px; height: 12px; }
/* REQ-300-RS2 — expandable demographic resources */
.safety-banner-extra { margin-top: 4px !important; font-size: 12px; }
.safety-banner-expand {
  appearance: none; border: 0; background: transparent; padding: 0;
  margin-top: 4px; font-size: 11px; color: var(--crisis); cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px; line-height: 1.4;
}
.safety-banner-expand:hover { opacity: 0.75; }

/* ── Memory status banner ───────────────────────────────────────────── */
/* Shown after a memory file is loaded ('loaded') or as a soft nudge    */
/* to set one up ('hint'). Dismissed by the user or auto-fades.         */
.mem-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid color-mix(in oklch, var(--accent) 35%, var(--line));
  background: color-mix(in oklch, var(--accent) 7%, var(--surface));
  font-size: 13px;
  color: var(--ink);
  animation: msg-in var(--t-med) both;
}
.mem-banner-icon {
  width: 22px; height: 22px;
  border-radius: 999px;
  background: color-mix(in oklch, var(--accent) 18%, transparent);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  margin-top: 1px;
}
.mem-banner-icon svg { width: 12px; height: 12px; }
.mem-banner-body { flex: 1; min-width: 0; }
.mem-banner-body strong { font-weight: 500; display: block; margin-bottom: 2px; }
.mem-banner-body p { margin: 0; color: var(--ink-2); line-height: 1.5; }
.mem-banner-action {
  appearance: none; border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-family: var(--font-body);
  cursor: pointer;
  padding: 0;
  margin-top: 4px;
  text-decoration: underline;
  text-underline-offset: 2px;
  display: block;
}
.mem-banner-action:hover { opacity: 0.75; }
.mem-banner .dismiss {
  appearance: none;
  border: 0; background: transparent;
  color: var(--muted);
  width: 22px; height: 22px;
  border-radius: 4px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.mem-banner .dismiss:hover { background: color-mix(in oklch, var(--ink) 6%, transparent); color: var(--ink); }
.mem-banner .dismiss svg { width: 12px; height: 12px; }

/* ── Technique check-in banner (SPEC-850 §9 — response-side popup) ── */
/* Shown when Nikko's response recommends a named technique.            */
/* Accent color matches memory UI; distinct from SafetyBanner (crisis). */
.technique-checkin-banner {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  padding: 11px 14px;
  margin-bottom: 6px;
  background: color-mix(in oklch, var(--accent) 7%, var(--surface));
  border: 1px solid color-mix(in oklch, var(--accent) 22%, transparent);
  border-radius: var(--r-lg);
  font-size: 13px;
  line-height: 1.45;
}
.technique-checkin-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--accent);
}
.technique-checkin-icon svg { width: 100%; height: 100%; }
.technique-checkin-body {
  flex: 1;
  min-width: 0;
}
.technique-checkin-body strong {
  display: block;
  font-weight: 600;
  color: var(--ink-1, var(--ink));
  margin-bottom: 1px;
}
.technique-checkin-body p {
  margin: 0;
  color: var(--ink-2);
}
.technique-checkin-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.technique-checkin-yes {
  padding: 5px 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.technique-checkin-no {
  padding: 5px 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line, #d4cfc1);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.technique-checkin-yes:hover { filter: brightness(1.08); }
.technique-checkin-no:hover  { background: var(--bg-2, #e1ddd2); }

/* ── Memory proposal card (SPEC-850 §9, step 2) ───────────────────── */
/* Shown above the composer when the backend proposes a write-back entry. */
/* REQ-850-092: visually distinct from the support response; clearly labelled. */
.mem-proposal-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: color-mix(in oklch, var(--accent) 6%, var(--surface));
  border: 1px solid color-mix(in oklch, var(--accent) 30%, transparent);
  border-radius: var(--r-lg);
  font-size: 13px;
  line-height: 1.5;
}
.mem-proposal-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: color-mix(in oklch, var(--accent) 12%, var(--surface));
  border-radius: 50%;
  color: var(--accent);
}
.mem-proposal-icon svg { width: 14px; height: 14px; }
.mem-proposal-body { flex: 1; min-width: 0; }
.mem-proposal-label {
  font-weight: 500;
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mem-proposal-entry { color: var(--ink); line-height: 1.5; }
.mem-proposal-section {
  font-weight: 500;
  color: var(--ink-2);
}
.mem-proposal-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.mem-proposal-accept,
.mem-proposal-decline {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.4;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.mem-proposal-accept {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.mem-proposal-accept:hover {
  opacity: 0.88;
}
.mem-proposal-decline {
  background: var(--surface);
  color: var(--ink-2);
}
.mem-proposal-decline:hover {
  background: var(--bg-3);
  color: var(--ink);
  border-color: var(--line);
}

/* Save memory topbar button — accent outline style to stand out */
.ghostbtn.mem-save-btn {
  border-color: color-mix(in oklch, var(--accent) 40%, transparent);
  color: var(--accent);
}
.ghostbtn.mem-save-btn:hover {
  background: color-mix(in oklch, var(--accent) 8%, transparent);
  border-color: var(--accent);
}

.composer {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-soft);
  transition: all var(--t-fast);
}
.composer:focus-within {
  border-color: color-mix(in oklch, var(--accent) 50%, var(--line));
  box-shadow: var(--shadow-soft), 0 0 0 4px color-mix(in oklch, var(--accent) 14%, transparent);
}
.composer textarea {
  flex: 1;
  min-height: 26px;
  max-height: 160px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-chat);
  font-size: 15px;
  line-height: 1.55;
  padding: 8px 0;
}
.composer textarea::placeholder { color: var(--faint); }
.send {
  appearance: none;
  width: 36px; height: 36px;
  border-radius: 999px;
  border: 0;
  background: var(--ink);
  color: var(--bg);
  display: grid; place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--t-fast);
}
.send:hover:not(:disabled) { transform: translateY(-1px); }
.send:disabled { opacity: 0.35; cursor: not-allowed; }
.send svg { width: 14px; height: 14px; }

.composer-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--faint);
  text-transform: uppercase;
  padding: 0 4px;
}
/* Right-side slot in composer footer — groups the counter + "Cleared on refresh" */
.composer-foot-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Character counter — hidden below 60% of limit (controlled via React).
   Transitions smoothly between states so the colour shift isn't jarring. */
.composer-count {
  font-variant-numeric: tabular-nums;
  color: var(--faint);
  transition: color 0.2s ease;
}
/* 80%–100% of limit — amber warning */
.composer-count.warn {
  color: var(--accent);
}
/* Over limit — red, slightly bold so it reads as an error */
.composer-count.over {
  color: #e05252;
  font-weight: 600;
}

.composer-foot .kbd {
  display: inline-flex;
  height: 13px;
  padding: 0 4px;
  align-items: center;
  border-radius: 3px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  font-size: 8.5px;
  letter-spacing: 0;
  color: var(--ink-2);
  margin: 0 1px;
}

.caret {
  display: inline-block;
  width: 7px; height: 14px;
  background: var(--sun);
  border-radius: 1.5px;
  vertical-align: -2px;
  margin-left: 2px;
  animation: caret 1.1s ease-in-out infinite;
}
@keyframes caret {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.suggest-row {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 14px;
}
.suggest {
  appearance: none;
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--ink-2);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: all var(--t-fast);
  text-align: left;
}
.suggest:hover {
  background: var(--surface);
  border-color: color-mix(in oklch, var(--accent) 35%, var(--line));
  color: var(--ink);
}

.sun-mark { display: inline-block; position: relative; }

.thread::-webkit-scrollbar, .panel-body::-webkit-scrollbar { width: 8px; }
.thread::-webkit-scrollbar-thumb, .panel-body::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

/* Modals */
.modal-veil {
  position: fixed; inset: 0;
  background: color-mix(in oklch, var(--ink) 35%, transparent);
  z-index: 200;
  display: grid; place-items: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  animation: fade-in var(--t-med) both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(540px, 100%);
  max-height: 90vh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
  /* padding-bottom intentionally 0 — overflow-y:auto drops padding-bottom in
     Chrome/Edge when content scrolls. Bottom clearance is provided by ::after. */
  padding: 28px 28px 0;
  overflow-y: auto;
}
/* Spacer that scroll containers actually respect (unlike padding-bottom). */
.modal::after {
  content: '';
  display: block;
  height: 24px;
  flex-shrink: 0;
}
.modal h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.modal h2 em { font-family: var(--font-brand); font-style: normal; font-weight: 400; color: var(--ink); }
.modal .lede { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.modal .warn-list {
  list-style: none; padding: 0; margin: 0 0 18px;
  display: flex; flex-direction: column; gap: 8px;
}
.modal .warn-list li {
  position: relative;
  padding: 10px 12px 10px 30px;
  background: color-mix(in oklch, var(--accent-2) 8%, var(--bg));
  border: 1px solid color-mix(in oklch, var(--accent-2) 22%, var(--line-soft));
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--ink);
  line-height: 1.5;
}
.modal .warn-list li::before {
  content: "";
  position: absolute; left: 12px; top: 14px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-2);
}
.modal .input-row {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 14px;
}
.modal .input-row label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.modal input[type="password"], .modal input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--ink);
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
}
.modal input:focus { border-color: var(--accent); }
.modal .err {
  background: var(--crisis-soft);
  color: var(--crisis);
  border: 1px solid color-mix(in oklch, var(--crisis) 40%, var(--line));
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: 13px;
  margin-bottom: 14px;
}
.modal .actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 10px;
}
.btn-primary {
  appearance: none; border: 0;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary {
  appearance: none;
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--bg); color: var(--ink); }

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: var(--r-md);
  padding: 22px;
  text-align: center;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--t-fast);
  margin-bottom: 14px;
}
.dropzone:hover, .dropzone.over {
  border-color: var(--accent);
  background: color-mix(in oklch, var(--accent-soft) 50%, var(--bg));
  color: var(--ink);
}
.dropzone .filename {
  display: block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink);
}

/* Tutorial */
.tutorial-veil {
  position: fixed; inset: 0;
  z-index: 150;
  background: color-mix(in oklch, var(--ink) 60%, transparent);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 20px;
  animation: fade-in var(--t-med) both;
}
.tutorial {
  width: min(620px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
  padding: 32px 32px 24px;
  position: relative;
}
.tutorial .step-num {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}
.tutorial h2 {
  margin: 4px 0 8px;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 28px;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.tutorial p {
  margin: 0 0 18px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-2);
}
.tutorial .feature-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 18px;
}
@media (max-width: 540px) {
  .tutorial .feature-grid { grid-template-columns: 1fr; }
}
.tutorial .feature {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
[data-theme="dark"] .tutorial .feature { background: var(--bg-2); }
.tutorial .feature .ico {
  width: 26px; height: 26px;
  border-radius: 8px;
  background: color-mix(in oklch, var(--accent) 14%, var(--surface));
  color: var(--accent);
  display: grid; place-items: center;
  margin-bottom: 4px;
}
.tutorial .feature .ico svg { width: 14px; height: 14px; }
.tutorial .feature h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.tutorial .feature p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-2);
}
.tutorial .actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 6px;
}
.tutorial .dots { display: flex; gap: 5px; }
.tutorial .dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--line);
  display: inline-block;
}
.tutorial .dots i.on { background: var(--accent); }
.tutorial .right-actions { display: flex; gap: 6px; }

/* Decorative bubbles & sparkles */
.decor {
  position: fixed; inset: 0;
  z-index: 0; pointer-events: none;
  overflow: hidden;
}
[data-theme="light"] .decor .sparkles { display: none; }
[data-theme="dark"] .decor .bubbles { display: none; }
.bubble-orb {
  position: absolute;
  bottom: -80px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,.95) 0%, rgba(255,255,255,.55) 28%, color-mix(in oklch, var(--sun) 38%, transparent) 62%, transparent 100%);
  border: 1.5px solid color-mix(in oklch, var(--sun) 45%, transparent);
  opacity: 0;
  animation: bubble-rise linear infinite;
  box-shadow:
    inset 0 -3px 10px color-mix(in oklch, var(--sun) 30%, transparent),
    inset 1px 1px 5px rgba(255,255,255,.7),
    0 2px 6px rgba(206,132,76,.18);
}
.bubble-orb.cool {
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,.95) 0%, rgba(255,255,255,.55) 28%, color-mix(in oklch, var(--accent) 38%, transparent) 62%, transparent 100%);
  border-color: color-mix(in oklch, var(--accent) 50%, transparent);
  box-shadow:
    inset 0 -3px 10px color-mix(in oklch, var(--accent) 30%, transparent),
    inset 1px 1px 5px rgba(255,255,255,.7),
    0 2px 6px rgba(39,154,241,.20);
}
@keyframes bubble-rise {
  0% { transform: translate3d(0,0,0) scale(0.6); opacity: 0; }
  10% { opacity: 0.85; }
  50% { transform: translate3d(14px, -55vh, 0) scale(1); opacity: 0.85; }
  90% { opacity: 0.7; }
  100% { transform: translate3d(-8px, -110vh, 0) scale(1.05); opacity: 0; }
}
.spark {
  position: absolute;
  color: var(--accent);
  opacity: 0.6;
  animation: spark-spin linear infinite, spark-pulse ease-in-out infinite;
  filter: drop-shadow(0 0 6px color-mix(in oklch, var(--accent) 60%, transparent));
}
.spark svg { width: 100%; height: 100%; display: block; }
@keyframes spark-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes spark-pulse { 0%,100% { opacity: 0.30; } 50% { opacity: 0.85; } }

@media (prefers-reduced-motion: reduce) {
  .bubble-orb, .spark { animation: none; opacity: 0.4; }
}

/* ── FLOATING LAYOUT ──────────────────────────────────────────────── */
.app { background: transparent; }
.topbar.floating {
  position: fixed; top: 14px; left: 14px; right: 14px;
  z-index: 30;
  border: 0; padding: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  pointer-events: none;
}
.topbar.floating > * { pointer-events: auto; }
.pillbar {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: color-mix(in oklch, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}
.pillbar .brand-mini {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 10px 0 6px;
}
.pillbar .brand-mini .wordmark {
  font-family: var(--font-brand);
  font-weight: 400; font-size: 18px;
  color: var(--ink);
}
.pillbar .pill {
  background: transparent;
  border: 0;
  padding: 6px 10px;
}
.pillbar .pill.linklike { cursor: help; }
.pillbar .pill.linklike:hover {
  background: color-mix(in oklch, var(--ink) 6%, transparent);
}
.pillbar .iconbtn {
  width: 30px; height: 30px;
  border: 0;
  background: transparent;
  border-radius: 999px;
}
.pillbar .iconbtn:hover { background: color-mix(in oklch, var(--ink) 8%, transparent); }
.pillbar .ghostbtn {
  border: 0;
  background: transparent;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
}
.pillbar .ghostbtn:hover { background: color-mix(in oklch, var(--ink) 8%, transparent); }
.pillbar .ghostbtn.danger {
  color: var(--crisis);
  border: 0;
}
.pillbar .ghostbtn.danger:hover { background: var(--crisis-soft); }
.pillbar .divider {
  width: 1px; height: 20px; background: var(--line); margin: 0 2px;
}
.pillbar .ghostbtn.active {
  background: color-mix(in oklch, var(--accent) 14%, transparent);
  color: var(--accent);
}

/* tooltip on research-preview pill */
.tip-host { position: relative; }
.tip {
  position: absolute; top: calc(100% + 8px); left: 0;
  z-index: 60;
  width: max-content;
  max-width: 280px;
  padding: 9px 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  line-height: 1.45;
  border-radius: 10px;
  opacity: 0; pointer-events: none;
  transform: translateY(-2px);
  transition: opacity var(--t-fast), transform var(--t-fast);
  box-shadow: var(--shadow-card);
  text-transform: none; letter-spacing: 0;
  font-family: var(--font-body);
}
.tip a { color: var(--sun); text-decoration: underline; }
.tip-host:hover .tip, .tip-host:focus-within .tip {
  opacity: 1; transform: translateY(0);
}

/* memory popover */
.popover {
  position: absolute; top: calc(100% + 10px); right: 0;
  z-index: 60;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  padding: 14px;
  font-family: var(--font-body);
  text-transform: none; letter-spacing: 0;
}
.popover h4 {
  margin: 0 0 8px; font-family: var(--font-display);
  font-size: 16px; font-weight: 400; color: var(--ink);
}
.popover .status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-2);
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 10px;
  margin-bottom: 10px;
}
.popover .status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--line);
}
.popover .status.on .dot { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 28%, transparent); }
.popover .row {
  display: flex; gap: 6px;
}
.popover button {
  flex: 1; height: 36px; border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--t-fast);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.popover button:hover { border-color: var(--accent); background: var(--surface); }
.popover button svg { width: 13px; height: 13px; }
.popover .hint {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

/* layout: single column thread, panels float as sheets */
.chat.floating,
.chat.floating[data-left="open"],
.chat.floating[data-right="open"],
.chat.floating[data-left="open"][data-right="open"] {
  grid-template-columns: 1fr;
  position: relative;
}
.chat.floating .tabrail { display: none; }
.chat.floating .panel.left,
.chat.floating .panel.right {
  position: fixed;
  top: 76px;
  bottom: 110px;
  width: min(360px, 88vw);
  z-index: 20;
  background: color-mix(in oklch, var(--surface) 96%, transparent);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  overflow: hidden;
}
.chat.floating .panel.left { left: 14px; }
.chat.floating .panel.right { right: 14px; }
.chat.floating .panel.left::before,
.chat.floating .panel.right::before { content: none; }

/* floating tab launchers (when panel closed) */
.tab-float {
  position: fixed; top: 50%;
  z-index: 15;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: color-mix(in oklch, var(--surface) 94%, transparent);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  transition: all var(--t-fast);
}
.tab-float:hover { color: var(--ink); border-color: color-mix(in oklch, var(--ink) 18%, var(--line)); }
.tab-float.left { left: 14px; transform: translateY(-50%); border-radius: 14px 18px 18px 14px; padding-left: 10px; }
.tab-float.right { right: 14px; transform: translateY(-50%); border-radius: 18px 14px 14px 18px; padding-right: 10px; }
.tab-float svg { width: 14px; height: 14px; color: var(--accent-2); }
.tab-float.right svg { color: var(--sun); }

/* composer floats too */
.chat.floating .composer-wrap {
  position: fixed; bottom: 14px;
  left: 14px; right: 14px;
  z-index: 18;
  background: transparent;
  border: 0;
  padding: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: none;
}
.chat.floating .composer-inner {
  pointer-events: auto;
  background: color-mix(in oklch, var(--surface) 96%, transparent);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 10px 12px 8px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}
.chat.floating .composer { box-shadow: none; border-color: var(--line-soft); }
.chat.floating .thread {
  padding-top: 96px;
  /* Increased from 140px: accounts for composer + composer-foot + AiDisclaimer
     (~28px) to ensure the last bubble is never hidden behind the fixed bar. */
  padding-bottom: 200px;
}

/* mood diary — progressive-disclosure layout */
.mood-body {
  display: flex; flex-direction: column;
  gap: 18px;
}
.mood-day-stamp {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.mood-section {
  display: flex; flex-direction: column; gap: 8px;
}
.mood-section > label,
.mood-section > .reflection-head > label {
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 0;
  text-transform: none;
}
.mood-scale-ends {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 0 2px;
}
.mood-disclosure {
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  padding: 6px 0;
}
.mood-disclosure > summary {
  list-style: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
}
.mood-disclosure > summary::-webkit-details-marker { display: none; }
.mood-disclosure > summary::before {
  content: "+";
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--faint);
  margin-right: 8px;
  transition: transform var(--t-fast);
}
.mood-disclosure[open] > summary::before { content: "−"; }
.mood-disclosure > summary:hover { color: var(--ink-2); }
.mood-disclosure-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent-2);
}
.mood-disclosure[open] {
  padding-bottom: 14px;
}
.mood-disclosure[open] > summary { margin-bottom: 6px; }
.mood-disclosure .mood-section + .mood-section { margin-top: 12px; }

.mood-add-reflection {
  appearance: none;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 12px;
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.mood-add-reflection:hover {
  color: var(--ink-2);
  border-color: color-mix(in oklch, var(--accent-2) 35%, var(--line));
  background: color-mix(in oklch, var(--accent-2) 5%, transparent);
}
.mood-add-reflection .plus {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent-2);
}

.reflection-block {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px;
  gap: 10px;
}
[data-theme="dark"] .reflection-block { background: var(--bg-2); }
.reflection-head {
  display: flex; align-items: baseline; justify-content: space-between;
}
.mood-link {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  cursor: pointer;
}
.mood-link:hover { color: var(--ink-2); }

.mood-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  padding-top: 4px;
}

.mood-divider {
  height: 1px;
  background: var(--line-soft);
  margin: 4px 0;
}
.mood-past-head {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.mood-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 4px 2px 8px;
}
.mood-past-list {
  display: flex; flex-direction: column;
  gap: 2px;
  margin: 0 -6px;
}
.mood-row {
  appearance: none;
  background: transparent;
  border: 0;
  text-align: left;
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: baseline;
  gap: 10px;
  padding: 9px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-body);
  color: var(--ink-2);
  transition: background var(--t-fast);
}
.mood-row:hover { background: var(--bg-2); }
.mood-row.active {
  background: color-mix(in oklch, var(--accent-2) 10%, var(--surface));
}
.mood-row-dot {
  width: 8px; height: 8px; border-radius: 50%;
  align-self: center;
  flex-shrink: 0;
}
.mood-row-date {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 92px;
}
.mood-row-summary {
  font-size: 12.5px;
  color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mood-row-score {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
  letter-spacing: 0.04em;
}
.mood-row.active .mood-row-date,
.mood-row.active .mood-row-score { color: var(--accent-2); }

.mood-chip.ghost {
  border-style: dashed;
  color: var(--muted);
  background: transparent;
}
.mood-chip.ghost:hover {
  color: var(--ink-2);
  border-color: color-mix(in oklch, var(--accent-2) 40%, var(--line));
}

/* ── Memory file snapshot inside mood diary panel ────────────────── */
/* Collapsible block that surfaces Helpful Interventions and Support Notes
   from the user's loaded memory file so they have context while logging mood. */
.mood-memory-snap {
  background: color-mix(in oklch, var(--accent-2) 6%, var(--surface));
  border: 1px solid color-mix(in oklch, var(--accent-2) 18%, var(--line));
  border-radius: 10px;
  margin-bottom: 14px;
  overflow: hidden;
}

/* The header row — controlled div replaces <summary> (avoids open-prop collapse bug) */
.mood-memory-sum {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent-2);
  cursor: pointer;
  user-select: none;
}
.mood-memory-sum svg {
  width: 12px; height: 12px;
  flex-shrink: 0;
  color: var(--accent-2);
  opacity: 0.75;
}
/* Arrow character; toggled by JS via memSnapOpen state */
.mood-mem-arrow {
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
}

/* Body padding when disclosure is open */
.mood-memory-body {
  padding: 0 13px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Individual sub-block (one per section: interventions / support notes) */
.mood-memory-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Sub-heading inside each block */
.mood-memory-sublabel {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

/* Flat memory file reference section — shown above the Save button when a file
   is loaded. No collapse toggle; user scrolls to it within the panel body. */
.mood-mem-section {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 4px;
  margin-bottom: 6px;
}
.mood-mem-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.mood-mem-section-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  flex: 1;
}

/* Empty-state shown when memory file is loaded but both sections contain only
   placeholder comments (new file). Keeps the block visible so Edit is reachable. */
.mood-mem-empty {
  font-size: 12.5px;
  color: var(--muted);
  font-style: italic;
  padding: 4px 0 6px;
  line-height: 1.5;
}
.mood-mem-empty strong { font-style: normal; color: var(--accent-2); font-weight: 600; }

/* Individual memory file line (entry or support note line) */
.mood-mem-line {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.55;
}
/* Lines starting with '- ' (bullet items in support notes) get a slight indent */
.mood-mem-line.bullet {
  padding-left: 10px;
  position: relative;
}
.mood-mem-line.bullet::before {
  content: '·';
  position: absolute;
  left: 2px;
  color: var(--muted);
}

/* ── Memory snapshot edit mode ──────────────────────────────────────
   Edit button sits in the summary row; textareas appear in-place. */
.mood-mem-edit-btn {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-2);
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--t-fast);
}
.mood-mem-edit-btn:hover { opacity: 1; }

.mood-mem-edit-area {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--ink);
  line-height: 1.55;
  resize: vertical;
  min-height: 72px;
  transition: border-color var(--t-fast);
}
.mood-mem-edit-area:focus {
  outline: none;
  border-color: var(--accent-2);
}
.mood-mem-edit-area::placeholder { color: var(--faint); }

.mood-mem-edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* ── Agent transparency ribbon (above each assistant message) ── */
.agent-ribbon {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 6px;
  margin-bottom: 6px;
  padding: 0 2px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  opacity: 0.5;
}
.agent-ribbon-count {
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.agent-ribbon-dot { color: var(--faint); padding: 0 2px; }
.agent-ribbon-sources-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
}
.agent-ribbon-sources {
  display: inline-flex; flex-wrap: wrap; gap: 4px;
  font-family: var(--font-body);
  font-size: 11.5px;
  color: var(--ink-2);
  letter-spacing: 0;
  text-transform: none;
}
.agent-ribbon-source {
  font-weight: 500;
}
.agent-ribbon-sep { color: var(--faint); margin-right: 2px; }

/* AgentRibbon processing state: live stage label in secondary typography */
.agent-ribbon.processing .agent-ribbon-stage {
  font-weight: 400;
  color: var(--ink-2);
  font-style: italic;
  text-transform: none;
  letter-spacing: 0.02em;
}
/* Completed: mode label */
.agent-ribbon-count {
  text-transform: lowercase;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  font-weight: 500;
}

/* ── Mood check-in popup ────────────────────────────────────────────────── */
/* [REQ-FIS-MC1–MC8] Inline card shown in the chat thread after welcome-back
   message on encrypted memory file load. Appears as a distinct card so the
   user sees it as an action item, not just more assistant text. */
.mood-checkin-popup {
  background: var(--surface-2, var(--surface));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px 16px;
  margin: 8px 0 8px 54px;  /* indent to align with message bubbles */
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mood-checkin-header {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.mood-checkin-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}
.mood-checkin-sub {
  font-size: 12.5px;
  color: var(--ink-2);
}
/* 1–10 rating row */
.mood-checkin-rating {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.mood-checkin-num {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  display: flex; align-items: center; justify-content: center;
}
.mood-checkin-num:hover { border-color: var(--accent); color: var(--accent); }
/* Active state: use the same gradient colour scale as the diary panel pips
   (MOOD_COLORS in panels.jsx / pip.on[data-r] rules) so both surfaces are
   visually consistent. Unselected buttons also get a very soft tint so the
   scale is readable before clicking. */
.mood-checkin-num.active {
  color: #fff !important; /* !important needed — specificity tie with data-r color rules */
  text-shadow: 0 1px 3px rgba(0,0,0,0.35); /* mid-range gold backgrounds ~2:1 contrast without this */
  border-color: transparent;
  font-weight: 600;
}
/* Unselected tints — very subtle so they don't compete with selected state */
.mood-checkin-num[data-r="1"]  { border-color: rgba(201, 90, 90, 0.25); }
.mood-checkin-num[data-r="2"]  { border-color: rgba(215,116, 82, 0.25); }
.mood-checkin-num[data-r="3"]  { border-color: rgba(219,143, 78, 0.25); }
.mood-checkin-num[data-r="4"]  { border-color: rgba(212,163, 82, 0.25); }
.mood-checkin-num[data-r="5"]  { border-color: rgba(201,178, 96, 0.25); }
.mood-checkin-num[data-r="6"]  { border-color: rgba(169,183,106, 0.25); }
.mood-checkin-num[data-r="7"]  { border-color: rgba(136,179,120, 0.25); }
.mood-checkin-num[data-r="8"]  { border-color: rgba(106,171,131, 0.25); }
.mood-checkin-num[data-r="9"]  { border-color: rgba( 79,156,140, 0.25); }
.mood-checkin-num[data-r="10"] { border-color: rgba( 61,138,142, 0.25); }
/* Active: solid fill from the same scale */
.mood-checkin-num.active[data-r="1"]  { background: #c95a5a; }
.mood-checkin-num.active[data-r="2"]  { background: #d77452; }
.mood-checkin-num.active[data-r="3"]  { background: #db8f4e; }
.mood-checkin-num.active[data-r="4"]  { background: #d4a352; }
.mood-checkin-num.active[data-r="5"]  { background: #c9b260; }
.mood-checkin-num.active[data-r="6"]  { background: #a9b76a; }
.mood-checkin-num.active[data-r="7"]  { background: #88b378; }
.mood-checkin-num.active[data-r="8"]  { background: #6aab83; }
.mood-checkin-num.active[data-r="9"]  { background: #4f9c8c; }
.mood-checkin-num.active[data-r="10"] { background: #3d8a8e; }
.mood-checkin-scale-hint {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--faint);
  margin-top: -8px;
}
/* Emotion chips */
.mood-checkin-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.mood-chip {
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.mood-chip:hover { border-color: var(--accent); color: var(--accent); }
.mood-chip.active {
  background: var(--accent-muted, rgba(206,132,76,0.15));
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 500;
}
/* Skip / Log buttons */
.mood-checkin-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.mood-checkin-skip {
  background: none;
  border: none;
  color: var(--ink-2);
  font-size: 12.5px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
}
.mood-checkin-skip:hover { background: var(--hover-bg, rgba(0,0,0,0.06)); }
.mood-checkin-log {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 18px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.12s;
}
.mood-checkin-log:disabled { opacity: 0.38; cursor: default; }
.mood-checkin-log:not(:disabled):hover { opacity: 0.88; }

/* Mobile: full width on narrow viewports */
@media (max-width: 600px) {
  .mood-checkin-popup { margin-left: 0; max-width: 100%; }
  .mood-checkin-num { width: 30px; height: 30px; font-size: 12px; }
}

/* ── Debug trigger (top-left sun) ── */
.debug-trigger {
  display: inline-flex;
  position: relative;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.debug-trigger.holding::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 999px;
  border: 1.5px solid color-mix(in oklch, var(--accent) 60%, transparent);
  animation: debug-hold-ring 3s linear forwards;
  pointer-events: none;
}
@keyframes debug-hold-ring {
  0%   { transform: scale(.85); opacity: 0; }
  10%  { opacity: 1; }
  100% { transform: scale(1.25); opacity: 0; }
}

/* ── Debug overlay ── */
.debug-veil {
  position: fixed; inset: 0;
  z-index: 200;
  background: color-mix(in oklch, var(--ink) 35%, transparent);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  animation: debug-veil-in 200ms cubic-bezier(.3,.7,.4,1);
}
@keyframes debug-veil-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.debug-panel {
  background: var(--surface);
  border-left: 1px solid var(--line);
  width: min(560px, 100%);
  max-width: 100%;
  display: flex; flex-direction: column;
  box-shadow: -32px 0 72px -32px rgba(0,0,0,.35);
  transition: width var(--t-med);
  font-family: var(--font-body);
  color: var(--ink);
  animation: debug-panel-in 240ms cubic-bezier(.3,.7,.4,1);
}
.debug-panel.wide { width: min(900px, 100%); }
@keyframes debug-panel-in {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.debug-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.debug-head h3 {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  color: var(--ink);
}
.debug-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
.debug-empty {
  padding: 32px 20px;
  color: var(--muted);
  font-size: 14px;
}
.debug-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.debug-turn-picker {
  display: flex; flex-direction: column; gap: 4px;
}
.debug-turn-picker select {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.debug-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
}
.debug-mode {
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 500;
  background: color-mix(in oklch, var(--accent) 14%, var(--bg-3));
  color: var(--accent);
  border: 1px solid color-mix(in oklch, var(--accent) 30%, var(--line));
}
.debug-mode.mode-CRISIS {
  background: var(--crisis-soft);
  color: var(--crisis);
  border-color: color-mix(in oklch, var(--crisis) 40%, var(--line));
}
.debug-mode.mode-COMFORT {
  background: color-mix(in oklch, var(--accent-2) 14%, var(--bg-3));
  color: var(--accent-2);
  border-color: color-mix(in oklch, var(--accent-2) 30%, var(--line));
}
.debug-meta-item {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  text-transform: uppercase;
}
.debug-pipeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex; flex-direction: column;
  gap: 1px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
}
.debug-phase {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
}
.debug-phase + .debug-phase { border-top: 1px solid var(--line-soft); }
.debug-phase-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--faint);
  width: 18px;
  text-align: right;
}
.debug-phase-line {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px;
}
.debug-phase-label {
  font-weight: 500;
  font-size: 13px;
  color: var(--ink);
}
.debug-phase-agent {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--faint);
}
.debug-phase-pill {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  background: color-mix(in oklch, var(--accent) 14%, var(--bg-3));
  color: var(--accent);
  border: 1px solid color-mix(in oklch, var(--accent) 30%, var(--line));
}
.debug-phase-pill.public {
  background: color-mix(in oklch, var(--sun) 14%, var(--bg-3));
  color: var(--sun);
  border-color: color-mix(in oklch, var(--sun) 30%, var(--line));
}
.debug-phase-dur {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  margin-left: auto;
}
.debug-phase-summary {
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 2px;
}
.debug-phase-status {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent);
}
.debug-phase-status.status-bypass { color: var(--faint); }
.debug-phase.status-fail .debug-phase-status { color: var(--crisis); }
.debug-actions {
  display: flex; justify-content: flex-end;
}
.debug-readmore {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.debug-readmore:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.debug-detail {
  display: flex; flex-direction: column; gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}
.debug-detail-head {
  display: flex; flex-direction: column; gap: 2px;
}
.debug-detail-note {
  font-size: 11.5px;
  color: var(--muted);
  font-style: italic;
}
.debug-detail-block {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 10px 12px;
}
.debug-detail-title {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 6px;
}
.debug-detail-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--faint);
}
.debug-detail-name { font-weight: 500; font-size: 13px; }
.debug-detail-agent {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
}
.debug-detail-json {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.debug-foot {
  padding: 10px 20px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  text-align: center;
}

/* ── Adapter cards (debug panel) ───────────────────────────── */
.adp-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0;
}
.adp-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-raised, rgba(0,0,0,0.03));
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}
[data-theme="dark"] .adp-card { background: rgba(255,255,255,0.04); }
.adp-card-step {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink-3, #ccc);
  color: var(--bg, #fff);
  font-size: 0.7rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.adp-card-body { flex: 1; min-width: 0; }
.adp-card-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
}
.adp-card-name {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
}
.adp-card-role {
  font-size: 0.72rem;
  color: var(--ink-2);
}
.adp-card-result {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.adp-card-running {
  display: flex;
  align-items: center;
  gap: 3px;
}
.adp-card-verdict {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.adp-card-detail {
  font-size: 0.72rem;
  color: var(--ink-2);
}
.adp-card-elapsed {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--faint);
  margin-left: auto;
}
/* Meta pills */
.debug-meta-pill {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: 0.04em;
}
.debug-meta-pill.live    { background: rgba(34,170,100,0.12); color: #1a9; }
.debug-meta-pill.sim     { background: rgba(0,0,0,0.07); color: var(--ink-2); }
.debug-meta-pill.regen   { background: rgba(230,144,0,0.12); color: #c70; }
/* Raw payload */
.debug-raw { margin-top: 6px; }
.debug-raw-toggle {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  cursor: pointer;
  padding: 4px 0;
  user-select: none;
}
.debug-raw-toggle:hover { color: var(--ink); }
.mood-section > label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.mood-rating-row {
  display: flex; gap: 3px;
}
.mood-rating-row .pip {
  flex: 1;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--ink-2);
  font-size: 11.5px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.mood-rating-row .pip:hover { background: var(--bg-2); }
.mood-rating-row .pip.on {
  border-color: transparent;
  color: #fff !important; /* overrides per-data-r color rules that follow in source order */
  text-shadow: 0 1px 3px rgba(0,0,0,0.35); /* low-contrast mid-range golds need this to read */
  font-weight: 500;
}
/* mood color scale (1=red-ish through 10=green-ish) — unselected get a subtle
   border tint so the gradient is visible before selection (equal visual weight) */
.mood-rating-row .pip[data-r="1"]  { border-color: rgba(201, 90, 90, 0.30); color: rgba(201, 90, 90, 0.70); }
.mood-rating-row .pip[data-r="2"]  { border-color: rgba(215,116, 82, 0.30); color: rgba(215,116, 82, 0.70); }
.mood-rating-row .pip[data-r="3"]  { border-color: rgba(219,143, 78, 0.30); color: rgba(219,143, 78, 0.70); }
.mood-rating-row .pip[data-r="4"]  { border-color: rgba(212,163, 82, 0.30); color: rgba(212,163, 82, 0.70); }
.mood-rating-row .pip[data-r="5"]  { border-color: rgba(201,178, 96, 0.30); color: rgba(201,178, 96, 0.70); }
.mood-rating-row .pip[data-r="6"]  { border-color: rgba(169,183,106, 0.30); color: rgba(169,183,106, 0.70); }
.mood-rating-row .pip[data-r="7"]  { border-color: rgba(136,179,120, 0.30); color: rgba(136,179,120, 0.70); }
.mood-rating-row .pip[data-r="8"]  { border-color: rgba(106,171,131, 0.30); color: rgba(106,171,131, 0.70); }
.mood-rating-row .pip[data-r="9"]  { border-color: rgba( 79,156,140, 0.30); color: rgba( 79,156,140, 0.70); }
.mood-rating-row .pip[data-r="10"] { border-color: rgba( 61,138,142, 0.30); color: rgba( 61,138,142, 0.70); }
/* Selected (on) — solid fill, white text */
.mood-rating-row .pip.on[data-r="1"]  { background: #c95a5a; }
.mood-rating-row .pip.on[data-r="2"]  { background: #d77452; }
.mood-rating-row .pip.on[data-r="3"]  { background: #db8f4e; }
.mood-rating-row .pip.on[data-r="4"]  { background: #d4a352; }
.mood-rating-row .pip.on[data-r="5"]  { background: #c9b260; }
.mood-rating-row .pip.on[data-r="6"]  { background: #a9b76a; }
.mood-rating-row .pip.on[data-r="7"]  { background: #88b378; }
.mood-rating-row .pip.on[data-r="8"]  { background: #6aab83; }
.mood-rating-row .pip.on[data-r="9"]  { background: #4f9c8c; }
.mood-rating-row .pip.on[data-r="10"] { background: #3d8a8e; }

.mood-chips {
  display: flex; flex-wrap: wrap; gap: 5px;
}
.mood-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--ink-2);
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--t-fast);
  font-family: var(--font-body);
}
.mood-chip:hover { border-color: color-mix(in oklch, var(--accent-2) 40%, var(--line)); }
.mood-chip.on {
  background: var(--accent-2);
  color: var(--bubble-user-ink);
  border-color: var(--accent-2);
}

.mood-text {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-3);
  color: var(--ink);
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  min-height: 56px;
  outline: none;
}
.mood-text:focus { border-color: var(--accent-2); }

.pomodoro {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
}
[data-theme="dark"] .pomodoro { background: var(--bg-2); }
.pomodoro .clock {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.04em;
}
.pomodoro .clock.warn { color: var(--crisis); }
.pomodoro .meta {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.pomodoro button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--ink-2);
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  cursor: pointer;
}
.pomodoro button:hover { border-color: var(--accent-2); color: var(--ink); }

.char-count {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: right;
}
.char-count.warn { color: var(--crisis); }

/* ── AI Limitation Disclaimer (G-UI-01 / REQ-300-164) ────────────── */
/* Persistent strip below the composer. Cannot be dismissed by design —
   users must always be aware they are talking to an AI that can err.   */
.ai-disclaimer {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px 2px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  line-height: 1.4;
}
.ai-disclaimer svg {
  flex-shrink: 0;
  width: 11px;
  height: 11px;
  opacity: 0.55;
}
[data-theme="dark"] .ai-disclaimer { color: var(--muted); }

/* ── Thinking / typing indicator (REQ-FIS-001 streaming UX) ───── */
.thinking-bubble {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  padding: 14px 18px;
  min-width: 200px;
  max-width: 300px;
}
.t-dots-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.t-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-2, #888);
  opacity: 0.4;
  animation: tBounce 1.3s ease-in-out infinite;
}
.t-dot:nth-child(2) { animation-delay: 0.18s; }
.t-dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes tBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-6px); opacity: 1; }
}
.t-label {
  font-size: 0.76rem;
  color: var(--ink-2, #888);
  font-style: italic;
  line-height: 1.4;
  margin: 0;
  animation: tLabelFade 0.4s ease;
}
@keyframes tLabelFade {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Cold-start notice (inside ThinkingBubble) ───────────────────
   Shown only when isColdStart=true: backend hasn't sent message_start
   within 12s, meaning Render/HF Space is cold-starting (~60–90s).
   Fades in smoothly; disappears the moment the SSE stream begins.    */
.cold-start-active {
  min-width: 260px;
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE BOTTOM SHEETS (≤600px)
   Panels slide up from the bottom instead of floating on the sides.
   Side tab-float buttons are replaced by a fixed bottom tab bar.
   ═══════════════════════════════════════════════════════════════════ */

/* Hidden at desktop — shown only in the mobile media query below */
.mobile-tabbar { display: none; }
.sheet-backdrop { display: none; }

@media (max-width: 600px) {
  /* ── Side panel → bottom sheet ─────────────────────────────────── */
  .chat.floating .panel.left,
  .chat.floating .panel.right {
    /* Override the fixed side-card positioning */
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 82vh;
    border-radius: 18px 18px 0 0;
    border: 1px solid var(--line-soft);
    border-bottom: 0;
    /* Slide-up entrance animation */
    animation: sheet-up 0.28s cubic-bezier(0.4, 0, 0.2, 1) both;
    z-index: 50;
    /* Safe-area padding for phones with home indicator */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Drag handle pill above the panel header */
  .chat.floating .panel.left .panel-head,
  .chat.floating .panel.right .panel-head {
    position: relative;
    padding-top: 22px;
  }
  .chat.floating .panel.left .panel-head::before,
  .chat.floating .panel.right .panel-head::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: var(--line);
    border-radius: 2px;
  }

  /* ── Backdrop ──────────────────────────────────────────────────── */
  .sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: fade-in 0.2s ease both;
    cursor: pointer;
  }

  /* ── Side tab-float → hidden (replaced by mobile tabbar) ──────── */
  .tab-float { display: none !important; }

  /* ── Mobile bottom tab bar ─────────────────────────────────────── */
  .mobile-tabbar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    background: color-mix(in oklch, var(--surface) 96%, transparent);
    border-top: 1px solid var(--line-soft);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    /* Safe-area inset for phones with home indicator */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .mobile-tabbar .mtab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 0 12px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color var(--t-fast);
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-tabbar .mtab svg {
    width: 20px;
    height: 20px;
  }
  .mobile-tabbar .mtab.active { color: var(--accent-2); }
  .mobile-tabbar .mtab.sources.active { color: var(--sun); }

  /* ── Composer: lift above the tab bar ─────────────────────────── */
  .chat.floating .composer-wrap {
    bottom: calc(52px + env(safe-area-inset-bottom, 0px) + 8px);
    left: 10px;
    right: 10px;
  }
  /* Extra thread padding for composer + tabbar stack */
  .chat.floating .thread {
    padding-bottom: 240px;
  }

  /* ── Topbar: tighter on mobile ─────────────────────────────────── */
  .topbar.floating {
    top: 8px;
    left: 8px;
    right: 8px;
  }
  .pillbar .brand-mini .wordmark { font-size: 16px; }
}

/* ── Slide-up keyframe (reused by bottom sheets) ─────────────────── */
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — PHONE SIZING (≤480px)
   Font sizes, padding, gate card, modals, touch targets.
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  /* Gate card */
  .gate-card {
    padding: 28px 20px 22px;
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
  }
  .gate-title { font-size: 28px; }
  .gate { align-items: flex-end; padding: 0; }

  /* Modals — full-width bottom sheet */
  .modal-veil { align-items: flex-end; padding: 0; }
  .modal {
    width: 100%;
    max-height: 95vh;
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    padding: 24px 20px 0;
  }

  /* Mood diary — larger touch targets */
  .mood-chip { padding: 7px 13px; font-size: 13px; min-height: 36px; }
  .pip { min-width: 28px; height: 28px; font-size: 12px; }

  /* Topbar pills — hide non-essential on very narrow screens */
  /* Hide research-preview pill on very narrow phones — wraps awkwardly */
  .pillbar .research-pill { display: none; }
}
