/* =========================================================================
   APEX · QC DISPATCH
   Editorial newsprint × ops terminal. Cream paper, deep ink, vermilion signal.
   ========================================================================= */

:root {
  --paper:        #ffffff;
  --paper-2:      #f5f8ff;
  --paper-3:      #e6eeff;
  --ink:          #0b1e4a;        /* deep navy */
  --ink-2:        #14306b;
  --muted:        #56688f;
  --muted-2:      #8d9cbd;
  --rule:         #d6deef;
  --rule-2:       #b6c4e2;
  --signal:       #1d4ed8;        /* royal blue */
  --signal-soft:  #dbe6ff;
  --signal-deep:  #1e3a8a;
  --good:         #0e7490;
  --good-soft:    #d6eef5;
  --bad:          #b91c1c;

  --font-display: "Inter", -apple-system, system-ui, sans-serif;
  --font-body:    "Inter", -apple-system, system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  --rail: 240px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv01", "cv02";
  overflow: hidden;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

a { color: var(--ink); text-decoration-color: var(--rule-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--signal); }

/* ---------- paper grain overlay ---------- */
.grain {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.35;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.08  0 0 0 0 0.12  0 0 0 0 0.24  0 0 0 0.05 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: multiply;
}

/* ---------- shared utility ---------- */
.kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.rule { border: 0; border-top: 1px solid var(--rule); margin: 0; }
.rule-ink { border: 0; border-top: 1.5px solid var(--ink); margin: 0; }

/* =========================================================================
   LOGIN
   Split layout: editorial brand statement on the left, surgical form on the right.
   ========================================================================= */

.login-shell {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  min-height: 100vh;
}
@media (max-width: 820px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { padding: 48px 36px !important; min-height: auto !important; }
}

.login-brand {
  background: var(--ink);
  color: var(--paper);
  padding: 64px 72px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  min-height: 100vh;
}
.login-brand::after {
  /* faint vermilion glyph in the corner */
  content: "";
  position: absolute;
  right: -120px; bottom: -120px;
  width: 480px; height: 480px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 50%;
  pointer-events: none;
}
.login-brand::before {
  content: "";
  position: absolute;
  right: 60px; top: 60px;
  width: 8px; height: 8px;
  background: var(--signal);
  border-radius: 50%;
  box-shadow: 0 0 24px var(--signal);
}

.brand-masthead {
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.brand-masthead .glyph {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 34px;
  letter-spacing: -0.02em;
  color: var(--signal);
}
.brand-masthead .name {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--paper);
  opacity: 0.85;
}

.brand-statement {
  max-width: 520px;
}
.brand-statement h1 {
  font-family: var(--font-display);
  font-weight: 300;
  font-style: normal;
  font-size: clamp(40px, 4.6vw, 68px);
  line-height: 1.02;
  letter-spacing: -0.025em;
  margin: 0 0 28px;
  color: var(--paper);
  font-variation-settings: "opsz" 96, "SOFT" 30;
  overflow-wrap: break-word;
  word-break: normal;
}
.brand-statement h1 em {
  font-style: italic;
  color: var(--signal);
  font-weight: 400;
}
.brand-statement p {
  font-size: 16px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.72);
  max-width: 420px;
  margin: 0;
}

.brand-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}
.brand-footer .vol {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand-footer .vol span:first-child {
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
}

/* Login form pane */
.login-form-pane {
  background: var(--paper);
  padding: 64px 72px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
@media (max-width: 820px) {
  .login-form-pane { padding: 44px 28px; }
}
.login-card {
  width: 100%;
  max-width: 420px;
}
.login-card .eyebrow { margin-bottom: 18px; }
.login-card h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-size: 40px;
  line-height: 1.05;
  letter-spacing: -0.018em;
  margin: 0 0 12px;
  color: var(--ink);
}
.login-card .lede {
  color: var(--muted);
  margin: 0 0 36px;
  max-width: 360px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
}
.field label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input[type="password"],
.field input[type="text"] {
  background: transparent;
  border: 0;
  border-bottom: 1.5px solid var(--ink);
  padding: 10px 0;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink);
  outline: none;
  border-radius: 0;
}
.field input::placeholder { color: var(--muted-2); font-family: var(--font-mono); }
.field input:focus { border-bottom-color: var(--signal); }
.field .hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}
.field .hint code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--paper-3);
  padding: 1px 6px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  background: var(--signal);
  color: var(--paper-2);
  border: 0;
  padding: 16px 22px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  transition: transform 80ms ease, background 120ms ease;
  border-radius: 0;
}
.btn-primary:hover { background: var(--signal-deep); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary::after {
  content: "→";
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0;
  transform: translateY(-1px);
}

.alert {
  background: var(--paper-2);
  border-left: 2px solid var(--bad);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--bad);
  margin-bottom: 22px;
  font-family: var(--font-mono);
}

