:root {
  --bg: #FFFFFF;
  --surface: #FDFDFC;
  --surface-soft: rgba(0,0,0,0.03);
  --text: #171717;
  --text-soft: #404040;
  --muted: #737373;
  --muted-light: #A3A3A3;
  --placeholder: #888888;
  --line: rgba(0,0,0,0.06);
  --line-strong: rgba(0,0,0,0.10);
  --line-hover: rgba(0,0,0,0.16);
  --primary: #000000;
  --primary-hover: rgba(0,0,0,0.80);
  --primary-inverse: #FFFFFF;
  --success: #166534;
  --success-soft: rgba(22,101,52,0.08);
  --success-border: rgba(22,101,52,0.12);
  --warning: #B54708;
  --warning-soft: rgba(181,71,8,0.08);
  --warning-border: rgba(181,71,8,0.12);
  --danger: #E53E3E;
  --danger-soft: rgba(229,62,62,0.08);
  --danger-border: rgba(229,62,62,0.14);
  --shadow: none; --shadow-soft: none; --shadow-lift: none;
  --radius: 16px; --radius-sm: 12px; --radius-xs: 8px; --radius-full: 999px;
  --shell-gutter: 24px; --shell-max: 1152px;
  --ease-out: cubic-bezier(0.22,1,0.36,1);
  --ease-soft: cubic-bezier(0.16,1,0.3,1);
  --ring: 0 0 0 3px rgba(0,0,0,0.08);
  --font-sans: "Geist Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { margin: 0; color: var(--text); background: var(--bg); font-family: var(--font-sans); font-size: 15px; line-height: 1.65; letter-spacing: -0.01em; text-rendering: optimizeLegibility; }
body.has-dialog, body.is-generating { overflow: hidden; }
a { color: var(--text); text-decoration: none; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; }
button { border: 0; background: none; }
button:not(:disabled) { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
.hidden { display: none !important; }

/* Shell */
.app-shell { width: min(var(--shell-max), calc(100% - var(--shell-gutter))); margin: 0 auto; padding: 14px 0 40px; }
@media (min-width: 1400px) { :root { --shell-gutter: 40px; --shell-max: 1280px; } }

/* Site Header */
.site-header { position: sticky; top: 12px; z-index: 1000; display: grid; grid-template-columns: minmax(160px, auto) minmax(200px, 1fr) auto; align-items: center; gap: 16px; min-height: 60px; margin-bottom: 20px; padding: 8px 16px; border: 1px solid var(--line); border-radius: var(--radius-full); background: rgba(255,255,255,0.94); backdrop-filter: blur(16px) saturate(1.12); -webkit-backdrop-filter: blur(16px) saturate(1.12); }
.site-brand { min-width: 0; display: inline-grid; grid-template-columns: 36px minmax(0, auto); align-items: center; gap: 10px; color: var(--text); text-decoration: none; transition: transform 0.2s ease; }
.site-brand:hover { transform: scale(1.03); }
.site-brand-mark, .brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--radius-xs); background: var(--text); }
.site-brand-mark svg, .brand-mark svg { width: 29px; height: 29px; display: block; }
.site-brand-mark .icon-frame, .site-brand-mark .icon-line, .site-brand-mark .icon-dot,
.brand-mark .icon-frame, .brand-mark .icon-line, .brand-mark .icon-dot { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.site-brand-mark .ai-spark, .brand-mark .ai-spark { fill: rgba(255,255,255,0.45); stroke: #fff; stroke-width: 0.5; }
.site-brand-mark .ai-spark.small, .brand-mark .ai-spark.small { fill: #fff; stroke: none; opacity: 0.8; }
.site-brand-name { min-width: 0; overflow: hidden; color: var(--text); font-size: 15px; font-weight: 700; line-height: 1; letter-spacing: -0.025em; text-overflow: ellipsis; white-space: nowrap; }
.site-nav { justify-self: center; display: inline-flex; align-items: center; gap: 4px; min-width: 0; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius-full); background: var(--surface-soft); }
.site-nav a { height: 32px; min-width: 64px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-full); padding: 0 14px; color: var(--muted); font-size: 13px; font-weight: 500; text-decoration: none; letter-spacing: -0.01em; transition: background 0.2s ease, color 0.2s ease; }
.site-nav a:hover { background: rgba(0,0,0,0.04); color: var(--text); }
.site-nav a.active { background: var(--primary); color: var(--primary-inverse); }
.site-actions { justify-self: end; display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.site-balance { height: 32px; display: inline-flex; align-items: center; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius-full); background: transparent; color: var(--text-soft); font-size: 13px; font-weight: 500; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.site-action { height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-full); padding: 0 14px; font-size: 13px; font-weight: 500; white-space: nowrap; text-decoration: none; border: 1px solid var(--line); background: transparent; color: var(--muted); transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease; }
.site-action:hover { background: rgba(0,0,0,0.04); color: var(--text); border-color: var(--line-hover); }
.site-action-primary { border: 0; background: var(--primary); color: var(--primary-inverse); }
.site-action-primary:hover { background: var(--primary-hover); color: var(--primary-inverse); border-color: transparent; }
.site-invite-code { height: 32px; max-width: 150px; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-full); padding: 0 14px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease; }
.site-invite-code:hover { background: rgba(0,0,0,0.04); color: var(--text); border-color: var(--line-hover); }
.site-menu-button, .site-mobile-menu { display: none; }

@media (max-width: 980px) { .site-header { grid-template-columns: minmax(140px, 1fr) auto; } .site-nav { order: 3; grid-column: 1 / -1; justify-self: stretch; display: grid; grid-template-columns: repeat(auto-fit, minmax(68px, 1fr)); } .site-actions { grid-column: 2; } }
@media (max-width: 720px) {
  .site-header { position: sticky; top: 10px; z-index: 1000; display: grid !important; grid-template-columns: minmax(0, 1fr) 44px !important; justify-content: space-between; align-items: center; min-height: 56px; padding: 8px 12px 8px 16px; border-radius: var(--radius-full); overflow: visible !important; gap: 12px; }
  .site-brand { width: auto; grid-template-columns: 30px minmax(0, auto) !important; gap: 9px; padding: 0; align-items: center; }
  .site-brand-name { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .site-brand-mark { width: 30px; height: 30px; border-radius: 8px; }
  .site-brand-mark svg { width: 24px; height: 24px; }
  .site-nav, .site-actions { display: none; }
  .site-menu-button { width: 44px; height: 44px; display: grid; place-content: center; gap: 5px; border: 1px solid var(--line); border-radius: 13px; background: #fff; cursor: pointer; }
  .site-menu-button span { width: 18px; height: 2px; border-radius: var(--radius-full); background: var(--text); transition: transform 0.18s ease, opacity 0.18s ease; }
  .site-header.is-menu-open .site-menu-button span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .site-header.is-menu-open .site-menu-button span:nth-child(2) { opacity: 0; }
  .site-header.is-menu-open .site-menu-button span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .site-mobile-menu { position: absolute; top: calc(100% + 8px); right: 0; width: min(280px, calc(100vw - 24px)); display: none; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,0.98); -webkit-backdrop-filter: blur(16px) saturate(1.12); backdrop-filter: blur(16px) saturate(1.12); }
  .site-header.is-menu-open .site-mobile-menu { display: grid; }
  .site-mobile-balance { min-height: 40px; display: flex; align-items: center; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius-full); color: var(--text-soft); font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .site-mobile-nav, .site-mobile-actions { display: grid; grid-template-columns: 1fr; gap: 6px; }
  .site-mobile-nav a, .site-mobile-actions a, .site-mobile-actions button { width: 100%; min-height: 40px; display: flex; align-items: center; justify-content: flex-start; padding: 0 14px; border: 1px solid transparent; border-radius: var(--radius-full); background: var(--surface-soft); color: var(--text-soft); font-size: 13px; font-weight: 600; text-align: left; text-decoration: none; cursor: pointer; }
  .site-mobile-nav a.active, .site-mobile-actions button { border-color: var(--primary); background: var(--primary); color: var(--primary-inverse); }
  .site-mobile-nav a:not(.active):hover, .site-mobile-actions a:hover { border-color: var(--line-strong); background: rgba(0,0,0,0.04); color: var(--text); }
  .app-shell { padding-bottom: 96px; }
}

/* Mobile Bottom Nav */
.mobile-bottom-nav, .mobile-account-sheet { display: none; }
@media (max-width: 720px) {
  .mobile-bottom-nav { position: fixed; right: 12px; bottom: 12px; left: 12px; z-index: 1100; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; padding: 5px; border: 1px solid var(--line); border-radius: var(--radius-full); background: rgba(255,255,255,0.96); backdrop-filter: blur(16px) saturate(1.12); -webkit-backdrop-filter: blur(16px) saturate(1.12); }
  .mobile-bottom-nav a, .mobile-bottom-nav button { min-width: 0; min-height: 44px; display: grid; place-items: center; gap: 1px; border: 0; border-radius: var(--radius-full); background: transparent; color: var(--muted); font-size: 10px; font-weight: 600; text-decoration: none; letter-spacing: -0.01em; }
  .mobile-bottom-nav .mobile-nav-icon { width: 22px; height: 22px; display: grid; place-items: center; line-height: 1; }
  .mobile-bottom-nav .mobile-nav-icon svg { width: 22px; height: 22px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-bottom-nav a.active, .mobile-bottom-nav button.active { background: var(--primary); color: var(--primary-inverse); }
  .mobile-account-sheet { position: fixed; inset: 0; z-index: 1200; display: grid; align-items: end; padding: 12px; background: rgba(0,0,0,0.30); }
  .mobile-account-sheet.hidden { display: none; }
  .mobile-account-panel { width: 100%; display: grid; gap: 12px; border-radius: var(--radius); padding: 20px; background: var(--surface); border: 1px solid var(--line); }
  .mobile-account-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .mobile-account-balance { min-height: 42px; display: flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-full); padding: 0 16px; color: var(--text-soft); font-weight: 600; font-size: 14px; }
  .mobile-account-invite { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: var(--radius-full); padding: 0 16px; background: transparent; color: var(--text-soft); font-size: 13px; font-weight: 600; text-align: left; }
  .mobile-account-invite strong { font-family: var(--font-mono); }
  .mobile-account-actions { display: grid; gap: 8px; }
  .mobile-account-actions a, .mobile-account-actions button { min-height: 42px; display: flex; align-items: center; justify-content: flex-start; border: 1px solid var(--line); border-radius: var(--radius-full); padding: 0 16px; background: transparent; color: var(--text-soft); font-size: 14px; font-weight: 500; text-align: left; text-decoration: none; }
  .mobile-account-actions button { border: 0; background: var(--primary); color: var(--primary-inverse); font-weight: 600; }
}

/* Old Topbar compat */
.app-topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; min-height: 60px; margin-bottom: 20px; padding: 8px 16px; border: 1px solid var(--line); border-radius: var(--radius-full); background: rgba(255,255,255,0.94); backdrop-filter: blur(16px) saturate(1.12); -webkit-backdrop-filter: blur(16px) saturate(1.12); }
.topbar-brand { min-width: 0; width: fit-content; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; align-items: center; color: inherit; text-decoration: none; }
.brand-copy { min-width: 0; }
.eyebrow, .brand-copy .eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 10px; font-weight: 600; line-height: 1.2; letter-spacing: 0.04em; text-transform: uppercase; }

