/* ───────────────────────────────────────────────────────────────────────
   SenseiLab — "daylight studio" theme.
   White surfaces, ink typography, indigo accents; calm, modern, airy.
   ─────────────────────────────────────────────────────────────────────── */
:root {
  --bg:         #FFFFFF;
  --ink:        #FFFFFF;   /* card surface */
  --ink-raise:  #F4F5F8;   /* raised / inset surface */
  --ink-deep:   #FAFAFC;   /* wells (inputs, pre) */
  --line:       #E6E8EF;
  --line-strong:#D4D7E1;
  --text:       #14161F;
  --text-dim:   #6B7280;

  --accent:      #0E7490;  /* deep teal — primary actions & links */
  --accent-deep: #155E75;
  --accent-soft: #E3F4F8;
  --leaf:        #0A9469;  /* emerald — synced / live / success */
  --leaf-deep:   #0A7D5A;
  --leaf-soft:   #E6F6F0;
  --blush:       #DC2653;  /* errors */
  --amber:       #A16207;  /* credits & costs */
  --sky:         #0369A1;

  /* device illustration palette (used inside the SVGs) */
  --dev-body:   #262833;
  --dev-screen: #12131A;
  --dev-strap:  #26283330;

  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 22, 31, .05);
  --shadow-md: 0 6px 24px -6px rgba(20, 22, 31, .12);
  --font-display: "Sora", "Manrope", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
  --font-data: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; letter-spacing: -.015em; }
