/* Shared styles for the user-facing portal (landing, sign-up, login, app, billing).
   Mobile first: base styles target 360–390px phones, then enhance at 480 / 640 / 820 / 1024px.
   Spacing follows an 8px scale. Thai text needs generous line-height for stacked vowels and tone marks. */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --text: #1b1c1a;
  --muted: #5d5f5a;
  --border: #e2e2dc;
  --border-strong: #c9c9c1;
  --accent: #2456d6;
  --accent-text: #ffffff;
  --accent-soft: #e7edfc;
  --ok: #1f7a45;
  --ok-soft: #e3f3e8;
  --warn: #8a5a00;
  --warn-soft: #fbf0d9;
  --danger: #b3261e;
  --danger-text: #ffffff;
  --danger-soft: #fbe7e5;
  --backdrop: rgba(16, 18, 14, .45);
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --shadow-lg: 0 8px 32px rgba(20, 30, 60, .12);
  --header-h: 56px;
  --font: "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
/* Theme: html[data-theme] is set by theme.js only when the user forces light or dark; otherwise the
   device decides. Every dark rule must use this pattern (media query guarded by :not([data-theme="light"])
   plus the same values under [data-theme="dark"]) so a forced theme always beats the OS setting. */
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121311;
    --surface: #1b1c1a;
    --surface-2: #252623;
    --text: #ececE8;
    --muted: #a7a9a2;
    --border: #33352f;
    --border-strong: #4a4c45;
    --accent: #7ea2ff;
    --accent-text: #0d1330;
    --accent-soft: #1e2744;
    --ok: #6fd39a;
    --ok-soft: #173123;
    --warn: #f0c46a;
    --warn-soft: #3a2e14;
    --danger: #ff8d84;
    --danger-text: #2a0b09;
    --danger-soft: #3e1c1a;
    --backdrop: rgba(0, 0, 0, .62);
    --shadow: none;
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121311;
  --surface: #1b1c1a;
  --surface-2: #252623;
  --text: #ececE8;
  --muted: #a7a9a2;
  --border: #33352f;
  --border-strong: #4a4c45;
  --accent: #7ea2ff;
  --accent-text: #0d1330;
  --accent-soft: #1e2744;
  --ok: #6fd39a;
  --ok-soft: #173123;
  --warn: #f0c46a;
  --warn-soft: #3a2e14;
  --danger: #ff8d84;
  --danger-text: #2a0b09;
  --danger-soft: #3e1c1a;
  --backdrop: rgba(0, 0, 0, .62);
  --shadow: none;
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
main { flex: 1 0 auto; width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.4; margin: 0 0 8px; font-weight: 700; }
h1 { font-size: 1.75rem; letter-spacing: -.01em; }
h2 { font-size: 1.125rem; font-weight: 600; }
h3 { font-size: 1.0625rem; font-weight: 600; }
p { margin: 0 0 12px; }
code, .mono { font-family: var(--mono); font-size: .9em; }
svg { flex-shrink: 0; }
[hidden] { display: none !important; }
.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; }
.nobr { white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .875rem; line-height: 1.6; }
.prose { max-width: 38rem; }
@media (min-width: 640px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.25rem; }
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 640px) { .wrap { padding: 0 24px; } }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .site-header {
    background: color-mix(in srgb, var(--surface) 84%, transparent);
    -webkit-backdrop-filter: saturate(1.5) blur(14px);
    backdrop-filter: saturate(1.5) blur(14px);
  }
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: var(--header-h); flex-wrap: nowrap;
}
.brand {
  font-weight: 700; font-size: 1.0625rem; color: var(--text); text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; white-space: nowrap; min-width: 0;
}
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: inline-block; position: relative; flex-shrink: 0; }
.brand-mark::after { content: ""; position: absolute; inset: 8px; border: 2px solid var(--accent-text); border-radius: 50%; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; }
.nav-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 0 10px; border-radius: var(--radius-sm);
  color: var(--text); font-weight: 600; font-size: .9375rem; text-decoration: none; white-space: nowrap;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link-text { display: none; }
