/* Reset, typography, controls. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 15px/1.55 var(--font);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 520px at 12% -8%, rgba(255, 159, 69, 0.13), transparent 62%),
    radial-gradient(760px 480px at 96% 4%, rgba(121, 192, 255, 0.07), transparent 60%),
    radial-gradient(1200px 700px at 50% 120%, rgba(217, 112, 26, 0.08), transparent 70%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-weight: 760;
}

h1 {
  font-size: clamp(2.1rem, 5vw, 3.5rem);
}
h2 {
  font-size: clamp(1.4rem, 2.6vw, 1.9rem);
}
h3 {
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

a {
  color: var(--ink);
  text-decoration-color: var(--line-2);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--ember);
}

ul,
ol {
  margin: 0;
  padding: 0;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 60;
  padding: 10px 16px;
  border-radius: var(--r-sm);
  background: var(--ember);
  color: #1a1207;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.18s ease;
}

.skip-link:focus {
  top: 12px;
  color: #1a1207;
}

/* ---------- type helpers ---------- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ember);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 18px;
  height: 1px;
  background: currentColor;
  opacity: 0.7;
}

.lead {
  color: var(--ink-2);
  font-size: 1.05rem;
  line-height: 1.6;
}

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

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

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

.ok {
  color: var(--mint);
}

.bad {
  color: var(--rose);
}

.num {
  font-variant-numeric: tabular-nums;
}

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

.btn {
  --btn-bg: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--btn-bg);
  color: var(--ink);
  font-weight: 620;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.btn:hover {
  border-color: var(--ember);
  color: var(--ink);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  border-color: var(--line);
}

.btn.primary {
  background: linear-gradient(160deg, var(--ember) 0%, var(--ember-2) 100%);
  border-color: transparent;
  color: #1a1207;
  font-weight: 760;
  box-shadow: 0 12px 28px -16px rgba(255, 159, 69, 0.85);
}

.btn.primary:hover {
  filter: brightness(1.05);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line-2);
  color: var(--ink-2);
}

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

.btn.quiet {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding: 8px 10px;
}

.btn.quiet:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.btn.sm {
  padding: 8px 13px;
  font-size: 13px;
}

.btn.block {
  width: 100%;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color 0.16s ease, color 0.16s ease;
}

.icon-btn:hover {
  border-color: var(--line-2);
  color: var(--ink);
}

.icon-btn[aria-pressed="false"] {
  color: var(--faint);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.segmented button {
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 620;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  background: var(--surface-3);
  color: var(--ink);
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
}

.field input:focus {
  border-color: var(--ember);
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 159, 69, 0.16);
}

/* ---------- surfaces ---------- */

.card {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 40%), var(--surface);
  box-shadow: var(--shadow-1);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  padding: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.02);
  color: var(--ink-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge.ok {
  border-color: rgba(125, 211, 160, 0.5);
  color: var(--mint);
  background: rgba(125, 211, 160, 0.08);
}

.badge.bad {
  border-color: rgba(255, 122, 107, 0.5);
  color: var(--rose);
  background: rgba(255, 122, 107, 0.08);
}

.badge.warn {
  border-color: rgba(244, 198, 90, 0.5);
  color: var(--gold);
  background: rgba(244, 198, 90, 0.08);
}

.badge.ember {
  border-color: rgba(255, 159, 69, 0.5);
  color: var(--ember);
  background: rgba(255, 159, 69, 0.08);
}

.divider {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: 0;
}

/* ---------- help modal ---------- */

body.help-open {
  overflow: hidden;
}

.help-scrim {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: clamp(12px, 4vw, 32px);
  background: rgba(6, 5, 4, 0.72);
  backdrop-filter: blur(6px);
  animation: help-fade 0.16s ease-out;
}

.help-scrim[hidden] {
  display: none;
}

.help-modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(760px, 100%);
  max-height: min(86vh, 900px);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  animation: help-in 0.18s ease-out;
}

.help-modal:focus {
  outline: none;
}

.help-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(16px, 3vw, 26px);
  border-bottom: 1px solid var(--line);
}

.help-head h2 {
  margin-top: 6px;
  font-size: clamp(1.25rem, 2.4vw, 1.6rem);
}

.help-head .muted {
  margin-top: 4px;
  font-size: 13px;
}

.help-body {
  display: grid;
  gap: 22px;
  padding: clamp(16px, 3vw, 26px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.help-block h3 {
  margin-bottom: 8px;
}

.help-block p {
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.6;
}

.help-block p + p,
.help-block p + .help-list,
.help-block .help-list + p {
  margin-top: 10px;
}

.help-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding-left: 18px;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.5;
}

.help-list b {
  color: var(--ink);
}

.help-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px clamp(16px, 3vw, 26px);
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  background: var(--surface-2);
}

@keyframes help-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes help-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 70;
  width: min(92vw, 420px);
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--surface-3);
  color: var(--ink);
  font-size: 13px;
  box-shadow: var(--shadow-2);
  animation: toast-in 0.18s ease-out;
}

.toast.bad {
  border-color: rgba(255, 122, 107, 0.55);
  color: #ffd9d4;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
