/* Design tokens
   Palette: warm paper + near-black ink, amber accent (guidance/lantern),
   deep teal for success/live states. Deliberately not the common
   cream+terracotta AI-design default — amber leans gold/ochre, not salmon. */
:root {
  --paper: #FAF7F2;
  --paper-raised: #FFFFFF;
  --ink: #1C1A17;
  --ink-soft: #5B564C;
  --line: #E6E0D4;
  --accent: #C97A2B;
  --accent-deep: #8F5518;
  --accent-wash: #F5E6D3;
  --teal: #2F6E5C;
  --teal-wash: #E1EEE9;
  --red: #A63D2F;
  --red-wash: #F5E2DE;
  --radius: 10px;
  --font-display: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Menlo', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 960px; margin: 0 auto; padding: 0 24px 80px; }

/* Header */
.header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent) 0%, var(--accent-deep) 100%);
  display: inline-block; flex-shrink: 0;
}
.brand h1 { font-family: var(--font-display); font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.brand .tag { color: var(--ink-soft); font-size: 13px; }
.session-context { font-size: 13px; color: var(--ink-soft); text-align: right; }
.session-context b { color: var(--ink); }

nav.tabs { display: flex; gap: 4px; margin-bottom: 28px; border-bottom: 1px solid var(--line); }
nav.tabs button {
  background: none; border: none; font-family: var(--font-body); font-size: 14px;
  padding: 10px 16px; cursor: pointer; color: var(--ink-soft); border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
nav.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
nav.tabs button:hover { color: var(--ink); }

h2.section-title { font-family: var(--font-display); font-size: 19px; margin: 0 0 4px; }
p.section-sub { color: var(--ink-soft); font-size: 13px; margin: 0 0 20px; }

/* Cards */
.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }

.niche-card { cursor: pointer; transition: border-color .15s; }
.niche-card:hover { border-color: var(--accent); }
.niche-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.niche-card h3 { font-family: var(--font-display); font-size: 16px; margin: 0 0 6px; }
.niche-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.pill {
  display: inline-block; font-size: 11px; padding: 3px 9px; border-radius: 100px;
  background: var(--accent-wash); color: var(--accent-deep); font-weight: 600;
  letter-spacing: 0.02em;
}
.pill.teal { background: var(--teal-wash); color: var(--teal); }
.pill.red { background: var(--red-wash); color: var(--red); }
.pill.muted { background: #EFEBE2; color: var(--ink-soft); }

/* Forms */
label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin: 14px 0 5px; text-transform: uppercase; letter-spacing: 0.04em; }
input, select, textarea {
  width: 100%; font-family: var(--font-body); font-size: 14px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--paper-raised); color: var(--ink);
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.row { display: flex; gap: 14px; }
.row > * { flex: 1; }
.radio-group { display: flex; gap: 8px; }
.radio-group button {
  flex: 1; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper-raised);
  cursor: pointer; font-size: 13px; color: var(--ink-soft);
}
.radio-group button.selected { border-color: var(--accent); background: var(--accent-wash); color: var(--accent-deep); font-weight: 600; }

button.btn {
  font-family: var(--font-body); font-size: 14px; font-weight: 600; padding: 11px 20px;
  border-radius: 8px; border: none; cursor: pointer; background: var(--ink); color: var(--paper);
}
button.btn:hover { background: var(--accent-deep); }
button.btn.secondary { background: var(--paper-raised); color: var(--ink); border: 1px solid var(--line); }
button.btn.secondary:hover { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-deep); }
button.btn:disabled { opacity: 0.5; cursor: not-allowed; }
button.btn-block { width: 100%; margin-top: 16px; }

/* Session detail */
.stat-row { display: flex; gap: 24px; margin: 16px 0; flex-wrap: wrap; }
.stat { }
.stat .num { font-family: var(--font-display); font-size: 26px; display: block; }
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); }

.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--red);
  display: inline-block; margin-right: 6px; animation: pulse 1.6s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.event-log { font-family: var(--font-mono); font-size: 12px; background: #F1ECE1; border-radius: 8px; padding: 12px 14px; max-height: 200px; overflow-y: auto; }
.event-log div { padding: 2px 0; color: var(--ink-soft); }
.event-log div.charge { color: var(--accent-deep); }
.event-log div.warn { color: var(--red); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 12px 20px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,0.2); z-index: 100;
}

.review-q { margin-bottom: 16px; }
.review-q .qtext { font-size: 13px; margin-bottom: 6px; }
.scale { display: flex; gap: 4px; }
.scale button {
  flex: 1; aspect-ratio: 1; border: 1px solid var(--line); background: var(--paper-raised);
  border-radius: 6px; cursor: pointer; font-size: 12px; color: var(--ink-soft); font-family: var(--font-mono);
}
.scale button.selected { background: var(--accent); border-color: var(--accent); color: white; font-weight: 700; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty-state .glyph { font-size: 32px; margin-bottom: 8px; }

@media (max-width: 600px) {
  .row { flex-direction: column; }
  .header { flex-direction: column; gap: 6px; align-items: flex-start; }
}
