@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --window: oklch(0.119 0 0);
  --content: oklch(0.14 0 0);
  --surface: oklch(0.196 0 0);
  --surface-light: radial-gradient(ellipse 120% 70% at 100% 0%, oklch(0.87 0.017 65 / 0.12), oklch(0.87 0.017 65 / 0.045) 50%, transparent 100%);
  --card: oklch(0.23 0 0);
  --card-hover: oklch(0.265 0 0);
  --foreground: oklch(0.955 0 0);
  --muted-foreground: oklch(0.76 0 0);
  --subtle-foreground: oklch(0.6 0 0);
  --secondary: oklch(1 0 0 / 0.06);
  --accent: oklch(1 0 0 / 0.1);
  --border: oklch(1 0 0 / 0.08);
  --border-strong: oklch(1 0 0 / 0.14);
  --ring: oklch(1 0 0 / 0.45);
  --media-overlay: oklch(0 0 0 / 0.55);
  --media-overlay-strong: oklch(0 0 0 / 0.6);
  --success: oklch(0.78 0.15 155);
  --destructive: oklch(0.62 0.19 25);
  --destructive-soft: oklch(0.62 0.19 25 / 0.14);
  --on-primary: oklch(0.196 0 0);
  --on-primary-soft: oklch(0.196 0 0 / 0.08);

  --radius-panel: 16px;
  --radius-card: 12px;
  --radius-control: 8px;

  --shadow-popover: inset 0 1px 0 oklch(1 0 0 / 0.07), 0 12px 32px oklch(0 0 0 / 0.45);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'PP Formula', 'Inter', system-ui, sans-serif;
  --text-ui: 13px;
  --text-body: 14px;
  --text-heading: 16px;
  --text-title: 22px;

  --panel-width: 360px;
  --gap: 12px;
  --page-pad: 12px;
  --page-gap: 12px;
  --radius-shell: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--content);
  color: var(--foreground);
  font: var(--text-ui) / 1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.pill-lime {
  height: 32px; padding: 0 12px; font-size: var(--text-ui); border-radius: var(--radius-control);
  background: var(--foreground); color: var(--on-primary); font-weight: 600;
}

body.in-desktop { --page-gap: 8px; --radius-panel: var(--radius-shell); }

.wrap {
  display: grid; grid-template-columns: var(--panel-width) 1fr; grid-template-rows: minmax(0, 1fr); gap: var(--page-gap);
  padding: var(--page-pad); height: calc(100vh - var(--draft-bar, 0px));
}

.panel {
  background: var(--surface-light) fixed, var(--surface); border-radius: var(--radius-panel);
  padding: 16px 20px 20px;
  display: flex; flex-direction: column; gap: 20px; font-size: var(--text-body);
  align-self: start; position: sticky; top: var(--page-pad);
  height: calc(100vh - var(--draft-bar, 0px) - 2 * var(--page-pad)); overflow-y: auto; scrollbar-width: thin;
}
body.in-desktop .wrap { padding: 0; }
body.in-desktop .panel { top: 0; height: 100vh; }
.panel.busy > :not(#go):not(#status):not(.hero), .panel.busy > .hero > * { opacity: 0.4; transition: opacity 0.2s; }

.hero { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; flex: none; }
.hero > img, .hero > video { display: none; }
.hero > div { min-width: 0; text-align: right; }
.hero b {
  display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: var(--text-heading); line-height: 24px; font-weight: 600;
}
.hero span { display: none; }
.back {
  display: inline-flex; align-items: center; gap: 4px; flex: none; height: 28px; padding: 0 8px 0 4px; margin-left: -4px;
  border-radius: var(--radius-control); color: var(--muted-foreground); font-size: var(--text-body);
}
.back:hover { background: color-mix(in oklch, var(--accent) 40%, transparent); color: var(--foreground); }
.back svg { width: 16px; height: 16px; }

.lb, .box > label, .prompt > label {
  display: block; margin-bottom: 8px; color: var(--muted-foreground);
  font-size: var(--text-ui); font-weight: 400;
}
.label {
  display: block; margin-bottom: 8px; color: var(--foreground);
  font-size: var(--text-body); font-weight: 500; line-height: 20px;
}
.label .optional { margin-left: 4px; color: var(--muted-foreground); font-weight: 400; }
.box { flex: none; }
.note { margin: 8px 0 0; color: var(--muted-foreground); font-size: var(--text-body); }

.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px;
  background: var(--secondary); border-radius: 10px;
}
.seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 26px; padding: 0 8px; border-radius: 7px;
  color: var(--muted-foreground); font-size: var(--text-body); white-space: nowrap;
}
.seg button svg { flex: none; }
.seg button:hover { color: var(--foreground); }
.seg button.on { background: var(--accent); color: var(--foreground); }
.seg button:disabled { opacity: 0.5; cursor: not-allowed; }
.where-home { display: none; }
.adv summary {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  color: var(--foreground); font-size: var(--text-body); font-weight: 500; line-height: 20px;
  list-style: none; cursor: pointer; user-select: none;
}
.adv summary::-webkit-details-marker { display: none; }
.adv summary::after {
  content: ''; flex: none; width: 6px; height: 6px; margin: 0 4px 4px 0;
  border-right: 1.5px solid var(--muted-foreground); border-bottom: 1.5px solid var(--muted-foreground);
  transform: rotate(45deg); transition: transform 0.15s;
}
.adv[open] summary { margin-bottom: 12px; }
.adv[open] summary::after { margin: 4px 4px 0 0; transform: rotate(-135deg); }
.card .seg { display: inline-flex; }
.card .seg button { white-space: nowrap; }

