:root {
  --desk: #e6ecf1;
  --paper: #fffefa;
  --ink: #172336;
  --muted: #56657a;
  --rule: #9dbbd6;
  --margin: #d24b55;
  --ring: #19a9e0;
  --ok: #1d7a52;
  --wait: #a86a12;
  --stop: #b0263a;
  --line: #cbd6e0;
  --ui: "Atkinson Hyperlegible", system-ui, sans-serif;
  --serif: "Newsreader", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { background: var(--desk); }
body {
  margin: 0;
  color: var(--ink);
  font: 17px/1.5 var(--ui);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
code, .mono { font-family: var(--mono); font-size: .82em; }

/* Header */
.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 40px 18px;
  flex-wrap: wrap;
}
.brand h1 {
  font: 650 3.4rem/1 var(--serif);
  letter-spacing: -.02em;
  margin: 0 0 6px;
}
.brand p { margin: 0; max-width: 62ch; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.conn { color: var(--muted); font-size: .9rem; margin-right: 6px; }
.conn.live::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); margin-right: 7px; vertical-align: 1px;
}
.conn.down { color: var(--stop); }

.btn {
  font: 700 .95rem var(--ui);
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  text-decoration: none;
}
.btn.primary { background: var(--ink); color: var(--paper); }
.btn:disabled { opacity: .5; cursor: progress; }

/* Layout */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 28px;
  padding: 8px 40px 24px;
  align-items: start;
}

