:root {
  --bg: #f1f1ef;
  --surface: #fbfbfa;
  --sunken: #eeeeec;
  --line: #dcdcda;
  --ink: #1c1c1e;
  --ink-body: #3a3a3d;
  --ink-soft: #8a8a8e;
  --ink-faint: #b3b3b0;
  --accent: #55606f;
  --error: #a3402f;
  --shadow-lifted: 0 1px 2px rgba(0,0,0,.03), 0 16px 32px -16px rgba(0,0,0,.16);
  --shadow-composer: 0 1px 2px rgba(0,0,0,.03), 0 14px 32px -14px rgba(0,0,0,.14);
  --shadow-bubble: 0 1px 2px rgba(0,0,0,.04), 0 10px 24px -12px rgba(0,0,0,.25);
  --font: 'Space Grotesk', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
/* The app shell is a fixed-viewport layout — every scrollable region (.messages,
   .shell-body, .compact-stack) manages its own overflow already, so the outer
   page should never need to scroll at all. If it ever does by a stray px (flex/
   padding rounding), overflow:hidden here removes that scrollbar entirely rather
   than trying to keep re-styling one that shouldn't exist in the first place. */
html, body { height: 100%; overflow: hidden; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--accent); }
a:hover { color: var(--ink); }

/* ── login ── */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.login-card {
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lifted);
  padding: 2.5rem 2rem; max-width: 23rem; width: 100%;
}
.mark { height: 34px; width: auto; display: block; color: var(--ink); }
.mark text { font-family: 'Georgia', serif; }
.login-card h1 { font-size: 1.25rem; font-weight: 600; margin: 1.1rem 0 .4rem; }
.login-card .sub { color: var(--ink-soft); font-size: .9rem; line-height: 1.5; margin: 0 0 1.5rem; }
.login-card form { display: flex; flex-direction: column; gap: .7rem; }
.login-card input {
  border: 1px solid var(--line); border-radius: 12px; padding: .75rem 1rem; font-size: .95rem;
  width: 100%; font-family: inherit; background: var(--bg); color: var(--ink);
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button {
  background: var(--ink); color: var(--bg); border: 0; border-radius: 12px;
  padding: .75rem; font-size: .95rem; font-weight: 500;
}
.login-card button:disabled { opacity: .5; }
.msg { color: var(--ink-soft); font-size: .9rem; line-height: 1.5; margin-top: 1rem; }

/* ── app shell — same two-pane layout as edd-shell (pi/protopi/README.md notes
   why: same team, same proven shape). Chat (left) is the constant; Shell
   (right) is elastic, absent until there's something to hold. ── */
.app { display: flex; flex-direction: column; height: 100%; }

.topbar { display: flex; align-items: center; gap: 18px; padding: 28px 40px 0; flex-shrink: 0; }
.client-tag { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.topbar .spacer { flex: 1; }
.signout {
  background: none; border: 0; padding: 0; width: 32px; height: 32px; border-radius: 50%;
  color: var(--ink-soft); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.signout:hover { background: var(--sunken); color: var(--ink); }

.stage { flex: 1; position: relative; min-height: 0; }

.chat-area { height: 100%; display: flex; flex-direction: column; min-height: 0; max-width: 800px; width: 100%; margin: 0 auto; padding: 44px 40px 32px; }

body.dock .stage { display: flex; }
body.dock .chat-area { flex: 0 0 400px; max-width: 400px; width: 400px; margin: 0; }
.section-label {
  font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 24px; flex-shrink: 0;
}
.shell-area .section-label { padding-left: 22px; }
.messages {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; min-height: 0;
  padding: 4px 20px 26px 0; scrollbar-gutter: stable;
}

.messages, .shell-body, .compact-stack {
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,.2) transparent;
}
.messages::-webkit-scrollbar, .shell-body::-webkit-scrollbar, .compact-stack::-webkit-scrollbar { width: 6px; background: transparent; }
.messages::-webkit-scrollbar-track, .shell-body::-webkit-scrollbar-track, .compact-stack::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb, .shell-body::-webkit-scrollbar-thumb, .compact-stack::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.2); border-radius: 999px;
}
.messages::-webkit-scrollbar-thumb:hover, .shell-body::-webkit-scrollbar-thumb:hover, .compact-stack::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.35); }
.m { max-width: 90%; font-size: 15px; line-height: 1.6; }
.m p { margin: 0 0 10px; }
.m p:last-child { margin-bottom: 0; }
.m ul { margin: 4px 0 10px; padding-left: 20px; }
.m ul:last-child { margin-bottom: 0; }
.m li { margin: 3px 0; }
.m code {
  background: var(--sunken); color: var(--ink); padding: 2px 6px; border-radius: 6px;
  font-size: .9em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.m a { color: var(--accent); text-decoration: underline; text-decoration-color: rgba(85,96,111,.35); word-break: break-word; }
.m a:hover { color: var(--ink); }

.m.assistant { align-self: flex-start; color: var(--ink-body); }
.m.user {
  align-self: flex-end; background: var(--ink); color: var(--bg);
  font-size: 14.5px; line-height: 1.55; padding: 12px 18px;
  border-radius: 16px 16px 4px 16px; box-shadow: var(--shadow-bubble);
}
.m.user code { background: rgba(255,255,255,.14); color: var(--bg); }
.m.user a { color: var(--bg); text-decoration-color: rgba(241,241,239,.55); }
.m.user a:hover { color: #fff; }
.m.status { align-self: flex-start; color: var(--ink-soft); font-size: 13.5px; font-style: italic; }
/* Loading indicator = the spinning spark, not pulsing dots - shared base-theme
   decision (Paul, 15 Sep 2026): same glyph + same CSS technique as Scoper's
   asterisk-btn spin (transform-box:fill-box + transform-origin:center is what
   makes an off-center path rotate around its own visual middle, not the
   viewBox origin). ProtoPi and Scoper draw the identical spark asset, so this
   is one design decision applied twice, not two - and edd-shell's own dots
   are the one still left on the old pattern, to fold in whenever it's next
   touched, not urgently. */
.m.status.typing { display: flex; gap: 8px; align-items: center; padding: 2px 0; }
.spark-spin { width: 16px; height: 16px; flex-shrink: 0; color: var(--ink-faint); }
.spark-spin path { transform-box: fill-box; transform-origin: center; animation: spark-spin 1s linear infinite; }
@keyframes spark-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.m.error { align-self: flex-start; color: var(--error); font-size: 14.5px; }

.composer-wrap { padding: 24px 0 8px; flex-shrink: 0; }
.composer {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--surface); border-radius: 22px; padding: 8px 8px 8px 20px;
  box-shadow: var(--shadow-composer);
}
.composer textarea {
  flex: 1; resize: none; max-height: 8rem; border: 0; background: transparent;
  font-family: inherit; font-size: 14.5px; line-height: 1.5; color: var(--ink); padding: 8px 0;
}
.composer textarea:focus { outline: none; }
.composer textarea::placeholder { color: var(--ink-faint); }
.send-btn {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--ink); color: var(--bg); border: 0;
  display: flex; align-items: center; justify-content: center;
}
.send-btn:disabled { opacity: .5; }