.login-altlink {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--paper-3);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.login-altlink a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--paper-3); }
.login-altlink a:hover { color: var(--ink); border-bottom-color: var(--ink); }

/* =========================================================================
   CHAT SHELL
   Thin masthead rail (left) + wide reading column (right).
   ========================================================================= */

.app {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  height: 100vh;
}
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .rail { border-right: 0 !important; border-bottom: 1px solid var(--rule); }
}

.rail {
  border-right: 1px solid var(--rule);
  background: var(--paper-2);
  display: flex;
  flex-direction: column;
  padding: 28px 24px;
  gap: 28px;
  position: relative;
  min-height: 0;
  overflow-y: auto;
}
.rail .masthead {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rail .masthead .mark {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 32px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.rail .masthead .mark .dot {
  color: var(--signal);
  font-style: normal;
}
.rail .masthead .tagline {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 6px;
}

.rail-block {
  border-top: 1px solid var(--rule);
  padding-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rail-block .eyebrow { margin-bottom: 4px; }
.rail-block .live-date {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.1;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.rail-block .live-date .day {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--signal);
  margin-bottom: 4px;
}

.rail .examples {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.rail .examples .example-q {
  display: block;
  padding: 10px 0;
  border-bottom: 1px dashed var(--rule);
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink-2);
  cursor: pointer;
  transition: color 100ms ease, padding-left 120ms ease;
}
.rail .examples .example-q:hover {
  color: var(--signal);
  padding-left: 6px;
}
.rail .examples .example-q::before {
  content: "› ";
  color: var(--signal);
  font-family: var(--font-mono);
}

.rail .note {
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  font-style: italic;
  font-family: var(--font-display);
  margin-top: 4px;
}

.rail .spacer { flex: 1; }

.rail .rail-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--rule);
  padding-top: 18px;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--ink);
  color: var(--ink);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: center;
  border-radius: 0;
  transition: background 100ms ease, color 100ms ease;
}
.btn-ghost:hover { background: var(--ink); color: var(--paper); }
.btn-ghost.reset { border-color: var(--rule-2); color: var(--muted); }
.btn-ghost.reset:hover { background: var(--paper-3); color: var(--ink); border-color: var(--ink); }

.rail form { margin: 0; }

/* ---------- main reading column ---------- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.main-head {
  padding: 22px 56px 18px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  background: var(--paper);
}
.main-head h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 28px;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--ink);
}
.main-head h1 em {
  font-style: italic;
  color: var(--signal);
  font-weight: 400;
}
.main-head .meta {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: right;
}

.thread {
  flex: 1;
  overflow-y: auto;
  padding: 36px 56px 24px;
  scroll-behavior: smooth;
}
/* When only the empty state is present (no conversation yet), center it
   vertically and horizontally in the available thread height. */
.thread:has(> #empty-state) {
  display: flex;
  flex-direction: column;   /* keep stacking vertical even if a stray
                               empty-state lingers alongside messages */
  align-items: center;
  justify-content: center;
  padding: 24px 56px;
}
@media (max-width: 720px) {
  .main-head { padding: 18px 24px; }
  .thread { padding: 24px 24px 16px; }
}
.thread::-webkit-scrollbar { width: 10px; }
.thread::-webkit-scrollbar-thumb { background: var(--rule-2); }
.thread::-webkit-scrollbar-track { background: transparent; }

.empty-state {
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  text-align: left;
}
.empty-state .stamp {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--signal);
  margin-bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.empty-state .stamp::before {
  content: "";
  display: inline-block;
  width: 24px; height: 1.5px;
  background: var(--signal);
}
.empty-state h2 {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(32px, 3.6vw, 48px);
  line-height: 1.02;
  letter-spacing: -0.022em;
  margin: 0 0 16px;
  color: var(--ink);
  font-variation-settings: "opsz" 144, "SOFT" 50;
}
.empty-state p {
  font-size: 15px;
  color: var(--muted);
  max-width: 480px;
  margin: 0 0 24px;
}