h1 { font-size: 1.9rem; margin: 0 0 .4rem; }
h2 { font-size: 1.3rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p.lede { color: var(--text-dim); max-width: 58ch; margin-top: 0; }

/* ── top bar ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 1.6rem;
  padding: .65rem 1.4rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-family: var(--font-display); font-weight: 700; font-size: 1.12rem; color: var(--text); letter-spacing: -.02em; white-space: nowrap; display: inline-flex; align-items: center; gap: .45rem; }
.brand em { color: var(--text); font-style: normal; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; border-radius: 6px; flex: none; }
.brand-mark-big { width: 42px; height: 42px; border-radius: 10px; vertical-align: -9px; margin-right: .15rem; }
.topnav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topnav a {
  color: var(--text-dim); font-weight: 500; font-size: .9rem;
  padding: .32rem .8rem; border-radius: 999px;
}
.topnav a:hover { color: var(--text); background: var(--ink-raise); text-decoration: none; }
.topnav a.active { color: var(--accent-deep); background: var(--accent-soft); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .8rem; }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: .4rem .9rem; }
  .topnav { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: .2rem; }
  .topnav a { white-space: nowrap; }
}
.credits-chip {
  font-family: var(--font-data); font-size: .78rem;
  background: #FFF9EB; border: 1px solid #F2E3BC;
  color: var(--amber); padding: .25rem .65rem; border-radius: 999px;
}
.inline-form { display: inline; }

/* ── layout ──────────────────────────────────────────────────────────── */
.page { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 1.8rem 1.4rem 3rem; }
.footer { text-align: center; color: var(--text-dim); font-size: .8rem; padding: 1.2rem; border-top: 1px solid var(--line); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  box-shadow: var(--shadow-sm);
}
.card h2:first-child, .card h3:first-child { margin-top: 0; }

/* ── forms & buttons ─────────────────────────────────────────────────── */
label { display: block; font-weight: 600; font-size: .85rem; margin: .8rem 0 .25rem; }
input[type=text], input[type=password], input[type=email], input[type=number],
select, textarea {
  width: 100%; background: var(--ink-deep); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 10px;
  padding: .55rem .7rem; font-family: var(--font-body); font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
}
textarea { font-family: var(--font-data); font-size: .88rem; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.helptext, .form-hint { color: var(--text-dim); font-size: .78rem; display: block; margin-top: .2rem; }
.errorlist { color: var(--blush); list-style: none; padding: 0; margin: .2rem 0; font-size: .85rem; }

.btn {
  display: inline-block; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--ink); color: var(--text);
  font-family: var(--font-body); font-weight: 600; font-size: .9rem;
  padding: .5rem 1.1rem; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .08s ease, background .15s, border-color .15s;
}
.btn:hover { background: var(--ink-raise); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-deep); }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); background: var(--ink-raise); }
.btn-sm { font-size: .78rem; padding: .3rem .8rem; }
.btn-danger { border-color: #F3C4CF; color: var(--blush); background: transparent; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ── flashes ─────────────────────────────────────────────────────────── */
.flashes { max-width: 1180px; margin: .8rem auto 0; padding: 0 1.4rem; }
.flash { border-radius: 10px; padding: .55rem .9rem; margin-bottom: .5rem; font-size: .9rem; border: 1px solid var(--line); background: var(--ink-raise); }
.flash-success { border-color: var(--leaf); background: var(--leaf-soft); color: var(--leaf-deep); }
.flash-error { border-color: var(--blush); background: #FDF0F3; color: var(--blush); }

/* ── tables ──────────────────────────────────────────────────────────── */
table.data { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.data th { text-align: left; color: var(--text-dim); font-weight: 600; padding: .4rem .5rem; border-bottom: 1px solid var(--line-strong); }
table.data td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); }
.mono { font-family: var(--font-data); }
.tag { display: inline-block; font-size: .7rem; font-weight: 600; padding: .12rem .55rem; border-radius: 999px; background: var(--ink-raise); border: 1px solid var(--line); color: var(--text-dim); }
.tag-live { color: var(--leaf-deep); border-color: #BCE5D4; background: var(--leaf-soft); }
.tag-dead { color: var(--blush); border-color: #F3C4CF; background: #FDF0F3; }

/* ── auth pages ──────────────────────────────────────────────────────── */
.auth-wrap { max-width: 430px; margin: 3rem auto; }
.auth-wrap .brand-big { font-family: var(--font-display); font-weight: 700; font-size: 2.1rem; text-align: center; display: block; margin-bottom: 1.2rem; letter-spacing: -.02em; }
.auth-wrap .brand-big em { font-style: normal; }

/* ════════════════════════ AGENT BUILDER ═══════════════════════════════ */
.builder { display: grid; grid-template-columns: 290px 1fr; gap: 1.3rem; align-items: start; }
@media (max-width: 900px) { .builder { grid-template-columns: 1fr; } }
.block-rail { position: sticky; top: 4.4rem; max-height: calc(100vh - 6rem); overflow-y: auto; }
.block-cat { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--text-dim); margin: 1rem 0 .35rem; font-weight: 600; }
.block-cat:first-child { margin-top: 0; }
.block-chip {
  width: 100%; text-align: left; background: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: .5rem .7rem; margin-bottom: .45rem;
  color: var(--text); cursor: pointer; font-family: var(--font-body);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, transform .08s;
}
.block-chip:hover { border-color: var(--accent); }
.block-chip:active { transform: scale(.985); }
.block-chip strong { display: block; font-size: .85rem; }
.block-chip span { font-size: .73rem; color: var(--text-dim); }
.builder-meta { display: grid; grid-template-columns: 2fr 70px 1fr 1fr 90px; gap: .7rem; }
@media (max-width: 900px) { .builder-meta { grid-template-columns: 1fr 1fr; } }
.emoji-picker { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-top: .6rem; }
.emoji-chip {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--ink-deep); font-size: 1.05rem; line-height: 1; cursor: pointer;
  display: grid; place-items: center; transition: border-color .15s, transform .08s;
}
.emoji-chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.emoji-chip.active { border-color: var(--accent); background: var(--accent-soft); }

/* ════════════════════════ PHONE SIMULATOR ═════════════════════════════ */
.steps-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr) 384px; gap: 1.6rem; align-items: start; }
@media (max-width: 1120px) { .steps-layout { grid-template-columns: 1fr; justify-items: stretch; } }

