@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Noto+Sans+SC:wght@400;500;600;700;900&display=swap');

:root {
  color-scheme: light;
  --ink: #101114;
  --muted: #66676d;
  --canvas: #e9e9e5;
  --paper: #f8f7f2;
  --surface: #ffffff;
  --line: #c9c9c2;
  --line-strong: #9c9d98;
  --orange: #ff5c35;
  --yellow: #ffdd4a;
  --blue: #3156ee;
  --green: #25a461;
  --shadow: 5px 5px 0 #101114;
  --radius: 4px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f4f3ec;
  --muted: #aaa9a2;
  --canvas: #15161a;
  --paper: #202126;
  --surface: #191a1e;
  --line: #414249;
  --line-strong: #686970;
  --shadow: 5px 5px 0 #ff5c35;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Noto Sans SC", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
button, textarea, select, input { font: inherit; }
button { color: inherit; }
button:focus-visible, textarea:focus-visible, select:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.topbar {
  height: 68px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--ink);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 18px; font-weight: 900; width: fit-content; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; background: var(--orange); color: #fff; border: 1px solid #101114; box-shadow: 2px 2px 0 #101114; }
.header-note { font: 500 12px/1 "DM Mono", monospace; letter-spacing: .12em; color: var(--muted); }
.header-note span { color: var(--orange); padding: 0 4px; }
.topbar .theme-toggle { justify-self: end; }

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}
.icon-button:hover { background: var(--yellow); transform: translate(-1px, -1px); }
.icon-button svg, .shuffle-button svg, .copy-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.asset-icon { display: inline-block; flex: none; background: currentColor; mask-position: center; mask-repeat: no-repeat; mask-size: contain; -webkit-mask-position: center; -webkit-mask-repeat: no-repeat; -webkit-mask-size: contain; }
.icon-brand { width: 21px; height: 21px; mask-image: url("./assets/brand-sparkle.png"); -webkit-mask-image: url("./assets/brand-sparkle.png"); }
.icon-sun { width: 22px; height: 22px; mask-image: url("./assets/sun.png"); -webkit-mask-image: url("./assets/sun.png"); }
.icon-generate { width: 23px; height: 23px; justify-self: start; mask-image: url("./assets/generate-sparkles.png"); -webkit-mask-image: url("./assets/generate-sparkles.png"); }
.icon-medal { width: 18px; height: 18px; mask-image: url("./assets/medal.png"); -webkit-mask-image: url("./assets/medal.png"); }

.workspace { max-width: 1480px; min-height: calc(100vh - 68px); margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(380px, .8fr); }
.builder-panel { padding: 42px clamp(28px, 4vw, 64px) 72px; border-right: 1px solid var(--ink); }
.output-panel { padding: 42px clamp(24px, 3vw, 44px); background: var(--surface); position: relative; }
.output-panel::before { content: ""; position: absolute; inset: 0; opacity: .035; pointer-events: none; background-image: radial-gradient(var(--ink) 1px, transparent 1px); background-size: 8px 8px; }
.output-panel > * { position: relative; }

.panel-heading, .output-topline, .output-heading, .history-heading, .quality-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.eyebrow { margin: 0 0 8px; font: 500 12px/1.2 "DM Mono", monospace; letter-spacing: .12em; color: var(--orange); text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(30px, 4vw, 52px); line-height: 1.05; letter-spacing: -.055em; font-weight: 900; }
.shuffle-button { display: inline-flex; align-items: center; gap: 8px; border: 0; border-bottom: 1px solid var(--ink); background: transparent; padding: 8px 0; cursor: pointer; font-size: 14px; font-weight: 600; }
.shuffle-button:hover svg { transform: rotate(90deg); }
.shuffle-button svg { transition: transform .2s ease; }