.btn.btn-nav { min-height: 44px; padding: 0 16px; font-size: .9375rem; }
@media (min-width: 480px) {
  .nav-link-text { display: inline; }
  .nav-link .icon-only { display: none; }
}
/* Auth pages show only the brand on phones */
.nav-auth { display: none; }
@media (min-width: 480px) { .nav-auth { display: flex; } }
/* Billing: back link on the left */
.back-link { margin-left: -10px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: 1rem; line-height: 1.3; text-decoration: none; cursor: pointer;
  text-align: center; transition: background-color .15s, border-color .15s, filter .15s, opacity .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn-soft:hover { background: var(--accent-soft); filter: brightness(.97); }
.btn-outline { background: transparent; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-lg { min-height: 52px; padding: 12px 22px; font-size: 1.0625rem; }
.btn-sm { min-height: 44px; padding: 8px 14px; font-size: .9375rem; }
.btn-block { width: 100%; }
.btn .btn-sub { font-weight: 400; opacity: .85; font-size: .9375rem; }
@media (min-width: 1024px) and (hover: hover) {
  .btn-sm { min-height: 36px; padding: 6px 12px; font-size: .875rem; }
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .9375rem; margin: 0 0 6px; }
.field { margin-bottom: 16px; }
.hint { color: var(--muted); font-size: .875rem; line-height: 1.6; margin-top: 6px; }
.field-error { color: var(--danger); font-size: .875rem; line-height: 1.6; margin-top: 6px; }
input[type="email"], input[type="password"], input[type="text"], input[type="url"], textarea, select {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px; line-height: 1.5; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
textarea { min-height: 128px; resize: vertical; line-height: 1.7; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.row { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .row { grid-template-columns: 2fr 1fr; } }

.pw-field { position: relative; }
.pw-field input { padding-right: 76px; }
.pw-toggle {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  min-height: 44px; min-width: 64px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent;
  color: var(--accent); font: inherit; font-size: .9375rem; font-weight: 600; cursor: pointer;
}
.check-row {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 12px 14px; margin: 0 0 12px;
  background: var(--surface-2); border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; line-height: 1.5;
}
.check-row input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }

/* ---------- Cards & layout ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); min-width: 0;
}
@media (min-width: 640px) { .card { padding: 24px; } }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head h1, .card-head h2 { margin: 0; }
.card-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
.grid { display: grid; gap: 12px; }
.grid-2, .grid-3 { grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid { gap: 16px; } }
.stack > * + * { margin-top: 12px; }
@media (min-width: 640px) { .stack > * + * { margin-top: 16px; } }

/* ---------- Notices ---------- */
.notice { border-radius: var(--radius-sm); padding: 12px 14px; border: 1px solid transparent; margin-bottom: 16px; font-size: .9375rem; line-height: 1.65; }
.notice-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.notice-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.notice-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.notice-info { background: var(--accent-soft); color: var(--text); border-color: transparent; }
.notice strong { display: block; margin-bottom: 2px; }
.hint-warn { display: flex; gap: 8px; align-items: flex-start; color: var(--warn); font-size: .875rem; line-height: 1.6; margin: 0 0 16px; }
.hint-warn svg { margin-top: 2px; }

/* ---------- Secrets & code ---------- */
.secret { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 16px; }
.secret code, .code-block {
  display: block; min-width: 0; padding: 12px 14px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--border); font-family: var(--mono); font-size: .8125rem; line-height: 1.6;
}
.secret code { overflow-wrap: anywhere; word-break: break-all; -webkit-user-select: all; user-select: all; }
.secret .btn { width: 100%; }
.code-block { white-space: pre; overflow-x: auto; margin: 0 0 16px; -webkit-overflow-scrolling: touch; }
@media (min-width: 480px) {
  .secret { flex-direction: row; align-items: stretch; }
  .secret code { flex: 1; }
  .secret .btn { width: auto; min-width: 104px; flex-shrink: 0; }
}

/* ---------- Badges, pills, chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: .875rem; font-weight: 600; line-height: 1.6; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge-pro { background: var(--accent); color: var(--accent-text); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-err { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; flex-shrink: 0; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: .875rem; font-weight: 600;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; max-width: 100%; padding: 2px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  font-size: .875rem; line-height: 1.6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Inline line icon beside small text (chips, tile labels): 16px, inherits the muted text colour. */
.ico { width: 16px; height: 16px; flex-shrink: 0; vertical-align: -3px; margin-right: 6px; }
.chip-btn {
  min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: .9375rem; cursor: pointer; white-space: nowrap;
}
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Disclosure (details/summary) ---------- */
.disclosure > summary, .collapse > summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px; cursor: pointer; font-weight: 600;
}
.disclosure > summary::-webkit-details-marker, .collapse > summary::-webkit-details-marker { display: none; }
.chev {
  width: 10px; height: 10px; flex-shrink: 0; margin-right: 6px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px); transition: transform .2s; color: var(--muted);
}
details[open] > summary .chev { transform: rotate(-135deg) translate(-2px, -2px); }
.disclosure.boxed { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); padding: 0 16px; }
.disclosure.boxed[open] { padding-bottom: 12px; }
.disclosure.boxed > summary { color: var(--text); }
.disclosure.inline > summary { justify-content: flex-start; color: var(--accent); }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.checklist { list-style: none; margin: 0 0 12px; padding: 0; }
.checklist li { position: relative; padding: 6px 0 6px 32px; line-height: 1.6; }
.checklist li::before {
  content: "✓"; position: absolute; left: 0; top: 7px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ok-soft); color: var(--ok); font-size: .8125rem; font-weight: 700; display: grid; place-items: center; line-height: 1;
}
ul.plain { padding-left: 1.2em; margin: 0 0 12px; }
ul.plain li { margin-bottom: 8px; }