textarea, .prompt textarea {
  display: block; width: 100%; min-height: 88px; resize: vertical; padding: 8px 12px;
  border: 0; border-radius: var(--radius-control); background: var(--secondary);
  line-height: 20px;
}
textarea::placeholder, input::placeholder { color: var(--muted-foreground); }
textarea:focus, input:focus, select:focus { outline: none; box-shadow: 0 0 0 1px var(--ring); }
select, input[type='text'], input:not([type]), .addr input, input.field {
  width: 100%; height: 32px; padding: 0 10px; border: 0;
  border-radius: var(--radius-control); background: var(--secondary);
}
.panel input[type='text'], .panel input:not([type]), .panel .addr input { height: 36px; padding: 0 12px; }
.panel textarea { padding: 8px 12px; font-size: var(--text-body); }
.addr { display: flex; gap: 8px; }
.addr button { flex: none; height: 36px; padding: 0 12px; border-radius: var(--radius-control); background: var(--secondary); font-weight: 500; }
.addr button:hover { background: var(--accent); }
.local { display: flex; flex-direction: column; gap: 8px; }
.local .label { margin: 0; }
.conn { margin: 0; font-size: var(--text-body); color: var(--muted-foreground); }
.conn.ok { color: var(--success); }
.conn.bad { color: var(--destructive); }
.help {
  font-size: var(--text-body); color: var(--muted-foreground); background: var(--destructive-soft);
  border-radius: var(--radius-control); padding: 10px;
}
.help code {
  display: block; margin-top: 6px; padding: 6px 8px; border-radius: 6px; background: var(--content);
  color: var(--foreground); font-size: var(--text-body); word-break: break-all; user-select: all;
}

.select { position: relative; display: block; }
.select select {
  appearance: none; display: block; width: 100%; height: 36px; padding: 0 36px 0 12px; border: 0;
  border-radius: var(--radius-control); background: var(--secondary); color: var(--foreground);
  font-size: var(--text-body); cursor: pointer;
}
.select select:hover { background: var(--accent); }
.select select:disabled { opacity: 0.5; cursor: not-allowed; }
select option { background: var(--card); color: var(--foreground); }
select option:disabled { color: var(--muted-foreground); }
.select svg { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); color: var(--muted-foreground); pointer-events: none; }

.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 128px; padding: 20px 16px; overflow: hidden;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-card); background: transparent;
  color: var(--muted-foreground); font-size: var(--text-body); text-align: center; cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.drop:hover, .drop.over { border-color: var(--ring); background: var(--secondary); }
