/* ==========================================================================
   Hufan — core design system
   Tokens, typography, controls and motion shared by every surface.
   ========================================================================== */

:root {
  /* Surfaces */
  --bg: #ffffff;
  --s1: #fafafa;
  --s2: #f7f7f7;
  --s3: #f3f3f3;
  --s4: #ececec;
  --canvas: #f3f1ee;          /* warm-gray canvas behind previews */
  --canvas-2: #ebe8e3;

  /* Ink */
  --ink: #111111;
  --ink-2: #2b2b2b;           /* charcoal */
  --muted: #6b6b6b;
  --faint: #9b9b9b;
  --ghost: #c4c4c4;

  /* Lines */
  --line: rgba(0, 0, 0, 0.08);
  --line-2: rgba(0, 0, 0, 0.12);
  --line-3: rgba(0, 0, 0, 0.2);

  /* The one accent — used only where interaction needs it */
  --accent: #ef5a2a;
  --accent-ink: #c8441a;
  --accent-soft: rgba(239, 90, 42, 0.1);

  /* Radius */
  --r-xs: 6px;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  /* Elevation */
  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 1px rgba(0, 0, 0, 0.02);
  --sh-2: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px -10px rgba(0, 0, 0, 0.14);
  --sh-3: 0 2px 6px rgba(0, 0, 0, 0.04), 0 24px 60px -20px rgba(0, 0, 0, 0.22);
  --sh-4: 0 4px 12px rgba(0, 0, 0, 0.05), 0 40px 100px -30px rgba(0, 0, 0, 0.35);

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --t-fast: 140ms;
  --t: 220ms;
  --t-slow: 520ms;

  /* Type */
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, video, svg, canvas { display: block; max-width: 100%; }
video { background: var(--s3); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, h5, p, figure, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
::selection { background: rgba(17, 17, 17, 0.9); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ---------- Type scale ---------- */
.display {
  font-size: clamp(40px, 6.4vw, 86px);
  line-height: 1.0;
  letter-spacing: -0.045em;
  font-weight: 500;
}
.h1 { font-size: clamp(36px, 4.4vw, 60px); line-height: 1.04; letter-spacing: -0.04em; font-weight: 500; }
.h2 { font-size: clamp(30px, 3.4vw, 44px); line-height: 1.08; letter-spacing: -0.035em; font-weight: 500; }
.h3 { font-size: clamp(22px, 2vw, 28px); line-height: 1.2; letter-spacing: -0.025em; font-weight: 500; }
.h4 { font-size: 18px; line-height: 1.3; letter-spacing: -0.015em; font-weight: 500; }
.lead { font-size: clamp(16px, 1.3vw, 18px); line-height: 1.55; color: var(--muted); letter-spacing: -0.005em; }
.body { font-size: 15px; color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.ink { color: var(--ink); }
.medium { font-weight: 500; }
.semibold { font-weight: 600; }
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: 0; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted);
}
.label {
  font-size: 12px; font-weight: 500; letter-spacing: 0.01em; color: var(--muted);
}
.section-index {
  font-size: 12px; font-weight: 500; color: var(--faint); letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.balance { text-wrap: balance; }
.pretty { text-wrap: pretty; }

/* ---------- Icons ---------- */
.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 16px; height: 16px; }
.i-xs { width: 14px; height: 14px; }
.i-lg { width: 20px; height: 20px; }
.i-xl { width: 24px; height: 24px; }
.i .fill { fill: currentColor; stroke: none; }

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; font-size: 18px; letter-spacing: -0.035em; color: var(--ink); }
.logo-mark { width: 24px; height: 24px; flex: none; }
.logo-word { line-height: 1; transform: translateY(-0.5px); }

/* ---------- Buttons ---------- */
.btn {
  --h: 44px;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 18px;
  border-radius: 11px;
  font-size: 14px; font-weight: 500; letter-spacing: -0.005em; white-space: nowrap;
  border: 1px solid transparent;
  transition: transform var(--t-fast) var(--ease), background-color var(--t) var(--ease), border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), color var(--t) var(--ease), opacity var(--t) var(--ease);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-lg { --h: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn-sm { --h: 36px; padding: 0 14px; font-size: 13px; border-radius: 9px; }
.btn-xs { --h: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn-icon { width: var(--h); padding: 0; }
.btn-block { width: 100%; }

.btn-primary { background: var(--ink); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,0.08) inset, 0 1px 2px rgba(0,0,0,0.18); }
.btn-primary:hover:not(:disabled) { background: #262626; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line-2); box-shadow: var(--sh-1); }
.btn-secondary:hover:not(:disabled) { border-color: var(--line-3); background: var(--s1); }
.btn-ghost { color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: var(--s3); }
.btn-quiet { color: var(--muted); }
.btn-quiet:hover:not(:disabled) { color: var(--ink); background: var(--s3); }
.btn-danger { background: #fff; color: #b3261e; border-color: rgba(179, 38, 30, 0.25); }
.btn-danger:hover:not(:disabled) { background: #fdf3f2; }

.btn .arrow { transition: transform var(--t) var(--ease); }
.btn:hover .arrow { transform: translateX(2px); }

.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border-radius: 50%; border: 1.5px solid rgba(255,255,255,0.35); border-top-color: #fff;
  animation: spin 700ms linear infinite;
}
.btn-secondary.is-loading::after { border-color: rgba(0,0,0,0.15); border-top-color: var(--ink); }

.link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-3); text-underline-offset: 3px; transition: text-decoration-color var(--t) var(--ease); }
.link:hover { text-decoration-color: var(--ink); }
.link-quiet { color: var(--muted); transition: color var(--t) var(--ease); }
.link-quiet:hover { color: var(--ink); }

/* ---------- Inputs ---------- */
.field { display: grid; gap: 8px; }
.field > label, .field-label { font-size: 13px; font-weight: 500; color: var(--ink); }
.field-hint { font-size: 12px; color: var(--faint); }
.field-error { font-size: 12px; color: #b3261e; }
.input, .select, .textarea {
  width: 100%; height: 48px; padding: 0 14px;
  background: #fff; border: 1px solid var(--line-2); border-radius: 11px;
  font-size: 15px; color: var(--ink);
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), background-color var(--t) var(--ease);
  outline: none;
}
.input-sm, .select-sm { height: 38px; font-size: 13.5px; border-radius: 9px; padding: 0 12px; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 4px rgba(17,17,17,0.06); }
.input.is-invalid { border-color: #b3261e; box-shadow: 0 0 0 4px rgba(179,38,30,0.08); }
.textarea { height: auto; min-height: 120px; padding: 12px 14px; line-height: 1.55; resize: vertical; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236b6b6b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input-wrap { position: relative; }
.input-wrap > .i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-wrap > .i + .input { padding-left: 38px; }
.input-wrap > .input-action { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }

/* ---------- Segmented control ---------- */
.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px;
  background: var(--s3); position: relative;
}
.seg button {
  position: relative; z-index: 1;
  height: 30px; padding: 0 12px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--muted);
  transition: color var(--t) var(--ease), background-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.seg button:hover { color: var(--ink); }
.seg button.is-active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.08), 0 0 0 0.5px rgba(0,0,0,0.06); }
.seg-block { display: flex; width: 100%; }
.seg-block button { flex: 1; }

/* ---------- Choice pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 999px;
  font-size: 13px; font-weight: 500; color: var(--ink-2);
  border: 1px solid var(--line-2); background: #fff;
  transition: all var(--t) var(--ease);
  white-space: nowrap;
}
.pill:hover { border-color: var(--line-3); background: var(--s1); }
.pill.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.pill-soft { border-color: transparent; background: var(--s3); color: var(--muted); }
.pill-soft:hover { background: var(--s4); color: var(--ink); border-color: transparent; }
.pill-soft.is-active { background: var(--ink); color: #fff; }

.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.opt {
  height: 34px; padding: 0 12px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff;
  font-size: 13px; font-weight: 500; color: var(--muted);
  transition: all var(--t) var(--ease);
}
.opt:hover { color: var(--ink); border-color: var(--line-3); }
.opt.is-active { color: var(--ink); border-color: var(--ink); box-shadow: inset 0 0 0 0.5px var(--ink); }

/* ---------- Tags ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 500; letter-spacing: 0.01em;
  background: var(--s3); color: var(--ink-2);
}
.tag-outline { background: transparent; border: 1px solid var(--line-2); }
.tag-dark { background: var(--ink); color: #fff; }
.tag-glass { background: rgba(255,255,255,0.82); color: var(--ink); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.tag-onmedia { background: rgba(0,0,0,0.38); color: #fff; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.dot-accent { background: var(--accent); }
.dot-live { background: var(--accent); box-shadow: 0 0 0 0 rgba(239,90,42,0.5); animation: live 2s var(--ease) infinite; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); }
.status .dot { width: 7px; height: 7px; }
.status-ok .dot { background: #2f9e5b; }
.status-warn .dot { background: #d38b12; }
.status-bad .dot { background: #c9372c; }
.status-idle .dot { background: var(--ghost); }
.status-run .dot { background: var(--accent); animation: live 1.8s var(--ease) infinite; }

/* ---------- Switch ---------- */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 13.5px; color: var(--ink-2); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 32px; height: 20px; border-radius: 999px; background: var(--s4);
  position: relative; transition: background-color var(--t) var(--ease); flex: none;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.2), 0 0 0 0.5px rgba(0,0,0,0.04);
  transition: transform var(--t) var(--ease-out);
}
.switch input:checked + .track { background: var(--ink); }
.switch input:checked + .track::after { transform: translateX(12px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; }
.check input { appearance: none; -webkit-appearance: none; width: 16px; height: 16px; margin: 0; border-radius: 5px; border: 1px solid var(--line-3); background: #fff; display: grid; place-items: center; transition: all var(--t) var(--ease); cursor: pointer; }
.check input:checked { background: var(--ink); border-color: var(--ink); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E"); background-size: 11px; background-position: center; background-repeat: no-repeat; }

/* ---------- Range ---------- */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 20px; background: transparent; cursor: pointer; --p: 50%; }
.range::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--ink) var(--p), var(--s4) var(--p)); }
.range::-moz-range-track { height: 3px; border-radius: 3px; background: var(--s4); }
.range::-moz-range-progress { height: 3px; border-radius: 3px; background: var(--ink); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6.5px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 1px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.18); transition: transform var(--t-fast) var(--ease); }
.range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 1px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.18); }
.range:active::-webkit-slider-thumb { transform: scale(1.1); }