/* right: shell — elastic, absent until there's something to hold. */
.shell-area {
  position: absolute; top: 44px; right: 40px; bottom: 40px;
  max-width: 460px; display: flex; flex-direction: column;
}
body.dock .shell-area { position: static; flex: 1; max-width: none; width: auto; padding: 44px 40px 40px 0; }
.shell-body {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; min-height: 0;
  padding: 6px 22px 36px 22px; scrollbar-gutter: stable;
}
body.dock .shell-body { flex-direction: row; align-items: stretch; overflow: visible; padding: 6px 0 0 0; gap: 18px; }
.compact-stack {
  display: flex; flex-direction: column; gap: 16px; flex-shrink: 0;
}
body.dock .compact-stack {
  width: 424px; overflow-y: auto; padding: 0 22px 36px 22px;
}

.card { position: relative; width: 380px; max-width: 100%; background: var(--surface); border-radius: 18px; padding: 20px; box-shadow: var(--shadow-lifted); flex-shrink: 0; }
.card.wide { width: 100%; }
.card-close {
  position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; border-radius: 50%;
  background: transparent; border: 0; color: var(--ink-faint);
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.card-close:hover { background: var(--sunken); color: var(--ink); }
.site-embed { margin-top: 14px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.site-embed iframe { display: block; width: 100%; height: min(78vh, 820px); border: 0; background: var(--bg); }

body.dock .card.wide { display: flex; flex-direction: column; height: 100%; flex: 1; min-width: 0; width: auto; }
body.dock .site-embed { flex: 1; min-height: 0; }
body.dock .site-embed iframe { height: 100%; }
.card h3 { margin: 0 0 8px; padding-right: 22px; font-size: 14.5px; font-weight: 600; }
.card p { margin: 0; font-size: 13px; line-height: 1.55; color: var(--ink-soft); }
.card .hint { margin-top: 10px; font-size: 12px; color: var(--ink-faint); }
.card a.button {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 14px;
  background: var(--ink); color: var(--bg); text-decoration: none;
  padding: 11px 18px; border-radius: 14px; font-size: 13.5px; font-weight: 500;
}
.card a.button:hover { opacity: .85; color: var(--bg); }

@media (max-width: 860px) {
  .stage, body.dock .stage { display: flex; flex-direction: column; gap: 20px; }
  .chat-area, body.dock .chat-area { max-width: none; width: 100%; flex: none; padding: 24px 20px 20px; }
  .shell-area, body.dock .shell-area {
    position: static; width: 100%; max-width: none; max-height: 46vh; padding: 0 20px 20px; flex: none;
  }
  .shell-body, body.dock .shell-body { flex-direction: column; overflow-y: auto; padding: 2px 4px 8px 0; }
  .compact-stack, body.dock .compact-stack { width: 100%; overflow: visible; padding: 0; }
}
