/* Remembering Thamus. The shell is Data Crawler Carl's: dark header, gold accent, modals. */

:root {
  --gold: #f1b300;
  --gold-soft: rgba(241, 179, 0, 0.12);
  --ink: #191919;
  --muted: #666;
  --bg: #f4f4f2;
  --card-bg: #fff;
  --border: rgba(25, 25, 25, 0.1);
  --green: #166534;
  --red: #b91c1c;
  --mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: light; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: inherit; }

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--ink);
  color: #fff;
  flex-wrap: wrap;
}
.app-title-link { text-decoration: none; color: inherit; }
.app-title-link:hover h1 { opacity: 0.8; }
.app-header h1 { font-size: 1.2rem; font-weight: 800; letter-spacing: -0.02em; transition: opacity 0.15s; }
.app-header h1 span { color: var(--gold); }
.app-subtitle { font-size: 0.85rem; color: #999; }
.app-header-actions { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.about-btn,
.api-key-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.about-btn:hover,
.api-key-btn:hover { border-color: var(--gold); background: rgba(241, 179, 0, 0.1); }
.api-key-dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; transition: background 0.2s; }
.api-key-dot.connected { background: #22c55e; }

/* ── Body ── */
.app-body { width: min(100% - 2rem, 1480px); margin: 0 auto; padding: 1.5rem 0 3rem; }

.lede { max-width: 56rem; margin: 0.5rem auto 1.5rem; text-align: center; }
.lede-quote { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 0.6rem; }
.lede-text { color: #333; font-size: 0.98rem; }

/* ── Ask bar ── */
.ask { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 0.9rem 1rem; margin-bottom: 1.25rem; }
.ask-row { display: flex; gap: 0.5rem; align-items: stretch; flex-wrap: wrap; }
.ask-row input[type="text"] {
  flex: 1 1 24rem;
  padding: 0.6rem 0.8rem;
  border: 2px solid rgba(25, 25, 25, 0.12);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
}
.ask-row input[type="text"]:focus { border-color: var(--gold); }
.ask-row select.method {
  flex: 0 1 14rem;
  min-width: 11rem;
  padding: 0.5rem 0.6rem;
  border: 2px solid var(--gold);
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  background: var(--gold-soft);
  color: var(--ink);
}
.ask-row select.method.is-end { background: var(--ink); color: var(--gold); border-color: var(--ink); }
.ask-btn {
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  border: 2px solid var(--gold);
  background: var(--gold);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.ask-btn:hover { background: #f5c842; }
.ask-btn:disabled { opacity: 0.5; cursor: progress; }

.ask-row-own { margin-top: 0.5rem; }
.ask-row-own input[type="text"] { font-size: 0.92rem; border-style: dashed; }
.room-answer { margin: 0; padding: 0.5rem 0.8rem; font-size: 0.95rem; color: #333; background: #f3f3f1; border-left: 3px solid #bbb; border-radius: 6px; }
.room-answer:empty { display: none; }
.presets { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.7rem; }
.preset {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 2px solid rgba(241, 179, 0, 0.4);
  background: rgba(241, 179, 0, 0.08);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.preset:hover { background: rgba(241, 179, 0, 0.2); border-color: var(--gold); }
.ecfr-link { text-decoration: none; }

/* ── The current way ── */
.way {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem 1.6rem 1rem;
  display: flex; flex-direction: column; gap: 0.9rem;
  min-height: 24rem;
  transition: box-shadow 0.2s;
}
.way.is-busy { box-shadow: 0 0 0 3px var(--gold-soft); }
.way-head { display: flex; gap: 0.9rem; align-items: flex-start; }
.way-num {
  flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%;
  background: var(--ink); color: var(--gold);
  font-weight: 800; font-size: 1.2rem; display: grid; place-items: center;
}
.way-head h2 { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.way-sub { font-size: 1rem; color: var(--muted); margin-top: 0.15rem; }
#way-body { display: flex; flex-direction: column; gap: 0.9rem; }

.ask-btn.small { padding: 0.4rem 0.9rem; font-size: 0.85rem; }

.way-status { font-size: 0.95rem; color: #7a5a00; font-weight: 600; }
.way-status:empty { display: none; }
.way-status::before { content: ""; display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--gold); margin-right: 0.5rem; animation: pulse 1.2s infinite ease-in-out; }
@keyframes pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

.way-answer {
  font-size: 1.35rem;
  line-height: 1.45;
  padding: 1rem 1.2rem;
  background: var(--gold-soft);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  white-space: pre-wrap;
  word-wrap: break-word;
  min-height: 4rem;
  letter-spacing: -0.005em;
}
.way-answer:empty { display: none; }
.way-answer.is-muted { background: #f3f3f1; border-left-color: #bbb; color: #444; font-size: 1rem; }
.way-answer.is-error { background: rgba(185, 28, 28, 0.07); border-left-color: var(--red); color: var(--red); font-size: 1rem; }

.way-trail { font-size: 0.9rem; border-top: 1px solid var(--border); padding-top: 0.8rem; }
.way-trail h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 0.5rem; }
.trail-body { display: flex; flex-direction: column; gap: 0.6rem; }
.trail-note { color: #333; }
.trail-list { padding-left: 1.3rem; display: flex; flex-direction: column; gap: 0.5rem; }
.trail-list li a { font-weight: 700; color: #7a5a00; }
.trail-list li p { color: #444; margin-top: 0.1rem; }
.trail-list code { font-family: var(--mono); font-size: 0.82rem; background: rgba(25, 25, 25, 0.06); padding: 0.05rem 0.35rem; border-radius: 3px; }
.trail-engines, .trail-score { color: var(--muted); font-family: var(--mono); font-size: 0.78rem; }
.trail-source { color: var(--green); font-weight: 600; }
.trail-source a { color: inherit; }
.trail-text summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.trail-text pre {
  margin-top: 0.3rem;
  padding: 0.6rem 0.8rem;
  background: #f6f6f4;
  border: 1px solid var(--border);
  border-radius: 6px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: inherit;
  font-size: 0.86rem;
  max-height: 20rem;
  overflow: auto;
}

.way-meta { font-size: 0.78rem; color: #999; font-family: var(--mono); }
.way-meta:empty { display: none; }

.way-tradeoff {
  font-size: 0.92rem;
  display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.9rem;
  padding: 0.8rem 1rem;
  background: #fafaf8; border: 1px solid var(--border); border-radius: 10px;
}
.way-tradeoff dt { font-weight: 800; text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.05em; padding-top: 0.25rem; white-space: nowrap; }
.way-tradeoff dt.is-benefit { color: var(--green); }
.way-tradeoff dt.is-cost { color: var(--red); }
.way-tradeoff dt.is-watch { color: #7a5a00; }
.way-tradeoff dd { color: #333; }

.way-end { background: var(--ink); color: #eee; border-radius: 12px; padding: 1.6rem 1.8rem; }
.discussion-q { font-size: 1.7rem; font-weight: 800; line-height: 1.25; color: #fff; margin-bottom: 0.9rem; letter-spacing: -0.015em; }
.way-end p { font-size: 1.02rem; color: #ccc; margin-bottom: 0.8rem; }
.end-list { padding-left: 1.3rem; color: #ddd; display: flex; flex-direction: column; gap: 0.4rem; font-size: 1rem; }

.way-nav { display: flex; gap: 0.6rem; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.nav-btn {
  padding: 0.55rem 1.1rem; border-radius: 8px;
  border: 2px solid rgba(25, 25, 25, 0.15); background: #fff; color: var(--ink);
  font-size: 0.95rem; font-weight: 700; font-family: inherit; cursor: pointer;
}
.nav-btn:hover { border-color: var(--gold); }
.nav-btn.is-primary { border-color: var(--gold); background: var(--gold); }
.nav-btn.is-primary:hover { background: #f5c842; }
.nav-btn:disabled { opacity: 0.4; cursor: default; }

.link-btn {
  background: none; border: none; padding: 0;
  color: #7a5a00; font-size: 0.85rem; font-weight: 700; font-family: inherit;
  cursor: pointer; text-decoration: underline;
}
.link-btn:hover { color: var(--ink); }

.paste-line { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; font-size: 0.95rem; color: #333; }
.paste-line[hidden] { display: none; }
#paste-text {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 2px solid rgba(25, 25, 25, 0.12);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.45;
  resize: vertical;
  outline: none;
}
#paste-text:focus { border-color: var(--gold); }
.paste-tools { display: flex; gap: 0.9rem; flex-wrap: wrap; align-items: center; margin-top: 0.5rem; }

.app-footer { max-width: 56rem; margin: 2rem auto 0; font-size: 0.8rem; color: var(--muted); text-align: center; display: flex; flex-direction: column; gap: 0.4rem; }
.app-footer a { color: #7a5a00; font-weight: 600; }

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem;
  transform: translateX(-50%) translateY(1rem);
  background: var(--ink); color: #fff;
  padding: 0.7rem 1rem; border-radius: 0.6rem;
  font-size: 0.9rem; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; z-index: 300;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Modals (shared with Carl) ── */
.modal-overlay { display: none; position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, 0.5); }
.modal-overlay.visible { display: grid; place-items: center; }
.modal-dialog {
  background: #fff;
  padding: 2rem 2.5rem;
  border-radius: 1rem;
  max-width: 540px;
  width: 92%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  color: var(--ink);
  line-height: 1.6;
  font-size: 0.95rem;
}
.modal-dialog.modal-wide { max-width: 860px; }
.modal-dialog h2 { margin: 0 0 0.8rem; font-size: 1.3rem; }
.modal-dialog h3 { margin: 1.2rem 0 0.4rem; font-size: 1rem; }
.modal-dialog p { margin: 0 0 0.7rem; }
.modal-dialog blockquote { margin: 0 0 0.8rem; padding: 0.4rem 0 0.4rem 1rem; border-left: 3px solid var(--gold); color: #333; font-style: italic; }
.modal-dialog .cite { font-size: 0.82rem; color: var(--muted); }
.modal-dialog code { background: rgba(25, 25, 25, 0.06); padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.85em; }
.how-list { padding-left: 1.3rem; margin: 0 0 0.8rem; display: flex; flex-direction: column; gap: 0.5rem; }
.api-key-input-section { background: rgba(241, 179, 0, 0.05); border: 2px solid rgba(241, 179, 0, 0.2); border-radius: 0.5rem; padding: 0.8rem; margin-bottom: 0.8rem; }
.api-key-row { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.api-key-row input { flex: 1 1 14rem; padding: 0.5rem 0.7rem; border: 2px solid rgba(25, 25, 25, 0.15); border-radius: 0.4rem; font-size: 0.9rem; font-family: inherit; outline: none; }
.api-key-row input:focus { border-color: var(--gold); }
.api-key-status { font-size: 0.82rem; margin-top: 0.4rem; color: var(--muted); }
.api-key-status.ok { color: var(--green); font-weight: 600; }
.fine summary { cursor: pointer; color: #7a5a00; font-weight: 700; font-size: 0.9rem; }
.fine ul { padding-left: 1.2rem; margin: 0.5rem 0; font-size: 0.85rem; display: flex; flex-direction: column; gap: 0.3rem; color: #333; }
.modal-close-btn {
  display: inline-block; margin-top: 0.8rem; padding: 0.5rem 1.5rem;
  border: 2px solid var(--gold); border-radius: 8px;
  background: rgba(241, 179, 0, 0.1); color: var(--ink);
  font-size: 0.95rem; font-weight: 700; font-family: inherit; cursor: pointer;
}
.modal-close-btn:hover { background: rgba(241, 179, 0, 0.25); }

@media (max-width: 768px) {
  .app-header h1 { font-size: 1rem; }
  .app-subtitle { display: none; }
  .modal-dialog { padding: 1.4rem 1.2rem; }
}

/* ── How it works: a slideshow ── */
.how-dialog { padding-top: 1.2rem; }
.show { position: relative; min-height: 24rem; }
.slide { display: none; animation: slide-in 0.25s ease; }
.slide.is-active { display: block; }
@keyframes slide-in { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
.slide h3 { margin: 0 0 0.6rem; font-size: 1.25rem; display: flex; align-items: center; gap: 0.5rem; letter-spacing: -0.01em; }
.slide p { margin: 0 0 0.6rem; font-size: 0.95rem; }
.slide ul { padding-left: 1.2rem; margin: 0; font-size: 0.92rem; display: flex; flex-direction: column; gap: 0.25rem; }
.slide-split { display: grid; grid-template-columns: 240px 1fr; gap: 1.4rem; align-items: start; }
.slide-split > img { width: 100%; height: auto; align-self: center; }
.slide-icon { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; padding-top: 0.3rem; }
.lifeline { width: 100%; max-width: 230px; height: auto; filter: drop-shadow(0 4px 10px rgba(10, 26, 63, 0.25)); }
.slide-lifeline { font-size: 0.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: #2f5fa8; text-align: center; }
.how-num { flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--ink); color: var(--gold); font-size: 0.8rem; font-weight: 800; display: grid; place-items: center; }
.slide-tradeoff { margin: 0.6rem 0 0; font-size: 0.85rem; display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.7rem; padding: 0.6rem 0.8rem; background: #fafaf8; border: 1px solid var(--border); border-radius: 8px; }
.slide-tradeoff dt { font-weight: 800; text-transform: uppercase; font-size: 0.66rem; letter-spacing: 0.05em; padding-top: 0.2rem; }
.slide-tradeoff dt.is-benefit { color: var(--green); }
.slide-tradeoff dt.is-cost { color: var(--red); }
.slide-tradeoff dd { margin: 0; color: #333; }

/* The splash: a ring logo whose inner wheel turns. Nothing zooms. */
.splash-board { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.logo { display: block; width: 100%; max-width: 760px; height: auto; border-radius: 12px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.logo-ring { font-size: 30px; font-weight: 900; letter-spacing: 0.2em; fill: #fff; }
.logo-center { font-size: 44px; font-weight: 900; letter-spacing: 0.06em; fill: #fff; paint-order: stroke; stroke: #06112f; stroke-width: 6px; }
.logo-sec { font-size: 74px; font-weight: 900; fill: url(#lg-gold); text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: #3a2600; stroke-width: 2px; }
.logo-spin { animation: logo-spin 28s linear infinite; }
.logo-spin-slow { animation: logo-spin 60s linear infinite reverse; }
.logo-flare { animation: logo-flare 5s ease-in-out infinite; }
.logo-flare-2 { animation-delay: 2.5s; }
@keyframes logo-spin { to { transform: rotate(360deg); } }
@keyframes logo-flare { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
.splash-sub { margin: 0.2rem 0 0; font-size: 0.95rem; color: #333; text-align: center; }
@media (prefers-reduced-motion: reduce) { .logo-spin, .logo-spin-slow, .logo-flare { animation: none; } }

.board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.8rem; padding: 1.2rem 1rem; border-radius: 12px; background: radial-gradient(ellipse at 50% 40%, #16307a 0%, #0a1a3f 60%, #060f28 100%); }
.board figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.board .lifeline { max-width: 150px; }
.board figcaption { text-align: center; font-size: 0.74rem; color: #cfe0ff; line-height: 1.3; }
.board figcaption strong { display: block; color: #fff; font-size: 0.82rem; }

.show-nav { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin: 0.9rem 0 1rem; }
.show-dots { display: flex; gap: 0.4rem; }
.show-dots button { width: 0.7rem; height: 0.7rem; border-radius: 50%; border: none; background: #d6d6d2; cursor: pointer; padding: 0; }
.show-dots button.is-active { background: var(--gold); }
@media (max-width: 700px) {
  .slide-split { grid-template-columns: 1fr; }
  .slide-icon { flex-direction: row; justify-content: flex-start; }
  .lifeline { max-width: 150px; }
  .board { grid-template-columns: repeat(2, 1fr); }
}
.how-more { margin: 0 0 0.6rem; }
.how-more > summary { cursor: pointer; font-weight: 700; color: #7a5a00; }
.how-more .how-list { margin-top: 0.5rem; }
