:root {
  --paper: #f6f3ee;
  --surface: #fffdf9;
  --soft: #efeae1;
  --ink: #1c1a17;
  --muted: #6d675d;
  --line: #ddd6c9;
  --accent: #c8472b;
  --accent-ink: #ffffff;
  --accent-soft: #f6ddd4;
  --warn: #8a5a00;
  --warn-soft: #f7ecd2;
  --ok: #2f6b4f;
  --radius: 14px;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #151412;
    --surface: #1e1c19;
    --soft: #262320;
    --ink: #ece7de;
    --muted: #a39c8f;
    --line: #38342e;
    --accent: #ef6f4f;
    --accent-ink: #1a0f0b;
    --accent-soft: #3a211a;
    --warn: #e6b450;
    --warn-soft: #33290f;
    --ok: #7fc5a3;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
}

h1,
h2,
h3,
h4,
p,
ul,
blockquote {
  margin: 0;
}

h1 {
  font: 600 clamp(28px, 4vw, 40px) / 1.15 var(--serif);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h2 {
  font: 600 22px/1.25 var(--serif);
}

h3 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

h4 {
  font-size: 15px;
  font-weight: 600;
}

.lede {
  font-size: 18px;
  color: var(--muted);
  max-width: 62ch;
  text-wrap: pretty;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13.5px;
}

ul.plain {
  padding-left: 1.1em;
  display: grid;
  gap: 4px;
}

blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  font-family: var(--serif);
  font-size: 16.5px;
}

/* ---------- shell */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 600 19px var(--serif);
}

.brand .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
}

.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  position: relative;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.tab:hover {
  color: var(--ink);
}

.tab.on {
  background: var(--ink);
  color: var(--paper);
}

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.4s infinite;
}

@keyframes blink {
  50% {
    opacity: 0.3;
  }
}

.view {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 56px) clamp(16px, 4vw, 40px) 96px;
}

.view-talk {
  max-width: 820px;
}

.view-profile {
  max-width: 820px;
}

.view-signin {
  max-width: 420px;
}

.signin {
  display: grid;
  gap: 16px;
  padding-top: 10vh;
}

.signin .btn {
  justify-self: start;
}

.tab.signout {
  font-weight: 400;
  font-size: 14px;
}

/* ---------- controls */

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 550;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 42px;
}

.btn:hover:not(:disabled) {
  border-color: var(--ink);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.07);
  border-color: var(--accent);
}

.btn.big {
  font-size: 18px;
  padding: 14px 28px;
}

.btn.wide {
  width: 100%;
}