.drop input[type='file'] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop:has(input[type='file']:focus-visible) { outline: 2px solid var(--ring); outline-offset: 2px; }
.drop-hint { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted-foreground); }
.drop-hint svg { flex: none; }
.media-list { display: flex; flex-direction: column; gap: 16px; }
.media-shown { position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--secondary); }
.media-shown.over { border-color: var(--ring); }
.media-shown img, .media-shown video { display: block; width: 100%; max-height: 300px; object-fit: contain; }
.media-list .media-shown img, .media-list .media-shown video { max-height: 160px; }
.media-list .field-head > .label { color: var(--muted-foreground); font-size: var(--text-ui); font-weight: 400; }
.field-head { display: flex; align-items: center; gap: 8px; min-height: 28px; margin-bottom: 8px; }
.field-head > .label { margin-bottom: 0; }
.media-actions { display: flex; gap: 2px; margin-left: auto; }
.media-action {
  display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border-radius: var(--radius-control); background: transparent; color: var(--muted-foreground); cursor: pointer;
}
.media-action:hover:not(:disabled) { background: var(--secondary); color: var(--foreground); }
.media-action:disabled { opacity: 0.5; cursor: default; }
.media-caption { margin: 8px 2px 0; color: var(--muted-foreground); font-size: var(--text-ui); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted-foreground); font-size: 12px; }
.samples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; color: var(--muted-foreground); font-size: var(--text-body); }
.samples > span { margin-right: 4px; }
.try-door {
  position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 10px; height: 36px; padding: 0 12px 0 6px;
  border-radius: 999px; background: none; color: var(--muted-foreground); font-size: var(--text-ui);
}
.try-door[hidden] { display: none; }
.try-door:hover { background: var(--accent); color: var(--foreground); }
.try-door:focus-visible { outline: 1px solid var(--ring); outline-offset: 2px; }
.try-peek { display: inline-flex; }
.try-face {
  display: block; width: 24px; height: 24px; overflow: hidden;
  border: 1.5px solid var(--surface); border-radius: var(--radius-control); background: var(--card);
  box-shadow: 0 2px 4px oklch(0 0 0 / 0.3);
  transition: transform 0.2s var(--ease-out-expo);
}
.try-face + .try-face { margin-left: -8px; }
.try-face:nth-child(1) { transform: rotate(-6deg); }
.try-face:nth-child(3) { transform: rotate(6deg); }
@media (hover: hover) and (pointer: fine) {
  .try-door:hover .try-face:nth-child(1) { transform: translateY(-1px) rotate(-12deg); }
  .try-door:hover .try-face:nth-child(3) { transform: translateY(-1px) rotate(12deg); }
}
.try-face img, .try-face video { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.try-dialog {
  display: none; flex-direction: column; width: min(520px, calc(100vw - 32px)); max-height: min(640px, calc(100vh - 32px));
  padding: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius-panel); background: var(--card); color: var(--foreground);
  box-shadow: var(--shadow-popover); font-size: var(--text-body);
}
.try-dialog:has(.try-tabs) { height: min(640px, calc(100vh - 32px)); }
.try-dialog[open] { display: flex; animation: try-in 0.18s var(--ease-out-expo); }
.try-dialog::backdrop { background: var(--media-overlay); }
.try-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 12px 20px; }
.try-head h2 { margin: 0; font-size: var(--text-heading); font-weight: 600; }
.try-tabs { margin-bottom: 0; }
.try-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 20px 20px; scrollbar-width: thin; }
.try-close { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-control); color: var(--muted-foreground); }
.try-close:hover { background: var(--secondary); color: var(--foreground); }
.try-close:focus-visible, .try-pick:focus-visible, .recent-pick:focus-visible { outline: 1px solid var(--ring); outline-offset: 2px; }
.try-grid, .try-recent .recent-row { display: grid; grid-template-columns: repeat(auto-fill, 144px); justify-content: center; gap: 16px 12px; }
.try-pick, .recent-pick { display: flex; flex-direction: column; gap: 6px; padding: 0; color: var(--muted-foreground); font-size: var(--text-body); text-align: center; }
.try-pick img, .try-pick video, .recent-pick img, .recent-none {
  display: block; width: 144px; height: 144px; object-fit: cover; border-radius: var(--radius-card); background: var(--secondary); transition: filter 0.15s;
}
.try-pick > span, .recent-app { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; }
.try-pick:hover, .recent-pick:hover { color: var(--foreground); }
.try-pick:hover img, .try-pick:hover video, .recent-pick:hover img { filter: brightness(1.1); }
.recent-pick:disabled { opacity: 0.5; cursor: progress; }
.recent-none { display: grid; place-items: center; color: var(--muted-foreground); font-weight: 600; text-transform: uppercase; }
@keyframes try-in { from { opacity: 0; transform: scale(0.97); } }
@media (prefers-reduced-motion: reduce) {
  .try-face { transition: none; }
  .try-door:hover .try-face:nth-child(1), .try-door:hover .try-face:nth-child(3) { transform: none; }
  .try-dialog[open] { animation: none; }
}
.ats { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 8px; color: var(--muted-foreground); font-size: var(--text-body); }
.ats button {
  height: 28px; padding: 0 8px; border-radius: var(--radius-control); background: none;
  color: var(--muted-foreground); font-size: var(--text-body); font-weight: 400;
}
.ats button:hover { background: var(--secondary); color: var(--foreground); }
.chip {
  height: 24px; padding: 0 8px; border-radius: var(--radius-control);
  background: var(--secondary); color: var(--muted-foreground); font-size: 12px; font-weight: 500;
}
.chip:hover { background: var(--accent); color: var(--foreground); }
.chip.on { background: var(--foreground); color: var(--on-primary); }

.go-dock {
  order: 2; margin: auto 0 -20px; padding: 12px 0 20px; position: sticky; bottom: -20px; z-index: 2; flex: none;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface-light) fixed, var(--surface);
}
.go {
  position: relative; flex: none; height: 40px; padding: 0 16px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-control); background: var(--foreground); color: var(--on-primary);
  font-size: var(--text-body); font-weight: 600; text-align: center;
  transition: background-color 0.15s;
}
.go:hover { background: color-mix(in oklch, var(--foreground) 88%, var(--surface)); }
.go:disabled { opacity: 0.5; cursor: not-allowed; }
.go small {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px;
  border-radius: 6px; background: var(--on-primary-soft);
  font-size: var(--text-ui); font-weight: 600; font-variant-numeric: tabular-nums;
}
.go small:empty { display: none; }
.go.working { cursor: progress; }
.go.working::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(100deg, transparent 30%, oklch(1 0 0 / 0.35) 50%, transparent 70%) 0 0 / 200% 100%;
  animation: shine 1.4s linear infinite;
}
.status { margin: 0; color: var(--muted-foreground); font-size: var(--text-body); text-align: center; }
.status:empty { display: none; }
.where { position: relative; }
.where-pick {
  display: flex; align-items: flex-start; gap: 8px; width: 100%; height: 56px; margin: 0; padding: 11px 12px 0;
  border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--secondary); color: var(--foreground);
  font-size: var(--text-body); font-weight: 500; text-align: left;
}
.where + .go { z-index: 1; margin-top: -24px; }
button.where-pick:hover, .where-pick[aria-expanded="true"] { background: var(--accent); }
.where-icon, .where-check, .where-chevron { display: inline-grid; place-items: center; flex: none; }
.where-name { flex: 0 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.where-short { flex: none; color: var(--muted-foreground); font-weight: 400; white-space: nowrap; }
.where-cost {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 3;
  display: flex; flex-direction: column; gap: 12px; padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--card); box-shadow: var(--shadow-popover);
  font-size: var(--text-body);
}
.where-cost[hidden] { display: none; }
.where-cost p { display: flex; flex-direction: column; gap: 2px; margin: 0; }
.where-cost b { font-weight: 500; }
.where-cost span { color: var(--muted-foreground); }
.where-cost a { width: fit-content; color: var(--foreground); text-decoration: underline; text-underline-offset: 2px; }
.where-pick.unchosen { border-color: var(--ring); }
.where-pick.unchosen .where-icon { display: none; }
.where-chevron { margin-left: auto; color: var(--muted-foreground); }
.where-menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 3;
  display: flex; flex-direction: column; gap: 2px; padding: 4px; overflow-y: auto; overscroll-behavior: contain;
  border-radius: var(--radius-card); background: var(--card); box-shadow: var(--shadow-popover);
}
.where-menu .where-build { padding: 8px 10px 8px 36px; }
.where-menu .where-build b { font-weight: 400; }
.where-menu .where-group:disabled { opacity: 1; cursor: default; }
.where-sep { flex: none; height: 1px; margin: 4px 6px; background: var(--border); }
.where-menu button {
  flex: none;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: 10px;
  padding: 10px; border-radius: var(--radius-control); text-align: left; font-size: var(--text-body);
}
.where-menu button:hover:not(:disabled), .where-menu button:focus-visible { background: var(--secondary); }
.where-menu button:disabled { opacity: 0.4; cursor: not-allowed; }
.where-menu b { font-weight: 500; }
.where-menu small { grid-column: 2; color: var(--muted-foreground); font-size: var(--text-body); }
.where-menu .where-check { grid-row: 1; grid-column: 3; visibility: hidden; }
.where-menu > *, .how-sheet > * { flex-shrink: 0; }
.where-menu [aria-checked="true"] .where-check { visibility: visible; }
.status.err { color: var(--destructive); }

