:root {
  --bg: #0d0e10;
  --panel: #15161a;
  --card: #1c1e23;
  --card-2: #25282e;
  --edge: rgba(255, 255, 255, 0.08);
  --ink: #f4f5f2;
  --ink-2: rgba(244, 245, 242, 0.64);
  --ink-3: rgba(244, 245, 242, 0.4);
  --lime: #c9f917;
  --lime-ink: #141a00;
  --lime-deep: #8fb30a;
  --red: #ff7a6b;
  --display: 'Inter Tight', 'Inter', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
img, video { display: block; max-width: 100%; }

.shell { display: grid; grid-template-columns: 372px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 10px; height: 100dvh; padding: 10px; }

/* ---- left panel ---- */
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border: 1px solid var(--edge); border-radius: 22px; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; }
.brand img { width: 44px; height: 44px; border-radius: 12px; }
.brand small { display: block; color: var(--ink-3); font-size: 12px; }
.brand strong { font: 800 24px/1 var(--display); letter-spacing: -0.03em; text-transform: uppercase; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 0 12px 10px; padding: 4px; background: #0e0f12; border-radius: 14px; }
.seg button { height: 38px; border-radius: 10px; color: var(--ink-2); font-weight: 600; font-size: 14px; }
.seg button.on { background: var(--card-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--edge); }
.seg.small { margin: 0; }

.scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; scrollbar-color: var(--card-2) transparent; }
.group { background: var(--card); border: 1px solid var(--edge); border-radius: 16px; }
.group.pad { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.group-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 13px 14px; color: var(--ink-2); font-weight: 500; text-align: left; }
.group-head span { flex: 1; }
.group-head em { font-style: normal; color: var(--ink-3); }
.group-head .dot { width: 8px; height: 8px; border-radius: 8px; background: var(--lime); }
.group label { color: var(--ink-3); font-size: 12px; font-weight: 500; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 8px 8px; }
.group.pad .tiles { padding: 0; }
.tiles.four { grid-template-columns: repeat(4, 1fr); }
.tile { min-height: 44px; padding: 8px 6px; border-radius: 12px; background: #101114; border: 1.5px solid var(--edge); color: var(--ink-2); font-size: 13px; font-weight: 500; line-height: 1.2; transition: border-color 0.12s, color 0.12s; }
.tile:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.2); }
.tile.on { border-color: var(--lime); color: var(--ink); box-shadow: 0 0 0 3px rgba(201, 249, 23, 0.14); }
.tiles-pic .tile { padding: 0 0 7px; overflow: hidden; background: #fff; color: #17181b; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.tiles-pic .tile img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.tiles-pic .tile span { padding: 0 4px; }
.tiles-pic .tile.on { color: #17181b; border-color: var(--lime); }
.tiles-swatch .tile, .tiles-icon .tile { padding: 6px 6px 8px; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.swatch { display: block; height: 44px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1); }
.glyph { font-style: normal; font-size: 30px; line-height: 44px; color: var(--ink); }

input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
img, video { display: block; max-width: 100%; }

.shell { display: grid; grid-template-columns: 372px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 10px; height: 100dvh; padding: 10px; }

/* ---- left panel ---- */
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border: 1px solid var(--edge); border-radius: 22px; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; }
.brand img { width: 44px; height: 44px; border-radius: 12px; }
.brand small { display: block; color: var(--ink-3); font-size: 12px; }
.brand strong { font: 800 24px/1 var(--display); letter-spacing: -0.03em; text-transform: uppercase; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 0 12px 10px; padding: 4px; background: #0e0f12; border-radius: 14px; }
.seg button { height: 38px; border-radius: 10px; color: var(--ink-2); font-weight: 600; font-size: 14px; }
.seg button.on { background: var(--card-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--edge); }
.seg.small { margin: 0; }

.scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; scrollbar-color: var(--card-2) transparent; }
.group { background: var(--card); border: 1px solid var(--edge); border-radius: 16px; }
.group.pad { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.group-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 13px 14px; color: var(--ink-2); font-weight: 500; text-align: left; }
.group-head span { flex: 1; }
.group-head em { font-style: normal; color: var(--ink-3); }
.group-head .dot { width: 8px; height: 8px; border-radius: 8px; background: var(--lime); }
.group label { color: var(--ink-3); font-size: 12px; font-weight: 500; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 8px 8px; }
.group.pad .tiles { padding: 0; }
.tiles.four { grid-template-columns: repeat(4, 1fr); }
.tile { min-height: 44px; padding: 8px 6px; border-radius: 12px; background: #101114; border: 1.5px solid var(--edge); color: var(--ink-2); font-size: 13px; font-weight: 500; line-height: 1.2; transition: border-color 0.12s, color 0.12s; }
.tile:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.2); }
.tile.on { border-color: var(--lime); color: var(--ink); box-shadow: 0 0 0 3px rgba(201, 249, 23, 0.14); }
.tiles-pic .tile { padding: 0 0 8px; overflow: hidden; background: #fff; color: #17181b; display: flex; flex-direction: column; gap: 4px; }
.tiles-pic .tile img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.tiles-pic .tile.on { color: #17181b; border-color: var(--lime); }

input, textarea { width: 100%; padding: 10px 12px; border-radius: 12px; background: #101114; border: 1.5px solid var(--edge); resize: none; }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:focus, textarea:focus { outline: none; border-color: var(--lime); }
.empty, .hint { margin: 0; color: var(--ink-3); font-size: 13px; }

.sources { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.source { position: relative; border-radius: 12px; overflow: hidden; border: 2px solid transparent; background: #fff; aspect-ratio: 3 / 4; }
.source img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; }
.source span { position: absolute; inset: auto 0 0; padding: 14px 6px 5px; font-size: 11px; font-weight: 600; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, 0.7)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source.on { border-color: var(--lime); }

.foot { padding: 12px 14px 14px; border-top: 1px solid var(--edge); display: flex; flex-direction: column; gap: 10px; }
.picked-head { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 12px; font-weight: 500; }
.picked-head button { color: var(--ink-2); font-size: 12px; }
.picked-head button:disabled { color: var(--ink-3); }
.picked { display: flex; flex-wrap: wrap; gap: 6px; max-height: 68px; overflow-y: auto; }
.chip { padding: 4px 10px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--edge); color: var(--ink-2); font-size: 12px; font-weight: 500; }
.chip.ghost { background: none; color: var(--ink-3); }
.note { margin: 0; padding: 9px 12px; border-radius: 12px; background: var(--card); color: var(--ink-2); font-size: 13px; }
.note.error { color: var(--red); }
.go { display: flex; gap: 8px; }
.shuffle { flex: none; width: 56px; height: 56px; border-radius: 16px; background: #fff; color: #17181b; display: grid; place-items: center; }
.generate { flex: 1; height: 56px; padding: 0 18px; border-radius: 16px; background: var(--lime); color: var(--lime-ink); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 4px 0 var(--lime-deep); transition: transform 0.08s, box-shadow 0.08s, opacity 0.12s; text-decoration: none; }
.generate b { font-weight: 600; opacity: 0.72; font-size: 15px; }
.generate:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--lime-deep); }
.generate:disabled { opacity: 0.45; }
.generate.inline { flex: none; height: 46px; font-size: 15px; border-radius: 14px; }
.fine { margin: 0; color: var(--ink-3); font-size: 12px; text-align: center; }

/* ---- right stage ---- */
.stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #101114; border: 1px solid var(--edge); border-radius: 22px; overflow: hidden; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; }
.tabs { display: flex; gap: 4px; }
.tabs button { height: 38px; padding: 0 14px; border-radius: 12px; color: var(--ink-2); font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.tabs button.on { background: var(--card-2); color: var(--ink); }
.tabs em { font-style: normal; font-size: 12px; padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); }
.content { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 14px 24px; scrollbar-width: thin; scrollbar-color: var(--card-2) transparent; }

.hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 26px 16px 34px; }
.fan { position: relative; display: flex; align-items: center; justify-content: center; height: 300px; margin-bottom: 26px; }
.fan-card { width: 168px; height: 236px; margin: 0 -14px; border-radius: 14px; overflow: hidden; background: #fff; box-shadow: 0 24px 44px -18px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.08); transition: transform 0.18s; }
.fan-card img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; }
.fan-card.f0 { transform: rotate(-7deg) translateY(14px); }
.fan-card.f1 { transform: rotate(-3.5deg) translateY(2px); z-index: 1; height: 258px; }
.fan-card.f2 { z-index: 2; width: 190px; height: 290px; }
.fan-card.f3 { transform: rotate(3.5deg) translateY(2px); z-index: 1; height: 258px; }
.fan-card.f4 { transform: rotate(7deg) translateY(14px); }
.fan-card:hover { transform: translateY(-6px); z-index: 3; }
.hero h1 { margin: 0; font: 800 clamp(34px, 4.4vw, 56px) / 0.98 var(--display); letter-spacing: -0.04em; text-transform: uppercase; }
.hero h1 span { color: var(--lime); }
.hero p { max-width: 600px; margin: 16px 0 0; color: var(--ink-2); font-size: 16px; }
.steps { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 22px 0 0; padding: 0; }
.steps li { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px 0 6px; border-radius: 999px; background: var(--card); border: 1px solid var(--edge); font-size: 14px; font-weight: 500; }
.steps b { width: 26px; height: 26px; border-radius: 26px; background: var(--lime); color: var(--lime-ink); display: grid; place-items: center; font-size: 13px; }
.steps i { font-style: normal; color: var(--ink-3); }

.masonry { columns: 4 240px; column-gap: 12px; }
.card { position: relative; display: block; width: 100%; margin: 0 0 12px; break-inside: avoid; border-radius: 16px; overflow: hidden; background: #fff; }
.card img, .card video { width: 100%; }
.card .tag { position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); padding: 4px 10px; border-radius: 999px; background: rgba(13, 14, 16, 0.78); color: var(--ink); font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity 0.12s; }
.card:hover .tag, .card:focus-visible .tag, .card.queued .tag, .card.running .tag, .card.failed .tag { opacity: 1; }
.card.queued, .card.running, .card.failed { background: var(--card); border: 1px solid var(--edge); }
.wait { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; color: var(--ink-2); font-size: 14px; text-align: center; }
.card.queued .wait, .card.running .wait { background: linear-gradient(100deg, transparent 30%, rgba(201, 249, 23, 0.1) 50%, transparent 70%) 0 0 / 220% 100%; animation: sheen 1.6s linear infinite; }
.card.failed .wait { color: var(--red); }
@keyframes sheen { to { background-position: -220% 0; } }

.filters { display: flex; gap: 6px; margin: 4px 0 14px; }
.filters button { height: 34px; padding: 0 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--edge); color: var(--ink-2); font-size: 14px; font-weight: 500; }
.filters button.on { background: #fff; color: #17181b; }

.blank { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 90px 20px; text-align: center; }
.blank h2 { margin: 0; font: 800 30px/1 var(--display); letter-spacing: -0.03em; text-transform: uppercase; }
.blank p { margin: 0 0 8px; max-width: 380px; color: var(--ink-2); }

/* ---- lightbox ---- */
.lb { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(5, 6, 7, 0.78); backdrop-filter: blur(8px); }
.lb-box { position: relative; display: grid; grid-template-columns: minmax(0, auto) 300px; max-width: min(1000px, 100%); max-height: calc(100vh - 40px); background: var(--panel); border: 1px solid var(--edge); border-radius: 22px; overflow: hidden; outline: none; }
.lb-media { position: relative; min-width: 280px; min-height: 320px; background: #fff; display: grid; place-items: center; }
.lb-media img, .lb-media video { max-height: calc(100vh - 42px); width: auto; }
.lb-media .wait { position: static; color: #17181b; }
.lb-side { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 22px 18px; overflow-y: auto; }
.lb-side small { color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.lb-side h3 { margin: 0; font: 800 26px/1.05 var(--display); letter-spacing: -0.03em; }
.lb-side p { margin: 0; color: var(--ink-2); }
.lb-side .picked { max-height: none; margin-bottom: 6px; }
.plain { height: 42px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--edge); color: var(--ink); font-weight: 500; font-size: 14px; display: grid; place-items: center; text-decoration: none; }
.plain.danger { background: none; color: var(--red); }
.lb-close { position: absolute; top: 10px; right: 10px; z-index: 2; width: 34px; height: 34px; border-radius: 34px; background: rgba(13, 14, 16, 0.7); color: var(--ink); font-size: 20px; line-height: 1; }

@media (max-width: 900px) {
  html, body, #root { height: auto; }
  .shell { grid-template-columns: 1fr; grid-template-rows: auto; height: auto; }
  .panel { max-height: none; }
  .scroll { max-height: 46vh; }
  .stage { min-height: 80vh; }
  .fan { height: 210px; }
  .fan-card { width: 104px; height: 150px; margin: 0 -10px; }
  .fan-card.f1, .fan-card.f3 { height: 164px; }
  .fan-card.f2 { width: 120px; height: 184px; }
  .lb-box { grid-template-columns: 1fr; overflow-y: auto; }
  .lb-media img, .lb-media video { max-height: 56vh; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