/* Voice column */
.voice {
  background: var(--paper);
  border-radius: 14px;
  padding: 26px 24px 20px;
  box-shadow: 0 1px 0 var(--line), 0 12px 32px -18px rgba(23, 35, 54, .35);
}
.ring {
  display: block;
  margin: 0 auto;
  width: 132px; height: 132px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: conic-gradient(from 200deg, #0d6f9b, var(--ring), #7ad3f2, var(--ring), #0d6f9b);
  transition: transform .2s;
}
.ring-inner {
  display: grid; place-items: center;
  width: 100px; height: 100px; margin: 16px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
}
.ring-inner svg { width: 40px; height: 40px; fill: currentColor; }
.ring.listening { animation: breathe 1.4s ease-in-out infinite; }
.ring.speaking .ring-inner { background: #0d4f70; }
.ring.thinking { background: conic-gradient(from 0deg, var(--rule), var(--ink), var(--rule)); }
@keyframes breathe { 50% { transform: scale(1.06); box-shadow: 0 0 0 14px rgba(25, 169, 224, .18); } }
.ring-hint { text-align: center; color: var(--muted); font-size: .92rem; margin: 12px 0 18px; }

.transcript {
  list-style: none;
  margin: 0;
  padding: 0;
  height: 330px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.transcript li { max-width: 88%; padding: 10px 14px; border-radius: 14px; line-height: 1.4; }
.transcript .you { align-self: flex-end; background: var(--ink); color: var(--paper); border-bottom-right-radius: 4px; }
.transcript .recall { align-self: flex-start; background: #e7f5fb; border-bottom-left-radius: 4px; }
.transcript .recall.blocked { background: #fbe9eb; color: #6d1422; }
.transcript .recall.done { background: #e4f3ec; }
.transcript .who { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 2px; }
.transcript .you .who { color: #aebbd0; }

.say { display: flex; gap: 8px; margin-top: 14px; }
.say input {
  flex: 1;
  font: inherit;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips button {
  font: .86rem var(--ui);
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
  color: var(--ink);
}
.chips button:hover { border-color: var(--ink); }
.source { margin-top: 14px; font-size: .9rem; color: var(--muted); }
.source summary { cursor: pointer; }
.source textarea {
  width: 100%; margin-top: 8px; font: .9rem/1.45 var(--ui);
  border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--ink);
}

/* Desk */
.desk { display: grid; gap: 20px; }
.stats { display: flex; gap: 34px; }
.stats strong { font: 650 2.1rem/1 var(--serif); display: block; }
.stats span { color: var(--muted); font-size: .9rem; }

.study {
  background: var(--paper);
  border-radius: 12px;
  padding: 22px 26px;
  border-left: 6px solid var(--ring);
}
.study-topic { margin: 0 0 6px; color: var(--muted); font-size: .88rem; }
.study-q { margin: 0; font: 500 1.55rem/1.35 var(--serif); }
.study-a { margin: 10px 0 0; color: var(--ok); font-weight: 700; }

/* The plan index card: ruled paper with a red header line */
.plan {
  position: relative;
  background:
    linear-gradient(var(--paper) 0 76px, transparent 76px),
    repeating-linear-gradient(var(--paper) 0 31px, var(--rule) 31px 32px);
  border-radius: 6px;
  padding: 18px 28px 22px;
  box-shadow: 0 1px 1px rgba(23, 35, 54, .12), 0 18px 34px -20px rgba(23, 35, 54, .45);
}
.plan::before {
  content: ""; position: absolute; left: 0; right: 0; top: 76px; height: 2px; background: var(--margin);
}
.plan.enter { animation: drop .45s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes drop { from { transform: translateY(-14px) rotate(-1.2deg); opacity: 0; } }
.plan-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; height: 52px; }
.plan-head h2 { font: 650 1.6rem var(--serif); margin: 0; }
.plan-head .mono { color: var(--muted); }
/* Body text sits on the card's 32px rules: every block below is a multiple of 32px. */
.plan-summary { font-size: 1.15rem; margin: 26px 0 0; line-height: 32px; max-width: calc(100% - 170px); }
.plan-preview { margin: 0; padding-left: 20px; color: var(--muted); line-height: 32px; font-family: var(--serif); max-width: calc(100% - 170px); }
.plan-facts { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 0 36px; margin: 0 0 32px; }
.plan-facts dt { color: var(--muted); font-size: .82rem; line-height: 32px; }
.plan-facts dd { margin: 0; line-height: 32px; }
.phrase { font-weight: 700; font-size: 1.15rem; letter-spacing: .04em; }

.track { list-style: none; display: grid; grid-template-columns: repeat(4, 140px); gap: 6px; padding: 0; margin: 0; counter-reset: s; }
.track li {
  counter-increment: s;
  background: #eef2f6;
  border-radius: 6px;
  padding: 6px 12px;
  line-height: 20px;
  color: var(--muted);
  font-weight: 700;
  font-size: .92rem;
}
.track li::before { content: counter(s) " "; color: var(--rule); }
.track li.active { background: #fdf3e2; color: var(--wait); }
.track li.done { background: #e4f3ec; color: var(--ok); }
.track li.blocked { background: #fbe9eb; color: var(--stop); }

.stamp {
  position: absolute;
  right: 30px; top: 100px;
  width: 136px; height: 136px;
  border-radius: 50%;
  border: 4px double currentColor;
  display: grid; place-content: center; text-align: center;
  color: var(--ok);
  transform: rotate(-12deg);
  background: rgba(255, 254, 250, .82);
}
.stamp[hidden] { display: none; }
.stamp span { font: 650 1.45rem var(--serif); }
.stamp small { font-size: .66rem; max-width: 96px; margin: 2px auto 0; line-height: 1.25; }
.stamp.blocked { color: var(--stop); }
.stamp.press { animation: press .35s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes press { from { transform: rotate(-12deg) scale(1.8); opacity: 0; } }

.ledger { background: var(--paper); border-radius: 12px; padding: 18px 24px; }
.ledger h2 { font: 650 1.25rem var(--serif); margin: 0; }
.ledger-note { margin: 2px 0 10px; color: var(--muted); font-size: .9rem; }
.ledger ol { list-style: none; margin: 0; padding: 0; max-height: 190px; overflow-y: auto; }
.ledger li {
  display: grid; grid-template-columns: 1fr auto; gap: 12px;
  padding: 6px 0; border-top: 1px solid #edf1f5; font-size: .93rem;
}
.ledger li .mono { color: var(--muted); }
.ledger li.gate { font-weight: 700; }
.ledger li.stop { color: var(--stop); }

.foot { padding: 6px 40px 22px; color: var(--muted); font-size: .85rem; }
.foot p { margin: 0; max-width: 110ch; }

@media (min-width: 901px) and (max-height: 860px) {
  .transcript { height: 250px; }
  .top { padding-top: 20px; }
}
@media (max-width: 900px) {
  .top, .layout, .foot { padding-left: 16px; padding-right: 16px; }
  .layout { grid-template-columns: 1fr; }
  .brand h1 { font-size: 2.6rem; }
  .plan-facts { grid-template-columns: 1fr; }
  .plan-summary, .plan-preview { max-width: none; }
  .track { grid-template-columns: repeat(2, 1fr); }
  .stamp { position: static; width: 110px; height: 110px; margin: 16px 0 0 auto; }
  .transcript { height: 260px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
