/* =========================================================================
   Magnet Studio — stylesheet
   External only (no build step, no CDN, no external fonts).
   Palette lives entirely in custom properties; theme comes from
   <html data-theme="light|dark"> set by theme-boot.js.
   ========================================================================= */

/* ------------------------------- tokens ---------------------------------- */

/* The `hidden` attribute must win over component display rules. Without this,
 * `.stack-tight { display: flex }` etc. keep a [hidden] element visible. */
[hidden] {
  display: none !important;
}

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Roboto,
    "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
    Arial, sans-serif;

  --text-xs: 0.78rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.15rem;
  --text-xl: 1.6rem;
  --text-2xl: 2rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --measure: 68rem;
  --measure-narrow: 42rem;

  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --dur-fast: 120ms;
  --dur: 200ms;

  --ring: 0 0 0 3px var(--focus-ring);
}

html[data-theme="light"] {
  --bg: #f7f5f1;
  --surface: #fffdf9;
  --surface-2: #f1eee7;
  --surface-3: #e8e4db;
  --text: #23211d;
  --muted: #6a655b;
  --border: #e1dcd1;
  --border-strong: #cdc6b8;
  --accent: #2f5d50;
  --accent-ink: #ffffff;
  --accent-soft: rgba(47, 93, 80, 0.1);
  --accent-warm: #9a6320;
  --danger: #9c3b32;
  --danger-soft: rgba(156, 59, 50, 0.1);
  --success: #2e6045;
  --shadow-sm: 0 1px 2px rgba(35, 33, 29, 0.06);
  --shadow-md: 0 10px 30px -18px rgba(35, 33, 29, 0.35);
  --focus-ring: rgba(47, 93, 80, 0.35);
  --scrim: rgba(35, 33, 29, 0.45);
}

html[data-theme="dark"] {
  --bg: #16181a;
  --surface: #1e2225;
  --surface-2: #252a2e;
  --surface-3: #2e3439;
  --text: #ebe7e0;
  --muted: #a09a90;
  --border: #333a40;
  --border-strong: #465057;
  --accent: #9dc7b6;
  --accent-ink: #12211c;
  --accent-soft: rgba(157, 199, 182, 0.12);
  --accent-warm: #e0b884;
  --danger: #eb9c93;
  --danger-soft: rgba(235, 156, 147, 0.14);
  --success: #9dc7b6;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 12px 34px -20px rgba(0, 0, 0, 0.8);
  --focus-ring: rgba(157, 199, 182, 0.4);
  --scrim: rgba(0, 0, 0, 0.6);
}

/* ------------------------------- baseline -------------------------------- */

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

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3,
p,
ul,
ol,
figure {
  margin: 0;
}

h1 {
  font-size: var(--text-2xl);
  line-height: 1.2;
  letter-spacing: -0.015em;
  font-weight: 600;
}

h2 {
  font-size: var(--text-lg);
  line-height: 1.3;
  font-weight: 600;
}

h3 {
  font-size: var(--text-md);
  font-weight: 600;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

img {
  max-width: 100%;
  display: block;
}

ul {
  padding: 0;
  list-style: none;
}

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

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

::selection {
  background: var(--accent-soft);
}

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

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -3rem;
  z-index: 30;
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transition: top var(--dur) var(--ease);
}

.skip-link:focus {
  top: var(--space-3);
}

/* -------------------------------- header --------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--space-3) var(--space-5);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-5);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-name {
  font-size: var(--text-md);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1 1 auto;
}

.site-nav a {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: var(--text-sm);
}

.site-nav a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  background: var(--surface-2);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.credits-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.credits-badge:hover {
  text-decoration: none;
  border-color: var(--border-strong);
}

.credits-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
}

.icon-button:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.icon-button .icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lang-button {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0;
  min-width: 40px;
}

html[data-theme-preference="auto"] .icon-sun,
html[data-theme-preference="auto"] .icon-moon {
  opacity: 1;
}

html[data-theme-preference="auto"] .icon-moon {
  display: none;
}

html[data-theme="light"] .icon-moon,
html[data-theme="dark"] .icon-sun {
  display: none;
}

/* --------------------------------- layout -------------------------------- */

main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-8);
}