/* ---------- Surfaces ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); }
.card-soft { background: var(--s1); border-radius: var(--r-lg); }
.hairline { height: 1px; background: var(--line); border: 0; margin: 0; }
.vline { width: 1px; align-self: stretch; background: var(--line); }
.kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; font-size: 11px; font-weight: 500; color: var(--muted); background: var(--s3); border: 1px solid var(--line); font-family: var(--font); }

.avatar { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; flex: none; background: var(--s3); display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 44px; height: 44px; font-size: 14px; }

/* ---------- Media ---------- */
.media {
  position: relative; overflow: hidden; border-radius: var(--r-lg);
  background: var(--s3); isolation: isolate;
}
.media > img, .media > video, .media > .media-poster {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.media > video { opacity: 0; transition: opacity 420ms var(--ease); background: transparent; }
.media.is-playing > video { opacity: 1; }
.media-916 { aspect-ratio: 9 / 16; }
.media-45 { aspect-ratio: 4 / 5; }
.media-34 { aspect-ratio: 3 / 4; }
.media-11 { aspect-ratio: 1 / 1; }
.media-169 { aspect-ratio: 16 / 9; }
.media-shade::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 45%; z-index: 1; pointer-events: none;
  background: linear-gradient(to top, rgba(0,0,0,0.42), rgba(0,0,0,0));
  opacity: 0; transition: opacity var(--t) var(--ease);
}
.media-meta { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 2; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.media-actions { position: absolute; top: 10px; right: 10px; z-index: 2; display: flex; gap: 6px; opacity: 0; transform: translateY(-4px); transition: all var(--t) var(--ease); }
.media-btn { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,0.92); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.12); transition: transform var(--t-fast) var(--ease), background-color var(--t) var(--ease); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.media-btn:hover { background: #fff; }
.media-btn:active { transform: scale(0.95); }
.media-btn.is-on { color: var(--accent); }
.media-btn.is-on .i { fill: currentColor; }
.hover-lift { transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.hover-lift:hover { transform: translateY(-2px); box-shadow: var(--sh-2); }

/* Grain for media that should feel like phone footage */
.grain::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0.06; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Dropzone ---------- */
.dropzone {
  position: relative; display: grid; place-items: center; text-align: center; gap: 6px;
  border: 1px dashed var(--line-3); border-radius: var(--r); background: var(--s1);
  color: var(--muted); font-size: 13px; cursor: pointer; padding: 16px;
  transition: border-color var(--t) var(--ease), background-color var(--t) var(--ease), color var(--t) var(--ease), transform var(--t) var(--ease);
}
.dropzone:hover { border-color: var(--ink); color: var(--ink); }
.dropzone.is-drag { border-style: solid; border-color: var(--ink); background: #fff; color: var(--ink); box-shadow: 0 0 0 4px rgba(17,17,17,0.05); transform: scale(1.01); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- Progress ---------- */
.progress-line { position: relative; height: 2px; background: rgba(0,0,0,0.08); overflow: hidden; border-radius: 2px; }
.progress-line > i { position: absolute; left: 0; top: 0; bottom: 0; width: var(--p, 0%); background: var(--ink); transition: width 400ms var(--ease); border-radius: 2px; }
.progress-line.is-indeterminate > i { width: 30%; animation: indet 1.4s var(--ease-in-out) infinite; }
.meter { height: 4px; border-radius: 4px; background: var(--s4); overflow: hidden; }
.meter > i { display: block; height: 100%; width: var(--p, 0%); background: var(--ink); border-radius: 4px; transition: width 600ms var(--ease-out); }

/* ---------- Plan cards (pricing page and Studio Billing) ---------- */
.pricing-toggle { flex: none; background: var(--s4); }
.save { font-size: 11px; font-weight: 500; color: var(--accent-ink); margin-left: 2px; }
.plans { display: grid; grid-template-columns: repeat(4, 1fr); background: #fff; border: 1px solid var(--line); border-radius: 22px; overflow: hidden; box-shadow: var(--sh-1); }
.plan { position: relative; display: flex; flex-direction: column; gap: 20px; padding: 28px 26px 30px; border-left: 1px solid var(--line); }
.plan:first-child { border-left: 0; }
.plan.is-rec { box-shadow: inset 0 2px 0 var(--ink); background: linear-gradient(to bottom, #fff, #fcfcfc); }
.plan-top { display: flex; justify-content: space-between; align-items: center; min-height: 24px; }
.plan-name { font-size: 15px; font-weight: 500; }
.plan-desc { font-size: 13.5px; color: var(--muted); line-height: 1.5; min-height: 40px; }
.plan-price { display: flex; align-items: baseline; gap: 6px; }
.plan-price .amt { font-size: 46px; letter-spacing: -0.045em; font-weight: 500; line-height: 1; transition: opacity 200ms var(--ease); }
.plan-price .per { font-size: 13px; color: var(--muted); }
.plan-bill { font-size: 12px; color: var(--faint); min-height: 18px; margin-top: -12px; }
.plan-then { font-size: 13px; color: var(--ink-2); }
.plan-then b { font-weight: 500; color: var(--ink); }
.plan-trial { display: grid; gap: 3px; margin-top: -6px; padding: 11px 13px; border-radius: 12px; background: var(--s1); border: 1px solid var(--line); }
.plan-trial span { font-size: 11.5px; color: var(--muted); }
.plan-trial b { font-size: 13px; font-weight: 500; }
.plan-credits { font-size: 14px; font-weight: 500; padding-top: 18px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; }
.plan-credits span { color: var(--muted); font-weight: 400; }
.plan-list { display: grid; gap: 2px; margin-top: -6px; }
.plan-list li { display: flex; gap: 10px; align-items: center; font-size: 13.5px; color: var(--ink-2); padding: 5px 0; }
.plan-list li .i { width: 15px; height: 15px; color: var(--ink); }
.plan-list li.is-off { color: var(--faint); }
.plan-list li.is-off .i { color: var(--ghost); }

/* ---------- Tooltip ---------- */
/* The label only exists while hovered or focused: a hidden label near the screen edge would widen the page */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); display: none; position: absolute; left: 50%; bottom: calc(100% + 8px);
  transform: translateX(-50%); padding: 5px 8px; border-radius: 7px;
  background: var(--ink); color: #fff; font-size: 11.5px; font-weight: 500; white-space: nowrap; letter-spacing: 0;
  pointer-events: none; z-index: 50; --tip-from: 0 3px;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { display: block; animation: tip-in 120ms var(--ease) 350ms both; }
[data-tip-pos="bottom"]::after { bottom: auto; top: calc(100% + 8px); --tip-from: 0 -3px; }
[data-tip-pos="right"]::after { left: calc(100% + 8px); bottom: auto; top: 50%; transform: translateY(-50%); --tip-from: -3px 0; }
@keyframes tip-in { from { opacity: 0; translate: var(--tip-from); } to { opacity: 1; translate: 0 0; } }
/* Touch screens have no hover: a tapped button would keep its label stuck on screen */
@media (hover: none) { [data-tip]::after { display: none !important; } }

/* ---------- Menu / dropdown ---------- */
.menu {
  position: absolute; z-index: 60; min-width: 200px; padding: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-3);
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity 140ms var(--ease), transform 140ms var(--ease);
}
.menu.is-open { opacity: 1; transform: none; pointer-events: auto; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px; border-radius: 8px; font-size: 13.5px; color: var(--ink-2); text-align: left; transition: background-color var(--t-fast) var(--ease); }
.menu-item:hover, .menu-item:focus-visible { background: var(--s3); outline: none; }
.menu-item .i { color: var(--muted); }
.menu-item.is-danger { color: #b3261e; }
.menu-item.is-danger .i { color: #b3261e; }
.menu-sep { height: 1px; background: var(--line); margin: 6px -6px; }
.menu-label { padding: 8px 10px 4px; font-size: 11.5px; color: var(--faint); font-weight: 500; }

/* ---------- Modal / sheet / drawer ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px;
  background: rgba(20, 20, 20, 0.28); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity 220ms var(--ease);
}
.overlay.is-open { opacity: 1; }
.overlay-dark { background: rgba(10, 10, 10, 0.86); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.modal {
  width: min(560px, 100%); max-height: calc(100dvh - 48px); overflow: auto;
  background: #fff; border-radius: 18px; box-shadow: var(--sh-4);
  transform: scale(0.98) translateY(6px); opacity: 0;
  transition: transform 260ms var(--ease-out), opacity 200ms var(--ease);
}
.overlay.is-open .modal { transform: none; opacity: 1; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 0; }
.modal-body { padding: 18px 24px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--line); background: var(--s1); border-radius: 0 0 18px 18px; }
.modal-title { font-size: 18px; font-weight: 500; letter-spacing: -0.02em; }
.modal-sub { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.close-btn { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--muted); transition: all var(--t) var(--ease); flex: none; }
.close-btn:hover { background: var(--s3); color: var(--ink); }

.drawer-overlay { place-items: stretch end; padding: 0; background: rgba(20,20,20,0.16); backdrop-filter: none; -webkit-backdrop-filter: none; }
.drawer {
  width: min(460px, 100vw); height: 100dvh; background: #fff; box-shadow: var(--sh-4); overflow: auto;
  transform: translateX(24px); opacity: 0; transition: transform 300ms var(--ease-out), opacity 220ms var(--ease);
  display: flex; flex-direction: column;
}
.overlay.is-open .drawer { transform: none; opacity: 1; }
.drawer-head { position: sticky; top: 0; z-index: 2; background: rgba(255,255,255,0.94); backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer-body { padding: 22px; display: grid; gap: 22px; flex: 1; align-content: start; }
.drawer-foot { position: sticky; bottom: 0; background: #fff; padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

.sheet-overlay { place-items: end stretch; padding: 0; }
.sheet {
  width: 100%; max-height: 86dvh; overflow: auto; background: #fff; border-radius: 20px 20px 0 0;
  box-shadow: var(--sh-4); padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(24px); opacity: 0; transition: transform 300ms var(--ease-out), opacity 200ms var(--ease);
}
.overlay.is-open .sheet { transform: none; opacity: 1; }
.sheet-grip { width: 36px; height: 4px; border-radius: 4px; background: var(--s4); margin: 4px auto 14px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 200; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 8px 8px 8px 14px; border-radius: 12px;
  background: var(--ink); color: #fff; font-size: 13.5px; box-shadow: var(--sh-3);
  opacity: 0; transform: translateY(8px) scale(0.98); transition: all 260ms var(--ease-out);
}
.toast.is-in { opacity: 1; transform: none; }
.toast .i { color: rgba(255,255,255,0.7); }
.toast-action { height: 30px; padding: 0 10px; border-radius: 8px; background: rgba(255,255,255,0.12); color: #fff; font-size: 13px; font-weight: 500; }
.toast-action:hover { background: rgba(255,255,255,0.2); }
.toast:not(:has(.toast-action)) { padding-right: 16px; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fff; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: middle; }
.table tbody tr { transition: background-color var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--s1); }
.table tbody tr.is-click { cursor: pointer; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: #fff; }
.table-wrap .table tr:last-child td { border-bottom: 0; }

/* ---------- Skeleton / scan ---------- */
.skeleton { background: linear-gradient(90deg, var(--s3) 0%, var(--s2) 50%, var(--s3) 100%); background-size: 200% 100%; animation: shimmer 1.6s linear infinite; border-radius: 8px; }

/* ---------- Reveal ---------- */
[data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity 900ms var(--ease-out), transform 900ms var(--ease-out); transition-delay: var(--d, 0ms); }
[data-reveal].is-in { opacity: 1; transform: none; }
[data-reveal="fade"] { transform: none; }
[data-reveal="scale"] { transform: scale(0.985) translateY(10px); }
[data-reveal="none"] { opacity: 1; transform: none; transition: none; }

/* ---------- Scrollbars ---------- */
.scroll-thin { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,0.14) transparent; }
.scroll-thin::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll-thin::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
.no-scrollbar { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* ---------- Utilities ---------- */
.row { display: flex; align-items: center; gap: 8px; }
.row-2 { display: flex; align-items: center; gap: 12px; }
.row-3 { display: flex; align-items: center; gap: 16px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 8px; }
.stack-2 { display: grid; gap: 12px; }
.stack-3 { display: grid; gap: 16px; }
.stack-4 { display: grid; gap: 24px; }
.center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.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; }
.nowrap { white-space: nowrap; }

/* ---------- Keyframes ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(239,90,42,0.45); } 70% { box-shadow: 0 0 0 6px rgba(239,90,42,0); } 100% { box-shadow: 0 0 0 0 rgba(239,90,42,0); } }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes riseSm { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes scan { 0% { top: 0%; } 100% { top: 100%; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes breathe { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  [data-reveal] { opacity: 1; transform: none; }
}

/* ---------- Server notices & form alerts ---------- */
/* ---------- Model makers' logos ---------- */
.brand-logo { flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: #fff; border: 1px solid var(--line); overflow: hidden; }
.brand-logo img { display: block; width: 62%; height: 62%; object-fit: contain; }
.brand-logo.is-empty { color: var(--muted); }
.brand-logo.is-empty .i { width: 58%; height: 58%; }
.brand-logo.lg { width: 40px; height: 40px; border-radius: 11px; }
.brand-logo.sm { width: 22px; height: 22px; border-radius: 6px; }
.brand-logo.xs { width: 16px; height: 16px; border: 0; border-radius: 4px; background: transparent; }
.brand-logo.xs img { width: 100%; height: 100%; }
.model-cell { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }

/* ---------- Popover (rich dropdown anchored to a button) ---------- */
.popover {
  position: fixed; z-index: 110; overflow: auto; overscroll-behavior: contain;
  background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--sh-3);
  opacity: 0; transform: translateY(-4px) scale(0.99); transform-origin: top center; pointer-events: none;
  transition: opacity 160ms var(--ease), transform 220ms var(--ease-out);
}
.popover.is-open { opacity: 1; transform: none; pointer-events: auto; }

.server-notice { display: grid; justify-items: center; text-align: center; gap: 12px; max-width: 460px; margin: 0 auto; padding: 48px 24px; }
.server-notice .ico { width: 52px; height: 52px; border-radius: 14px; background: var(--s3); display: grid; place-items: center; color: var(--ink-2); }
.server-notice h1 { font-size: 24px; font-weight: 500; letter-spacing: -0.03em; }
.server-notice p { font-size: 14px; color: var(--muted); line-height: 1.6; }
.server-notice pre { margin: 4px 0 0; padding: 10px 16px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 13px; }
.form-alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: 11px; background: #fdf3f2; border: 1px solid rgba(179, 38, 30, 0.18); color: #8c1d18; font-size: 13.5px; line-height: 1.45; }
.form-alert .i { flex: none; margin-top: 1px; }
.notice-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--s2); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.notice-bar .i { color: var(--muted); flex: none; }

.media.no-poster > video { opacity: 1; }