/* ---------- Skeletons & empty states ---------- */
.skel {
  display: block; border-radius: 10px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 300% 100%;
}
@media (prefers-reduced-motion: no-preference) { .skel { animation: shimmer 1.4s ease-in-out infinite; } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.skel-line { height: 14px; margin: 10px 0; }
.skel-line.w-40 { width: 40%; }
.skel-line.w-60 { width: 60%; }
.skel-line.w-80 { width: 80%; }
.skel-block { height: 44px; margin-top: 16px; }
.skel-big { height: 40px; width: 45%; margin: 12px 0; }
.empty-state { text-align: center; padding: 20px 8px 8px; color: var(--muted); }
.empty-state .empty-icon {
  width: 44px; height: 44px; border-radius: 50%; background: var(--surface-2); color: var(--muted);
  display: grid; place-items: center; margin: 0 auto 8px;
}
.empty-state p { margin: 0 0 12px; }
.empty { color: var(--muted); padding: 12px 0; }

/* =================================================================
   Landing
   ================================================================= */
.hero { padding: 28px 0 8px; }
.hero-title { font-size: clamp(1.75rem, 1.05rem + 3.4vw, 3rem); line-height: 1.35; margin: 16px 0 12px; letter-spacing: -.015em; }
.hero .lead { font-size: 1.0625rem; line-height: 1.7; color: var(--muted); max-width: 34rem; margin-bottom: 24px; }
.hero .cta { display: flex; flex-direction: column; gap: 12px; }
.hero .cta .btn { width: 100%; }
.trust { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: .875rem; }
.trust li { display: inline-flex; align-items: center; gap: 6px; }
.trust li::before { content: "✓"; color: var(--ok); font-weight: 700; }
.hero-login { margin: 12px 0 0; font-size: .9375rem; color: var(--muted); }
.hero-login a { display: inline-block; padding: 10px 4px; font-weight: 600; }
.hero-demo { display: none; }
@media (min-width: 640px) {
  .hero { padding: 56px 0 48px; }
  .hero .lead { font-size: 1.1875rem; }
  .hero .cta { flex-direction: row; }
  .hero .cta .btn { width: auto; }
  .hero-login { display: none; }
}
@media (min-width: 960px) {
  .hero { padding: 72px 0 56px; }
  .hero-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 56px; align-items: center; }
  .hero-demo { display: block; }
}
.demo-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 24px; box-shadow: var(--shadow-lg); }
.demo-label { font-size: .875rem; color: var(--muted); font-weight: 600; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.demo-prompt { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 16px; }
.demo-steps { list-style: none; margin: 0; padding: 0; }
.demo-steps li { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; font-size: .9375rem; line-height: 1.6; }
.demo-steps li::before {
  content: "✓"; width: 24px; height: 24px; border-radius: 50%; background: var(--ok-soft); color: var(--ok);
  font-size: .8125rem; font-weight: 700; display: grid; place-items: center; flex-shrink: 0; margin-top: 1px;
}
.demo-steps .sub { display: block; color: var(--muted); font-size: .875rem; }

.section { padding: 36px 0; }
.section-title { font-size: 1.375rem; font-weight: 700; margin: 0 0 8px; }
.section-sub { color: var(--muted); max-width: 38rem; margin: 0 0 20px; }
@media (min-width: 640px) {
  .section { padding: 56px 0; }
  .section-title { font-size: 1.75rem; }
}
.section-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

/* How it works: vertical timeline on phones, 3 cards on wide screens */
.timeline { list-style: none; margin: 0 0 8px; padding: 0; counter-reset: step; }
.timeline li { counter-increment: step; position: relative; padding: 0 0 24px 48px; }
.timeline li:last-child { padding-bottom: 8px; }
.timeline li::before {
  content: counter(step); position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-weight: 700; display: grid; place-items: center; font-size: .9375rem; line-height: 1;
}
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 15px; top: 40px; bottom: 8px; width: 2px; background: var(--border); border-radius: 2px; }
.timeline h3 { margin: 2px 0 4px; }
.timeline p { color: var(--muted); margin: 0; }
.more { margin-top: 8px; }
.more ul { color: var(--muted); font-size: .9375rem; }
@media (min-width: 640px) {
  .timeline { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .timeline li { padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
  .timeline li:last-child { padding-bottom: 20px; }
  .timeline li::before { position: static; margin-bottom: 12px; width: 36px; height: 36px; }
  .timeline li:not(:last-child)::after { display: none; }
}
@media (min-width: 960px) { .timeline li { padding: 24px; } .timeline li:last-child { padding-bottom: 24px; } }

/* Plans */
.plan-cards { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) { .plan-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; max-width: 880px; } }
.plan-card {
  position: relative; display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 16px 16px; box-shadow: var(--shadow); min-width: 0;
}
@media (min-width: 640px) { .plan-card { padding: 28px 24px 24px; } }
.plan-card.featured { border: 2px solid var(--accent); box-shadow: var(--shadow-lg); }
.plan-card.skel-card { min-height: 420px; }
.plan-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-name { font-size: 1.125rem; font-weight: 700; margin: 0; }
.plan-tagline { color: var(--muted); font-size: .9375rem; margin: 2px 0 12px; }
.price { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.price-num { font-size: 2.25rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.price-unit { color: var(--muted); font-size: 1rem; }
.features { list-style: none; margin: 0 0 20px; padding: 0; border-top: 1px solid var(--border); flex: 1; }
.features li { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); line-height: 1.55; }
.features li:last-child { border-bottom: 0; }
.feat-label { color: var(--text); font-size: .9375rem; min-width: 0; }
.feat-value { font-weight: 600; text-align: right; font-size: .9375rem; min-width: 0; overflow-wrap: anywhere; max-width: 60%; }
.feat-value.yes { color: var(--ok); }
.feat-value.no { color: var(--muted); font-weight: 400; }
.feat-note { display: block; color: var(--muted); font-weight: 400; font-size: .875rem; }
.plan-note { margin: 0; min-height: 48px; display: flex; align-items: center; justify-content: center; text-align: center; font-size: .9375rem; }

/* Earn */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 12px; }
@media (min-width: 640px) { .tiles { gap: 16px; max-width: 720px; } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 10px; min-width: 0; }
.tile-num { font-size: 1.5rem; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; color: var(--accent); white-space: nowrap; }
.tile-label { color: var(--muted); font-size: .875rem; line-height: 1.5; margin-top: 4px; }
@media (min-width: 640px) { .tile { padding: 16px 20px; } .tile-num { font-size: 2rem; } }
.earn-note { max-width: 38rem; }
.earn .disclosure { max-width: 720px; margin-top: 16px; }

/* Facts */
.facts { list-style: none; margin: 0; padding: 0 16px; display: grid; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.facts li { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--border); }
.facts li:last-child { border-bottom: 0; }
@media (min-width: 820px) {
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 0; background: none; border: 0; }
  .facts li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 20px; }
  .facts li:last-child { border-bottom: 1px solid var(--border); }
}
.fact-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex-shrink: 0; }
.fact-icon.warn { background: var(--warn-soft); color: var(--warn); }
.facts strong { display: block; line-height: 1.5; margin-bottom: 2px; }
.facts p { margin: 0; color: var(--muted); font-size: .9375rem; line-height: 1.65; }

/* Closing CTA */
.cta-band { background: var(--accent-soft); border-radius: 20px; padding: 28px 20px; text-align: center; }
.cta-band h2 { font-size: 1.375rem; font-weight: 700; margin-bottom: 4px; }
.cta-band p { color: var(--muted); margin-bottom: 20px; }
.cta-band .btn { width: 100%; }
@media (min-width: 640px) {
  .cta-band { padding: 48px 32px; }
  .cta-band h2 { font-size: 1.75rem; }
  .cta-band .btn { width: auto; min-width: 240px; }
}

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 24px 0 calc(24px + env(safe-area-inset-bottom)); color: var(--muted); font-size: .9375rem; }
.footer-inner { display: grid; gap: 8px; }
.footer-inner .brand { font-size: 1rem; }
.footer-tag { margin: 0; font-size: .875rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0 16px; margin: 0 -4px; }
.footer-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; color: var(--text); text-decoration: none; font-weight: 600; }
.footer-links a:hover { color: var(--accent); }
.copyright { margin: 0; font-size: .875rem; }
@media (min-width: 820px) {
  .footer-inner { grid-template-columns: 1fr auto; align-items: center; }
  .copyright { grid-column: 1 / -1; }
}

/* =================================================================
   Auth pages (sign-up, login)
   ================================================================= */
.auth-main { padding: 24px 0 calc(40px + env(safe-area-inset-bottom)); }
.auth-card { max-width: 440px; margin: 0 auto; }
.auth-card h1 { font-size: clamp(1.6rem, 6vw, 2rem); margin-bottom: 4px; }
.auth-sub { color: var(--muted); font-size: 1rem; line-height: 1.65; margin-bottom: 24px; }
.auth-alt { text-align: center; margin: 16px 0 0; color: var(--muted); font-size: .9375rem; }
.auth-alt a { display: inline-block; padding: 10px 4px; font-weight: 600; }
.auth-card .btn-primary[type="submit"] { margin-top: 8px; }
@media (min-width: 480px) {
  .auth-main { display: grid; align-content: center; min-height: calc(100vh - var(--header-h)); min-height: calc(100dvh - var(--header-h)); padding: 40px 0 64px; }
  .auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); width: 100%; }
}
.success-hero { text-align: center; margin-bottom: 20px; }
.success-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; margin: 0 auto 12px; }
.success-hero p { color: var(--muted); margin: 0; }
.secret-block { margin-bottom: 8px; }
.secret-block h2 { margin-bottom: 4px; }
.secret-block p { margin-bottom: 8px; }
.auth-card .disclosure.boxed { margin: 8px 0 16px; }