main:focus {
  outline: none;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.stack-tight {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.lede {
  color: var(--muted);
  max-width: 44rem;
}

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

.small {
  font-size: var(--text-sm);
}

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

.narrow {
  max-width: var(--measure-narrow);
  margin: 0 auto;
  width: 100%;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.row-between {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: var(--space-4);
}

/* ---------------------------------- card --------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.card-flat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.card-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.card.is-muted {
  opacity: 0.6;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
}

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

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

.btn-danger {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}

.btn-small {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
}

.btn-block {
  width: 100%;
}

.btn .icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field label {
  font-size: var(--text-sm);
  font-weight: 600;
}

.field .hint {
  font-size: var(--text-sm);
  color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
select {
  width: 100%;
  padding: var(--space-3) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

input[aria-invalid="true"] {
  border-color: var(--danger);
}

.password-wrap {
  position: relative;
}

.field-error {
  font-size: var(--text-sm);
  color: var(--danger);
  min-height: 1.2em;
}

/* ------------------------------- drop zone ------------------------------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-7) var(--space-5);
  text-align: center;
  background: var(--surface-2);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--muted);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.dropzone:hover,
.dropzone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.dropzone.is-dragging {
  border-style: solid;
}

.dropzone strong {
  color: var(--text);
  font-size: var(--text-md);
  font-weight: 600;
}

.dropzone-hint {
  font-size: var(--text-sm);
}

.dropzone .btn {
  pointer-events: none;
}

.preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

.preview-thumb {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.preview-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  flex: 1 1 12rem;
}

.preview-name {
  font-size: var(--text-sm);
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* -------------------------------- caption -------------------------------- */

.caption-preview {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.caption-line {
  font-size: var(--text-lg);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.aspect-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: var(--space-2);
}

.aspect-option {
  position: relative;
}

.aspect-option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.aspect-option span {
  display: block;
  padding: var(--space-3);
  text-align: center;
  font-size: var(--text-sm);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.aspect-option input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

.aspect-option input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.aspect-option input:disabled + span {
  opacity: 0.5;
  cursor: not-allowed;
}

/* -------------------------------- progress ------------------------------- */

.progress-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.progress-track {
  position: relative;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}

.progress-track::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 36%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  animation: slide 1.4s var(--ease) infinite;
}

@keyframes slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(320%);
  }
}

.progress-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--muted);
}

/* --------------------------------- result -------------------------------- */

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}

.result-image {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-2);
  overflow: hidden;
}

.result-image img {
  width: 100%;
  height: auto;
}

.detail-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.detail-list div {
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

.detail-list dt,
.detail-list .detail-key {
  color: var(--muted);
}

.detail-list dd,
.detail-list .detail-value {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

/* -------------------------------- pricing -------------------------------- */

.plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: var(--space-4);
  align-items: stretch;
}

.plan {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.plan.is-highlight {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.plan-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.plan-name {
  font-weight: 600;
}

.plan-price {
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.plan-credits {
  color: var(--text);
}

.plan-per {
  font-size: var(--text-sm);
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
}

html[data-theme="light"] .badge {
  color: #24503f;
}

.badge-warm {
  background: rgba(154, 99, 32, 0.12);
  color: var(--accent-warm);
}

.badge-muted {
  background: var(--surface-3);
  color: var(--muted);
}

.notice {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-warm);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: var(--text-sm);
}

.notice-title {
  font-weight: 600;
}

.notice-danger {
  border-left-color: var(--danger);
}

.faq {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: 0;
}

.faq li {
  display: flex;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--muted);
}

.faq li::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  margin-top: 0.55em;
  border-radius: 50%;
  background: var(--accent);
}

/* --------------------------------- account ------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: var(--space-4);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--muted);
}

.stat-value {
  font-size: var(--text-xl);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.stat-value-sm {
  font-size: var(--text-md);
  font-weight: 500;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--surface-3);
  color: var(--muted);
}

.status-chip.is-paid,
.status-chip.is-done {
  background: var(--accent-soft);
  color: var(--accent);
}

html[data-theme="light"] .status-chip.is-paid,
html[data-theme="light"] .status-chip.is-done {
  color: #24503f;
}

.status-chip.is-error,
.status-chip.is-failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-chip.is-pending,
.status-chip.is-running,
.status-chip.is-queued {
  background: rgba(154, 99, 32, 0.14);
  color: var(--accent-warm);
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

th,
td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  font-weight: 600;
  color: var(--muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.delta-pos {
  color: var(--success);
  font-weight: 600;
}

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

.order-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.order-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

.order-row:last-child {
  border-bottom: 0;
}

.order-main {
  flex: 1 1 12rem;
  min-width: 0;
}

.order-title {
  font-weight: 600;
}

.order-sub {
  font-size: var(--text-sm);
  color: var(--muted);
}

.order-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ------------------------- generation thumbnail grid ---------------------- */

.gen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr));
  gap: var(--space-4);
}

.gen-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}