.idea-field { display: block; position: relative; margin: 28px 0 38px; }
.idea-field::after { content: "IDEA"; position: absolute; top: -9px; left: 18px; background: var(--yellow); color: #101114; border: 1px solid #101114; padding: 2px 7px; font: 500 11px/1.2 "DM Mono", monospace; letter-spacing: .12em; }
.idea-field textarea { width: 100%; min-height: 150px; resize: vertical; border: 2px solid var(--ink); border-radius: var(--radius); padding: 27px 52px 22px 22px; background: var(--paper); color: var(--ink); font-size: 18px; line-height: 1.8; box-shadow: var(--shadow); }
.char-count { position: absolute; right: 16px; bottom: 13px; color: var(--muted); font: 400 12px/1 "DM Mono", monospace; }
.char-count strong { color: var(--ink); }

.option-section { margin-top: 34px; }
.section-label { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.section-label span { width: 26px; height: 26px; display: grid; place-items: center; background: var(--ink); color: var(--canvas); font: 500 11px/1 "DM Mono", monospace; }
.section-label h2 { margin: 0; font-size: 16px; letter-spacing: -.02em; }
.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.choice-card { min-height: 120px; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 2px; padding: 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: left; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.choice-card:hover { transform: translateY(-2px); border-color: var(--ink); }
.choice-card.selected { border: 2px solid var(--ink); padding: 9px; box-shadow: 3px 3px 0 var(--ink); }
.choice-card span:not(.style-swatch) { font-size: 14px; font-weight: 700; }
.choice-card small { font: 500 10px/1.2 "DM Mono", monospace; color: var(--muted); letter-spacing: .08em; }
.style-swatch { width: 100%; height: 62px; margin-bottom: 6px; border-radius: 2px; border: 1px solid rgba(16,17,20,.25); position: relative; overflow: hidden; }
.style-swatch::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(135deg, transparent 0 44%, rgba(255,255,255,.65) 45% 48%, transparent 49%); }
.swatch-cinema { background: linear-gradient(135deg, #0b204d 0 46%, #ff6c40 47% 67%, #f8cf59 68%); }
.swatch-photo { background: linear-gradient(105deg, #d3dadc, #576260 55%, #e4bf87 56%); }
.swatch-anime { background: linear-gradient(150deg, #76caff 0 48%, #ff94b5 49% 70%, #ffe89f 71%); }
.swatch-3d { background: linear-gradient(145deg, #ffbc9f, #f05d5e 48%, #682e83 49%); }
.swatch-poster { background: linear-gradient(90deg, #ff5c35 0 35%, #ffdd4a 36% 68%, #3156ee 69%); }
.swatch-ink { background: linear-gradient(135deg, #f4f0e5 0 46%, #66706d 47% 51%, #191b1a 52% 67%, #d6ded7 68%); }

.two-column-options { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.pill-group { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); padding: 9px 14px; font-size: 14px; line-height: 1.2; cursor: pointer; }
.pill:hover { border-color: var(--ink); }
.pill.selected { background: var(--ink); color: var(--canvas); border-color: var(--ink); }

.compact-options { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.select-field { display: flex; flex-direction: column; gap: 8px; }
.select-field > span { font-size: 14px; font-weight: 600; }
.select-field b { font: 500 11px/1 "DM Mono", monospace; color: var(--orange); margin-right: 4px; }
.select-field select { width: 100%; min-height: 46px; appearance: none; color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0 34px 0 12px; background-color: var(--surface); background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%); background-position: calc(100% - 16px) 20px, calc(100% - 11px) 20px; background-size: 5px 5px; background-repeat: no-repeat; }

.advanced-panel { margin-top: 28px; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.advanced-panel summary { display: flex; justify-content: space-between; align-items: center; list-style: none; cursor: pointer; padding: 16px 2px; font-size: 14px; font-weight: 700; }
.advanced-panel summary::-webkit-details-marker { display: none; }
.advanced-panel summary span { display: flex; align-items: center; gap: 8px; }
.advanced-panel summary svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.advanced-panel[open] .chevron { transform: rotate(180deg); }
.chevron { transition: transform .2s ease; }
.advanced-content { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; padding: 0 0 18px; }
.advanced-content label { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--muted); }
.advanced-content input[type="text"] { min-height: 44px; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0 12px; background: var(--surface); color: var(--ink); }
.advanced-content input[type="range"] { accent-color: var(--orange); margin-top: 10px; }
.advanced-content output { float: right; color: var(--orange); font-family: "DM Mono", monospace; }

.generate-button { width: 100%; min-height: 58px; margin-top: 26px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border: 2px solid #101114; border-radius: var(--radius); background: var(--orange); color: #fff; padding: 0 18px; font-size: 17px; font-weight: 900; box-shadow: 4px 4px 0 #101114; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.generate-button:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 #101114; }
.generate-button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #101114; }
.shortcut { justify-self: end; font: 500 11px/1 "DM Mono", monospace; border: 1px solid rgba(255,255,255,.7); padding: 5px 7px; border-radius: 3px; }

.status { display: flex; align-items: center; gap: 7px; font: 500 11px/1 "DM Mono", monospace; color: var(--muted); }
.status i { width: 7px; height: 7px; background: var(--green); border-radius: 50%; box-shadow: 0 0 0 3px color-mix(in srgb, var(--green), transparent 78%); }
.output-heading { margin-top: 16px; align-items: flex-end; }
.output-heading h2 { margin-bottom: 0; font: 500 clamp(38px, 5vw, 68px)/.95 "DM Mono", monospace; letter-spacing: -.08em; }
.language-tabs { display: flex; border: 1px solid var(--ink); border-radius: 3px; overflow: hidden; }
.language-tab { width: 42px; height: 32px; border: 0; border-right: 1px solid var(--ink); background: var(--surface); cursor: pointer; font: 500 12px/1 "DM Mono", monospace; }
.language-tab:last-child { border-right: 0; }
.language-tab.selected { background: var(--ink); color: var(--surface); }

.prompt-paper { min-height: 310px; margin-top: 18px; padding: 42px 26px 26px; background: var(--paper); border: 1px solid var(--ink); position: relative; box-shadow: 6px 6px 0 color-mix(in srgb, var(--ink), transparent 80%); overflow: hidden; }
.prompt-paper::before { content: ""; position: absolute; width: 145px; height: 145px; right: -54px; top: -52px; background: var(--yellow); mask: url("./assets/burst.png") center / contain no-repeat; -webkit-mask: url("./assets/burst.png") center / contain no-repeat; opacity: .9; transform: rotate(9deg); }
.paper-index { position: absolute; top: 16px; left: 26px; color: var(--orange); font: 500 10px/1 "DM Mono", monospace; letter-spacing: .12em; }
.prompt-paper p { position: relative; min-height: 150px; margin: 0; font-size: 17px; line-height: 1.9; letter-spacing: .005em; }
.prompt-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 22px; }
.prompt-tags span { border: 1px solid var(--line-strong); border-radius: 999px; padding: 5px 9px; color: var(--muted); font: 500 10px/1 "DM Mono", monospace; text-transform: uppercase; }

.output-actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 16px; }
.copy-button { min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 9px; border: 1px solid var(--ink); border-radius: var(--radius); background: var(--ink); color: var(--surface); font-weight: 700; cursor: pointer; }
.copy-button:hover { background: var(--blue); }
.quality-card { margin-top: 28px; padding: 18px; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface), var(--yellow) 5%); }
.quality-heading { font-size: 14px; }
.quality-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.quality-icon { width: 28px; height: 28px; display: grid; place-items: center; color: #fff; background: var(--blue); border: 1px solid var(--ink); border-radius: 2px; box-shadow: 2px 2px 0 var(--ink); }
.quality-icon .icon-medal { width: 16px; height: 16px; }
.quality-heading strong { font: 500 20px/1 "DM Mono", monospace; color: var(--blue); }
.score-track { height: 7px; margin: 12px 0 14px; background: var(--line); overflow: hidden; }
.score-track span { display: block; width: 92%; height: 100%; background: var(--blue); transition: width .4s ease; }
.quality-items { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 12px; }
.quality-items span::before { content: "○"; margin-right: 4px; }
.quality-items .done::before { content: "●"; color: var(--green); }

.history-section { margin-top: 34px; }
.history-heading h3 { margin: 0; font-size: 16px; }
.history-heading button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; }
.history-heading button:hover { color: var(--orange); }
.history-list { display: grid; gap: 8px; margin-top: 12px; }
.history-item { width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.history-item:hover .history-copy { color: var(--orange); }
.history-number { color: var(--orange); font: 500 10px/1 "DM Mono", monospace; }
.history-copy { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.history-time { color: var(--muted); font: 400 10px/1 "DM Mono", monospace; }
.history-empty { padding: 18px 0; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); }

.ad-slot { min-height: 94px; padding: 12px 18px; border-top: 1px solid var(--ink); background: var(--surface); text-align: center; overflow: hidden; }
.ad-slot > span { display: block; margin-bottom: 7px; color: var(--muted); font: 500 9px/1 "DM Mono", monospace; letter-spacing: .14em; }

.toast { position: fixed; left: 50%; bottom: 26px; z-index: 50; transform: translate(-50%, 16px); padding: 11px 16px; background: var(--ink); color: var(--surface); border: 1px solid var(--surface); box-shadow: 3px 3px 0 var(--orange); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .builder-panel { border-right: 0; border-bottom: 1px solid var(--ink); }
  .output-panel { padding-bottom: 72px; }
  .prompt-paper { min-height: 260px; }
}

@media (max-width: 640px) {
  .topbar { height: 60px; grid-template-columns: 1fr auto; padding: 0 16px; }
  .header-note { display: none; }
  .builder-panel, .output-panel { padding: 28px 16px 52px; }
  .panel-heading { align-items: flex-start; }
  h1 { font-size: 34px; }
  .shuffle-button { margin-top: 23px; font-size: 13px; }
  .idea-field textarea { min-height: 170px; font-size: 16px; padding-left: 16px; }
  .choice-grid { grid-template-columns: repeat(2, 1fr); }
  .two-column-options, .compact-options, .advanced-content { grid-template-columns: 1fr; }
  .two-column-options { gap: 28px; }
  .shortcut { display: none; }
  .generate-button { grid-template-columns: auto 1fr; gap: 12px; }
  .output-heading h2 { font-size: 48px; }
  .prompt-paper { padding: 40px 18px 22px; }
  .paper-index { left: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