/* =================================================================
   App (dashboard)
   ================================================================= */
.app-main { padding: 0 0 calc(40px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .app-main { padding-bottom: 56px; } }
.app-loading { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }

/* Shell: category tabs + one short page at a time. Phones: a sticky row of tabs under the header that
   scrolls sideways; from 1024px a left sidebar (same pattern as /admin). */
.app-shell { max-width: 1180px; margin: 0 auto; }
.app-tabs {
  position: sticky; top: calc(var(--header-h) + env(safe-area-inset-top)); z-index: 15;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.app-tabs-inner {
  display: flex; gap: 4px; overflow-x: auto; padding: 8px 16px; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; scroll-padding: 0 16px; overscroll-behavior-x: contain;
}
.app-tabs-inner::-webkit-scrollbar { display: none; }
.app-tab {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px;
  color: var(--muted); font-weight: 600; font-size: .9375rem; text-decoration: none; white-space: nowrap; flex-shrink: 0;
  transition: background-color .15s, color .15s;
}
.app-tab svg { width: 18px; height: 18px; flex-shrink: 0; }
.app-tab:hover { color: var(--text); background: var(--surface-2); }
.app-tab[aria-selected="true"] { color: var(--accent); background: var(--accent-soft); }
.app-tab:focus-visible { outline-offset: -2px; }
.app-content { min-width: 0; padding: 16px 16px 0; }
@media (min-width: 640px) { .app-content { padding: 24px 24px 0; } .app-tabs-inner { padding: 8px 24px; } }
@media (min-width: 641px) and (max-width: 1023px) { .app-content { max-width: 816px; margin: 0 auto; } }
@media (min-width: 1024px) {
  .app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); align-items: start; }
  .app-tabs {
    top: var(--header-h); height: calc(100dvh - var(--header-h)); overflow-y: auto;
    border-bottom: 0; border-right: 1px solid var(--border); background: transparent;
  }
  .app-tabs-inner { flex-direction: column; overflow: visible; padding: 24px 12px; gap: 2px; }
  .app-tab { border-radius: var(--radius-sm); min-height: 44px; white-space: normal; line-height: 1.35; padding: 8px 14px; }
  .app-content { padding: 28px 32px 0; max-width: 900px; }
}
.app-panel:focus { outline: none; }
.panel-title { font-size: 1.375rem; margin: 0; }
@media (min-width: 640px) { .panel-title { font-size: 1.5rem; } }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.link-more { font-weight: 600; font-size: .9375rem; white-space: nowrap; display: inline-flex; align-items: center; min-height: 44px; }

/* Account menu */
.account { position: relative; }
.account > summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; min-height: 44px; border-radius: 999px; }
.account > summary::-webkit-details-marker { display: none; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 1.0625rem; text-transform: uppercase; flex-shrink: 0;
}
.account > summary { padding: 2px; }
.account-email-inline { display: none; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .9375rem; }
@media (min-width: 640px) { .account-email-inline { display: block; } .account > summary { padding: 2px 2px 2px 12px; } .account > summary:hover { background: var(--surface-2); } }
.account-menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(280px, calc(100vw - 32px)); z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 8px;
}
.account-menu .menu-email { padding: 8px 12px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.account-menu .menu-email span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.menu-item {
  display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); font: inherit; font-size: 1rem; text-decoration: none; cursor: pointer; text-align: left;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }
/* Sign-up: what is collected and why, next to the button (PDPA notice at collection) */
.collection-notice { margin: 4px 0 16px; line-height: 1.6; }

/* Quota hero */
.quota-card { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "main" "meter" "tiles" "extra" "cta"; }
.quota-card .card-head { grid-area: head; margin-bottom: 8px; }
.quota-main { grid-area: main; }
.quota-meter { grid-area: meter; }
.quota-card .tiles { grid-area: tiles; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 16px 0 0; }
.quota-extra { grid-area: extra; }
.quota-cta { grid-area: cta; margin-top: 16px; }
@media (min-width: 641px) {
  .quota-card { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "head cta" "main main" "meter meter" "tiles tiles" "extra extra"; }
  .quota-cta { margin: 0 0 8px; align-self: start; }
  .quota-cta .btn { width: auto; }
}
.quota-label { color: var(--muted); font-size: .9375rem; margin: 0; }
.stat-xl { font-size: 2.75rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-unit { font-size: 1.125rem; font-weight: 600; color: var(--muted); margin-left: 6px; }
.meter { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 12px 0 8px; }
.meter > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .3s; }
.meter.full > span { background: var(--danger); }
.meter-caption { color: var(--muted); font-size: .875rem; line-height: 1.6; margin: 0; }
.quota-card .tile { background: var(--surface-2); border: 0; }
.quota-card .tile-num { color: var(--text); font-size: 1.25rem; }
.quota-card .tile-label { margin: 0 0 2px; }
.plan-expiry { margin: 12px 0 0; }
.plan-expiry:empty { display: none; }
.models-row { margin-top: 16px; }
.models-row .small { margin: 0 0 6px; }

/* Composer */
.composer .field { margin-bottom: 12px; }
.examples { margin: 0 0 16px; }
.examples .small { margin: 0 0 6px; }
.upsell-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 0 0 16px;
  border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); font-size: .875rem; line-height: 1.55;
}
.upsell-row svg { color: var(--muted); }
.upsell-row span { flex: 1; min-width: 0; }
.upsell-row a { font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; }
.repo-details { margin: 0 0 16px; }
.repo-details > summary { color: var(--accent); justify-content: flex-start; }
.repo-details[open] > summary { margin-bottom: 8px; }
.composer .btn[type="submit"] { width: 100%; }
@media (min-width: 1024px) { .composer .btn[type="submit"] { width: auto; min-width: 220px; } }

/* Card section heads with a count / action */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.section-head h2 { margin: 0; }

