/* Flots — theme ported from the artifact's theme.css (same palette, same
   Newsreader serif for thought text, same animations), with the Tailwind
   utility classes from the React client translated to plain CSS. */
@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;1,6..72,400;1,6..72,500&display=swap');

:root {
  color-scheme: light dark;
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --surface-kept: #f3e9d7;
  --text: #1c1917;
  --dim: #78716c;
  --border: #e3dac6;
  --accent: #b45309;
  --accent-deep: #92400e;
  --accent-ink: #ffffff;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17140f;
    --surface: #221e17;
    --surface-kept: #33291a;
    --text: #f3ecdd;
    --dim: #a89e8c;
    --border: #3a342a;
    --accent: #e8a33d;
    --accent-deep: #f0bc66;
    --accent-ink: #1c1503;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.font-thought {
  font-family: "Newsreader", Georgia, "Times New Roman", serif;
}

/* Phone tap targets: at least 32px tall. */
button, [role="button"], select, summary, input:not([type="checkbox"], [type="radio"]) {
  min-height: 2rem;
}

button { font: inherit; color: inherit; }

.page { min-height: 100vh; background: var(--bg); }
.pt-safe { padding-top: env(safe-area-inset-top); }

.wrap {
  margin-inline: auto;
  width: 100%;
  max-width: 36rem;
  padding-inline: 1rem;
  padding-bottom: 4rem;
}

/* ---------- masthead ---------- */
.masthead { padding-top: 2.5rem; padding-bottom: 0.5rem; text-align: center; }
.brand { font-size: 2.25rem; font-weight: 600; letter-spacing: -0.025em; margin: 0; }
.tagline { margin: 0.5rem 0 0; font-size: 1rem; color: var(--dim); }

/* ---------- shared bits ---------- */
.eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dim);
  margin: 0;
}
.eyebrow.centered { text-align: center; }
.hint { font-size: 0.875rem; color: var(--dim); margin: 0.25rem 0 0; }
.label { display: block; margin-top: 1.5rem; font-size: 0.875rem; font-weight: 500; }

.btn-primary {
  width: 100%;
  border: none;
  border-radius: 9999px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}
.btn-primary:disabled { opacity: 0.4; cursor: default; }

.btn-pill {
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
}
.btn-pill:active { background: var(--surface-kept); }
.btn-pill-sm { padding: 0.375rem 0.875rem; }

.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.chip-row.centered-row { justify-content: center; margin-top: 0; }

.error-banner {
  margin-top: 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}
.error-dismiss {
  flex-shrink: 0;
  padding-inline: 0.5rem;
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  min-height: auto;
}

/* ---------- idle ---------- */
.phase-idle { margin-top: 1.5rem; }
.intro { font-size: 1.25rem; line-height: 1.375; margin: 0; }
.fragment-input {
  margin-top: 0.5rem;
  width: 100%;
  resize: none;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.75rem 1rem;
  font-size: 1.25rem;
  color: var(--text);
}
.fragment-input::placeholder { color: var(--dim); }
.fragment-input:focus { border-color: var(--accent); outline: none; }
#start-btn { margin-top: 1rem; }
.examples { margin-top: 1.25rem; }
.examples-label { font-size: 0.875rem; color: var(--dim); margin: 0; }