/* ---------- empty-state suggestion grid (prominent) ---------- */
.suggestion-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 1.5px solid var(--ink);
  border-left: 1px solid var(--rule);
  max-width: 640px;
}
@media (max-width: 560px) {
  .suggestion-grid { grid-template-columns: 1fr; }
}
.suggestion-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 18px 16px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  position: relative;
  transition: background 120ms ease, padding-left 140ms ease;
}
.suggestion-card:hover {
  background: var(--paper-2);
  padding-left: 26px;
}
.suggestion-card:hover .suggestion-arrow { color: var(--signal); transform: translateX(2px); }
.suggestion-card .suggestion-tag {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--signal);
}
.suggestion-card .suggestion-text {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.25;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.suggestion-card .suggestion-text em { font-style: italic; }
.suggestion-card .suggestion-arrow {
  position: absolute;
  right: 16px; bottom: 14px;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--muted-2);
  transition: color 140ms ease, transform 140ms ease;
}

/* ---------- composer-area suggestion strip (always visible) ---------- */
.composer-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 980px;
  margin: 0 auto 12px;
  padding-bottom: 2px;
}
.composer-suggestions::before {
  content: "Try";
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted-2);
  align-self: center;
  margin-right: 4px;
}
.chip {
  background: transparent;
  border: 1px solid var(--rule);
  padding: 5px 11px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--muted);
  cursor: pointer;
  border-radius: 0;
  transition: all 120ms ease;
  line-height: 1.2;
  text-align: left;
}
.chip:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.chip:focus-visible {
  outline: none;
  border-color: var(--signal);
  color: var(--signal);
}


/* ---------- message rows ---------- */
.msg-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 36px;
  max-width: 760px;
}
.msg-row.user {
  align-items: flex-end;
  margin-left: auto;
}

.msg-user {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: transparent;
  border-right: 2px solid var(--signal);
  padding: 4px 16px 4px 0;
  max-width: 100%;
  white-space: pre-wrap;
  text-align: right;
}
.msg-user::before {
  content: "YOU ASKED ";
  font-size: 9px;
  letter-spacing: 0.24em;
  color: var(--muted-2);
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
}

.assistant-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-left: 1.5px solid var(--ink);
  padding-left: 22px;
  position: relative;
}
.assistant-block::before {
  content: "";
  position: absolute;
  left: -4px; top: 0;
  width: 6px; height: 6px;
  background: var(--signal);
  border-radius: 50%;
}

.tools-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 2px;
}

.tool-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: 5px 12px 5px 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-radius: 0;
  position: relative;
}
.tool-card .tool-name {
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.tool-card::before {
  content: "";
  width: 7px; height: 7px;
  background: var(--signal);
  display: inline-block;
  flex-shrink: 0;
}
.tool-card.pending::before {
  animation: pulse-dot 1.1s infinite ease-in-out;
}
.tool-card.done::before {
  background: var(--ink);
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.7); }
}

/* ---------- assistant markdown rendering ---------- */
.msg-assistant {
  color: var(--ink);
  font-size: 15.5px;
  line-height: 1.62;
}
.msg-assistant > *:first-child { margin-top: 0; }
.msg-assistant > *:last-child { margin-bottom: 0; }

.msg-assistant h1,
.msg-assistant h2,
.msg-assistant h3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 24px 0 10px;
  line-height: 1.15;
}
.msg-assistant h1 { font-size: 26px; }
.msg-assistant h2 { font-size: 22px; }
.msg-assistant h3 { font-size: 18px; font-style: italic; }
.msg-assistant p { margin: 10px 0; }
.msg-assistant strong { font-weight: 600; color: var(--ink); }
.msg-assistant em { font-style: italic; }

.msg-assistant ul, .msg-assistant ol {
  margin: 10px 0 10px 0;
  padding-left: 22px;
}
.msg-assistant li { margin: 4px 0; }
.msg-assistant li::marker { color: var(--signal); }

.msg-assistant code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--paper-3);
  padding: 1px 6px;
  border: 1px solid var(--rule);
  color: var(--ink);
}
.msg-assistant pre {
  background: var(--ink);
  color: var(--paper-2);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  overflow-x: auto;
  margin: 14px 0;
}
.msg-assistant pre code { background: transparent; border: 0; color: inherit; padding: 0; }