/* Tasks */
.task-list > li {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px;
  grid-template-areas: "p" "m" "r";
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.task-list > li:first-child { padding-top: 8px; }
.task-list > li:last-child { border-bottom: 0; padding-bottom: 0; }
.task-prompt { grid-area: p; margin: 0; font-weight: 600; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.task-meta { grid-area: m; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; }
.task-date { color: var(--muted); font-size: .875rem; white-space: nowrap; }
.task-meta .chip { padding: 0 8px; line-height: 1.6; }
.task-result { grid-area: r; min-width: 0; }
.task-result .btn { width: 100%; }
.task-summary { margin: 0; color: var(--muted); font-size: .875rem; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
@media (min-width: 641px) {
  .task-list > li { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "p r" "m r"; gap: 6px 24px; align-items: start; }
  .task-result { justify-self: end; align-self: center; max-width: 280px; text-align: right; }
  .task-result .btn { width: auto; }
}

/* Machines */
.machine-list { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); margin-top: 8px; }
@media (min-width: 641px) { .machine-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.machine { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; min-width: 0; }
.machine-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.machine-name { font-weight: 600; margin: 0; overflow-wrap: anywhere; min-width: 0; }
.machine-spec { color: var(--muted); font-size: .875rem; margin: 2px 0 10px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.mini-stat { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }
.mini-stat b { display: block; font-size: 1.125rem; font-variant-numeric: tabular-nums; line-height: 1.4; }
.mini-stat span { color: var(--muted); font-size: .875rem; }
.machine-seen { color: var(--muted); font-size: .875rem; margin: 0; }
.model-storage { border-top: 1px solid var(--border); margin: 12px 0 10px; padding-top: 12px; }
.model-storage-head { display: flex; justify-content: space-between; gap: 12px; font-size: .875rem; font-weight: 600; margin-bottom: 8px; }
.model-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.model-row { display: grid; gap: 2px; }
.model-row-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.model-name { font-size: .9375rem; min-width: 0; overflow-wrap: anywhere; }
.model-size { color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.model-tag { color: var(--muted); font-size: .75rem; overflow-wrap: anywhere; }
.model-bar { display: block; height: 4px; border-radius: 999px; background: var(--border); overflow: hidden; margin-top: 4px; }
.model-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); opacity: .7; }
.model-empty, .model-free { color: var(--muted); font-size: .875rem; margin: 8px 0 0; }

/* Collapsible secondary cards */
.collapse { padding-top: 4px; padding-bottom: 4px; }
.collapse > summary { min-height: 52px; }
.collapse > summary h2 { margin: 0; }
.collapse[open] { padding-bottom: 16px; }
@media (min-width: 640px) { .collapse { padding-top: 8px; padding-bottom: 8px; } .collapse[open] { padding-bottom: 24px; } }
.collapse-body { padding-top: 4px; }

/* Ledger & payments: two-sided rows */
.ledger-list > li, .pay-list > li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border);
}
.ledger-list > li:last-child, .pay-list > li:last-child { border-bottom: 0; }
.row-main { min-width: 0; }
.row-title { display: block; font-weight: 600; line-height: 1.5; }
.row-sub { display: block; color: var(--muted); font-size: .875rem; line-height: 1.5; }
.row-sub a { display: inline-block; padding: 12px 4px; margin: -12px -4px; }
.delta { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 1.0625rem; }
.delta.plus { color: var(--ok); }
.more-btn { margin-top: 8px; }

/* =================================================================
   Billing
   ================================================================= */
.billing-main { padding: 16px 0 calc(40px + env(safe-area-inset-bottom)); }
.billing-main > .wrap { max-width: 640px; }
.billing-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .billing-main { padding: 32px 0 64px; } .billing-grid { gap: 16px; } }
@media (min-width: 900px) {
  .billing-main > .wrap { max-width: 1000px; }
  .billing-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 24px; }
  .billing-grid > #history { grid-column: 1 / -1; }
}
.plan-hero .pill { margin-bottom: 12px; }
.plan-hero h1 { font-size: clamp(1.6rem, 6vw, 2rem); margin-bottom: 4px; }
.plan-hero .price { margin-bottom: 16px; }
.plan-hero .price-num { font-size: 2.5rem; }
.plan-hero .checklist li { min-height: 44px; display: flex; align-items: center; padding-top: 8px; padding-bottom: 8px; }
.plan-hero .checklist li::before { top: 50%; transform: translateY(-50%); }
.plan-compare { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 14px; margin: 4px 0 0; font-size: .9375rem; color: var(--muted); }
.plan-compare b { color: var(--text); }
.billing-expiry { margin: 12px 0 0; }
.checkout h2 { margin-bottom: 12px; }
.segmented { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0 0 16px; }
@media (max-width: 359px) { .segmented { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.seg { position: relative; margin: 0; font-weight: 400; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60px; padding: 6px 4px;
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); text-align: center; line-height: 1.3;
  transition: border-color .15s, background-color .15s;
}
.seg-box b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.seg-box span { font-size: .875rem; color: var(--muted); }
.seg input:checked + .seg-box { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.seg input:checked + .seg-box span { color: var(--accent); }
.seg input:focus-visible + .seg-box { outline: 2px solid var(--accent); outline-offset: 2px; }
.summary { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px 16px; margin: 0 0 16px; }
.summary-total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-bottom: 10px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.summary-total .amount { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; white-space: nowrap; }
.summary-total .amount small { font-size: 1rem; font-weight: 600; color: var(--muted); margin-left: 4px; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 16px; margin: 0; font-size: .9375rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; min-width: 0; }
.kv .sub { color: var(--muted); font-size: .875rem; }
.pay-explain { color: var(--muted); font-size: .9375rem; margin: 0 0 12px; }
.paybar { margin: 0 0 12px; }
.paybar .btn { width: 100%; min-height: 52px; font-size: 1.0625rem; }
.paybar .small { text-align: center; margin: 6px 0 0; }
@media (max-width: 639px) {
  .paybar {
    position: sticky; bottom: 0; z-index: 10; margin: 0 -16px 12px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -6px 16px rgba(0, 0, 0, .06);
  }
}
.stepper { list-style: none; margin: 0 0 12px; padding: 0; }
.stepper li { position: relative; padding: 0 0 12px 32px; font-size: .9375rem; line-height: 1.6; }
.stepper li::before { content: ""; position: absolute; left: 6px; top: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.stepper li:not(:last-child)::after { content: ""; position: absolute; left: 10px; top: 20px; bottom: 0; width: 2px; background: var(--border); }
.manual { border-top: 1px solid var(--border); margin-top: 8px; }
.manual > summary { font-weight: 600; color: var(--text); }
.manual-steps { list-style: none; margin: 0; padding: 0; counter-reset: mstep; }
.manual-steps > li { counter-increment: mstep; position: relative; padding: 0 0 8px 40px; }
.manual-steps > li::before {
  content: counter(mstep); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; font-size: .875rem; line-height: 1;
}
.manual-steps p { margin: 0 0 4px; font-size: .9375rem; line-height: 1.6; }
.manual-steps code { overflow-wrap: anywhere; }
.disabled-actions { display: grid; gap: 8px; }

/* Empty states inside lists */
.task-list > li.empty-state { display: block; border-bottom: 0; padding: 20px 8px 8px; }
.machine-list > li.empty-state { grid-column: 1 / -1; border: 0; }
.empty-state .btn { width: auto; }

/* =================================================================
   Legal pages (privacy, terms)
   ================================================================= */
.legal-main { padding: 24px 0 calc(48px + env(safe-area-inset-bottom)); }
.legal { max-width: 44rem; margin: 0 auto; }
.legal h1 { margin: 12px 0 8px; }
.legal h2 { margin: 28px 0 10px; }
.legal b { font-weight: 600; }
.legal .checklist li { padding-top: 8px; padding-bottom: 8px; }
.legal-foot { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); }
.legal-foot a { display: inline-block; padding: 10px 0; font-weight: 600; }

/* Studio entry points (landing, app) */
.studio-cta { display: grid; gap: 12px; align-items: center; background: var(--accent-soft); border-color: transparent; }
.studio-cta h2 { margin: 0 0 2px; }
.studio-cta p { margin: 0; color: var(--muted); }
.studio-cta .btn { width: 100%; }
.studio-cta-modes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
@media (min-width: 640px) {
  .studio-cta { grid-template-columns: minmax(0, 1fr) auto; }
  .studio-cta .btn { width: auto; min-width: 200px; }
}
.modes-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 820px) { .modes-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.mode-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.mode-card .mode-emoji {
  display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin-bottom: 12px;
  border-radius: 10px; background: var(--accent-soft); color: var(--accent);
}
.mode-card .mode-emoji svg { width: 22px; height: 22px; display: block; }
.mode-card.soon .mode-emoji { background: var(--surface); color: var(--muted); }
.mode-card h3 { margin: 0 0 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mode-card p { margin: 0; color: var(--muted); font-size: .9375rem; line-height: 1.6; }
.mode-card.soon { background: var(--surface-2); box-shadow: none; }
.header-actions { gap: 8px; }
.quota-card .tile-wide { grid-column: 1 / -1; }
.task-open { color: inherit; text-decoration: none; }
.task-open:hover { color: var(--accent); }
.hero-beta { margin: 8px 0 0; }
.studio-open { width: 100%; margin-top: 12px; }
@media (min-width: 640px) { .studio-open { width: auto; } }

/* =================================================================
   Dialogs (dialog.js: confirmDialog / alertDialog) — shared by every user-facing page
   Phones (<= 600px): bottom sheet. Wider: centred card. Motion 140-180ms, none if reduced motion.
   ================================================================= */
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--danger-text); }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); }
.dlg {
  width: min(440px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 48px); padding: 0; margin: auto;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg); font-family: var(--font); overflow: auto; overscroll-behavior: contain;
}
.dlg::backdrop { background: rgba(16, 18, 14, .45); }
:root[data-theme="dark"] .dlg::backdrop { background: rgba(0, 0, 0, .62); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .dlg::backdrop { background: rgba(0, 0, 0, .62); } }
.dlg-card { padding: 22px 22px 18px; }
.dlg-title { font-size: 1.125rem; font-weight: 700; line-height: 1.5; margin: 0 0 6px; }
.dlg-body { color: var(--muted); font-size: .9375rem; line-height: 1.65; }
.dlg-body p { margin: 0 0 8px; }
.dlg-body p:last-child { margin-bottom: 0; }
.dlg-quote {
  color: var(--text); font-weight: 600; padding: 8px 12px; border-radius: 10px; background: var(--surface-2);
  overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.dlg-actions .btn { min-width: 96px; }
.dlg:focus { outline: none; }
@media (max-width: 600px) {
  .dlg {
    width: 100%; max-width: 100%; margin: auto 0 0; max-height: 90dvh;
    border-radius: 20px 20px 0 0; border-width: 1px 0 0;
  }
  .dlg-card { padding: 8px 20px calc(16px + env(safe-area-inset-bottom)); }
  .dlg-card::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 0 auto 14px; }
  .dlg-actions { flex-direction: column-reverse; gap: 8px; margin-top: 18px; }
  .dlg-actions .btn { width: 100%; min-height: 48px; }
}
@media (prefers-reduced-motion: no-preference) {
  .dlg[open] { animation: dlg-in .18s cubic-bezier(.2, .8, .2, 1); }
  .dlg[open]::backdrop { animation: dlg-fade .18s ease; }
  .dlg.dlg-closing { animation: dlg-out .14s ease forwards; }
  .dlg.dlg-closing::backdrop { animation: dlg-fade .14s ease reverse forwards; }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 600px) {
  .dlg[open] { animation-name: dlg-up; }
  .dlg.dlg-closing { animation-name: dlg-down; }
}
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes dlg-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(4px) scale(.98); } }
@keyframes dlg-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes dlg-down { from { transform: none; } to { transform: translateY(100%); } }
@keyframes dlg-fade { from { opacity: 0; } to { opacity: 1; } }