/* Typography */
h1, h2 { margin: 0; color: var(--text); line-height: 1.15; letter-spacing: -0.02em; }
h1 { font-size: 36px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
h2 { font-size: 20px; font-weight: 600; }
.grid { display: grid; gap: 16px; }
.two-col { grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); align-items: stretch; }
.narrow-left { grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); }

/* Cards */
.card, .stat-card { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,0.85); backdrop-filter: blur(12px) saturate(1.08); -webkit-backdrop-filter: blur(12px) saturate(1.08); }
.card { padding: 20px; }
.section-card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 50px; margin-bottom: 16px; }
.card-head > div { min-width: 0; }
.card-head h2 { color: var(--text); font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.card-head-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; flex-wrap: wrap; }

/* Buttons */
.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: var(--radius-full); padding: 0 24px; font-weight: 500; font-size: 14px; line-height: 1; text-align: center; letter-spacing: -0.01em; transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease; }
.button.primary { border-color: var(--primary); background: var(--primary); color: var(--primary-inverse); }
.button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.button.secondary { border-color: var(--line); background: transparent; color: var(--text-soft); }
.button.secondary:hover, .button.secondary.active { border-color: var(--line-hover); background: rgba(0,0,0,0.04); color: var(--text); }
.button.danger { border-color: var(--danger-border); background: transparent; color: var(--danger); }
.button.danger:hover { background: var(--danger-soft); }
.button.small { min-height: 32px; padding: 0 16px; font-size: 13px; }
.button.online-action { border-color: var(--line); background: transparent; color: var(--text-soft); }
.button.online-action:hover { border-color: var(--line-hover); background: rgba(0,0,0,0.04); color: var(--text); }
.button.disabled { pointer-events: none; opacity: 0.4; }

/* Badges & Status */
.badge, .status { min-height: 26px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: var(--radius-full); padding: 0 10px; background: transparent; color: var(--text-soft); font-size: 12px; font-weight: 500; white-space: nowrap; letter-spacing: -0.01em; }
.status.succeeded, .alert.success, .inline-message.success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.status.failed, .alert.error, .inline-message.error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.status.running, .status.queued, .alert.warning, .inline-message.warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.status.deleted { background: var(--surface-soft); color: var(--muted); border-color: var(--line); }
.record-meta .status { flex: 0 0 auto; min-height: 22px; padding: 0 8px; font-size: 10px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }

/* Alerts */
.alert, .inline-message { margin-bottom: 14px; border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 12px 14px; background: transparent; color: var(--text-soft); font-weight: 500; }
.inline-message { margin: 14px 0 0; }
.generation-notice { margin-bottom: 14px; border: 1px solid var(--warning-border); border-radius: var(--radius-xs); padding: 11px 12px; background: var(--warning-soft); color: var(--warning); font-size: 13px; font-weight: 500; line-height: 1.6; }

/* Forms */
.form { display: grid; gap: 14px; }
.field, .field-grid { display: grid; gap: 8px; }
.field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.generation-options-grid.is-single-count { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.generation-options-grid.is-single-count .option-size { grid-column: 1 / -1; }
.prompt-api-grid { grid-template-columns: minmax(260px, 1.4fr) minmax(180px, 0.8fr) minmax(240px, 1fr); }
.field span { color: var(--text-soft); font-size: 13px; font-weight: 500; letter-spacing: -0.01em; }
.field-hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.settings-help-box { height: 42px; min-height: 42px; display: flex; align-items: center; align-self: end; overflow: hidden; border: 1px solid var(--line-strong); border-radius: var(--radius-xs); padding: 0 12px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius-xs); outline: none; background: var(--surface-soft); color: var(--text); transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease; }
input, select { height: 42px; padding: 0 12px; }
textarea { min-height: 144px; padding: 12px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--line-hover); }
input:focus, select:focus, textarea:focus { border-color: var(--text); background: #fff; box-shadow: 0 0 0 3px rgba(0,0,0,0.06); }
input[readonly] { background: var(--surface-soft); color: var(--muted); }
select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
textarea::placeholder, input::placeholder { color: var(--placeholder); }

/* Mode Toggle — segmented control */
.mode-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 0; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius-full); background: var(--surface-soft); }
.mode-toggle label { min-height: 36px; padding: 0 12px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-full); background: transparent; color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer; position: relative; transition: background 0.2s ease, color 0.2s ease; }
.mode-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.mode-toggle label:has(input:checked) { background: var(--primary); color: var(--primary-inverse); }