/* ---------- active ---------- */
.sticky-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  margin-inline: -1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding: 0.75rem 1rem;
}
.fragment-echo { margin: 0.125rem 0 0; font-size: 1.125rem; line-height: 1.375; }
.sticky-row {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cuts-line { font-size: 0.875rem; color: var(--dim); margin: 0; }

.canvas-slot { margin-top: 1rem; }
.canvas {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem;
}
.canvas-head { display: flex; align-items: baseline; justify-content: space-between; }
.canvas-count { font-size: 0.75rem; color: var(--dim); margin: 0; }
.canvas-empty { margin: 0.75rem 0 0; font-size: 0.875rem; line-height: 1.625; color: var(--dim); }
.canvas-forming { margin: 0.5rem 0 0; font-size: 0.875rem; color: var(--dim); }

.thread-list { margin: 0.75rem 0 0; padding: 0; list-style: none; }
.thread-item { position: relative; display: flex; gap: 0.75rem; padding-bottom: 0.75rem; }
.thread-item:last-child { padding-bottom: 0; }
.thread-line {
  position: absolute;
  top: 1.25rem;
  left: 7px;
  height: calc(100% - 14px);
  width: 2px;
  background: var(--accent);
  opacity: 0.6;
}
.thread-dot {
  position: relative;
  z-index: 1;
  margin-top: 6px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 9999px;
  border: 2px solid var(--accent);
  background: var(--surface-kept);
}
.thread-text { font-size: 1.125rem; line-height: 1.375; margin: 0; }

.guesses-head {
  margin-top: 1.5rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.section-h { font-size: 1.25rem; font-weight: 500; margin: 0; }

.guess-cards { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.guess-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.25rem;
  text-align: left;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
  width: 100%;
  cursor: pointer;
}
.guess-card:active { border-color: var(--accent); }
.guess-card.picked { border-color: var(--accent); background: var(--surface-kept); }
.guess-card.cut { opacity: 0.45; }
.guess-text { display: block; font-size: 1.25rem; line-height: 1.375; }
.kept-note { display: block; margin-top: 0.5rem; font-size: 0.875rem; font-weight: 500; color: var(--accent-deep); }
.cut-note { display: block; margin-top: 0.5rem; font-size: 0.875rem; color: var(--dim); }

.actions-col {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.5rem;
}
.actions-col .btn-pill { align-self: center; }

/* ---------- celebrating ---------- */
.celebrate-card {
  position: relative;
  overflow: hidden;
  margin-top: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 3rem 1.5rem;
  text-align: center;
}
.celebrate-dots {
  position: absolute;
  inset-inline: 0;
  bottom: 1.5rem;
  height: 6rem;
  pointer-events: none;
}
.celebrate-dot { position: absolute; bottom: 0; border-radius: 9999px; background: var(--accent); }
.celebrate-badge {
  position: relative;
  margin-inline: auto;
  width: fit-content;
  display: flex;
  align-items: center;
  justify-content: center;
}
.celebrate-ring {
  position: absolute;
  width: 4rem;
  height: 4rem;
  border-radius: 9999px;
  border: 2px solid var(--accent);
}
.celebrate-check {
  display: flex;
  width: 4rem;
  height: 4rem;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1.875rem;
}
.celebrate-title { margin: 1.5rem 0 0; font-size: 1.875rem; font-weight: 500; }
.celebrate-sub {
  margin: 0.75rem auto 0;
  max-width: 24rem;
  font-size: 1rem;
  line-height: 1.625;
  color: var(--dim);
}

/* ---------- complete ---------- */
.phase-complete { margin-top: 2rem; }
.whole-text {
  margin: 0.75rem 0 0;
  text-align: center;
  font-size: 1.875rem;
  line-height: 1.375;
  font-weight: 500;
}
.whole-meta { margin: 0.75rem 0 0; text-align: center; font-size: 0.875rem; color: var(--dim); }
.linked-path { margin-top: 2.5rem; }
.linked-path-h { font-size: 1.25rem; font-weight: 500; margin: 0; }
.linked-path-sub { margin: 0.25rem 0 0; font-size: 0.875rem; color: var(--dim); }
.linked-path .thread-list { margin-top: 1rem; }
.thread-item-lg { padding-bottom: 1rem; }
.thread-item-lg:last-child { padding-bottom: 0; }
.thread-sub { margin: 0.125rem 0 0; font-size: 0.875rem; color: var(--dim); }

/* ---------- side sections ---------- */
.side-section { margin-top: 2.5rem; border-top: 1px solid var(--border); padding-top: 2rem; }
.pocket-section { margin-top: 3.5rem; }
.pocket-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  text-align: left;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.side-h { font-size: 1.5rem; font-weight: 500; margin: 0; }
.body-dim { margin: 0.5rem 0 0; font-size: 1rem; line-height: 1.625; color: var(--dim); }
#protocol-pocket .body-dim { margin-top: 0.75rem; }
.seed-quote {
  margin: 1rem 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem 1.25rem;
  font-size: 1.125rem;
  line-height: 1.625;
}
.badge-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.badge-soon {
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--dim);
}

/* ---------- history ---------- */
.history-list {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.history-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.75rem 1rem;
}
.history-toggle {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.history-whole { font-size: 1.125rem; line-height: 1.375; margin: 0; }
.history-meta { margin: 0.25rem 0 0; font-size: 0.875rem; color: var(--dim); }
.history-detail { margin-top: 0.75rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }
.history-picks { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.history-picks li { font-size: 1rem; }
.history-picks .pick-num { font-size: 0.875rem; color: var(--dim); }
.history-actions { margin-top: 0.75rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.btn-danger-outline { border-color: var(--accent); color: var(--accent-deep); font-weight: 500; }

/* ---------- footer ---------- */
.footer { margin-top: 3rem; border-top: 1px solid var(--border); padding-top: 1.25rem; text-align: center; }
.footer-note { font-size: 0.875rem; color: var(--dim); margin: 0; }

/* ---------- animations (from the artifact's theme.css) ---------- */
@keyframes card-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.card-in { animation: card-in 0.45s ease both; }

@keyframes node-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.node-in { animation: node-in 0.5s ease both; }

@keyframes link-grow {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}
.link-grow { transform-origin: top; animation: link-grow 0.6s ease both; }

@keyframes celebrate-rise {
  0% { opacity: 0; transform: translateY(26px) scale(0.92); }
  55% { opacity: 1; }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.celebrate-rise { animation: celebrate-rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both; }

@keyframes celebrate-dot {
  0% { opacity: 0; transform: translateY(0) scale(1); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-72px) scale(0.6); }
}
.celebrate-dot { animation: celebrate-dot 2.2s ease-out both; }

@keyframes celebrate-ring {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(1.9); opacity: 0; }
}
.celebrate-ring { animation: celebrate-ring 1.6s ease-out both; }

@media (prefers-reduced-motion: reduce) {
  .card-in, .node-in, .link-grow, .celebrate-rise, .celebrate-dot, .celebrate-ring {
    animation: none;
  }
  .celebrate-dot { opacity: 0; }
}