/* =================================================================
   Theme choice (theme.js): segmented control (Studio settings, account menu) and the landing toggle
   ================================================================= */
.theme-seg {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; padding: 3px; margin: 0;
  border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border);
}
.theme-opt { position: relative; margin: 0; font-weight: 600; cursor: pointer; }
.theme-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.theme-opt span {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 6px;
  border-radius: 9px; color: var(--muted); font-size: .875rem; line-height: 1.2; white-space: nowrap;
  transition: background-color .15s, color .15s;
}
.theme-opt svg { width: 16px; height: 16px; flex-shrink: 0; }
.theme-opt:hover span { color: var(--text); }
.theme-opt input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--border); }
.theme-opt input:checked + span svg { color: var(--accent); }
.theme-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.theme-row { padding: 8px 4px 6px; border-top: 1px solid var(--border); margin-top: 4px; }
.theme-row-label { display: block; margin: 0 8px 6px; font-size: .8125rem; font-weight: 600; color: var(--muted); }
.theme-toggle { border: 0; background: transparent; cursor: pointer; font: inherit; color: var(--muted); padding: 0; }
.theme-toggle:hover { color: var(--text); }
.theme-toggle .ti { display: none; }
:root:not([data-theme-pref]) .theme-toggle .ti-auto,
:root[data-theme-pref="auto"] .theme-toggle .ti-auto,
:root[data-theme-pref="light"] .theme-toggle .ti-light,
:root[data-theme-pref="dark"] .theme-toggle .ti-dark { display: block; }
/* Landing header on small phones: brand + theme + login + Studio must fit in one row */
.btn-nav { white-space: nowrap; gap: 0; }
@media (max-width: 419px) {
  .wide-only { display: none; }
  .site-header .nav { gap: 0; }
  .btn.btn-nav { padding: 0 14px; margin-left: 4px; }
}