.msg-assistant table {
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
  font-family: var(--font-mono);
  width: 100%;
  border-top: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
}
.msg-assistant thead { border-bottom: 1px solid var(--ink); }
.msg-assistant th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 10.5px;
  color: var(--muted);
  background: transparent;
}
.msg-assistant td {
  padding: 8px 10px;
  border-top: 1px dashed var(--rule);
  color: var(--ink);
}
/* Honour markdown column alignment (marked.js emits align="..."). */
.msg-assistant th[align="right"],  .msg-assistant td[align="right"]  { text-align: right; }
.msg-assistant th[align="center"], .msg-assistant td[align="center"] { text-align: center; }
.msg-assistant th[align="left"],   .msg-assistant td[align="left"]   { text-align: left;  }
.msg-assistant tr:hover td { background: var(--paper-2); }

.msg-assistant blockquote {
  border-left: 3px solid var(--signal);
  padding-left: 14px;
  color: var(--muted);
  margin: 14px 0;
  font-style: italic;
  font-family: var(--font-display);
  font-size: 17px;
}

.msg-assistant a {
  color: var(--signal);
  text-decoration-color: var(--signal-soft);
}

/* ---------- error banner ---------- */
.error-banner {
  background: var(--paper-2);
  border-left: 2px solid var(--bad);
  color: var(--bad);
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  margin: 8px 0;
}

/* ---------- composer ---------- */
.composer-wrap {
  border-top: 1px solid var(--rule);
  background: var(--paper);
  padding: 18px 56px 22px;
}
@media (max-width: 720px) { .composer-wrap { padding: 14px 24px 18px; } }

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 18px;
  max-width: 980px;
  margin: 0 auto;
  position: relative;
}

#input {
  width: 100%;
  resize: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
  padding: 10px 0 12px;
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  outline: none;
  min-height: 44px;
  max-height: 200px;
}
#input::placeholder { color: var(--muted-2); }
#input:focus { border-bottom-color: var(--signal); }

#send-btn {
  background: var(--ink);
  color: var(--paper);
  border: 0;
  padding: 14px 22px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 700;
  cursor: pointer;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  transition: background 100ms ease;
}
#send-btn:hover { background: var(--signal); }
#send-btn:disabled { background: var(--muted-2); cursor: wait; }
#send-btn .glyph {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0;
}
#send-btn.sending .glyph {
  animation: spinner 0.9s linear infinite;
}
@keyframes spinner {
  0%   { content: "◐"; }
  25%  { content: "◓"; }
  50%  { content: "◑"; }
  75%  { content: "◒"; }
  100% { content: "◐"; }
}

/* The animated glyph rotates via JS character swap; CSS handles a fallback spin. */
#send-btn.sending .glyph {
  animation: rotate 1.2s linear infinite;
}
@keyframes rotate {
  to { transform: rotate(360deg); }
}

/* ---------- subtle reveal on first render ---------- */
.app, .login-shell { animation: pageIn 380ms ease both; }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================ SCHEDULE PAGE ============================ */
/* The chat layout locks html/body overflow so its inner panes scroll.
   The schedule page is a normal scrolling document — undo that. */