/* step sections: 1 unlocks 2 unlocks 3 */
.step-head { display: flex; align-items: center; gap: .65rem; margin-bottom: .8rem; }
.step-head h2 { margin: 0; font-size: 1.05rem; }
.step-head small { color: var(--text-dim); display: block; font-size: .76rem; }
.step-num {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: .9rem;
  background: var(--ink-raise); border: 1px solid var(--line-strong); color: var(--text-dim);
  transition: background .2s, color .2s, border-color .2s;
}
.step-num::before { content: attr(data-num); }
.step.active .step-num { background: var(--accent); border-color: var(--accent); color: #fff; }
.step.done .step-num { background: var(--leaf); border-color: var(--leaf); color: #fff; }
.step.done .step-num::before { content: "✓"; }
.step.locked .step-num::before { content: "🔒"; font-size: .7rem; }
.step.locked .step-body {
  opacity: .4; pointer-events: none; user-select: none;
  filter: grayscale(.5); transition: opacity .25s;
}
.step-body { transition: opacity .25s; }

.persona-input { margin-top: .4rem; }

/* sync bar under the library */
.sync-bar { display: flex; align-items: center; gap: .8rem; margin-top: 1rem; }
.sync-bar small { color: var(--text-dim); }

/* CTA above the phone */
.phone-cta { width: 100%; margin-bottom: .35rem; }
.phone-cta-note { display: block; color: var(--text-dim); font-size: .76rem; text-align: center; margin-bottom: .7rem; }
.phone-cta-row { display: flex; gap: .5rem; margin-bottom: .9rem; }
.phone-cta-row .btn { flex: 1; text-align: center; }

/* the phone itself: dark hardware around a light screen */
.phone {
  width: 384px; height: 730px;
  background: #101116;
  border-radius: 42px;
  border: 1px solid #101116;
  box-shadow: var(--shadow-md), inset 0 0 0 6px #1D1E26;
  display: flex; flex-direction: column; overflow: hidden; position: relative;
}
.phone::before { /* notch */
  content: ""; position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  width: 110px; height: 22px; border-radius: 12px; background: #1D1E26; z-index: 5;
}
.phone-status {
  display: flex; justify-content: space-between; font-family: var(--font-data);
  font-size: .68rem; color: #8B8FA3; padding: .55rem 1.6rem .2rem;
  background: #F6F6F9;
}
.chat-header {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .9rem;
  background: #F6F6F9; border-bottom: 1px solid var(--line);
}
.chat-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); display: grid; place-items: center; font-size: 1.1rem; }
.chat-title { font-weight: 600; font-size: .92rem; line-height: 1.1; color: var(--text); }
.chat-sub { font-size: .7rem; color: var(--leaf); }
.chat-scroll { flex: 1; overflow-y: auto; padding: .9rem .8rem; display: flex; flex-direction: column; gap: .45rem; background: #FDFDFE; }
.bubble {
  max-width: 78%; padding: .5rem .75rem; border-radius: 16px;
  font-size: .88rem; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word;
  animation: bubble-in .18s ease;
}
@keyframes bubble-in { from { opacity: 0; transform: translateY(5px); } }
.bubble-user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble-bot { align-self: flex-start; background: #F1F2F6; color: var(--text); border-bottom-left-radius: 4px; }
.bubble-system { align-self: center; background: transparent; color: var(--text-dim); font-size: .72rem; text-align: center; }
.typing { display: inline-flex; gap: 4px; padding: .6rem .8rem; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chat-input { display: flex; gap: .5rem; padding: .6rem .7rem .9rem; background: #F6F6F9; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; border-radius: 999px; background: #fff; }
.chat-input button { border-radius: 50%; width: 42px; height: 42px; padding: 0; font-size: 1rem; }

/* ── the nightstand: device dock (signature element) ─────────────────── */
.dock-title { display: flex; align-items: baseline; gap: .6rem; }
.dock-title small { color: var(--text-dim); }
.dock-quick { margin-left: auto; font-size: .74rem; color: var(--text-dim); white-space: nowrap; }
.dock-quick button {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--accent); font: inherit; font-weight: 600;
}
.dock-quick button:hover { text-decoration: underline; }
.dock-tabs, .seg-tabs {
  display: inline-flex; gap: .2rem; margin-top: .8rem;
  background: var(--ink-raise); border: 1px solid var(--line); border-radius: 12px; padding: .22rem;
}
.dock-tab, .seg-tab {
  background: transparent; border: none; color: var(--text-dim);
  border-radius: 9px; padding: .32rem .95rem; font-size: .8rem; font-weight: 600;
  font-family: var(--font-body); cursor: pointer; transition: color .15s, background .15s;
}
.dock-tab:hover, .seg-tab:hover { color: var(--text); }
.dock-tab.active, .seg-tab.active { color: var(--text); background: #fff; box-shadow: var(--shadow-sm); }
.seg-tabs { margin: .2rem 0 1.2rem; }
.pane > .card:only-child, .pane .grid-2 { margin-top: 0; }
.dock-tab-count { color: var(--accent); }
.rec-when { color: var(--text-dim); font-weight: 400; font-size: .68rem; margin-left: .3rem; }
.dock { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: .8rem; margin-top: .8rem; }
.device {
  position: relative; background: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .7rem .6rem .6rem; text-align: center;
  cursor: pointer; transition: border-color .2s, box-shadow .2s, transform .12s;
  user-select: none; box-shadow: var(--shadow-sm);
}
.device:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.device svg { width: 64px; height: 64px; display: block; margin: 0 auto .3rem; }
.device .dev-name { font-size: .78rem; font-weight: 600; line-height: 1.15; }
.device .dev-brand { font-size: .66rem; color: var(--text-dim); }
.device .dev-check {
  position: absolute; top: .45rem; right: .5rem; width: 18px; height: 18px;
  border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center;
  font-size: .62rem; color: transparent; background: #fff;
}
.device.selected { border-color: var(--accent); background: var(--accent-soft); }
.device.selected .dev-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.device.synced { border-color: var(--leaf); background: #fff; box-shadow: 0 0 0 3px var(--leaf-soft); }
.device.synced .dev-check { background: var(--leaf); border-color: var(--leaf); color: #fff; }
.device.synced::after {
  content: ""; position: absolute; inset: -1px; border-radius: var(--radius);
  border: 1px solid var(--leaf); animation: pulse 2.4s infinite; pointer-events: none;
}
@keyframes pulse { 0% { opacity: .9; } 70% { opacity: 0; transform: scale(1.05); } 100% { opacity: 0; } }
.device .dev-headline {
  font-family: var(--font-data); font-size: .64rem; color: var(--leaf-deep);
  margin-top: .3rem; min-height: 1em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) {
  .device.synced::after, .bubble, .typing i { animation: none; }
}

/* persona summary strip */
.persona-strip {
  margin-top: .9rem; border-left: 3px solid var(--accent); padding: .5rem .8rem;
  background: var(--accent-soft); border-radius: 0 10px 10px 0; font-size: .85rem; color: var(--text);
}
.persona-strip strong { color: var(--accent-deep); }
.flags { margin-top: .4rem; display: flex; flex-wrap: wrap; gap: .35rem; }

/* today's story card (experimenter-only ground truth) */
.story-head { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; margin-bottom: .3rem; }
.story-caption { color: var(--text-dim); font-size: .72rem; font-style: italic; }
.story-bio { font-size: .82rem; color: var(--text); margin-bottom: .35rem; }
.story-timeline { margin-top: .55rem; }
.story-timeline summary {
  cursor: pointer; font-size: .78rem; font-weight: 600; color: var(--accent-deep);
}
.timeline { list-style: none; margin: .5rem 0 0; padding: 0; }
.timeline li {
  display: flex; gap: .7rem; padding: .35rem 0;
  border-top: 1px dashed var(--line); font-size: .8rem;
}
.tl-time { flex: 0 0 5.6rem; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-body { display: block; }
.tl-body b { font-weight: 600; }
.tl-dur { color: var(--text-dim); font-weight: 400; }
.tl-detail { display: block; color: var(--text-dim); }

/* device readings modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 22, 31, .45); backdrop-filter: blur(3px);
  display: none; place-items: center; z-index: 50;
}
.modal-backdrop.open { display: grid; }
.modal {
  width: min(480px, 92vw); max-height: 80vh; overflow-y: auto;
  background: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.3rem; box-shadow: var(--shadow-md);
}
.modal h3 { display: flex; align-items: center; gap: .6rem; margin-top: 0; }
.modal h3 svg { width: 40px; height: 40px; }
.modal pre { background: var(--ink-deep); border: 1px solid var(--line); border-radius: 10px; padding: .8rem; font-size: .76rem; overflow-x: auto; }
.reading-row { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem 0; border-bottom: 1px dashed var(--line-strong); font-size: .86rem; }
.reading-row b { color: var(--text-dim); font-weight: 500; text-transform: capitalize; }
.reading-row span { font-family: var(--font-data); color: var(--leaf-deep); text-align: right; }

/* dashboard cards */
.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin: 1rem 0 1.4rem; }
.stat {
  background: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem 1.2rem; min-width: 150px; box-shadow: var(--shadow-sm);
}
.stat .num { font-family: var(--font-display); font-weight: 700; font-size: 1.7rem; color: var(--accent); }
.stat .lbl { font-size: .75rem; color: var(--text-dim); }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: .45rem 0; border-bottom: 1px dashed var(--line-strong); display: flex; justify-content: space-between; gap: 1rem; font-size: .9rem; }