.main {
  position: relative; min-width: 0; min-height: 0; background: var(--surface-light) fixed, var(--surface); border-radius: var(--radius-panel);
  padding: 0 20px 20px; display: flex; flex-direction: column; overflow-y: auto; scrollbar-width: thin;
}
.tabs {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px; margin-bottom: 20px;
  background: var(--secondary); border-radius: 10px;
}
.tabs button {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px; border-radius: 7px;
  color: var(--muted-foreground); font-size: var(--text-body);
}
.tab-row {
  position: sticky; top: 0; z-index: 5; flex: none; display: flex; align-items: center; gap: 8px;
  margin: 0 -20px 8px; padding: 16px 20px 12px; border-radius: var(--radius-panel) var(--radius-panel) 0 0;
  background: var(--surface-light) fixed, var(--surface);
}
.tab-row .tabs { margin-bottom: 0; }
.how-open {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
  background: var(--secondary); color: var(--muted-foreground);
}
.how-open:hover, .how-open[aria-expanded="true"] { background: var(--accent); color: var(--foreground); }
.tab-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.tab-edit {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 10px;
  background: var(--secondary); color: var(--foreground); font-size: var(--text-ui);
}
.tab-edit:hover { background: var(--accent); }
.how-sheet {
  position: fixed; z-index: 50; width: min(380px, calc(100vw - 40px)); max-height: calc(100vh - 88px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 20px; padding: 20px;
  border: 1px solid var(--border); border-radius: var(--radius-panel);
  background: color-mix(in oklch, var(--card) 86%, transparent); backdrop-filter: blur(20px) saturate(1.2); box-shadow: var(--shadow-popover);
  font-size: var(--text-body); line-height: 1.5;
  transition: transform 0.24s var(--ease-out-expo), opacity 0.24s var(--ease-out-expo);
}
body.in-desktop .how-sheet { width: min(380px, calc(100vw - 16px)); max-height: calc(100vh - 64px); }
.how-sheet[data-open="false"] {
  transform: translateY(-8px); opacity: 0; pointer-events: none; visibility: hidden;
  transition: transform 0.18s var(--ease-out-expo), opacity 0.18s var(--ease-out-expo), visibility 0s 0.18s;
}
.how-sheet.how-instant { transition: none; }
.how-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.how-head h2 { margin: 0; font-size: var(--text-heading); font-weight: 600; }
.how-close { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-control); color: var(--muted-foreground); }
.how-close:hover { background: var(--secondary); color: var(--foreground); }
.how-icon { display: inline-grid; place-items: center; flex: none; }
.how-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.how-steps li {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 20px 16px; text-align: center;
  border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--secondary);
}
.how-steps .how-icon { margin-bottom: 4px; }
.how-steps b, .how-good b { font-weight: 600; }
.how-steps p { margin: 0; color: var(--muted-foreground); }
.how-good { display: flex; flex-direction: column; gap: 6px; }
.how-good ul { margin: 0; padding-left: 20px; color: var(--muted-foreground); }
.how-licenses a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.how-licenses a:hover { color: var(--foreground); }
.how-details summary { cursor: pointer; color: var(--muted-foreground); }
.how-details summary:hover { color: var(--foreground); }
.how-full { margin-top: 10px; color: var(--muted-foreground); }
.how-full h2 { margin: 12px 0 4px; color: var(--foreground); font-size: var(--text-body); font-weight: 600; }
.how-full ol, .how-full ul { margin: 0; padding-left: 20px; }
.how-full li { margin: 4px 0; }
.how-start {
  height: 36px; border-radius: var(--radius-control);
  background: var(--foreground); color: var(--on-primary); font-weight: 600;
}
@media (prefers-reduced-motion: reduce) { .how-sheet, .how-sheet[data-open="false"] { transform: none; } }
.tabs button:hover { color: var(--foreground); }
.tabs button.on { background: var(--accent); color: var(--foreground); }
.tabs select { position: absolute; top: 16px; right: 20px; width: auto; min-width: 140px; height: 32px; }