html:has(.schedule-shell),
body:has(.schedule-shell) {
  overflow: auto;
  height: auto;
}
.schedule-shell {
  position: relative;
  min-height: 100vh;
  /* No animation here on purpose — pageIn uses transform, which would make
     this element a containing block for descendants and break the rail's
     position: fixed (it would pin to .schedule-shell instead of the viewport). */
}
.schedule-shell .rail {
  position: fixed;
  left: 0;
  top: 0;
  width: 320px;
  height: 100vh;
  z-index: 1;
}
.schedule-main {
  margin-left: 320px;
  padding: 24px 56px 80px 56px;
  max-width: 820px;
  /* Override .main's flex/overflow:hidden so this page scrolls naturally. */
  display: block;
  overflow: visible;
  height: auto;
  min-height: 100vh;
}
.schedule-topnav {
  margin-bottom: 18px;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display, Georgia, serif);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #1f3bd1;
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid rgba(31,59,209,0.25);
  border-radius: 2px;
  background: rgba(31,59,209,0.04);
  transition: background 120ms ease, border-color 120ms ease;
}
.back-link:hover {
  background: rgba(31,59,209,0.1);
  border-color: rgba(31,59,209,0.5);
}
.schedule-main .main-head {
  margin-bottom: 28px;
}
.rail-title {
  font-family: var(--font-display, Georgia, serif);
  font-size: 22px;
  line-height: 1.15;
  margin: 6px 0 10px 0;
}
.schedule-card {
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(12,23,56,0.12);
  padding: 22px 26px;
  margin-bottom: 22px;
}
.schedule-card .eyebrow {
  font-family: var(--font-display, Georgia, serif);
  font-size: 11.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(12,23,56,0.65);
  margin: 0 0 14px 0;
}
.schedule-form .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.schedule-form label {
  font-size: 12.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(12,23,56,0.7);
}
.hint-inline {
  text-transform: none;
  letter-spacing: 0;
  font-style: italic;
  color: rgba(12,23,56,0.45);
}
.schedule-form input[type="email"],
.schedule-form select,
.schedule-form textarea {
  font: inherit;
  font-size: 14.5px;
  padding: 10px 12px;
  background: #fdfbf5;
  border: 1px solid rgba(12,23,56,0.18);
  border-radius: 2px;
  color: var(--ink, #0c1738);
}
.schedule-form textarea {
  resize: vertical;
  min-height: 96px;
}
.schedule-form .hint {
  font-size: 12px;
  color: rgba(12,23,56,0.55);
  margin: 4px 0 0 0;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.subscription-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.subscription-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px dashed rgba(12,23,56,0.12);
}
.subscription-item:last-child { border-bottom: none; }
.sub-meta { flex: 1; }
.sub-line { font-size: 14px; line-height: 1.45; color: rgba(12,23,56,0.85); }
.sub-when { color: rgba(31,59,209,0.95); font-weight: 500; }
.sub-notes { font-style: italic; color: rgba(12,23,56,0.6); margin-top: 4px; }
.sub-meta-small { font-size: 12px; color: rgba(12,23,56,0.5); margin-top: 4px; }
.sub-meta-small .err { color: #b3261e; }
.sub-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.btn-ghost.danger { color: #b3261e; }
.sub-actions button[disabled] { opacity: 0.55; cursor: progress; }

/* Inline spinner inside the Send-test button. Hidden by default; revealed
   by the .is-loading class added on submit. */
.sub-actions .spinner {
  display: none;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  vertical-align: middle;
  border: 2px solid rgba(31, 59, 209, 0.25);
  border-top-color: #1f3bd1;
  border-radius: 50%;
  animation: schedule-spin 0.7s linear infinite;
}
.sub-actions button.is-loading .spinner { display: inline-block; }
.sub-actions button.is-loading .btn-label { color: rgba(12, 23, 56, 0.6); }
@keyframes schedule-spin {
  to { transform: rotate(360deg); }
}

/* Full-page busy overlay shown while the test send is running. */
.busy-overlay {
  position: fixed;
  inset: 0;
  background: rgba(244, 241, 234, 0.78);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fadeIn 160ms ease both;
}
.busy-overlay[hidden] { display: none; }
.busy-card {
  display: flex;
  align-items: center;
  gap: 18px;
  background: #fdfbf5;
  border: 1px solid rgba(12, 23, 56, 0.18);
  padding: 22px 28px;
  max-width: 460px;
  box-shadow: 0 18px 60px rgba(12, 23, 56, 0.18);
}
.busy-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(31, 59, 209, 0.18);
  border-top-color: #1f3bd1;
  border-radius: 50%;
  animation: schedule-spin 0.8s linear infinite;
  flex-shrink: 0;
}
.busy-title {
  font-family: var(--font-display, Georgia, serif);
  font-size: 16px;
  color: var(--ink, #0c1738);
  margin-bottom: 4px;
}
.busy-sub {
  font-size: 12.5px;
  color: rgba(12, 23, 56, 0.6);
  line-height: 1.45;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.flash {
  padding: 10px 14px;
  margin-bottom: 18px;
  font-size: 13.5px;
  border-left: 3px solid #1f3bd1;
  background: rgba(31,59,209,0.06);
}
.flash-err {
  border-left-color: #b3261e;
  background: rgba(179,38,30,0.08);
  color: #7a1f17;
}
@media (max-width: 720px) {
  .schedule-shell .rail {
    position: static;
    width: 100%;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }
  .schedule-main {
    margin-left: 0;
    padding: 28px 22px 60px 22px;
  }
  .field-row { grid-template-columns: 1fr; }
}