/* Landing: contribute section links to the worker download page (/worker) */
.earn-cta { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
@media (min-width: 640px) { .earn-cta { flex-direction: row; flex-wrap: wrap; } }
/* App: contribute card (download link, token + one-line command) */
.contrib-steps { margin: 0 0 12px; padding-left: 1.3em; color: var(--muted); }
.contrib-steps li + li { margin-top: 2px; }
.contrib-dl { margin-bottom: 12px; }
.contrib-foot { margin: 10px 0 0; }
.secret-label { margin: 8px 0 0; font-weight: 600; }
/* Landing header: the /worker link needs room; small phones reach it from the contribute section and footer */
@media (max-width: 479px) { .nav-worker { display: none; } }

/* =================================================================
   Site language (i18n.js, docs/specs/i18n.md) and the public pages' signed-in header (authNav.js)
   ================================================================= */
/* English replaces the Thai source text once the dictionary is in: keep the page hidden until then
   (i18n.js removes the class after at most 3 s whatever happens) */
html.i18n-pending body { visibility: hidden; }
/* Log in / Dashboard: keep the space, show neither until /api/session has answered */
html:not(.auth-known) [data-auth-slot] { visibility: hidden; }
.lang-toggle { border: 0; background: transparent; cursor: pointer; font: inherit; color: var(--muted); gap: 4px; padding: 0 8px; }
.lang-toggle:hover { color: var(--text); }
.lang-toggle svg { flex-shrink: 0; }
.lang-code { font-size: .8125rem; font-weight: 700; letter-spacing: .04em; }
@media (max-width: 419px) { .lang-toggle .icon-only-lang { display: none; } }
.lang-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); justify-self: start; }
.lang-opt {
  border: 0; background: transparent; font: inherit; font-size: .875rem; font-weight: 600; color: var(--muted);
  min-height: 36px; padding: 0 14px; border-radius: 9px; cursor: pointer;
}
.lang-opt:hover { color: var(--text); }
.lang-opt[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--border); }
.lang-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.lang-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .footer-inner .lang-seg { grid-column: 2; justify-self: end; } }
/* Public header (landing, /worker). Wide screens: language, theme, links, log in / dashboard, Open Studio.
   Phones: brand + one primary button (Open Studio signed in, Log in otherwise) + a menu sheet
   (<details>, closed by authNav.js on an outside tap or Escape) holding the rest. */
.nav-menu { position: relative; display: none; }
.site-header .wrap:has(.nav-menu) .brand { flex-shrink: 0; }
.nav-login { display: none; }
.nav-menu-btn { list-style: none; cursor: pointer; color: var(--text); }
.nav-menu-btn::-webkit-details-marker { display: none; }
.nav-menu[open] > .nav-menu-btn { background: var(--surface-2); }
.nav-sheet {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  width: min(264px, calc(100vw - 24px)); padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); display: grid; gap: 2px;
}
.nav-sheet-item, .nav-sheet-row {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; border-radius: var(--radius-sm);
  color: var(--text); font: inherit; font-weight: 600; font-size: .9375rem; text-decoration: none; text-align: left; width: 100%;
}
.nav-sheet-item > svg, .nav-sheet-row > svg, .nav-sheet-ti { color: var(--muted); flex-shrink: 0; }
.nav-sheet-item:hover { background: var(--surface-2); }
.nav-sheet-row { border-top: 1px solid var(--border); border-radius: 0; margin-top: 4px; padding-top: 4px; }
.nav-sheet-label { flex: 1; }
.nav-sheet-row .lang-seg { padding: 2px; }
.nav-sheet-row .lang-opt { min-height: 36px; min-width: 44px; padding: 0 10px; }
.nav-sheet .theme-toggle { color: var(--text); padding: 0 12px; }
.nav-sheet-ti { display: inline-flex; width: 20px; height: 20px; }
@media (max-width: 719px) {
  .site-header .nav-wide { display: none; }
  .site-header .nav { gap: 4px; flex-shrink: 0; }
  .nav-menu { display: block; }
  .nav-login { display: inline-flex; }
  html:not([data-auth="in"]) .site-header .nav-studio { display: none; }
  .site-header .btn.btn-nav { padding: 0 16px; margin-left: 0; }
}
@media (min-width: 360px) and (max-width: 719px) { .site-header .nav-studio .wide-only { display: inline; } }
@media (max-width: 359px) {
  .site-header .brand { font-size: 1rem; gap: 6px; }
  .site-header .btn.btn-nav { padding: 0 12px; font-size: .875rem; }
  .site-header .nav-menu-btn { min-width: 40px; padding: 0 8px; }
}
/* Billing header: back link, brand, language */
.back-link ~ .nav { margin-right: -8px; }