.gen-thumb {
  aspect-ratio: 1 / 1;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.gen-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gen-thumb .placeholder {
  font-size: var(--text-xs);
  color: var(--muted);
  text-align: center;
  padding: var(--space-3);
}

.gen-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
}

.gen-caption {
  font-size: var(--text-sm);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.gen-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.gen-actions .btn {
  flex: 1 1 auto;
}

/* --------------------------- download preferences ------------------------ */

.radio-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.radio-row {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.radio-row:hover {
  border-color: var(--border-strong);
}

.radio-row input {
  margin-top: 0.35em;
  accent-color: var(--accent);
}

.radio-row.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.radio-row.is-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.radio-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.radio-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: var(--text-sm);
}

.radio-hint {
  font-size: var(--text-sm);
  color: var(--muted);
}

.folder-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

.folder-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: var(--scrim);
}

.modal {
  width: min(28rem, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

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

.toast-region {
  position: fixed;
  left: 50%;
  bottom: var(--space-5);
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(30rem, calc(100% - 2rem));
  pointer-events: none;
}

.toast {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  pointer-events: auto;
  animation: toast-in var(--dur) var(--ease);
}

.toast.is-error {
  border-left: 3px solid var(--danger);
}

.toast.is-success {
  border-left: 3px solid var(--accent);
}

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

/* ------------------------------- empty state ----------------------------- */

.empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.error-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  color: var(--text);
  font-size: var(--text-sm);
}

.skeleton {
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  min-height: 1rem;
}

.skeleton-line-sm {
  height: 1.2rem;
  max-width: 14rem;
}

.skeleton-line {
  height: 1.2rem;
  max-width: 24rem;
}

.skeleton-block {
  height: 8rem;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

/* ------------------------------- responsive ------------------------------ */

@media (max-width: 900px) {
  .result-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  main {
    padding: var(--space-5) var(--space-4) var(--space-7);
  }

  .header-inner {
    padding: var(--space-3) var(--space-4);
    gap: var(--space-2) var(--space-3);
  }

  .brand-name {
    font-size: var(--text-sm);
  }

  .site-nav {
    order: 3;
    flex: 1 1 100%;
    gap: var(--space-1);
  }

  .header-actions {
    order: 2;
  }

  h1 {
    font-size: var(--text-xl);
  }

  .card,
  .card-flat,
  .plan {
    padding: var(--space-4);
    border-radius: var(--radius-md);
  }

  .dropzone {
    padding: var(--space-6) var(--space-4);
  }

  .gen-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr));
  }
}

/* ----------------------------- reduced motion ---------------------------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .btn:active {
    transform: none;
  }

  .progress-track::after {
    animation: none;
    width: 100%;
    opacity: 0.5;
  }
}

/* ------------------------- email verification nudge ---------------------- */

.verify-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 18px;
  background: var(--surface-2, #eef4f1);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
}

.verify-banner[hidden] {
  display: none;
}

.verify-banner-text {
  line-height: 1.4;
}

/* ---------------------------- sign-in methods --------------------------- */

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.google-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: #fff;
  color: #1a73e8;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  border: 1px solid var(--border);
}

.auth-divider {
  margin: 2px 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-tabs {
  display: flex;
  gap: 6px;
}

.auth-tabs .btn {
  flex: 1;
}

.auth-tabs .btn[aria-selected="true"] {
  background: var(--accent-soft);
  /* --accent-ink is white in light mode, which is invisible on the pale tint. */
  color: var(--accent);
  font-weight: 600;
}

/* ------------------------------- print (PDF) ----------------------------- */

@media print {
  .site-header,
  .verify-banner,
  .toast-region,
  .btn {
    display: none !important;
  }
}

/* ---------------------------- auth (provider first) ---------------------- */

.auth-shell {
  display: flex;
  justify-content: center;
  padding: var(--space-7) var(--space-4) var(--space-8);
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 400px;
}

.auth-hero {
  margin: 0;
  font-size: clamp(2rem, 6vw, 2.6rem);
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-sub {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.auth-bonus {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.auth-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.auth-provider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}

.auth-provider:hover {
  background: var(--surface-2);
}

.auth-provider.is-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.auth-provider.is-primary:hover {
  filter: brightness(1.06);
}

.auth-provider-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-or {
  margin: 2px 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.auth-field {
  margin: 0;
}

.auth-input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: var(--radius-md);
}

.auth-legal {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.auth-legal a {
  color: var(--accent);
}

.auth-alt {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  font-size: 13px;
}

.auth-alt a {
  color: var(--accent);
  font-weight: 600;
}

.auth-back {
  margin-bottom: -6px;
}

.auth-back .btn {
  padding-left: 0;
}

.auth-hint {
  margin: 0;
}