/* Upload */
.edit-upload-box { position: relative; width: 88px; min-width: 88px; height: 88px; display: grid; place-items: center; gap: 6px; border: 1px dashed var(--line-strong); border-radius: var(--radius-xs); padding: 10px; background: var(--surface-soft); transition: border-color 0.2s ease, background 0.2s ease; }
.edit-upload-box:hover { border-color: var(--text); background: rgba(0,0,0,0.02); }
.edit-upload-box input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.edit-upload-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--radius-xs); background: var(--surface-soft); color: var(--text); font-size: 24px; font-weight: 600; line-height: 1; }
.edit-upload-box strong { display: block; color: var(--text); font-size: 12px; font-weight: 600; line-height: 1.2; text-align: center; }
.edit-upload-box small { display: none; }
.edit-upload-preview { position: relative; z-index: 2; display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 88px)); gap: 10px; min-width: 0; }
.edit-upload-field:has(.edit-upload-preview:not(.hidden)) { grid-template-columns: minmax(0, 1fr) 88px; align-items: start; }
.edit-upload-field:has(.edit-upload-preview:not(.hidden)) > span { grid-column: 1 / -1; }
.edit-upload-field:has(.edit-upload-preview:not(.hidden)) .edit-upload-preview { grid-column: 1; grid-row: 2; }
.edit-upload-field:has(.edit-upload-preview:not(.hidden)) .edit-upload-box { grid-column: 2; grid-row: 2; }
.edit-preview-item { position: relative; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-xs); background: var(--surface-soft); }
.edit-preview-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.edit-preview-item button { position: absolute; right: 6px; bottom: 6px; z-index: 3; border: 0; border-radius: 6px; padding: 4px 7px; background: rgba(0,0,0,0.72); color: #fff; font-size: 12px; font-weight: 600; cursor: pointer; }

/* Generate */
.generate-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.generate-actions .button { white-space: nowrap; }
.prompt-field-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.prompt-optimize-button { width: auto; min-width: 88px; height: 30px; border: 1px solid var(--line-strong); border-radius: var(--radius-full); background: transparent; color: var(--text-soft); padding: 0 10px; font-size: 12px; font-weight: 500; cursor: pointer; transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease; }
.prompt-optimize-button:hover, .prompt-optimize-button:focus-visible { border-color: var(--line-hover); background: rgba(0,0,0,0.04); color: var(--text); }
.prompt-optimize-button:disabled { cursor: not-allowed; opacity: 0.5; }

/* Auth */
.auth-wrap { min-height: 62vh; display: grid; place-items: center; }
.simple-auth { min-height: calc(100vh - 150px); }
.auth-dashboard { min-height: calc(100vh - 142px); width: 100%; grid-template-columns: minmax(0, 1.08fr) minmax(360px, 440px); gap: 24px; align-items: stretch; place-items: stretch; }
.auth-info, .auth-form-card { min-height: 520px; }
.auth-info { position: relative; overflow: hidden; display: grid; align-content: space-between; border: 1px solid var(--line); border-radius: var(--radius); padding: 32px; background: var(--surface); }
.auth-info-head, .auth-metrics { position: relative; z-index: 2; }
.auth-tag { min-height: 30px; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-full); padding: 0 14px; background: transparent; color: var(--text-soft); font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.auth-info h2 { max-width: 560px; margin-top: 24px; font-size: 40px; font-weight: 600; line-height: 1.1; letter-spacing: -0.03em; }
.auth-info p { max-width: 500px; margin: 14px 0 0; color: var(--text-soft); font-size: 15px; font-weight: 400; line-height: 1.6; }
.auth-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.auth-metrics div { min-height: 92px; display: grid; align-content: center; gap: 7px; border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 14px; background: rgba(255,255,255,0.6); }
.auth-metrics span { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: -0.01em; }
.auth-metrics strong { overflow: hidden; color: var(--text); font-size: 18px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.auth-card { width: min(440px, 100%); }
.auth-form-card { width: 100%; display: grid; align-content: center; align-self: stretch; padding: 30px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.auth-card.wide { width: min(640px, 100%); }
.auth-card h2 { margin-bottom: 18px; }
.auth-card-head { margin-bottom: 22px; }
.auth-card-head h2 { margin-bottom: 8px; font-size: 26px; color: var(--text); }
.auth-form-card .field input { background: #fff; }
.auth-form-card .field input::placeholder { color: var(--placeholder); }
.auth-card-head span, .auth-switch { color: var(--muted); font-weight: 500; }
.auth-form-card .button.primary { width: 100%; min-height: 46px; margin-top: 4px; }
.auth-switch { margin: 18px 0 0; text-align: center; }

/* Setup */
.setup-card { width: min(920px, 100%); margin: 0 auto; }
.setup-form { gap: 18px; }
.setup-section { display: grid; gap: 12px; border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 16px; background: transparent; }
.setup-section h3 { margin: 0; color: var(--text); font-size: 16px; }
.muted { color: var(--muted); }

/* Preview */
.preview-card { display: grid; grid-template-rows: auto minmax(390px, 1fr); }
.preview-stage { min-height: 390px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-xs); background: linear-gradient(45deg, rgba(0,0,0,0.03) 25%, transparent 25%), linear-gradient(-45deg, rgba(0,0,0,0.03) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(0,0,0,0.03) 75%), linear-gradient(-45deg, transparent 75%, rgba(0,0,0,0.03) 75%), #fff; background-position: 0 0, 0 10px, 10px -10px, -10px 0; background-size: 20px 20px; }
.preview-stage img { width: 100%; height: 100%; max-height: 620px; object-fit: contain; background: #fff; }
.generated-image-grid { width: min(100% - 24px, 760px); max-height: calc(100% - 24px); display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; overflow: auto; padding: 4px; }
.generated-image-carousel { width: min(100% - 24px, 820px); max-height: calc(100% - 24px); overflow: hidden; }
.generated-image-track { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 76%); gap: 14px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; padding: 4px 4px 12px; }
.generated-image-slide, .generated-image-tile { position: relative; min-width: 0; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-xs); background: #fff; cursor: zoom-in; scroll-snap-align: center; }
.generated-image-slide img, .generated-image-tile img { display: block; width: 100%; height: 100%; max-width: none; max-height: none; object-fit: contain; box-shadow: none; }
.generated-image-slide span, .generated-image-tile span { position: absolute; right: 8px; bottom: 8px; min-width: 24px; height: 24px; display: grid; place-items: center; border-radius: var(--radius-full); background: rgba(0,0,0,0.65); color: #fff; font-size: 12px; font-weight: 600; }
.empty-state, .preview-loading { width: min(240px, 90%); min-height: 116px; display: grid; place-items: center; gap: 8px; border: 1px dashed var(--line-strong); border-radius: var(--radius-xs); padding: 18px; background: transparent; color: var(--muted); text-align: center; font-weight: 500; }
.preview-loading span { font-size: 13px; font-weight: 500; }
.generation-progress-card { width: min(520px, calc(100% - 28px)); display: grid; gap: 16px; border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 18px; background: rgba(255,255,255,0.96); }
.generation-progress-head { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: center; }
.generation-progress-head strong { display: block; color: var(--text); font-size: 16px; font-weight: 600; }
.generation-progress-head span { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1.5; }
.generation-progress-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.generation-progress-grid > div { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 10px 12px; background: var(--surface-soft); }
.generation-progress-grid span, .generation-summary-row span, .generation-summary-prompt span { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.generation-progress-grid strong { display: block; margin-top: 5px; color: var(--text); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.generation-progress-track { height: 8px; overflow: hidden; border-radius: var(--radius-full); background: var(--surface-soft); }
.generation-progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--text); transition: width 0.35s ease; }
.generation-summary { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.generation-summary-row { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 10px; align-items: start; }
.generation-summary-row strong { min-width: 0; color: var(--text-soft); font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.generation-summary-prompt { display: grid; gap: 6px; }
.generation-summary-prompt p { max-height: 112px; overflow: auto; margin: 0; border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 10px; background: #fff; color: var(--text-soft); font-size: 13px; font-weight: 400; line-height: 1.55; overflow-wrap: anywhere; white-space: pre-wrap; }
.preview-error { width: min(360px, 92%); min-height: 128px; display: grid; place-items: center; gap: 8px; border: 1px solid var(--danger-border); border-radius: var(--radius-xs); padding: 18px; background: var(--danger-soft); color: var(--danger); text-align: center; font-weight: 500; }
.preview-error span { color: var(--danger); font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.preview-spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--text); border-radius: var(--radius-full); animation: spin 0.8s linear infinite; }

/* Records / History */
.history-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; align-items: stretch; }
body.page-records .history-list { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.history-list .record-card { height: 264px; min-height: 264px; display: grid; grid-template-rows: 128px 1fr; border: 1px solid var(--line); border-radius: var(--radius); padding: 0; background: rgba(255,255,255,0.85); backdrop-filter: blur(12px) saturate(1.08); -webkit-backdrop-filter: blur(12px) saturate(1.08); color: inherit; cursor: pointer; text-align: left; transition: border-color 0.2s ease, transform 0.2s ease; overflow: hidden; }
.history-list .record-card:hover { border-color: var(--line-hover); transform: translateY(-2px); }
.history-list[data-latest-row] { max-height: 264px; overflow: hidden; }
.history-list .record-card.is-row-hidden { display: none; }
.record-image { display: grid; place-items: center; overflow: hidden; background: var(--surface-soft); color: var(--muted); font-weight: 500; position: relative; }
.record-image img { width: 100%; height: 100%; object-fit: cover; }
.history-list .record-image::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(180deg, rgba(0,0,0,0.01), rgba(0,0,0,0.10)); }
.record-body { min-width: 0; display: grid; align-content: start; gap: 7px; padding: 10px; }
.history-list .record-body { min-height: 0; display: flex; flex-direction: column; gap: 4px; padding: 8px 12px 6px; min-width: 0; }
.record-meta { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; font-weight: 600; }
.history-list .record-meta { display: block; }
.history-list .record-meta span { display: block; min-width: 0; overflow: hidden; color: var(--muted); font-size: 11px; font-weight: 600; line-height: 14px; text-overflow: ellipsis; white-space: nowrap; }
.history-list .record-meta .status { display: none; }
.record-meta span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-body p { max-height: 42px; margin: 0; overflow: hidden; color: var(--text-soft); font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.history-list .record-body p { display: -webkit-box; margin: 0; overflow: hidden; color: var(--text-soft); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.record-body time { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

/* Record foot — border-top, then time-row + button-row */
.history-list .record-foot { margin-top: auto; display: flex; flex-direction: column; gap: 5px; border-top: 1px solid var(--line); padding: 7px 0 3px; }

/* Foot row — time left, duration right */
.record-foot-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; }
.record-foot-row time { min-width: 0; overflow: hidden; color: var(--muted); font-size: 11px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 0; }
.record-duration { color: var(--muted-light); font-size: 10px; font-weight: 500; white-space: nowrap; flex-shrink: 0; }

/* Foot actions — buttons right-aligned second line */
.record-foot-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }

.record-delete { min-height: 22px; display: inline-flex; align-items: center; border: 1px solid var(--danger-border); border-radius: var(--radius-full); padding: 0 6px; background: transparent; color: var(--danger); font-size: 10px; font-weight: 500; cursor: pointer; transition: background 0.2s ease; white-space: nowrap; flex-shrink: 0; line-height: 1; }
.record-delete:hover { background: var(--danger-soft); }
.record-regenerate { min-height: 22px; display: inline-flex; align-items: center; border: 1px solid var(--success-border); border-radius: var(--radius-full); padding: 0 6px; background: var(--success-soft); color: var(--success); font-size: 10px; font-weight: 500; cursor: pointer; transition: background 0.2s ease; white-space: nowrap; flex-shrink: 0; line-height: 1; }
.record-regenerate:hover { background: rgba(22,101,52,0.12); }
.record-edit-again { min-height: 22px; display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--radius-full); padding: 0 6px; background: transparent; color: var(--text-soft); font-size: 10px; font-weight: 500; cursor: pointer; white-space: nowrap; flex-shrink: 0; line-height: 1; transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease; }
.record-edit-again:hover { border-color: var(--line-hover); background: rgba(0,0,0,0.04); color: var(--text); }

/* Record summary */
.record-summary { color: var(--text); font-size: 13px; font-weight: 500; }
.record-summary.is-remark::before { color: var(--text-soft); font-weight: 600; }
.record-summary.is-prompt { color: var(--text-soft); }

/* Record status overlay on image */
.record-status-overlay { position: absolute; top: 50%; left: 50%; z-index: 2; min-width: 52px; min-height: 24px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: var(--radius-full); padding: 0 14px; color: #fff; font-size: 12px; font-weight: 600; line-height: 1; letter-spacing: 0.02em; white-space: nowrap; transform: translate(-50%, -50%); background: var(--muted-light); }
.record-status-overlay.status.succeeded { background: var(--success); color: #fff; }
.record-status-overlay.status.failed { background: var(--danger); color: #fff; }
.record-status-overlay.status.running,
.record-status-overlay.status.queued { background: var(--warning); color: #fff; }
.record-status-overlay.status.deleted { background: var(--muted); color: #fff; }

/* Show overlay on record-image, hide duplicate inline status inside .record-image */
.history-list .record-image > .status:not(.record-status-overlay),
.history-list .record-image > span:not(.record-status-overlay):not(.record-image-empty) { display: none; }
/* Hide the duplicate status span inside record-meta — overlay already shows it */
.history-list .record-meta .status { display: none; }
.history-empty-inline { grid-column: 1 / -1; min-height: 92px; display: grid; place-items: center; border: 1px dashed var(--line-strong); border-radius: var(--radius-xs); color: var(--muted); background: transparent; font-weight: 500; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 18px; }
.pagination span { color: var(--muted); font-weight: 500; }

/* Admin Nav */
.admin-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; overflow-x: auto; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius-full); background: var(--surface-soft); }
.admin-nav .button { min-height: 32px; border: 0; font-size: 13px; }
.admin-nav .button.secondary.active { background: var(--primary); color: var(--primary-inverse); }
.admin-version-footer { margin-top: 22px; padding: 14px 0 4px; color: var(--muted); font-size: 13px; font-weight: 500; text-align: center; }
.site-footer { margin-top: 22px; padding: 14px 0 4px; color: var(--muted); font-size: 13px; text-align: center; }
.site-footer p { margin: 0; }
.site-footer a { color: var(--text-soft); font-weight: 500; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card { padding: 16px; min-height: 104px; display: grid; align-content: center; }
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 500; letter-spacing: -0.01em; }
.stat-card strong { display: block; margin-top: 6px; color: var(--text); font-size: 30px; line-height: 1.1; font-weight: 600; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Tables */
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
table { width: 100%; min-width: 760px; table-layout: fixed; border-collapse: collapse; background: #fff; }
th, td { border-bottom: 1px solid var(--line); padding: 13px 14px; text-align: left; vertical-align: middle; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th { position: sticky; top: 0; z-index: 1; height: 44px; border-bottom-color: var(--line); background: var(--surface-soft); color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }
tbody tr { transition: background 0.16s ease; }
tbody tr:hover td { background: rgba(0,0,0,0.02); }
tr.is-deleted td { background: var(--surface-soft); color: var(--muted); }
tr.is-deleted:hover td { background: rgba(0,0,0,0.03); }
.admin-prompt-cell { color: var(--text-soft); max-width: 360px; line-height: 1.45; }
.admin-record-row td { vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-user-cell { max-width: 130px; font-weight: 500; }
.table-primary-text { display: block; min-width: 0; overflow: hidden; color: var(--text); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.table-muted-cell { color: var(--muted); }
.admin-record-id { display: inline-block; color: var(--text); font-weight: 600; }
.admin-record-id-cell { line-height: 1.35; }
.admin-record-id-cell .status { margin-top: 5px; }
.deleted-time { margin-top: 6px; color: var(--muted); font-size: 12px; font-weight: 500; }
.admin-credit-cell { overflow: visible; }
.admin-credit-cell .inline-admin-form { display: grid; grid-template-columns: minmax(86px, 1fr) 58px; gap: 8px; align-items: center; }
.admin-credit-cell .compact-input { width: 100%; min-width: 0; }
.admin-table-actions { overflow: visible !important; white-space: nowrap !important; text-overflow: clip !important; }
.admin-table-actions > .button,
.admin-table-actions > .inline-delete-form,
.admin-table-actions > .table-action-group { vertical-align: middle; }
.table-check-cell input, [data-check-all-records] { width: 17px; height: 17px; accent-color: var(--text); }
.admin-number-cell { color: var(--text-soft); font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.admin-number-cell strong { color: var(--text); font-weight: 600; }
.table-thumb { width: 52px; height: 52px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-xs); background: var(--surface-soft); color: var(--muted); padding: 0; cursor: pointer; transition: border-color 0.2s ease, transform 0.2s ease; }
.table-thumb:hover { border-color: var(--line-hover); transform: translateY(-1px); }
.table-thumb img { width: 100%; height: 100%; object-fit: cover; }
.inline-delete-form { display: inline-flex; margin: 0 0 0 6px; }
.inline-admin-form,
.table-action-group { display: inline-flex; align-items: center; gap: 7px; min-width: 0; margin: 0; vertical-align: middle; }
.table-action-group { flex-wrap: nowrap; }
.compact-input { width: 88px; height: 36px; border-radius: var(--radius-xs); padding: 0 9px; font-size: 13px; }
.compact-input.password-input { width: 146px; }
.filter-bar { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(140px, 180px) auto; gap: 10px; align-items: end; margin-bottom: 14px; border: 1px solid var(--line); border-radius: var(--radius-xs); background: var(--surface-soft); padding: 14px; }
.filter-actions { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; flex-wrap: nowrap; white-space: nowrap; }
.filter-bar.admin-record-filter { grid-template-columns: minmax(110px, 1fr) minmax(140px, 1fr) minmax(80px, 1fr) minmax(90px, 1fr) auto; }
.filter-bar.user-record-filter { grid-template-columns: minmax(140px, 1fr) minmax(120px, 1fr) minmax(120px, 1fr) minmax(80px, 1fr) minmax(90px, 1fr) auto; }
.filter-bar.admin-user-filter { grid-template-columns: minmax(120px, 1fr) minmax(160px, 1fr) minmax(120px, 1fr) auto; }
.filter-bar.admin-code-filter { grid-template-columns: minmax(180px, 1fr) minmax(140px, 1fr) minmax(190px, 1fr); }
.admin-record-bulk-form { margin-bottom: 14px; border: 1px solid var(--danger-border); border-radius: var(--radius-xs); background: var(--danger-soft); padding: 10px 14px; }
.bulk-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Unified page rhythm */
body.page-app .app-shell,
body.page-records .app-shell,
body.page-credits .app-shell,
body.page-admin .app-shell {
  width: min(var(--shell-max), calc(100% - var(--shell-gutter)));
}

body.page-app main,
body.page-records main,
body.page-credits main,
body.page-admin main {
  gap: 16px;
}

body.page-records .records-page-card,
body.page-credits .credits-page-card {
  display: grid;
  gap: 16px;
  margin-top: 0;
}

body.page-records .records-page-card > .card-head,
body.page-credits .credits-page-card > .card-head {
  margin-bottom: 0;
}

body.page-records .records-page-card > .filter-bar,
body.page-credits .credits-page-card > .filter-bar {
  margin-bottom: 16px;
}

body.page-records .records-page-card > .invite-link-panel,
body.page-credits .credits-page-card > .invite-link-panel {
  margin-bottom: 8px;
}

body.page-records .records-page-card > .table-wrap,
body.page-credits .credits-page-card > .table-wrap {
  margin-bottom: 0;
}

body.page-records .pagination,
body.page-credits .pagination,
body.page-admin .pagination {
  margin-top: 0;
}
.code-create-card .card-head { margin-bottom: 12px; }
.code-create-form { grid-template-columns: repeat(4, minmax(0, 1fr)) auto; align-items: end; }
.code-create-form .button { min-width: 96px; }
.code-export-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.code-export-actions span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
code { font-family: var(--font-mono); font-size: 13px; }
.code-token { display: inline-flex; max-width: 100%; min-height: 30px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-xs); background: var(--surface-soft); padding: 0 9px; color: var(--text); font-family: var(--font-mono); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-copy-button { cursor: pointer; text-align: left; transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease; }
.code-copy-button:hover, .code-copy-button:focus-visible { border-color: var(--line-hover); background: rgba(0,0,0,0.04); }

/* Dialogs */
.redeem-dialog,
.record-dialog,
.generation-overlay,
.legal-dialog {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0,0,0,0.40);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.generation-overlay { z-index: 10002; pointer-events: auto; }
.redeem-panel,
.record-dialog-panel,
.legal-dialog-panel,
.generation-modal {
  width: min(430px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 16px 48px rgba(0,0,0,0.12);
}
.record-dialog-panel {
  width: min(920px, 100%);
  max-height: min(92dvh, calc(100dvh - 32px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.legal-dialog-panel {
  position: relative;
  width: min(860px, 100%);
  max-height: min(820px, calc(100vh - 40px));
  overflow: auto;
}
.generation-modal {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 26px 22px;
  text-align: center;
}
.generation-modal h2 { font-size: 22px; font-weight: 600; }
.generation-modal p { margin: 0; color: var(--muted); font-weight: 500; }
.generation-loader {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  height: 42px;
}
.generation-loader span {
  width: 10px; height: 10px;
  border-radius: var(--radius-full);
  background: var(--text);
  animation: pulse 0.9s ease-in-out infinite;
}
.generation-loader span:nth-child(2) { animation-delay: 0.12s; }
.generation-loader span:nth-child(3) { animation-delay: 0.24s; }
.generation-progress {
  width: 100%; height: 8px;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--surface-soft);
}
.generation-progress i {
  width: 42%; height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--text);
  animation: progress 1.3s ease-in-out infinite;
}
.redeem-head,
.record-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 18px 20px;
  background: var(--surface);
}
.record-dialog-head {
  position: sticky;
  top: 0;
  z-index: 1;
}
.redeem-form { padding: 20px; }
.dialog-close {
  min-width: 72px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  padding: 0 14px;
  background: transparent;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.dialog-close:hover {
  border-color: var(--line-hover);
  background: rgba(0,0,0,0.04);
  color: var(--text);
}
.record-dialog-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 20px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.record-dialog-image {
  min-height: min(420px, 44dvh);
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 500;
}
.record-dialog-image-button {
  width: 100%; height: 100%;
  min-height: inherit;
  display: grid;
  place-items: center;
  border: 0; padding: 0;
  background: transparent;
  position: relative;
  cursor: zoom-in;
}
.record-dialog-image-grid {
  width: 100%;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 48%);
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  padding: 4px 4px 12px;
}
.record-dialog-carousel { width: 100%; overflow: hidden; }
.record-dialog-image-grid .record-dialog-image-button {
  min-height: 180px;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  overflow: hidden;
  scroll-snap-align: center;
}
.record-dialog-image-button span {
  position: absolute;
  right: 8px; bottom: 8px;
  min-width: 42px; height: 24px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.record-dialog-image-button img,
.record-dialog-image img {
  width: 100%; height: 100%;
  max-height: 640px;
  object-fit: contain;
  background: #fff;
}
.record-input-images { display: grid; gap: 10px; }
.record-input-images > span { color: var(--muted); font-size: 12px; font-weight: 600; }
.record-input-images [data-dialog-input-list] {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
}
.record-input-image-button {
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--surface-soft);
  padding: 0;
  cursor: zoom-in;
}
.record-input-image-button img {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
}

/* Image Viewer */
.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 10020;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 16px;
  background: rgba(0,0,0,0.86);
}
.image-viewer-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.image-viewer-meta {
  min-width: 0;
  margin-right: auto;
  display: grid;
  gap: 2px;
  color: #fff;
}
.image-viewer-meta strong {
  max-width: min(42vw, 560px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
}
.image-viewer-meta span {
  color: rgba(255,255,255,0.64);
  font-size: 12px;
  font-weight: 500;
}
.image-viewer-toolbar button,
.image-viewer-toolbar > span,
.image-viewer-download {
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: var(--radius-full);
  padding: 0 14px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-weight: 500;
  text-decoration: none;
}
.image-viewer-toolbar > span { min-width: 72px; }
.image-viewer-stage {
  position: relative;
  min-width: 0; min-height: 0;
  overflow: auto;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-xs);
  background: transparent;
  cursor: grab;
}
.image-viewer-canvas {
  min-width: 100%; min-height: 100%;
  display: grid;
  place-items: center;
}
.image-viewer-stage.is-dragging { cursor: grabbing; }
.image-viewer-stage img {
  display: block;
  max-width: none; max-height: none;
  object-fit: contain;
  background: #fff;
  -webkit-user-select: none;
  user-select: none;
}
.image-viewer-nav {
  position: fixed;
  top: 50%;
  z-index: 10021;
  width: 48px; height: 56px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.20);
  border-radius: var(--radius-full);
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
}
.image-viewer-nav.prev { left: 24px; }
.image-viewer-nav.next { right: 24px; }
.image-viewer-nav:disabled { display: none; }
.image-viewer-thumbs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 76px;
  justify-content: center;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 4px;
}
.image-viewer-thumbs button {
  width: 76px; height: 58px;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: var(--radius-xs);
  padding: 0;
  background: rgba(255,255,255,0.12);
  cursor: pointer;
}
.image-viewer-thumbs button.is-active { border-color: #fff; }
.image-viewer-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Record Detail Grid */
.record-detail-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
}
.record-detail-grid div {
  min-height: 56px;
  display: grid;
  align-content: center;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 9px 10px;
  background: transparent;
}
.record-detail-grid > div:nth-child(1) {
  grid-column: 1 / -1;
}
.record-detail-grid > div:nth-child(2),
.record-detail-grid > div:nth-child(3) {
  grid-column: span 3;
}
.record-detail-grid > div:nth-child(4),
.record-detail-grid > div:nth-child(5) {
  grid-column: span 3;
}
.record-detail-grid span,
.record-full-prompt span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.record-detail-grid strong {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}
.record-detail-grid strong.status { color: inherit; font-size: 13px; }
.record-full-prompt {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 12px;
  background: #fff;
  align-content: start;
  min-height: 0;
}
.record-full-prompt.hidden { display: none; }
.record-full-prompt p {
  max-height: 120px;
  overflow: auto;
  margin: 0;
  color: var(--text-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.6;
}
.record-error {
  grid-column: 1 / -1;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-xs);
  padding: 12px;
  background: var(--danger-soft);
  color: var(--danger);
}
.record-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.record-dialog-actions .button { min-width: 88px; }

/* Toast & Layer */
.jpt-layer-root { position: relative; z-index: 10040; }
.jpt-toast-stack {
  position: fixed;
  top: 22px; right: 22px;
  z-index: 10060;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.jpt-toast {
  min-height: 46px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  padding: 10px 16px;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  overflow-wrap: anywhere;
  pointer-events: auto;
  animation: toastIn 0.28s var(--ease-soft);
}
.jpt-toast.is-leaving { animation: toastOut 0.18s var(--ease-out) forwards; }
.jpt-toast-icon,
.jpt-layer-icon {
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.jpt-toast-icon { width: 18px; height: 18px; background: var(--muted-light); }
.jpt-toast-icon::after { content: ""; width: 7px; height: 7px; border-radius: var(--radius-full); background: #fff; }
.jpt-toast.success { border-color: var(--success-border); color: var(--success); }
.jpt-toast.success .jpt-toast-icon { background: var(--success); }
.jpt-toast.success .jpt-toast-icon::after { content: "✓"; width: auto; height: auto; background: none; color: #fff; font-size: 10px; font-weight: 700; line-height: 1; }
.jpt-toast.error { border-color: var(--danger-border); color: var(--danger); }
.jpt-toast.error .jpt-toast-icon { background: var(--danger); }
.jpt-toast.error .jpt-toast-icon::after { content: "✕"; width: auto; height: auto; background: none; color: #fff; font-size: 10px; font-weight: 700; line-height: 1; }
.jpt-toast.warning { border-color: var(--warning-border); color: var(--warning); }
.jpt-toast.warning .jpt-toast-icon { background: var(--warning); }
.jpt-toast.warning .jpt-toast-icon::after { content: "!"; width: auto; height: auto; background: none; color: #fff; font-size: 12px; font-weight: 700; line-height: 1; }
.jpt-toast.info { border-color: var(--line); }
.jpt-toast.info .jpt-toast-icon { background: var(--text-soft); }
.jpt-toast.info .jpt-toast-icon::after { content: "i"; width: auto; height: auto; background: none; color: #fff; font-size: 11px; font-weight: 700; line-height: 1; font-style: italic; }
.jpt-layer-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0,0,0,0.40);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: overlayIn 0.22s var(--ease-out);
}
.jpt-layer-overlay.is-leaving { animation: overlayOut 0.18s var(--ease-out) forwards; }
.jpt-layer-panel {
  width: min(420px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  animation: panelIn 0.28s var(--ease-soft);
}
.jpt-layer-overlay.is-leaving .jpt-layer-panel { animation: panelOut 0.18s var(--ease-out) forwards; }
.jpt-layer-head {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  padding: 20px 20px 16px;
}
.jpt-layer-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: var(--text);
}
.jpt-layer-icon::after {
  content: "";
  width: 6px; height: 6px;
  border-radius: var(--radius-full);
  background: #fff;
}
.jpt-layer-panel.info .jpt-layer-icon { background: var(--text-soft); }
.jpt-layer-panel.info .jpt-layer-icon::after { content: "?"; width: auto; height: auto; background: none; color: #fff; font-size: 18px; font-weight: 600; line-height: 1; }
.jpt-layer-panel.success .jpt-layer-icon { background: var(--success); }
.jpt-layer-panel.success .jpt-layer-icon::after { content: "✓"; width: auto; height: auto; background: none; color: #fff; font-size: 16px; font-weight: 700; line-height: 1; }
.jpt-layer-panel.error .jpt-layer-icon { background: var(--danger); }
.jpt-layer-panel.error .jpt-layer-icon::after { content: "✕"; width: auto; height: auto; background: none; color: #fff; font-size: 16px; font-weight: 700; line-height: 1; }
.jpt-layer-panel.warning .jpt-layer-icon { background: var(--warning); }
.jpt-layer-panel.warning .jpt-layer-icon::after { content: "!"; width: auto; height: auto; background: none; color: #fff; font-size: 20px; font-weight: 700; line-height: 1; }
.jpt-layer-head h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.jpt-layer-head p {
  margin: 6px 0 0;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.jpt-layer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 14px 18px;
  background: transparent;
}
.jpt-layer-actions .button { min-width: 88px; }

/* Settings */
.logo-preview { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.logo-preview img { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: var(--radius-xs); object-fit: cover; }
.user-identity { min-width: 0; display: grid; gap: 6px; }
.user-identity strong, .user-identity span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-identity strong { color: var(--text); font-weight: 600; line-height: 1.2; }
.user-identity > span { color: var(--muted); font-size: 12px; font-weight: 500; }
.settings-page { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; }
.settings-tabs-page { grid-template-columns: minmax(0, 1fr); align-items: start; }
.settings-tab-nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius-full); background: var(--surface-soft); box-shadow: none; }
.settings-tab-nav button { min-height: 32px; padding: 0 18px; border: 0; border-radius: var(--radius-full); background: transparent; color: var(--muted); font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; flex-shrink: 0; transition: background 0.2s ease, color 0.2s ease; }
.settings-tab-nav button:hover, .settings-tab-nav button.active { background: var(--primary); color: var(--primary-inverse); }
.settings-tab-panel { grid-column: 1 / -1; }
.settings-tab-panel[hidden] { display: none !important; }
.settings-page > .card { display: flex; flex-direction: column; height: 100%; }
.settings-page > .card > .form { flex: 1; }
.settings-page > .card > .form > .button:last-child { margin-top: auto; }
.cloud-storage-card { grid-column: 1 / -1; }
.cloud-storage-form { align-content: start; }
.cloud-storage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: end; }
.storage-options-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.switch-field { min-height: 44px; display: flex; align-items: center; gap: 10px; align-self: end; border: 1px solid var(--line); border-radius: var(--radius-xs); background: transparent; padding: 0 12px; color: var(--text-soft); font-size: 13px; font-weight: 500; }
.switch-field input { width: 18px; height: 18px; margin: 0; accent-color: var(--text); }
.settings-page textarea { min-height: 104px; }

/* Dashboard */
.dashboard-main { gap: 16px; }
.dashboard-metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.dashboard-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.dashboard-today { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 4px 0 8px; }
.dashboard-today-item { display: grid; place-items: center; gap: 6px; min-height: 80px; border: 1px solid var(--line); border-radius: var(--radius-xs); background: var(--surface-soft); padding: 14px 10px; }
.dashboard-today-item strong { font-size: 32px; font-weight: 600; color: var(--text); line-height: 1; font-family: var(--font-mono); }
.dashboard-today-item strong.is-success { color: var(--success); }
.dashboard-today-item strong.is-failed { color: var(--danger); }
.dashboard-today-item strong.is-warning { color: var(--warning); }
.dashboard-today-item span { color: var(--muted); font-size: 12px; font-weight: 500; }
.dashboard-chart { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: end; min-height: 160px; padding: 10px 4px 0; }
.chart-bar-wrap { display: grid; grid-template-rows: 20px minmax(40px, 1fr) 22px; justify-items: center; gap: 4px; min-width: 0; }
.chart-bar-wrap .chart-value { color: var(--muted); font-size: 11px; font-weight: 500; }
.chart-bar-wrap .chart-bar { width: min(44px, 100%); border-radius: 6px 6px 0 0; background: var(--text); transition: height 0.35s var(--ease-soft); }
.chart-bar-wrap .chart-label { color: var(--muted); font-size: 11px; font-weight: 500; }

/* Dashboard admin table */
[data-admin-dashboard-recent] { min-width: 780px; }
[data-admin-dashboard-recent] th:nth-child(1), [data-admin-dashboard-recent] td:nth-child(1) { width: 72px; }
[data-admin-dashboard-recent] th:nth-child(2), [data-admin-dashboard-recent] td:nth-child(2) { width: 100px; }
[data-admin-dashboard-recent] th:nth-child(3), [data-admin-dashboard-recent] td:nth-child(3) { width: 72px; }
[data-admin-dashboard-recent] th:nth-child(4), [data-admin-dashboard-recent] td:nth-child(4) { width: 96px; }
[data-admin-dashboard-recent] th:nth-child(6), [data-admin-dashboard-recent] td:nth-child(6) { width: 88px; }
[data-admin-dashboard-recent] th:nth-child(7), [data-admin-dashboard-recent] td:nth-child(7) { width: 160px; }

/* Admin Tables */
[data-admin-records] { min-width: 1240px; }
[data-admin-records] th:nth-child(1), [data-admin-records] td:nth-child(1) { width: 64px; text-align: center; }
[data-admin-records] th:nth-child(2), [data-admin-records] td:nth-child(2) { width: 110px; }
[data-admin-records] th:nth-child(3), [data-admin-records] td:nth-child(3) { width: 92px; }
[data-admin-records] th:nth-child(4), [data-admin-records] td:nth-child(4) { width: 130px; }
[data-admin-records] th:nth-child(5), [data-admin-records] td:nth-child(5) { width: 88px; }
[data-admin-records] th:nth-child(6), [data-admin-records] td:nth-child(6) { width: 92px; }
[data-admin-records] th:nth-child(8), [data-admin-records] td:nth-child(8) { width: 176px; }
[data-admin-records] th:nth-child(9), [data-admin-records] td:nth-child(9) { width: 150px; }
[data-admin-users] { min-width: 1460px; }
[data-admin-users] th:nth-child(1), [data-admin-users] td:nth-child(1) { width: 150px; }
[data-admin-users] th:nth-child(2), [data-admin-users] td:nth-child(2) { width: 150px; }
[data-admin-users] th:nth-child(3), [data-admin-users] td:nth-child(3) { width: 220px; }
[data-admin-users] th:nth-child(4), [data-admin-users] td:nth-child(4), [data-admin-users] th:nth-child(5), [data-admin-users] td:nth-child(5), [data-admin-users] th:nth-child(7), [data-admin-users] td:nth-child(7), [data-admin-users] th:nth-child(8), [data-admin-users] td:nth-child(8), [data-admin-users] th:nth-child(9), [data-admin-users] td:nth-child(9) { width: 96px; }
[data-admin-users] th:nth-child(6), [data-admin-users] td:nth-child(6) { width: 190px; }
[data-admin-users] th:nth-child(10), [data-admin-users] td:nth-child(10) { width: 390px; }
[data-admin-codes] { min-width: 1160px; }
[data-admin-codes] th:nth-child(1), [data-admin-codes] td:nth-child(1) { width: 230px; }
[data-admin-codes] th:nth-child(2), [data-admin-codes] td:nth-child(2), [data-admin-codes] th:nth-child(3), [data-admin-codes] td:nth-child(3), [data-admin-codes] th:nth-child(4), [data-admin-codes] td:nth-child(4), [data-admin-codes] th:nth-child(5), [data-admin-codes] td:nth-child(5) { width: 96px; }
[data-admin-codes] th:nth-child(6), [data-admin-codes] td:nth-child(6), [data-admin-codes] th:nth-child(8), [data-admin-codes] td:nth-child(8) { width: 170px; }
[data-admin-codes] th:nth-child(7), [data-admin-codes] td:nth-child(7) { width: 120px; }
[data-admin-codes] th:nth-child(9), [data-admin-codes] td:nth-child(9) { width: 150px; }
[data-admin-credit-transactions] { min-width: 1160px; }
[data-admin-credit-transactions] th:nth-child(1), [data-admin-credit-transactions] td:nth-child(1) { width: 140px; }
[data-admin-credit-transactions] th:nth-child(2), [data-admin-credit-transactions] td:nth-child(2) { width: 132px; }
[data-admin-credit-transactions] th:nth-child(3), [data-admin-credit-transactions] td:nth-child(3), [data-admin-credit-transactions] th:nth-child(4), [data-admin-credit-transactions] td:nth-child(4), [data-admin-credit-transactions] th:nth-child(5), [data-admin-credit-transactions] td:nth-child(5) { width: 92px; }
[data-admin-credit-transactions] th:nth-child(6), [data-admin-credit-transactions] td:nth-child(6) { width: 140px; }
[data-admin-credit-transactions] th:nth-child(8), [data-admin-credit-transactions] td:nth-child(8) { width: 170px; }
[data-user-credit-transactions] { min-width: 1040px; }
[data-user-credit-transactions] th:nth-child(1), [data-user-credit-transactions] td:nth-child(1) { width: 132px; }
[data-user-credit-transactions] th:nth-child(2), [data-user-credit-transactions] td:nth-child(2), [data-user-credit-transactions] th:nth-child(3), [data-user-credit-transactions] td:nth-child(3), [data-user-credit-transactions] th:nth-child(4), [data-user-credit-transactions] td:nth-child(4) { width: 92px; }
[data-user-credit-transactions] th:nth-child(5), [data-user-credit-transactions] td:nth-child(5) { width: 140px; }
[data-user-credit-transactions] th:nth-child(7), [data-user-credit-transactions] td:nth-child(7) { width: 170px; }
.credit-positive strong { color: var(--success); }
.credit-negative strong { color: var(--danger); }
.user-credit-filter { grid-template-columns: minmax(110px, 1fr) minmax(90px, 1fr) minmax(130px, 1fr) minmax(130px, 1fr) auto; }
.admin-credit-filter { grid-template-columns: minmax(120px, 1fr) minmax(110px, 1fr) minmax(90px, 1fr) minmax(130px, 1fr) minmax(130px, 1fr) auto; }
.invite-table-cell { max-width: 170px; display: grid; gap: 4px; line-height: 1.3; }
.invite-table-cell strong { overflow: hidden; color: var(--text); font-family: var(--font-mono); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.invite-table-cell span { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.invite-link-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 12px; background: transparent; }
.invite-link-panel div { min-width: 0; display: grid; gap: 4px; }
.invite-link-panel span { color: var(--text-soft); font-size: 12px; font-weight: 500; }
.invite-link-panel strong { min-width: 0; overflow: hidden; color: var(--text); font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }

/* Center Auth */
body.page-auth:has(.center-auth-page) { min-height: 100vh; background: var(--bg); }
body.page-auth:has(.center-auth-page) .app-shell { width: min(100% - 36px, 430px); min-height: 100vh; display: grid; grid-template-rows: minmax(0, 1fr); padding: 28px 0 34px; }
body.page-auth:has(.center-auth-register) .app-shell { width: min(100% - 36px, 460px); }
.center-auth-page { width: 100%; align-self: center; display: grid; place-items: center; padding: 0; }
.center-auth-panel { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 36px 32px; background: var(--surface); }
.center-auth-top { margin-bottom: 28px; padding: 0; background: transparent; }
.center-auth-brand { display: grid; justify-items: center; gap: 10px; width: 100%; max-width: 100%; margin: 0 auto 24px; color: var(--text); text-align: center; text-decoration: none; transition: opacity 0.2s ease; }
.center-auth-brand:hover { opacity: 0.8; }
.center-auth-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: var(--radius-xs); background: var(--text); color: #fff; font-size: 19px; font-weight: 600; }
.center-auth-mark svg { width: 34px; height: 34px; display: block; }
.center-auth-mark .icon-frame, .center-auth-mark .icon-line, .center-auth-mark .icon-dot { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.center-auth-mark .ai-spark { fill: rgba(255,255,255,0.45); stroke: #fff; stroke-width: 0.5; }
.center-auth-mark .ai-spark.small { fill: #fff; stroke: none; opacity: 0.8; }
.center-auth-brand strong { display: block; color: var(--text); font-size: 26px; font-weight: 700; line-height: 1.08; letter-spacing: -0.03em; }
.center-auth-brand small { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; font-weight: 400; line-height: 1.3; }
.center-auth-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: var(--radius-full); padding: 4px; background: var(--surface-soft); }
.center-auth-tabs .center-auth-tab { display: grid; place-items: center; border: 0; border-radius: var(--radius-full); background: transparent; color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer; transition: background 0.2s ease, color 0.2s ease; }
.center-auth-tabs .center-auth-tab.active { background: var(--primary); color: var(--primary-inverse); }
.center-auth-tabs .center-auth-tab:not(.active):hover { color: var(--text); }
.center-auth-body { padding: 0; margin-top: 24px; min-height: 320px; }
.center-auth-form { display: grid; gap: 14px; }
.center-auth-register .center-auth-form { gap: 12px; }
.center-auth-field { display: grid; gap: 7px; }
.center-auth-field span { color: var(--text-soft); font-size: 13px; font-weight: 500; letter-spacing: -0.01em; }
.center-auth-field input { width: 100%; height: 46px; border: 1px solid var(--line-strong); border-radius: var(--radius-xs); padding: 0 14px; background: #fff; color: var(--text); font-size: 14px; outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.center-auth-field input::placeholder { color: var(--placeholder); }
.center-auth-field input:hover { border-color: var(--line-hover); }
.center-auth-field input:focus { border-color: var(--text); box-shadow: 0 0 0 3px rgba(0,0,0,0.06); }
.center-auth-code-row { display: grid; grid-template-columns: minmax(0, 1fr) 108px; gap: 8px; }
.center-auth-code-row button { height: 46px; border: 1px solid var(--line-strong); border-radius: var(--radius-full); background: transparent; color: var(--text-soft); font-size: 13px; font-weight: 500; cursor: pointer; transition: background 0.2s ease, color 0.2s ease; }
.center-auth-code-row button:hover { background: rgba(0,0,0,0.04); color: var(--text); }
.center-auth-code-row button:disabled { border-color: var(--line); background: var(--surface-soft); color: var(--muted-light); cursor: not-allowed; }
.center-auth-captcha { display: flex; align-items: center; gap: 8px; }
.center-auth-captcha img { display: block; border: 1px solid var(--line); border-radius: var(--radius-xs); height: 44px; flex-shrink: 0; cursor: pointer; }
.center-auth-captcha input { height: 44px; flex: 1; min-width: 0; }
.center-auth-submit { width: 100%; min-height: 46px; margin-top: 4px; border: 0; border-radius: var(--radius-full); background: var(--primary); color: var(--primary-inverse); font-size: 15px; font-weight: 600; cursor: pointer; transition: opacity 0.2s ease, transform 0.15s ease; letter-spacing: -0.01em; }
.center-auth-submit:hover { opacity: 0.88; }
.center-auth-submit:active { transform: scale(0.985); }
.center-auth-agreement { margin: 2px 0 0; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.7; text-align: center; }
.center-auth-agreement a { color: var(--text-soft); font-weight: 500; text-decoration: none; }
.center-auth-agreement a:hover { color: var(--text); }

/* Legal */
.legal-dialog-close { position: sticky; top: 14px; z-index: 2; float: right; margin: 14px 14px -48px 0; background: rgba(255,255,255,0.94); }
.legal-dialog-section { clear: both; }
.legal-page { width: min(920px, 100%); margin: 0 auto; padding: 24px 0 48px; }
.legal-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.legal-head { display: grid; gap: 8px; border-bottom: 1px solid var(--line); padding: 30px 30px 24px; }
.legal-head h1 { margin: 0; color: var(--text); font-size: 28px; font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; }
.legal-head p:last-child { margin: 0; color: var(--muted); font-size: 14px; font-weight: 400; line-height: 1.7; }
.legal-content { display: grid; gap: 12px; padding: 28px 30px 32px; }
.legal-content h2 { margin: 10px 0 0; color: var(--text); font-size: 17px; font-weight: 600; }
.legal-content p { margin: 0; color: var(--text-soft); font-size: 14px; font-weight: 400; line-height: 1.9; }
.legal-dialog .legal-head { padding-right: 92px; }

/* Animations */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { transform: translateY(0); opacity: 0.35; } 50% { transform: translateY(-7px); opacity: 1; } }
@keyframes progress { 0% { transform: translateX(-110%); } 100% { transform: translateX(260%); } }
@keyframes fadeLift { from { transform: translateY(8px) scale(0.985); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes overlayOut { to { opacity: 0; } }
@keyframes panelIn { from { transform: translateY(12px) scale(0.98); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
@keyframes panelOut { to { transform: translateY(10px) scale(0.985); opacity: 0; } }
@keyframes viewerIn { from { transform: scale(0.985); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes toastIn { from { transform: translateX(18px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { to { transform: translateX(18px); opacity: 0; } }

/* Transitions */
a, button, .button, .site-nav a, .site-action, .mode-toggle label, .record-card, .stat-card, .table-thumb, .record-input-image-button, .record-dialog-image-button, .dialog-close, input, select, textarea { transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .record-card:focus-visible { outline: none; box-shadow: var(--ring); }
.redeem-dialog, .record-dialog, .generation-overlay, .legal-dialog, .image-viewer { animation: overlayIn 0.22s var(--ease-out); }
.redeem-panel, .record-dialog-panel, .legal-dialog-panel, .generation-modal { animation: panelIn 0.28s var(--ease-soft); }
.image-viewer-stage img { animation: viewerIn 0.28s var(--ease-soft); }
.preview-stage img { animation: fadeLift 0.42s var(--ease-soft); }
.preview-stage { position: relative; box-shadow: none; }

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

/* Responsive */
@media (max-width: 1280px) { body.page-records .history-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1180px) { .app-shell { --shell-gutter: 24px; } .history-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .code-create-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dashboard-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 980px) { .app-topbar { grid-template-columns: 1fr; gap: 12px; position: static; } .topbar-right { justify-content: flex-start; } .two-col, .narrow-left, .auth-dashboard, .settings-page, .dashboard-row { grid-template-columns: 1fr; } .auth-info, .auth-form-card { min-height: auto; } .auth-info { gap: 28px; } .preview-card { grid-template-rows: auto minmax(300px, auto); } .preview-stage { min-height: 300px; } .code-create-form .button { width: 100%; } .cloud-storage-card { grid-column: auto; } .cloud-storage-grid, .storage-options-grid { grid-template-columns: 1fr; } .settings-tab-nav { gap: 4px; padding: 4px; } .settings-tab-nav button { min-height: 32px; padding: 0 10px; font-size: 13px; } }
@media (max-width: 720px) {
  /* ── Shell & Page ── */
  body.page-app, body.page-records, body.page-credits, body.page-admin { min-width: 0; width: 100%; max-width: 100%; overflow-x: hidden; overscroll-behavior-x: none; position: relative; touch-action: pan-y; }
  .app-shell { --shell-gutter: 14px; padding: 10px 0 100px; max-width: 100%; overflow-x: hidden; }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  .eyebrow { font-size: 9px; }

  /* ── Cards ── */
  .card, .stat-card { width: 100%; max-width: 100%; min-width: 0; overflow-x: hidden; padding: 14px; border-radius: var(--radius-sm); }
  .card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 0; margin-bottom: 12px; flex-wrap: wrap; }
  .card-head-actions { width: auto; min-width: 0; justify-self: end; justify-content: flex-end; gap: 6px; flex-wrap: nowrap; white-space: nowrap; }

  /* ── Forms & Fields ── */
  .field-grid, .prompt-api-grid, .auth-metrics,
  .filter-bar, .filter-bar.user-record-filter, .filter-bar.admin-user-filter,
  .filter-bar.admin-code-filter, .filter-bar.admin-record-filter,
  .code-create-form, .user-credit-filter, .admin-credit-filter,
  .invite-link-panel { grid-template-columns: 1fr; }
  .generation-options-grid.is-single-count { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .generation-options-grid.is-single-count .option-size { grid-column: 1 / -1; }
  .filter-actions { width: auto; min-width: 0; justify-self: end; justify-content: flex-end; gap: 6px; flex-wrap: nowrap; white-space: nowrap; }
  .generate-actions .button { font-size: 13px; padding: 0 12px; }
  input, select { height: 44px; }
  textarea { min-height: 138px; }
  .button { min-height: 44px; width: auto; font-size: 14px; }
  .mode-toggle label { min-height: 40px; font-size: 14px; }
  .invite-link-panel { gap: 10px; }
  .invite-link-panel .button { width: 100%; }
  .generation-notice { font-size: 12px; padding: 10px; line-height: 1.6; }
  .edit-upload-box { width: 100%; min-height: 78px; padding: 12px; }
  .edit-upload-field:has(.edit-upload-preview:not(.hidden)) { grid-template-columns: minmax(0, 1fr) auto; }
  .edit-upload-field:has(.edit-upload-preview:not(.hidden)) .edit-upload-box { width: 80px; min-width: 80px; height: 80px; }
  .edit-upload-field:has(.edit-upload-preview:not(.hidden)) .edit-upload-box strong { display: none; }
  .edit-upload-field:has(.edit-upload-preview:not(.hidden)) .edit-upload-box small { display: none; }
  .edit-upload-preview { grid-template-columns: repeat(auto-fill, minmax(68px, 80px)); gap: 8px; }
  .edit-preview-item button { right: 4px; bottom: 4px; padding: 3px 6px; font-size: 10px; }

  /* ── Records List ── */
  .history-list { grid-template-columns: 1fr; gap: 10px; }
  body.page-records .history-list { grid-template-columns: 1fr; }
  .history-list .record-card { height: auto; min-height: 148px; grid-template-columns: 100px minmax(0, 1fr); grid-template-rows: 1fr; gap: 10px; padding: 10px; border-radius: var(--radius-sm); }
  .history-list .record-image { width: 100px; height: 128px; min-height: 128px; border-radius: var(--radius-xs); }
  .history-list .record-image::after { display: none; }
  .history-list .record-body { gap: 5px; padding: 4px 4px 2px; }
  .history-list .record-body p { font-size: 12px; line-height: 1.5; }
  .history-list .record-meta span { font-size: 10px; }
  .history-list .record-foot { gap: 7px; padding: 8px 0 2px; }
  .history-list .record-foot-row { gap: 4px; }
  .history-list .record-foot-row time { font-size: 10px; }
  .record-duration { font-size: 9px; }
  .history-list .record-delete, .history-list .record-regenerate,
  .history-list .record-edit-again { min-height: 26px; padding: 0 10px; font-size: 11px; line-height: 1; border-radius: var(--radius-full); }
  .history-list .record-foot-actions { justify-content: flex-end; flex-wrap: wrap; gap: 5px; }
  .record-status-overlay { min-width: 44px; min-height: 20px; padding: 0 10px; font-size: 10px; }

  /* ── Bulk Actions ── */
  .record-bulk-actions { flex-wrap: wrap; gap: 10px; padding: 10px; }
  .record-bulk-actions .button.danger.small { width: 100%; min-height: 34px; justify-content: center; }
  .record-select { top: 6px; left: 6px; width: 18px; height: 18px; }
  .record-select::after { width: 7px; height: 4px; }

  /* ── Pagination ── */
  .pagination { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
  .pagination .button { font-size: 13px; min-height: 38px; padding: 0 16px; }
  .pagination span { font-size: 13px; min-width: 100%; text-align: center; order: -1; }

  /* ── Record Detail Dialog ── */
  .record-dialog, .redeem-dialog, .legal-dialog, .generation-overlay { align-items: center; justify-items: stretch; padding: 10px; overscroll-behavior: contain; }
  .record-dialog-panel { width: 100%; max-height: calc(100dvh - 20px); display: grid; grid-template-rows: auto minmax(0, 1fr); border-radius: var(--radius-sm); }
  .record-dialog-head { position: sticky; top: 0; z-index: 2; padding: 14px 14px 12px; }
  .record-dialog-body { grid-template-columns: 1fr; gap: 12px; padding: 14px; overflow-y: auto; }
  .record-dialog-image { grid-column: 1; grid-row: auto; min-height: clamp(200px, 40dvh, 320px); max-height: 44dvh; margin: 0; }
  .record-dialog-image-button, .record-dialog-image-button img,
  .record-dialog-image img { max-height: inherit; }
  .record-dialog-image-grid { grid-auto-columns: minmax(200px, 82%); gap: 10px; }
  .record-dialog-image-grid .record-dialog-image-button { min-height: 180px; }
  .record-dialog-body > .record-full-prompt,
  .record-dialog-body > .record-input-images,
  .record-detail-grid,
  .record-dialog-body > .record-error { grid-column: 1; }
  .record-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .record-detail-grid div { min-height: 52px; padding: 9px 10px; }
  .record-detail-grid > div:nth-child(1) { grid-column: 1 / -1; }
  .record-detail-grid > div:nth-child(2),
  .record-detail-grid > div:nth-child(3),
  .record-detail-grid > div:nth-child(4),
  .record-detail-grid > div:nth-child(5) { grid-column: span 1; }
  .record-full-prompt p { max-height: 100px; font-size: 13px; }
  .record-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 12px; }
  .record-dialog-actions .button { min-width: 72px; }
  .record-input-images [data-dialog-input-list] { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }

  /* ── Append Dialog ── */
  .record-append-dialog { align-items: end; padding: 8px; }
  .record-append-panel { width: 100%; max-height: calc(100dvh - 16px); overflow-y: auto; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
  .record-append-form { padding: 14px; gap: 12px; }
  .record-append-reference-image { grid-template-columns: 64px minmax(0, 1fr); gap: 10px; padding: 6px; }
  .record-append-reference-image img { width: 64px; height: 64px; }
  .record-append-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .record-append-actions .button { min-width: 0; width: 100%; min-height: 42px; }

  /* ── Redeem ── */
  .redeem-panel, .generation-modal { width: 100%; border-radius: var(--radius-sm); }
  .redeem-head { padding: 14px; }
  .redeem-form { padding: 14px; }

  /* ── Image Viewer ── */
  .image-viewer { padding: 8px; gap: 8px; }
  .image-viewer-toolbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .image-viewer-toolbar button, .image-viewer-toolbar > span,
  .image-viewer-download { width: 100%; padding: 0 8px; font-size: 12px; height: 34px; }
  .image-viewer-meta { grid-column: 1 / -1; margin-right: 0; }
  .image-viewer-meta strong { max-width: 100%; font-size: 13px; }
  .image-viewer-nav { width: 38px; height: 46px; font-size: 28px; }
  .image-viewer-nav.prev { left: 8px; }
  .image-viewer-nav.next { right: 8px; }
  .image-viewer-thumbs { grid-auto-columns: 60px; gap: 6px; }
  .image-viewer-thumbs button { width: 60px; height: 46px; }

  /* ── Preview Stage ── */
  .preview-card { grid-template-rows: auto minmax(220px, auto); }
  .preview-stage { min-height: 220px; }
  .generation-progress-card { width: calc(100% - 16px); padding: 14px; }
  .generation-progress-grid strong { font-size: 18px; }

  /* ── Auth ── */
  .auth-dashboard { gap: 12px; }
  .auth-info, .auth-form-card { padding: 18px; min-height: auto; }
  .auth-info h2 { font-size: 24px; }
  .auth-metrics { gap: 10px; }
  .auth-metrics div { min-height: 76px; padding: 12px; }

  /* ── Admin ── */
  body.page-admin .admin-nav { display: none; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .dashboard-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-row { grid-template-columns: 1fr; }
  .dashboard-today { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .dashboard-today-item strong { font-size: 24px; }
  .dashboard-today-item { min-height: 64px; padding: 10px 8px; }
  .chart-bar-wrap .chart-bar { width: min(28px, 100%); }
  .settings-tab-nav { gap: 4px; padding: 4px; }
  .settings-tab-nav button { padding: 0 8px; font-size: 12px; min-height: 36px; }
  .code-export-actions { align-items: stretch; flex-direction: column; }
  .code-export-actions .button { width: 100%; }

  /* ── Toasts & Layers ── */
  .jpt-toast-stack { top: 10px; right: 8px; left: 8px; width: auto; }
  .jpt-toast { padding: 10px 14px; font-size: 13px; }
  .jpt-layer-overlay { align-items: end; padding: 8px; }
  .jpt-layer-panel { width: 100%; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
  .jpt-layer-head { grid-template-columns: 32px minmax(0, 1fr); gap: 10px; padding: 16px 16px 12px; }
  .jpt-layer-icon { width: 32px; height: 32px; }
  .jpt-layer-head h2 { font-size: 16px; }
  .jpt-layer-head p { font-size: 13px; }
  .jpt-layer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 14px; }
  .jpt-layer-actions .button:only-child { grid-column: 1 / -1; }

  /* ── Center Auth ── */
  body.page-auth:has(.center-auth-page) .app-shell { width: min(100% - 32px, 390px); padding: 14px 0 20px; }
  body.page-auth:has(.center-auth-register) .app-shell { width: min(100% - 32px, 400px); }
  .center-auth-page { padding: 0; align-self: start; padding-top: clamp(12px, 5vh, 40px); }
  .center-auth-panel { padding: 24px 18px; border-radius: var(--radius-sm); }
  .center-auth-top { margin-bottom: 18px; }
  .center-auth-brand { gap: 8px; margin-bottom: 18px; }
  .center-auth-mark { width: 40px; height: 40px; }
  .center-auth-mark svg { width: 28px; height: 28px; }
  .center-auth-brand strong { font-size: 22px; }
  .center-auth-brand small { margin-top: 3px; font-size: 11px; }
  .center-auth-tabs { min-height: 40px; border-radius: var(--radius-full); }
  .center-auth-tabs .center-auth-tab { font-size: 13px; }
  .center-auth-body { margin-top: 18px; min-height: 280px; }
  .center-auth-form { gap: 11px; }
  .center-auth-field { gap: 6px; }
  .center-auth-field span { font-size: 12px; }
  .center-auth-field input { height: 44px; border-radius: var(--radius-xs); font-size: 14px; }
  .center-auth-code-row { grid-template-columns: minmax(0, 1fr) 96px; }
  .center-auth-code-row button { height: 44px; font-size: 12px; }
  .center-auth-submit { min-height: 44px; margin-top: 4px; font-size: 14px; }

  /* ── Legal ── */
  .legal-page { padding: 14px 0 28px; }
  .legal-head, .legal-content { padding-right: 18px; padding-left: 18px; }
  .legal-dialog .legal-head { padding-right: 76px; }
  .legal-dialog-close { top: 10px; margin: 10px 10px -44px 0; }
  .legal-head h1 { font-size: 24px; }
  .legal-dialog-panel { max-height: calc(100vh - 16px); }
}

@media (max-width: 380px) { .topbar-account { grid-template-columns: 1fr 1fr; } .topbar-account .balance { grid-column: 1 / -1; } .mobile-topbar-menu { width: min(260px, calc(100vw - 18px)) !important; } }

/* Gradients & Glass - Component Overrides */
.preview-stage::after { content: none; }
.preview-stage > * { position: relative; z-index: 1; }
.edit-upload-box.is-dragging, .edit-upload-box.is-paste-ready, .edit-upload-box.is-active { border-color: var(--text); background: rgba(0,0,0,0.02); box-shadow: 0 0 0 3px rgba(0,0,0,0.06); }
.generation-progress-grid strong, .stat-card strong { font-variant-numeric: tabular-nums; }
body.page-admin [data-admin-users] { min-width: 1740px; }
body.page-admin [data-admin-users] th:nth-child(1), body.page-admin [data-admin-users] td:nth-child(1) { width: 140px; }
body.page-admin [data-admin-users] th:nth-child(2), body.page-admin [data-admin-users] td:nth-child(2) { width: 132px; }
body.page-admin [data-admin-users] th:nth-child(3), body.page-admin [data-admin-users] td:nth-child(3) { width: 200px; }
body.page-admin [data-admin-users] th:nth-child(4), body.page-admin [data-admin-users] td:nth-child(4), body.page-admin [data-admin-users] th:nth-child(5), body.page-admin [data-admin-users] td:nth-child(5), body.page-admin [data-admin-users] th:nth-child(7), body.page-admin [data-admin-users] td:nth-child(7), body.page-admin [data-admin-users] th:nth-child(8), body.page-admin [data-admin-users] td:nth-child(8), body.page-admin [data-admin-users] th:nth-child(9), body.page-admin [data-admin-users] td:nth-child(9) { width: 92px; }
body.page-admin [data-admin-users] th:nth-child(6), body.page-admin [data-admin-users] td:nth-child(6) { width: 190px; }
body.page-admin [data-admin-users] th:nth-child(10), body.page-admin [data-admin-users] td:nth-child(10) { width: 170px; }
body.page-admin [data-admin-users] th:nth-child(11), body.page-admin [data-admin-users] td:nth-child(11) { width: 170px; }
body.page-admin [data-admin-users] th:nth-child(12), body.page-admin [data-admin-users] td:nth-child(12) { width: 280px; }

/* Legacy dialog overlays */
.record-append-dialog { position: fixed; inset: 0; z-index: 10020; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,0.40); }
.record-append-panel { width: min(620px, 100%); max-height: calc(100dvh - 40px); overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.record-append-form { display: grid; gap: 14px; padding: 18px; }
.record-append-form .generation-options-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.record-append-form .generation-options-grid.is-single-count .option-size { grid-column: 1 / -1; }
.record-append-reference { display: grid; gap: 8px; }
.record-append-reference > span { color: var(--text-soft); font-size: 13px; font-weight: 500; }
.record-append-reference-image { width: 100%; display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 8px; background: var(--surface-soft); color: var(--text); text-align: left; cursor: pointer; transition: border-color 0.2s ease; }
.record-append-reference-image:hover { border-color: var(--line-hover); }
.record-append-reference-image img { width: 76px; height: 76px; object-fit: cover; border-radius: 6px; display: block; }
.record-append-actions { display: flex; justify-content: flex-end; gap: 10px; }
.record-append-actions .button { min-width: 88px; }
.record-edit-again { min-height: 28px; border: 1px solid var(--line-strong); border-radius: var(--radius-full); padding: 0 10px; background: transparent; color: var(--text-soft); font-size: 12px; font-weight: 500; }
.record-edit-again:hover { border-color: var(--line-hover); background: rgba(0,0,0,0.04); color: var(--text); }

/* Record batch selection */
.record-select { position: absolute; top: 6px; left: 6px; z-index: 4; width: 20px; height: 20px; display: grid; place-items: center; border: 1.5px solid rgba(255,255,255,0.48); border-radius: 5px; background: rgba(0,0,0,0.16); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); opacity: 0.58; cursor: pointer; transition: opacity 0.15s ease, border-color 0.15s ease, background 0.15s ease; }
.record-select:hover, .record-card:hover .record-select { opacity: 1; border-color: rgba(255,255,255,0.72); background: rgba(0,0,0,0.28); }
.record-select:has(input:checked) { opacity: 1; border-color: var(--text); background: var(--text); }
.record-select input { position: absolute; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; appearance: none; -webkit-appearance: none; }
.record-select::after { content: ""; display: block; width: 8px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; transition: opacity 0.12s ease; }
.record-select:has(input:checked)::after { opacity: 1; }
.record-bulk-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 10px 12px; background: transparent; }
.record-bulk-check { display: inline-flex; align-items: center; gap: 8px; color: var(--text-soft); font-size: 13px; font-weight: 500; }
.record-bulk-check input { width: 16px; height: 16px; accent-color: var(--text); }

/* body override - no green gradient */
body { background: var(--bg); }
html { background: var(--bg); }

/* ═══════════════════════════════════════════
   Welcome / Landing Page
   ═══════════════════════════════════════════ */
body.page-welcome .site-header { margin-bottom: 0; }
body.page-welcome .site-nav { display: none; }
body.page-welcome .site-actions { display: inline-flex !important; }

/* ── Hero ── */
.welcome-hero { display: grid; place-items: center; min-height: 70vh; padding: 48px 0 56px; text-align: center; }
.welcome-hero-content { display: grid; justify-items: center; gap: 12px; max-width: 680px; }
.welcome-hero-eyebrow { margin: 0; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.welcome-hero-title { font-size: 44px; font-weight: 700; line-height: 1.12; letter-spacing: -0.035em; color: var(--text); margin: 0; }
.welcome-hero-desc { margin: 0; color: var(--text-soft); font-size: 18px; font-weight: 400; line-height: 1.75; max-width: 520px; }
.welcome-hero-actions { display: flex; gap: 14px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }
.welcome-hero-actions .button { min-height: 50px; padding: 0 32px; font-size: 15px; font-weight: 600; }
.welcome-hero-actions .button.primary { background: var(--primary); color: var(--primary-inverse); }
.welcome-hero-actions .button.primary:hover { opacity: 0.88; }
.welcome-hero-actions .button.secondary { border-color: var(--line-strong); }

/* Hero stats row */
.welcome-hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin-top: 28px; border: 1px solid var(--line); border-radius: var(--radius-full); overflow: hidden; }
.welcome-hero-stats div { min-height: 72px; display: grid; place-items: center; align-content: center; gap: 2px; padding: 12px 10px; }
.welcome-hero-stats div + div { border-left: 1px solid var(--line); }
.welcome-hero-stats strong { color: var(--text); font-size: 14px; font-weight: 600; }
.welcome-hero-stats span { color: var(--muted); font-size: 12px; font-weight: 500; }

/* ── Features ── */
.welcome-features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; max-width: 1000px; margin: 0 auto 64px; padding: 0; }
.welcome-feature-card { min-height: 200px; display: grid; justify-items: center; align-content: start; gap: 10px; border: 1px solid var(--line); border-radius: var(--radius); padding: 30px 22px; background: var(--surface); text-align: center; transition: border-color 0.25s ease, transform 0.25s ease; }
.welcome-feature-card:hover { border-color: var(--line-hover); transform: translateY(-3px); }
.welcome-feature-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--radius-xs); background: var(--text); }
.welcome-feature-icon svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.welcome-feature-card strong { color: var(--text); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.welcome-feature-card > span:last-child { color: var(--muted); font-size: 13px; line-height: 1.7; max-width: 260px; }

/* ── How It Works ── */
.welcome-section-eyebrow { text-align: center; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 8px; }
.welcome-section-title { text-align: center; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 36px; color: var(--text); }
.welcome-steps { max-width: 960px; margin: 0 auto 64px; padding: 0; }
.welcome-steps-grid { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 0; align-items: start; }
.welcome-step { display: grid; justify-items: center; gap: 8px; padding: 24px 16px; text-align: center; }
.welcome-step-num { width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--radius-full); background: var(--text); color: var(--primary-inverse); font-size: 18px; font-weight: 700; }
.welcome-step strong { color: var(--text); font-size: 16px; font-weight: 600; }
.welcome-step > span:last-child { color: var(--muted); font-size: 13px; line-height: 1.6; max-width: 220px; }
.welcome-step-arrow { display: grid; place-items: center; min-height: 100%; padding-top: 40px; color: var(--muted-light); font-size: 26px; font-weight: 300; }

/* ── CTA ── */
.welcome-cta { text-align: center; padding: 48px 20px 56px; border-top: 1px solid var(--line); }
.welcome-cta h2 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 8px; }
.welcome-cta p { color: var(--muted); margin: 0 0 22px; font-size: 15px; }
.welcome-cta .button { min-height: 50px; padding: 0 36px; font-size: 15px; font-weight: 600; }

/* ── Footer ── */
.welcome-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 20px 0 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.welcome-footer a { color: var(--muted); text-decoration: none; }
.welcome-footer a:hover { color: var(--text-soft); }

@media (max-width: 720px) {
  body.page-welcome .app-shell { padding-bottom: 24px; }
  body.page-welcome .site-header { grid-template-columns: minmax(0, 1fr) auto !important; gap: 12px; }
  body.page-welcome .site-actions { gap: 6px; }
  body.page-welcome .site-action { font-size: 12px; padding: 0 12px; height: 34px; }
  .welcome-hero { min-height: 54vh; padding: 32px 16px 40px; }
  .welcome-hero-title { font-size: 28px; }
  .welcome-hero-desc { font-size: 15px; }
  .welcome-hero-actions { flex-direction: column; width: 100%; max-width: 320px; }
  .welcome-hero-actions .button { width: 100%; }
  .welcome-hero-stats { grid-template-columns: 1fr; }
  .welcome-hero-stats div + div { border-left: 0; border-top: 1px solid var(--line); }
  .welcome-features { grid-template-columns: 1fr; gap: 10px; padding: 0 16px; }
  .welcome-feature-card { min-height: auto; padding: 22px 18px; }
  .welcome-steps-grid { grid-template-columns: 1fr; }
  .welcome-step-arrow { display: none; }
  .welcome-step { padding: 14px 12px; gap: 6px; }
  .welcome-section-title { font-size: 22px; margin-bottom: 24px; }
  .welcome-cta { padding: 40px 16px 48px; }
  .welcome-cta h2 { font-size: 22px; }
  .welcome-footer { flex-direction: column; text-align: center; gap: 8px; }
}