.group { margin-bottom: 28px; }
.group h3 { margin: 0 0 12px; font-size: var(--text-ui); font-weight: 500; color: var(--muted-foreground); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); align-items: start; gap: var(--gap); }
.list { display: flex; flex-direction: column; gap: var(--gap); }

.card {
  position: relative; margin: 0; overflow: hidden; border-radius: var(--radius-card);
  background: var(--card); border: 0;
}
.shot { position: relative; background: var(--window); }
.shot > img, .shot > video { display: block; width: 100%; height: auto; }
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: var(--media-overlay); font-size: 11px; font-weight: 500;
}
.shot > .tag { position: absolute; left: 10px; top: 10px; }
.cap { padding: 10px 12px 12px; }
.grid:not(:has(video, audio, .cmp, .hint3d)) > .card > .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 32px 12px 10px;
  background: linear-gradient(transparent, oklch(0 0 0 / 0.72));
}
.cap p {
  margin: 0 0 8px; color: var(--foreground); font-weight: 500;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cap div { display: flex; align-items: center; gap: 8px; color: var(--muted-foreground); font-size: 12px; }
.cap a, .cap button {
  margin-left: auto; height: 24px; padding: 0 8px; border-radius: 6px;
  background: var(--media-overlay); color: var(--foreground); font-size: 12px; font-weight: 500;
  display: inline-flex; align-items: center; backdrop-filter: blur(8px);
}
.cap a:hover, .cap button:hover { background: oklch(0 0 0 / 0.75); }
#history .grid:not(:has(video, audio, .cmp, .hint3d)) > .card:not(.live) > .cap { transition: opacity 0.15s; }
@media (hover: hover) {
  #history .grid:not(:has(video, audio, .cmp, .hint3d)) > .card:not(.live, :hover, :focus-within) > .cap { opacity: 0; }
}

.outputs-modal #history .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.outputs-modal #history .card.output { cursor: pointer; background: none; transition: filter 0.15s; }
.outputs-modal #history .card.output:hover { filter: brightness(1.08); }
.outputs-modal #history .card.output[aria-busy='true'] { cursor: progress; opacity: 0.6; }
.outputs-modal #history .card.output:focus-visible { outline: 2px solid var(--foreground); outline-offset: 2px; }
.outputs-modal #history .card.output > .cap,
.outputs-modal #history .card.output .tag,
.outputs-modal #history .card.output .cmp:not([data-view]) > :not(.output-media) { display: none; }
.outputs-modal #history .card.output .cmp { cursor: pointer; }
.outputs-modal #history .card.output .output-media { position: static; display: block; width: 100%; height: auto; clip-path: none; }

.fail {
  min-height: 180px; padding: 18px; display: grid; place-items: center; text-align: center;
  color: var(--destructive); background: var(--destructive-soft);
}
.fail b { display: block; color: var(--foreground); margin-bottom: 6px; }
.fail .pay {
  display: flex; align-items: center; width: fit-content; height: 28px; margin: 12px auto 0; padding: 0 12px;
  border-radius: var(--radius-control); background: var(--foreground); color: var(--on-primary);
  font-size: var(--text-body); font-weight: 500; text-decoration: none;
}
.fail .pay:hover { background: var(--muted-foreground); }
.fail .pay[hidden] { display: none; }
.fail .pay-note { display: block; margin-top: 12px; color: var(--muted-foreground); }
.fail .pay-note[hidden] { display: none; }
.wait {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted-foreground);
  background: linear-gradient(110deg, var(--card) 30%, var(--card-hover) 50%, var(--card) 70%) 0 0 / 200% 100%;
  animation: shine 1.6s linear infinite;
}