/* Landing: "new" announcement, six modes, image showcase */
.pill-new { gap: 8px; padding-left: 4px; }
.pill-tag { display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: .75rem; font-weight: 700; }
@media (min-width: 820px) { .modes-grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.showcase { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 640px) { .showcase { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
.shot { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.shot img { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: cover; background: var(--surface-2); }
.shot figcaption { padding: 12px 14px 14px; display: grid; gap: 2px; }
.shot-label { font-size: .75rem; font-weight: 700; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; }
.shot-prompt { font-size: .9375rem; line-height: 1.55; color: var(--text); }
.showcase-note { display: flex; align-items: flex-start; gap: 8px; margin: 14px 0 0; }
.showcase-note .ico { width: 16px; height: 16px; flex-shrink: 0; margin-top: 3px; }
@media (max-width: 639px) {
  /* Phones: a swipeable row instead of three full-width images */
  .showcase { grid-auto-flow: column; grid-auto-columns: 78%; grid-template-columns: none; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scroll-padding-left: 16px; }
  .shot { scroll-snap-align: start; }
}
.legal-note { margin: 12px 0; }
/* "nobr" keeps Thai phrases whole; English wraps between words by itself */
html[lang="en"] .nobr { white-space: normal; }
html[lang="en"] .hero-title { font-size: clamp(1.75rem, 1.1rem + 2.8vw, 2.625rem); line-height: 1.2; hyphens: manual; }

/* =================================================================
   App tabs: overview, usage, tasks, developer, account
   ================================================================= */
/* Header account menu: a thin divider before "account settings" and "log out" */
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* Overview */
.ov-hello { display: grid; gap: 4px; }
.ov-plan { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-size: .9375rem; }
.ov-plan:empty { display: none; }
.ov-stats { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
@media (min-width: 560px) { .ov-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; } }
.ov-stat {
  display: grid; gap: 2px; padding: 14px 16px; min-width: 0; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text); text-decoration: none;
  transition: border-color .15s;
}
.ov-stat:hover { border-color: var(--border-strong); }
@media (max-width: 559px) {
  .ov-stat { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "l n" "s n"; align-items: center; column-gap: 12px; }
  .ov-stat .ov-stat-label { grid-area: l; }
  .ov-stat .ov-stat-num { grid-area: n; }
  .ov-stat .ov-stat-sub { grid-area: s; }
}
.ov-stat-label { color: var(--muted); font-size: .875rem; font-weight: 600; }
.ov-stat-num { font-size: 1.625rem; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ov-stat-sub { color: var(--muted); font-size: .8125rem; line-height: 1.5; }
.ov-stat-sub:empty { display: none; }
.ov-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 8px; }
@media (min-width: 560px) { .ov-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ov-action {
  display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); color: var(--text); text-decoration: none; min-width: 0; transition: background-color .15s, border-color .15s;
}
.ov-action:hover { background: var(--surface-2); }
.ov-action-ico { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2); color: var(--accent); display: grid; place-items: center; flex-shrink: 0; }
.ov-action-ico svg { width: 20px; height: 20px; }
.ov-action-text { display: grid; min-width: 0; line-height: 1.45; }
.ov-action-text b { font-weight: 600; }
.ov-action-text span { color: var(--muted); font-size: .8125rem; }
.ov-action-accent { background: var(--accent-soft); border-color: transparent; }
.ov-action-accent:hover { background: var(--accent-soft); filter: brightness(.98); }
.ov-action-accent .ov-action-ico { background: var(--surface); }
.section-head .link-more { margin: -10px 0; }

/* Usage: plan comparison */
.compare-table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.compare-table th, .compare-table td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.compare-table tr:last-child td, .compare-table tr:last-child th { border-bottom: 0; }
.compare-table thead th { font-size: .875rem; color: var(--muted); font-weight: 600; padding-top: 4px; }
.compare-table tbody th { font-weight: 400; color: var(--muted); }
.compare-table td { font-weight: 600; font-variant-numeric: tabular-nums; }
.compare-table th:first-child { padding-left: 0; }
.compare-table td:last-child, .compare-table th:last-child { padding-right: 0; }

/* Tasks: status filter */
.task-filter {
  display: flex; gap: 2px; padding: 3px; margin: 0 0 8px; overflow-x: auto; scrollbar-width: none; max-width: 100%;
  border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); width: fit-content;
}
.task-filter::-webkit-scrollbar { display: none; }
.filter-opt { position: relative; margin: 0; font-weight: 600; cursor: pointer; flex-shrink: 0; }
.filter-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.filter-opt span { display: flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 9px; color: var(--muted); font-size: .875rem; white-space: nowrap; }
.filter-opt:hover span { color: var(--text); }
.filter-opt input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--border); }
.filter-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.task-list > li.empty { border-bottom: 0; color: var(--muted); padding: 16px 0 4px; }

/* Machines: contribute actions */
.contrib-actions { display: grid; gap: 8px; margin-bottom: 12px; }
.contrib-actions .contrib-dl { margin: 0; }
@media (min-width: 480px) { .contrib-actions { display: flex; flex-wrap: wrap; } }
#contribute:focus { outline: none; }

/* Developer */
.dev-steps { margin: 0; padding-left: 1.3em; }
.dev-steps li + li { margin-top: 6px; }
.dev-steps code { overflow-wrap: anywhere; }
kbd {
  font-family: var(--mono); font-size: .8125rem; padding: 1px 6px; border-radius: 6px; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px;
}
#dev-curl { font-size: .8125rem; line-height: 1.6; }
.api-ref { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px 16px; margin: 0; }
.api-ref dt { margin-top: 8px; }
.api-ref dt:first-child { margin-top: 0; }
.api-ref dd { margin: 0; color: var(--muted); }
@media (min-width: 560px) { .api-ref { grid-template-columns: max-content minmax(0, 1fr); } .api-ref dt { margin-top: 0; } }

/* Account */
.acct-kv { grid-template-columns: max-content minmax(0, 1fr); }
.acct-kv dd { text-align: left; overflow-wrap: anywhere; }
.acct-kv dd .badge { margin-right: 6px; }
.pw-form { max-width: 420px; }
.pw-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pw-form { margin-top: 4px; }
.prefs { display: grid; gap: 12px; max-width: 420px; }
.pref-row { display: grid; gap: 6px; }
.pref-label { font-size: .875rem; font-weight: 600; color: var(--muted); }
.link-rows { display: grid; }
.link-row {
  display: grid; gap: 0; padding: 10px 0; min-height: 52px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border);
}
.link-row:last-child { border-bottom: 0; padding-bottom: 0; }
.link-row > span:first-child { font-weight: 600; color: var(--accent); }
.link-row:hover > span:first-child { text-decoration: underline; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.danger-zone h2 { color: var(--danger); }
.btn-danger-outline { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger-soft); }
/* Phones: shortcuts as a compact 2 x 2 grid (icon over the label) */
@media (max-width: 559px) {
  .ov-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-action { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; }
  .ov-action-text span { display: none; }
  .ov-action-text b { font-size: .9375rem; line-height: 1.4; }
}
.quota-card .tiles { max-width: none; }
/* Deep links inside a tab (#contribute): clear the sticky tab row on phones and tablets */
@media (max-width: 1023px) { .app-panel .card { scroll-margin-top: 64px; } }

/* File storage (account tab): keep on my device / keep on the Hub */
.storage-opts { display: grid; gap: 8px; margin: 12px 0; }
.storage-opt { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.storage-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.storage-opt input { margin: 4px 0 0; flex: none; width: 18px; height: 18px; accent-color: var(--accent); }
.storage-opt-text { display: grid; gap: 2px; min-width: 0; }
.storage-opt-text b { font-weight: 600; }
.storage-opt-text .small { font-weight: 400; line-height: 1.55; }
.storage-device { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 12px; }
.storage-device .field { margin-bottom: 12px; }
.storage-device select { width: 100%; max-width: 420px; }
