/* ── Layout ─────────────────────────────────────────────── */

.root {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.shell {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: 16px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--accent);
  box-shadow: none;
  flex: none;
}

.brand-mark svg { width: 16px; height: 16px; display: block; color: var(--on-accent); }

.topbar-actions { display: inline-flex; align-items: center; gap: 10px; }

.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-bottom: 80px;
}

.footer {
  padding: 26px 0 34px;
  color: var(--subtle);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  margin-top: auto;
}

.footer-left { display: flex; flex-direction: column; gap: 8px; }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }

.footer-link {
  border: none;
  background: none;
  padding: 0;
  color: var(--subtle);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.16s var(--ease);
}

.footer-link:hover { color: var(--text); text-decoration: underline; }
.footer-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ── Legal pages ────────────────────────────────────────── */

.legal { max-width: 720px; margin: 0 auto; width: 100%; padding-top: 20px; display: flex; flex-direction: column; gap: 16px; }
.legal-title { font-size: clamp(28px, 4.2vw, 38px); letter-spacing: -0.03em; }
.legal-meta { font-size: 13px; color: var(--subtle); }
.legal-intro { font-size: 16px; color: var(--muted); line-height: 1.65; }
.legal .btn { align-self: flex-start; }

.legal-section { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.legal-section h2 { font-size: 17px; letter-spacing: -0.015em; }
.legal-section p { font-size: 14.5px; color: var(--muted); line-height: 1.7; }

/* ── Primitives ─────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 20px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.18s var(--ease), background 0.18s var(--ease),
              border-color 0.18s var(--ease), box-shadow 0.22s var(--ease), opacity 0.18s;
}

.btn:hover:not(:disabled) { background: var(--surface-hi); border-color: var(--line-hi); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.btn--primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  box-shadow: none;
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-hi);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn--lg { padding: 15px 30px; font-size: 16px; }
.btn--sm { padding: 8px 15px; font-size: 13.5px; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--ghost:hover:not(:disabled) { color: var(--text); background: var(--surface); }
.btn--block { width: 100%; }
.btn--danger { color: var(--danger); border-color: rgba(217, 128, 128, 0.3); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.chip--accent { border-color: var(--accent-soft); background: var(--accent-soft); color: var(--accent); }
.chip--good { border-color: rgba(111, 191, 143, 0.24); background: rgba(111, 191, 143, 0.1); color: var(--good); }
.chip--warn { border-color: rgba(214, 165, 92, 0.26); background: rgba(214, 165, 92, 0.1); color: var(--warn); }

/* Segmented control — two mutually exclusive buttons in one track */
.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  gap: 2px;
}

.segmented-btn {
  padding: 6px 14px;
  border-radius: var(--r-pill);
  border: none;
  background: transparent;
  color: var(--subtle);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}

.segmented-btn:hover { color: var(--text); }

.theme-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: none;
  transition: color 0.18s var(--ease), border-color 0.18s var(--ease), background 0.18s var(--ease);
}

.theme-btn:hover { color: var(--text); border-color: var(--line-hi); background: var(--surface-hi); }
.theme-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-btn svg { width: 16px; height: 16px; }
.segmented-btn[aria-pressed="true"] { background: var(--surface-hi); color: var(--text); }
.segmented-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.dot--pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.8); } }

.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 13.5px; font-weight: 500; color: var(--text); }
.field-hint { font-size: 13px; color: var(--subtle); line-height: 1.5; }

.input, .textarea {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.input::placeholder, .textarea::placeholder { color: var(--subtle); }

.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.textarea { resize: vertical; min-height: 96px; line-height: 1.6; }

.error-note {
  display: flex;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--r-md);
  border: 1px solid rgba(217, 128, 128, 0.3);
  background: rgba(217, 128, 128, 0.09);
  color: var(--danger);
  font-size: 14px;
}

.spinner {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.rise { animation: rise 0.6s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.rise-1 { animation-delay: 0.05s; }
.rise-2 { animation-delay: 0.11s; }
.rise-3 { animation-delay: 0.17s; }
.rise-4 { animation-delay: 0.23s; }

.mono { font-family: var(--font-mono); font-size: 13px; letter-spacing: -0.01em; }

/* ── One-shot entrance animations ─────────────────────────
   The app re-mounts the DOM on every state change; without this, every
   re-render replays the entrance animations and the page visibly blinks.
   app.js adds .anim-done to <html> right after a route's first paint. */
html.anim-done .rise,
html.anim-done .rise-1, html.anim-done .rise-2,
html.anim-done .rise-3, html.anim-done .rise-4,
html.anim-done .source-row,
html.anim-done .more-panel,
html.anim-done .choice-detail,
html.anim-done .msg {
  animation: none;
  opacity: 1;
  transform: none;
}
