/* `hidden` attribute must always hide, even on elements with display set via class */
[hidden] { display: none !important; }

/* ============ Tokens ============ */
:root {
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --bg-elev: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #0f172a;
  --text-soft: #475569;
  --text-mute: #94a3b8;
  --primary: #0e7490;
  --primary-hover: #155e75;
  --primary-soft: #ecfeff;
  --accent: #0c4a6e;
  --danger: #ef4444;
  --success: #16a34a;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow: 0 4px 14px rgba(15,23,42,.07);
  --shadow-lg: 0 24px 48px -12px rgba(15,23,42,.18);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --max-w: 1180px;
  --grad: linear-gradient(135deg, #0e7490 0%, #0c4a6e 100%);
}

html[data-theme="dark"] {
  --bg: #0b0d12;
  --bg-soft: #11141b;
  --bg-elev: #161a23;
  --border: #232a38;
  --border-strong: #2c3445;
  --text: #f1f5f9;
  --text-soft: #cbd5e1;
  --text-mute: #64748b;
  --primary: #22d3ee;
  --primary-hover: #67e8f9;
  --primary-soft: #164e63;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 6px 20px rgba(0,0,0,.4);
  --shadow-lg: 0 24px 48px -12px rgba(0,0,0,.55);
}

/* ============ Reset ============ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
p { margin: 0; }
img, svg { display: block; max-width: 100%; }

/* ============ Brand ============ */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand.small { font-size: 14px; }
.brand-mark-bg { fill: var(--primary); }

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--grad);
  color: white;
  border-color: transparent;
  box-shadow: 0 1px 0 rgba(255,255,255,.15) inset, var(--shadow-sm);
}
.btn-primary:hover { filter: brightness(1.05); background: var(--grad); }

.btn-ghost { border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-soft); border-color: var(--border-strong); }

.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn { padding: 8px; }
.icon-btn svg { display: block; }

/* Theme icon toggling */
.icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: block; }

/* ============ Utilities ============ */
.muted { color: var(--text-soft); }
.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.view[hidden] { display: none !important; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: toastIn .2s ease-out;
}
.toast.error { background: var(--danger); color: white; }
.toast.success { background: var(--success); color: white; }
@keyframes toastIn {
  from { transform: translate(-50%, 10px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ============ Modal ============ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 90%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .18s ease-out;
}
@keyframes modalIn {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  color: var(--text-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--bg-soft); color: var(--text); }
.modal-card h2 { margin-bottom: 8px; font-size: 20px; }
.modal-card p { margin-bottom: 20px; }

.waitlist-form {
  display: flex;
  gap: 8px;
}
.waitlist-form input {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.waitlist-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.waitlist-thanks {
  margin-top: 12px;
  color: var(--success);
  font-weight: 500;
}

/* ============ Auth modal ============ */
.auth-card { max-width: 420px; }
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.auth-form input {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.auth-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.auth-thanks {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--success);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
}
.auth-error {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(220, 38, 38, 0.08);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 13px;
}

/* ============ Upgrade modal ============ */
.upgrade-card { max-width: 560px; }
.upgrade-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}
.upgrade-option {
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.upgrade-option h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.upgrade-option p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  flex: 1;
}
.upgrade-foot {
  margin-top: 14px;
  font-size: 12px;
  text-align: center;
}
@media (max-width: 560px) {
  .upgrade-options { grid-template-columns: 1fr; }
}

/* ============ Magic-link confirm page ============ */
.signin-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-soft);
}
.signin-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.signin-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
  margin-bottom: 18px;
}
.signin-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 600;
}
.signin-lede {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.5;
}
.signin-foot {
  margin-top: 16px;
  font-size: 12px;
  line-height: 1.5;
}
.signin-error {
  margin-top: 16px;
  text-align: left;
}

/* ============ Forms (shared) ============ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
}
.field input, .field select, .field textarea {
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field .hint { font-size: 12px; color: var(--text-mute); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Range input */
.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.range-row input[type="range"] {
  flex: 1;
}
.range-row .range-val {
  min-width: 48px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-soft);
  text-align: right;
}