.btn.on {
  border-color: var(--ink);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn.working,
.link.working {
  animation: blink 1.2s infinite;
}

.link {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 550;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link.danger {
  color: var(--muted);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.field,
select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

select {
  width: auto;
  min-height: 42px;
}

textarea.field {
  resize: vertical;
  line-height: 1.55;
}

.field::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

label.inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

label.labelled {
  display: grid;
  gap: 6px;
}

label.labelled > span {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  gap: 14px;
}

.card.soft {
  background: var(--soft);
  border-color: transparent;
}

.card.warn {
  background: var(--warn-soft);
  border-color: transparent;
}

.card.warn h4 {
  color: var(--warn);
}

.notice {
  background: var(--soft);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14.5px;
}

.notice.error {
  background: var(--accent-soft);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 14.5px;
}

.tag,
.badge {
  font-size: 12.5px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--soft);
  white-space: nowrap;
}

.badge.final {
  background: color-mix(in srgb, var(--ok) 18%, transparent);
  color: var(--ok);
}

.row-actions,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  max-width: min(560px, calc(100vw - 32px));
  background: var(--ink);
  color: var(--paper);
  padding: 12px 18px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: var(--accent);
  color: var(--accent-ink);
}

/* ---------- talk: setup */

.setup,
.result {
  display: grid;
  gap: 22px;
}

.modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.mode {
  text-align: left;
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.mode span {
  color: var(--muted);
  font-size: 14px;
}

.mode:hover {
  border-color: var(--muted);
}

.mode.on {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: var(--accent-soft);
}

.start-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
}

.history {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.session {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.session summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.session .when {
  font-weight: 600;
}

.session > *:not(summary) {
  margin-top: 12px;
}

/* ---------- talk: live */

.stage {
  display: grid;
  gap: 20px;
}

.stage-top {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 12px 0 4px;
}

.orb {
  --lvl: 0;
  width: 148px;
  height: 148px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid var(--line);
  transition: border-color 0.2s;
}

.orb span {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--ink);
  transform: scale(calc(1 + var(--lvl) * 0.55));
  transition:
    transform 0.09s linear,
    background 0.25s;
}

.orb[data-state='speaking'] {
  border-color: var(--accent);
}

.orb[data-state='speaking'] span {
  background: var(--accent);
}

.orb[data-state='muted'] span {
  background: var(--muted);
  opacity: 0.5;
}

.orb[data-state='connecting'] span {
  background: var(--muted);
  animation: breathe 1.3s ease-in-out infinite;
}

@keyframes breathe {
  50% {
    transform: scale(0.82);
    opacity: 0.5;
  }
}

.status {
  font: 600 20px var(--serif);
}

.timer {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 6px;
}

.transcript {
  display: grid;
  align-content: start;
  gap: 12px;
  height: min(42vh, 420px);
  overflow-y: auto;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.transcript.static {
  height: auto;
  max-height: 480px;
}

.transcript:empty::before {
  content: 'The transcript runs along here.';
  color: var(--muted);
}

.line {
  max-width: 78ch;
  white-space: pre-wrap;
}

.line.model {
  color: var(--muted);
  font-family: var(--serif);
  font-style: italic;
}

.line.user {
  padding-left: 12px;
  border-left: 3px solid var(--accent);
}

.typed {
  display: flex;
  gap: 10px;
}

.waiting {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 12vh 0;
  text-align: center;
}

.pulse {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  animation: breathe 1.3s ease-in-out infinite;
}

/* ---------- ideas */

.ideas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.idea {
  display: grid;
  align-content: start;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.idea h4 {
  font: 600 18px/1.3 var(--serif);
}

.idea .btn {
  justify-self: start;
  margin-top: 4px;
}

.learned {
  gap: 18px;
}

.learned > div {
  display: grid;
  gap: 8px;
}

/* ---------- posts */

.posts {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.post-list {
  display: grid;
  gap: 8px;
  position: sticky;
  top: 84px;
}

.post-list h3 {
  margin-top: 16px;
}

.post-item {
  display: grid;
  gap: 2px;
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.post-item span {
  font-size: 13px;
}

.post-item:hover {
  background: var(--soft);
}

.post-item.on {
  background: var(--surface);
  border-color: var(--line);
}

.idea-row {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  background: var(--soft);
  border-radius: 10px;
}

.idea-row .link {
  justify-self: start;
  font-size: 14px;
}

.editor {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.editor-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.title-input {
  flex: 1;
  min-width: 0;
  font: 600 24px/1.2 var(--serif);
  color: var(--ink);
  background: none;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 4px 0;
}

.title-input:hover,
.title-input:focus {
  border-bottom-color: var(--line);
  outline: none;
}

.post-text {
  min-height: 260px;
  padding: 20px;
  font-size: 16.5px;
  line-height: 1.6;
  border-radius: var(--radius);
  resize: none;
  overflow: hidden;
}

.brief {
  font-size: 16.5px;
  padding: 16px;
}

.meta {
  display: flex;
  justify-content: space-between;
  min-height: 20px;
}

.opening {
  display: grid;
  gap: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.opening:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.opening .link {
  justify-self: start;
  font-size: 14px;
}

/* ---------- profile */

.profile {
  display: grid;
  gap: 22px;
}

.profile .card {
  gap: 18px;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.list-editor {
  display: grid;
  gap: 8px;
}

.items {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 6px;
}

.items li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 8px 8px 12px;
  background: var(--soft);
  border-radius: 10px;
}

.items li.empty {
  background: none;
  color: var(--muted);
  padding-left: 0;
  font-size: 14.5px;
}

.item-body {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 6px;
}

.sample {
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.x {
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.x:hover {
  background: var(--surface);
  color: var(--ink);
}

.add {
  display: flex;
  gap: 10px;
}

@media (max-width: 760px) {
  .posts {
    grid-template-columns: 1fr;
  }

  .post-list {
    position: static;
  }

  .grid2 {
    grid-template-columns: 1fr;
  }

  .tab {
    padding: 8px 10px;
  }

  .add,
  .typed {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