.empty {
  display: grid; place-items: center; align-content: center; gap: 4px; text-align: center;
  min-height: 60vh; background: none; border: 0;
}
.empty h1 { margin: 0; font-size: var(--text-heading); line-height: 24px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.empty p { margin: 0 auto; max-width: 460px; color: var(--muted-foreground); }

.how { max-width: 640px; color: var(--muted-foreground); }
.how h2 { color: var(--foreground); font-size: var(--text-heading); font-weight: 600; margin: 0 0 8px; }
.how li { margin: 6px 0; }

.live { grid-column: 1 / -1; padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.live .cap { position: static; padding: 0; background: none; }
.live-head { display: flex; align-items: baseline; gap: 12px; }
.live-head b { font-size: var(--text-heading); font-weight: 600; }
.live-stop {
  height: 28px; padding: 0 12px; border-radius: var(--radius-control);
  background: var(--secondary); color: var(--foreground); font-size: var(--text-ui); font-weight: 500;
}
.live-stop:hover:not(:disabled) { background: var(--accent); }
.live-stop:disabled { opacity: 0.5; cursor: default; }
.live-left { margin-left: auto; color: var(--foreground); font-weight: 600; font-variant-numeric: tabular-nums; }
.live-prompt { margin: 0; color: var(--muted-foreground); font-size: var(--text-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-total { height: 6px; border-radius: 3px; background: var(--secondary); overflow: hidden; }
.live-total i { display: block; height: 100%; width: 0; background: var(--foreground); border-radius: 3px; transition: width 0.25s linear; }
.live-meta { display: flex; gap: 14px; color: var(--subtle-foreground); font-size: 12px; font-variant-numeric: tabular-nums; }
.live-meta .live-pct { color: var(--foreground); font-weight: 600; }
.stages { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.stages li {
  display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; column-gap: 10px; row-gap: 4px; align-items: center;
  font-size: var(--text-ui); color: var(--subtle-foreground);
}
.stages li > span:nth-child(2) { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stages li.on > span:nth-child(2), .stages li.on .dt { grid-column: 2 / -1; }
.stages li.on .dt { text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stages .dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border-strong); }
.stages .dt { color: var(--muted-foreground); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.stages .bar { grid-column: 2 / -1; height: 4px; border-radius: 2px; background: var(--secondary); overflow: hidden; }
.stages .bar i { display: block; height: 100%; width: 0; background: var(--foreground); transition: width 0.25s linear; }
.stages li.done { color: var(--muted-foreground); }
.stages li.done .dot { background: var(--success); border-color: var(--success); }
.stages li.done .bar, .stages li.todo .bar { display: none; }
.stages li.on { color: var(--foreground); font-weight: 500; }
.stages li.on .dot { border-color: var(--foreground); border-top-color: transparent; animation: spin 0.8s linear infinite; }
.stages li.est .bar i { background: repeating-linear-gradient(135deg, var(--foreground) 0 8px, var(--muted-foreground) 8px 16px); }

@keyframes shine { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .go.working::after, .wait, .stages li.on .dot { animation: none; }
}

#examples > .grid:has(.card.example), #examples > .montage:has(.card.example), #examples .group > .grid:has(.card.example), #examples > .ex-slots {
  display: block; columns: 280px; column-gap: 16px;
}
#examples > .grid:has(.card.example) > .card, #examples > .montage:has(.card.example) > .card, #examples .group > .grid:has(.card.example) > .card, #examples > .ex-slots > .wait {
  break-inside: avoid; margin: 0 0 16px;
}
#examples .card.example { margin: 0; background: var(--window); }
#examples .card.example > .cap,
#examples .card.example .shot > :not(.example-media, :has(.example-media)),
#examples .card.example .cmp > :not(.example-media) { display: none; }
#examples .card.example .example-media { position: static; display: block; width: 100%; height: auto; clip-path: none; }
#examples .card.example::after {
  content: ''; position: absolute; inset: auto 0 0; height: 88px; pointer-events: none;
  background: linear-gradient(transparent, var(--media-overlay-strong) 45%);
}
.ex-foot {
  position: absolute; left: 16px; right: 12px; bottom: 10px; z-index: 1;
  display: flex; align-items: center; gap: 12px; min-height: 32px;
}
.ex-title {
  flex: 1; min-width: 0;
  font-size: var(--text-body); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#examples .card.example.ex-pick { cursor: pointer; }
.ex-use {
  position: absolute; right: 0; bottom: 0; flex: none; height: 32px; padding: 0 14px;
  border-radius: var(--radius-control); background: var(--foreground); color: var(--on-primary);
  font-size: var(--text-ui); font-weight: 600; opacity: 0; pointer-events: none;
}
.ex-use:focus-visible { position: static; opacity: 1; pointer-events: auto; }
.ex-slots > .wait { position: static; aspect-ratio: 16 / 9; border-radius: var(--radius-card); }
#examples .card[data-load] :is(.example-media, .shot > img, .shot > video) { aspect-ratio: auto var(--ex-ratio, 16 / 9); }
#examples .card[data-load] > * { transition: opacity 0.2s ease-out; }
#examples .card[data-load="wait"] > :not(.ex-shine), #examples .card[data-load="wait"]::after { opacity: 0; }
#examples .card[data-load="failed"] .shot { background: var(--card); }
#examples .card[data-load="failed"] .shot img { visibility: hidden; }

.cs { display: flex; flex-direction: column; gap: 12px; flex: 1 1 0; min-height: 360px; }
.cs-stage {
  position: relative; display: flex; flex-direction: column; flex: 1 1 0; min-height: 0;
  border-radius: var(--radius-card); overflow: hidden;
}
.cs-stage:has(> section) { display: block; overflow-y: auto; background: none; }
.cs-stage > section { margin: 0; }
.cs-view { flex: 1 1 0; min-height: 0; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); padding: 24px; }
.cs-view > div:not(.cs-inputs) { display: contents; }
.cs-view .card { width: 100%; height: 100%; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; background: none; }
.cs-view .shot {
  container-type: size; width: 100%; height: 100%; min-height: 0; aspect-ratio: auto;
  display: grid; place-content: center; background: none;
}
.cs-view .shot > * { grid-area: 1 / 1 / 2 / 2; }
.cs-view .shot > :is(img, video):not(.inset) { display: block; width: auto; height: auto; max-width: 100cqw; max-height: 100cqh; object-fit: contain; }
.cs-view .shot > .fail { max-width: 100cqw; max-height: 100cqh; overflow: auto; }
.cs-view .cap { justify-self: center; max-width: 100%; padding: 10px 0 0; }
.cs-view .cap p { display: none; }
.cs-view.many > div { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 12px; }
.cs-view .empty { place-self: center; min-height: 0; padding: 0; }

.cs-inputs { display: grid; grid-auto-rows: minmax(0, 1fr); gap: 12px; place-self: center; width: min(100%, 760px); height: min(100%, 360px); }
.cs-inputs.n1 { height: min(100%, 480px); }
.cs-inputs.n2 { grid-template-columns: repeat(2, 1fr); }
.cs-inputs.n3, .cs-inputs.n4 { grid-template-columns: repeat(2, 1fr); height: min(100%, 560px); }
.cs-drop {
  position: relative; display: grid; place-items: center; min-height: 0; padding: 24px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-card);
  color: var(--muted-foreground); text-align: center; cursor: pointer; overflow: hidden;
}
.cs-drop:hover, .cs-drop.over { border-color: var(--foreground); background: var(--secondary); }
.cs-drop.has { padding: 0; border-style: solid; border-color: var(--border); }
.cs-drop.has > img, .cs-drop.has > video, .cs-drop.has > .cs-previews { position: absolute; inset: 0; width: 100%; height: 100%; }
.cs-drop.has > img, .cs-drop.has > video { display: block; object-fit: contain; }
.cs-drop-icon { display: grid; place-items: center; margin-bottom: 8px; color: var(--muted-foreground); }
.cs-drop-text { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.cs-drop-text b { color: var(--foreground); font-size: var(--text-heading); font-weight: 500; }
.cs-drop-text small { font-size: var(--text-body); }
.cs-drop.has .cs-drop-text {
  position: absolute; left: 12px; bottom: 12px; max-width: calc(100% - 24px); align-items: flex-start; padding: 6px 10px; border-radius: var(--radius-control);
  background: var(--media-overlay); text-align: left; opacity: 0; transition: opacity 0.15s;
}
.cs-drop.has:hover .cs-drop-text, .cs-drop.has:focus-within .cs-drop-text { opacity: 1; }
.cs-drop.has .cs-drop-text b { font-size: var(--text-body); }
.cs-drop.has .cs-drop-text > * { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-file { color: var(--foreground); }

.cs-wait { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: auto; padding: 24px; text-align: center; }
.cs-wait b { font-size: var(--text-heading); font-weight: 500; }
.cs-wait p { margin: 0; max-width: 480px; color: var(--muted-foreground); }

.cs-foot { flex: none; display: grid; align-items: center; min-height: 64px; }
.cs-foot > * { grid-area: 1 / 1; }
.cs-strip { display: flex; gap: 8px; min-width: 0; overflow-x: auto; padding: 4px; }
.cs-foot.has-actions .cs-strip {
  --cs-fade-end: calc(var(--cs-foot-actions) + 44px);
  padding-inline-end: var(--cs-fade-end);
  mask-image: linear-gradient(to left, transparent calc(var(--cs-foot-actions) + 12px), #000 var(--cs-fade-end));
}
.cs-foot-actions { position: relative; z-index: 1; justify-self: end; display: flex; gap: 8px; }
.cs-thumb {
  position: relative; flex: none; display: grid; place-items: center; width: 56px; height: 56px; padding: 0;
  border-radius: var(--radius-control); background: var(--secondary); overflow: hidden; opacity: 0.6;
}
.cs-thumb:hover { opacity: 1; }
.cs-input-tile { position: relative; flex: none; display: flex; margin-right: 8px; }
.cs-input {
  display: flex; align-items: center; gap: 8px; box-sizing: border-box; width: 144px; height: 56px; padding: 0 14px 0 8px;
  border-radius: var(--radius-control); background: var(--secondary); color: var(--foreground); font-size: var(--text-ui); white-space: nowrap; opacity: 0.6;
}
.cs-input-tile:hover .cs-input { opacity: 1; }
.cs-input[aria-selected="true"] { opacity: 1; outline: 2px solid var(--foreground); outline-offset: 1px; }
.cs-input-thumbs { display: flex; }
.cs-input-thumbs > * { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; }
.cs-input-thumbs > :not(:first-child) { margin-left: -12px; }
.cs-input-empty {
  display: grid; place-items: center; box-sizing: border-box; border: 1.5px dashed var(--border-strong); color: var(--muted-foreground);
}
.cs-input-remove {
  position: absolute; top: 4px; right: 4px; display: grid; place-items: center; width: 20px; height: 20px;
  border-radius: 999px; background: var(--media-overlay); color: var(--foreground); opacity: 0; transition: opacity 0.15s;
}
.cs-input-tile:hover .cs-input-remove { opacity: 1; }
.cs-input-remove svg { display: block; }
.panel .media-shown > img { cursor: pointer; }
.cs-thumb[aria-selected="true"] { opacity: 1; outline: 2px solid var(--foreground); outline-offset: 1px; }
.cs-thumb img, .cs-thumb video { width: 100%; height: 100%; object-fit: cover; }
.cs-thumb-note { color: var(--muted-foreground); font-size: 11px; }
.cs-thumb.failed .cs-thumb-note { color: var(--destructive); }
.cs-all, .cs-clear {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: 999px;
  background: var(--secondary); color: var(--foreground); font-size: var(--text-ui); line-height: 1;
}
.cs-clear { padding-inline-start: 10px; }
.cs-clear svg { flex: none; display: block; }
.cs-all:hover, .cs-clear:hover { background: var(--accent); }
.cs-clear[hidden] { display: none; }

.cs-spin {
  width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--foreground);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
.cs-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 40; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.cs-toast { position: relative; overflow: hidden; border-radius: var(--radius-card); background: var(--card); box-shadow: var(--shadow-popover); }
.cs-toast-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.cs-toast-head .cs-spin { flex: none; width: 14px; height: 14px; }
.cs-toast-title { flex: 1; min-width: 0; font-size: var(--text-ui); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-toast-toggle, .cs-toast-cancel { flex: none; height: 28px; padding: 0 10px; border-radius: var(--radius-control); color: var(--muted-foreground); font-size: var(--text-ui); }
.cs-toast-toggle:hover, .cs-toast-cancel:hover:not(:disabled) { background: var(--secondary); color: var(--foreground); }
.cs-toast-cancel:disabled { opacity: 0.5; cursor: default; }
.cs-toast-bar { position: absolute; inset: auto 0 0; height: 2px; pointer-events: none; }
.cs-toast-bar i { display: block; height: 100%; background: var(--subtle-foreground); transform: scaleX(0); transform-origin: left; transition: transform 0.6s var(--ease-out-expo); }
.cs-toast-body { max-height: 50vh; overflow: auto; }
.cs-toast-body .card.live { margin: 0; padding: 0 12px 12px 36px; gap: 0; background: none; box-shadow: none; }
.cs-toast-body .live-head, .cs-toast-body .live-prompt, .cs-toast-body .live-total, .cs-toast-body .live-meta { display: none; }
.cs-toast-body .stages { margin: 0; gap: 6px; }
.cs-toast-body .stages li { grid-template-columns: 10px minmax(0, 1fr); }
.cs-toast-body .stages .dot { width: 6px; height: 6px; border-width: 0; background: var(--border-strong); }
.cs-toast-body .stages li.done .dot { background: var(--muted-foreground); }
.cs-toast-body .stages li.on .dot { width: 8px; height: 8px; border-width: 1.5px; background: none; }
.cs-toast-body .stages li.done .dt, .cs-toast-body .stages li.todo .dt { display: none; }
.cs-toast-body .stages li.on .dt { color: var(--subtle-foreground); }
@media (prefers-reduced-motion: reduce) { .cs-spin { animation: none; } .cs-toast-bar i { transition: none; } }
.cs-previews { display: grid; grid-auto-rows: minmax(0, 1fr); gap: 4px; width: 100%; height: 100%; }
.cs-previews.n2 { grid-template-columns: repeat(2, 1fr); }
.cs-previews.n3, .cs-previews.n4 { grid-template-columns: repeat(2, 1fr); }
.cs-previews img, .cs-previews video { display: block; width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 960px) {
  :root { --panel-width: 300px; }
}
.inputs-open, .inputs-close, .stage-status { display: none; }
@media (max-width: 640px) {
  .wrap { grid-template-columns: 1fr; height: calc(100dvh - var(--draft-bar, 0px)); }
  .panel { position: fixed; inset: var(--draft-bar, 0) 0 0; z-index: 30; height: calc(100dvh - var(--draft-bar, 0px)); border-radius: 0; }
  .inputs-close { display: grid; position: fixed; top: calc(16px + var(--draft-bar, 0px)); right: 20px; z-index: 31; }
  .inputs-close::before { content: ''; position: absolute; inset: -6px; }
  .panel, .inputs-close {
    transform: translateX(-100vw); visibility: hidden;
    transition: transform 0.2s var(--ease-out-expo), visibility 0s 0.2s;
  }
  body.inputs-shown :is(.panel, .inputs-close) { transform: none; visibility: visible; transition: transform 0.3s var(--ease-out-expo); }
  .inputs-open { display: inline-flex; flex: none; }
  .hero {
    position: sticky; top: -16px; z-index: 2; align-items: flex-start;
    margin: -16px -20px -12px; padding: 16px 64px 12px 20px; background: var(--surface-light) 0 0 / 100% 100dvh no-repeat, var(--surface);
  }
  .hero > .back { margin-top: 2px; }
  .hero > div { flex: 1; padding-top: 4px; }
  .tab-row { flex-wrap: wrap; }
  .tab-actions:not(:has(> :not([hidden]))) { display: none; }
  .tab-row .stage-status:not([hidden]) {
    display: block; position: absolute; top: 100%; left: 0; right: 0; padding: 0 20px 12px;
    background: var(--surface-light) fixed, var(--surface);
  }
  .panel .go-dock { background: var(--surface); }
}
@media (max-width: 360px) {
  .main { padding: 0 16px 16px; }
  .tab-row { gap: 6px; margin: 0 -16px 8px; padding: 16px 16px 12px; }
  .tab-row .tabs button { padding: 0 6px; }
  .tab-row .inputs-open { padding: 0 9px; }
  .tab-row .stage-status:not([hidden]) { padding: 0 16px 12px; }
  .hero b { white-space: normal; text-wrap: balance; }
}
@media (max-width: 640px) and (prefers-reduced-motion: reduce) {
  .panel, .inputs-close { transform: none; opacity: 0; transition: opacity 0.15s ease, visibility 0s 0.15s; }
  body.inputs-shown :is(.panel, .inputs-close) { opacity: 1; transition: opacity 0.15s ease; }
}
.shot.zoomable { position: relative; overflow: hidden; touch-action: none; cursor: zoom-in; user-select: none; }
.shot.zoomable img { -webkit-user-drag: none; }
.shot.zoomable.zoomed { cursor: grab; }
.shot.zoomable.panning { cursor: grabbing; }
.shot.zoomed input[type="range"] { pointer-events: none; }
.zoom-target { transform-origin: 0 0; transition: transform 0.12s var(--ease-out-expo); }
.panning .zoom-target { transition: none; }
