:root {
  color-scheme: light;
  --ink: #181721;
  --muted: #716f7c;
  --line: rgba(30, 27, 47, .11);
  --paper: #f5f3ef;
  --panel: rgba(255, 255, 255, .78);
  --purple: #7658ee;
  --purple-dark: #5d3ed3;
  --pink: #ec77b1;
  --green: #2f9b73;
  --red: #c94a5d;
  --shadow: 0 24px 70px rgba(55, 44, 83, .11);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 8%, rgba(156, 126, 255, .13), transparent 28rem),
    radial-gradient(circle at 10% 92%, rgba(247, 157, 196, .12), transparent 25rem),
    var(--paper);
  overflow-x: hidden;
}

button, input, select, textarea { font: inherit; }
button, summary, label[for] { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(2px);
  pointer-events: none;
}

.ambient-one {
  width: 18rem;
  height: 18rem;
  right: -8rem;
  top: 22%;
  border: 1px solid rgba(118, 88, 238, .14);
}

.ambient-two {
  width: 11rem;
  height: 11rem;
  left: -5rem;
  bottom: 8%;
  border: 1px solid rgba(236, 119, 177, .16);
}

.topbar {
  height: 74px;
  max-width: 1540px;
  margin: auto;
  padding: 0 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 760;
  font-size: 1.08rem;
  letter-spacing: -.025em;
}

.brand-mark {
  width: 27px;
  height: 27px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  transform: rotate(7deg);
}

.brand-mark i { border-radius: 3px; background: var(--purple); }
.brand-mark i:nth-child(2) { background: #ac91ff; border-radius: 8px 3px 3px; }
.brand-mark i:nth-child(3) { background: var(--pink); border-radius: 3px 3px 3px 8px; }
.brand-mark i:nth-child(4) { background: #382f55; }

.top-actions { display: flex; align-items: center; gap: 10px; }

.status-pill {
  height: 34px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .5);
  color: var(--muted);
  font-size: .76rem;
}

.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: #b2afba; }
.status-pill.ready i { background: var(--green); box-shadow: 0 0 0 4px rgba(47, 155, 115, .1); }
.status-pill.warning i { background: #d89c36; box-shadow: 0 0 0 4px rgba(216, 156, 54, .1); }
.status-pill.error i { background: var(--red); }

.quiet-button, .icon-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .62);
  border-radius: 999px;
  cursor: pointer;
}

.quiet-button { height: 34px; padding: 0 14px; font-size: .76rem; }
.icon-button { width: 36px; height: 36px; font-size: 1.2rem; }
.quiet-button:hover, .icon-button:hover { border-color: rgba(118, 88, 238, .32); background: white; }

.workspace {
  width: min(1540px, 100%);
  min-height: calc(100vh - 74px);
  margin: auto;
  display: grid;
  grid-template-columns: minmax(390px, 510px) minmax(0, 1fr);
}

.creator-panel {
  padding: clamp(42px, 5vw, 76px) clamp(28px, 4vw, 64px) 64px;
  border-right: 1px solid var(--line);
}

.intro { margin-bottom: 38px; }
.eyebrow, .dialog-kicker {
  display: block;
  margin-bottom: 13px;
  color: var(--purple);
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .19em;
}

.intro h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.2rem, 5.7vw, 5.35rem);
  font-weight: 500;
  line-height: .88;
  letter-spacing: -.055em;
}

.intro h1 em { color: var(--purple); font-weight: 500; }
.intro p { max-width: 32rem; margin: 20px 0 0; color: var(--muted); font-size: .9rem; line-height: 1.7; }

.api-warning {
  margin-bottom: 22px;
  padding: 13px 15px;
  border: 1px solid rgba(216, 156, 54, .3);
  border-radius: 12px;
  background: rgba(255, 240, 204, .48);
  color: #88601e;
  font-size: .8rem;
  line-height: 1.5;
}

.field-label { display: block; font-size: .75rem; font-weight: 750; letter-spacing: .01em; }
.prompt-shell { position: relative; margin-top: 10px; }

textarea {
  width: 100%;
  min-height: 144px;
  resize: vertical;
  padding: 17px 17px 34px;
  border: 1px solid var(--line);
  border-radius: 15px;
  outline: none;
  color: var(--ink);
  background: rgba(255, 255, 255, .72);
  box-shadow: inset 0 1px rgba(255, 255, 255, .8);
  font-size: .9rem;
  line-height: 1.7;
  transition: border-color .2s, box-shadow .2s, background .2s;
}

textarea:focus, .control input:focus, .control select:focus {
  border-color: rgba(118, 88, 238, .52);
  background: white;
  box-shadow: 0 0 0 4px rgba(118, 88, 238, .08);
}

textarea::placeholder { color: #a4a1aa; }
.shortcut-hint { position: absolute; right: 13px; bottom: 11px; color: #a09da7; font-size: .64rem; }

.field-heading {
  margin: 25px 0 10px;
  display: flex;
  align-items: end;
  justify-content: space-between;
}

.field-heading small { display: block; margin-top: 4px; color: var(--muted); font-size: .67rem; }
.reference-count { color: var(--muted); font-size: .68rem; }

.dropzone {
  min-height: 75px;
  padding: 13px 15px;
  display: flex;
  align-items: center;
  gap: 13px;
  border: 1px dashed rgba(118, 88, 238, .32);
  border-radius: 14px;
  background: rgba(255, 255, 255, .4);
  cursor: pointer;
  transition: .2s ease;
}

.dropzone:hover, .dropzone.dragging { border-color: var(--purple); background: rgba(118, 88, 238, .055); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-icon { width: 39px; height: 39px; display: grid; place-items: center; flex: none; border-radius: 11px; background: #ebe6fb; color: var(--purple); font-size: 1.35rem; }
.dropzone strong, .dropzone small { display: block; }
.dropzone strong { font-size: .75rem; }
.dropzone small { margin-top: 4px; color: var(--muted); font-size: .64rem; }

.reference-list { margin-top: 10px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.reference-item { position: relative; aspect-ratio: 1; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #ddd; }
.reference-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reference-item button { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; color: white; background: rgba(20, 18, 28, .72); cursor: pointer; font-size: .8rem; line-height: 1; }
.reference-item span { position: absolute; left: 4px; bottom: 4px; max-width: calc(100% - 8px); padding: 2px 5px; overflow: hidden; border-radius: 4px; color: white; background: rgba(20, 18, 28, .62); font-size: .52rem; text-overflow: ellipsis; white-space: nowrap; }

.parameters { margin-top: 23px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.parameters summary { padding: 16px 0; display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; font-size: .75rem; font-weight: 750; }
.parameters summary::-webkit-details-marker { display: none; }
.parameters summary::after { content: "+"; margin-left: auto; color: var(--muted); font-size: 1.1rem; font-weight: 400; }
.parameters[open] summary::after { content: "−"; }
.parameters summary small { color: var(--muted); font-size: .63rem; font-weight: 450; }
.parameter-grid { padding: 2px 0 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }

.control { min-width: 0; display: grid; gap: 6px; }
.control-wide { grid-column: span 2; }
.control > span { color: var(--muted); font-size: .64rem; font-weight: 650; }
.control input, .control select {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: rgba(255, 255, 255, .62);
  font-size: .74rem;
}

.compression-control input { height: 22px; padding: 0; accent-color: var(--purple); box-shadow: none; }
.compression-control.disabled { opacity: .42; }
.compression-control b { color: var(--purple); }

.generate-button {
  width: 100%;
  height: 56px;
  margin-top: 24px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 14px;
  color: white;
  background: linear-gradient(112deg, var(--purple-dark), var(--purple) 60%, #8d6ff8);
  box-shadow: 0 14px 32px rgba(93, 62, 211, .22);
  cursor: pointer;
  font-weight: 730;
  transition: transform .2s, box-shadow .2s, opacity .2s;
}

.generate-button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 18px 38px rgba(93, 62, 211, .28); }
.generate-button:disabled { cursor: wait; opacity: .68; }
.button-orb { width: 19px; height: 19px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, white 0 13%, #f1a9d2 15% 36%, #b194ff 60%, transparent 62%); }
.button-arrow { margin-left: auto; font-size: 1.15rem; font-weight: 400; }
.generate-button:disabled .button-orb { border: 2px solid rgba(255,255,255,.35); border-top-color: white; background: none; animation: spin .8s linear infinite; }

.output-panel { min-width: 0; padding: 30px clamp(22px, 3.3vw, 52px) 52px; }
.output-header { height: 44px; display: flex; align-items: center; justify-content: space-between; }
.tabs { display: flex; gap: 8px; }
.tab { height: 35px; padding: 0 13px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; cursor: pointer; font-size: .76rem; font-weight: 650; }
.tab.active { color: var(--ink); background: rgba(255, 255, 255, .78); box-shadow: 0 5px 16px rgba(54, 45, 76, .08); }
.tab span { margin-left: 4px; color: var(--purple); }
.output-body { padding-top: 25px; }

.working-card {
  margin-bottom: 17px;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid rgba(118, 88, 238, .18);
  border-radius: 15px;
  background: rgba(246, 243, 255, .72);
}
.working-card strong, .working-card span { display: block; }
.working-card strong { font-size: .78rem; }
.working-card span { margin-top: 4px; color: var(--muted); font-size: .66rem; }
.working-visual { width: 44px; height: 44px; display: flex; align-items: end; justify-content: center; gap: 3px; padding-bottom: 10px; border-radius: 12px; background: white; }
.working-visual i { width: 5px; border-radius: 8px; background: var(--purple); animation: wave 1s ease-in-out infinite; }
.working-visual i:nth-child(1) { height: 10px; }
.working-visual i:nth-child(2) { height: 19px; animation-delay: .14s; }
.working-visual i:nth-child(3) { height: 13px; animation-delay: .28s; }

.empty-state { min-height: 66vh; display: grid; place-items: center; align-content: center; text-align: center; }
.empty-art { width: 150px; height: 150px; position: relative; margin-bottom: 25px; }
.empty-art span { position: absolute; display: block; border-radius: 28px; transform: rotate(14deg); }
.empty-art span:nth-child(1) { inset: 8px 22px 34px 30px; background: linear-gradient(145deg, #cfbfff, #7658ee); box-shadow: 0 22px 45px rgba(118, 88, 238, .23); }
.empty-art span:nth-child(2) { width: 58px; height: 58px; right: 5px; bottom: 8px; background: linear-gradient(145deg, #f2b0d1, #e56ba8); }
.empty-art span:nth-child(3) { width: 34px; height: 34px; left: 7px; bottom: 17px; border-radius: 50%; background: #3b3450; }
.empty-state h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.45rem; font-weight: 500; letter-spacing: -.025em; }
.empty-state p { max-width: 390px; margin: 11px auto 0; color: var(--muted); font-size: .75rem; line-height: 1.65; }

.gallery { columns: 3 230px; column-gap: 15px; }
.art-card { margin: 0 0 15px; display: inline-block; width: 100%; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.72); box-shadow: 0 10px 28px rgba(50, 41, 70, .065); break-inside: avoid; }
.art-card figure { position: relative; margin: 0; overflow: hidden; background: #e9e6ee; cursor: zoom-in; }
.art-card img { width: 100%; height: auto; min-height: 130px; display: block; object-fit: cover; transition: transform .35s ease; }
.art-card figure:hover img { transform: scale(1.018); }
.art-card .quality-badge { position: absolute; top: 10px; left: 10px; padding: 5px 8px; border-radius: 999px; color: white; background: rgba(20,18,28,.58); backdrop-filter: blur(8px); font-size: .56rem; text-transform: uppercase; }
.card-copy { padding: 12px; }
.card-prompt { display: -webkit-box; overflow: hidden; color: #45424d; font-size: .7rem; line-height: 1.5; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.card-meta { margin-top: 8px; color: #9995a1; font-size: .58rem; }
.card-actions { margin-top: 11px; display: grid; grid-template-columns: 1fr auto; gap: 7px; }
.reference-button, .download-button { height: 33px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; text-decoration: none; cursor: pointer; font-size: .65rem; font-weight: 700; }
.reference-button { border: 1px solid rgba(118,88,238,.18); color: var(--purple-dark); background: #f0ecff; }
.download-button { width: 36px; border: 1px solid var(--line); color: var(--ink); background: white; }
.reference-button:hover { background: #e8e0ff; }
.download-button:hover { border-color: rgba(118,88,238,.35); }

.history-list { display: grid; gap: 9px; }
.history-row { padding: 14px 15px; display: grid; grid-template-columns: 12px minmax(0,1fr) auto; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.65); }
.history-dot { width: 9px; height: 9px; border-radius: 50%; background: #b8b5bd; }
.history-row.succeeded .history-dot { background: var(--green); }
.history-row.failed .history-dot { background: var(--red); }
.history-row.running .history-dot { background: var(--purple); animation: pulse 1.2s infinite; }
.history-main { min-width: 0; }
.history-prompt { overflow: hidden; font-size: .75rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.history-detail { margin-top: 5px; color: var(--muted); font-size: .61rem; }
.history-error { margin-top: 6px; color: var(--red); font-size: .61rem; line-height: 1.4; }
.history-time { color: #9995a1; font-size: .6rem; white-space: nowrap; }

.dialog { padding: 0; border: 0; border-radius: 20px; color: var(--ink); background: #fbfaf8; box-shadow: 0 35px 100px rgba(30, 24, 48, .28); }
.dialog::backdrop { background: rgba(24, 20, 34, .52); backdrop-filter: blur(8px); }
.dialog-close { position: absolute; z-index: 2; top: 13px; right: 13px; width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.8); cursor: pointer; font-size: 1.25rem; line-height: 1; }
.auth-dialog { width: min(420px, calc(100vw - 28px)); }
.auth-dialog form { padding: 38px; }
.auth-dialog h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 2rem; font-weight: 500; }
.auth-dialog p { margin: 12px 0 24px; color: var(--muted); font-size: .75rem; line-height: 1.65; }
.token-control { margin-bottom: 18px; }
.dialog-primary, .dialog-secondary { height: 43px; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; cursor: pointer; text-decoration: none; font-size: .75rem; font-weight: 750; }
.dialog-primary { border: 0; color: white; background: var(--purple); }
.dialog-secondary { border: 1px solid var(--line); color: var(--ink); background: white; }
.auth-dialog .dialog-primary { width: 100%; }

.preview-dialog { width: min(1050px, calc(100vw - 38px)); max-height: calc(100vh - 38px); overflow: hidden; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); }
.preview-dialog[open] { display: grid; }
.preview-image-shell { min-height: 420px; display: grid; place-items: center; overflow: auto; background: #24212c; }
.preview-image-shell img { max-width: 100%; max-height: calc(100vh - 38px); display: block; object-fit: contain; }
.preview-copy { padding: 48px 32px 32px; align-self: center; }
.preview-copy p { max-height: 13rem; margin: 0; overflow: auto; color: #46424e; font-size: .8rem; line-height: 1.7; }
.preview-meta { margin-top: 18px; color: var(--muted); font-size: .67rem; }
.preview-actions { margin-top: 25px; display: flex; gap: 8px; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 24px; max-width: min(440px, calc(100vw - 30px)); padding: 11px 16px; border-radius: 11px; color: white; background: rgba(28,25,36,.92); box-shadow: 0 15px 36px rgba(20,16,30,.22); opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: .23s ease; font-size: .72rem; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #a93f51; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wave { 50% { height: 23px; opacity: .55; } }
@keyframes pulse { 50% { opacity: .35; transform: scale(.8); } }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .creator-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .intro h1 { font-size: clamp(3.8rem, 12vw, 6rem); }
  .empty-state { min-height: 48vh; }
  .gallery { columns: 3 210px; }
}

@media (max-width: 620px) {
  .topbar { height: 64px; padding: 0 18px; }
  .status-pill > span { display: none; }
  .status-pill { width: 34px; padding: 0; justify-content: center; }
  .workspace { min-height: calc(100vh - 64px); }
  .creator-panel { padding: 40px 18px 42px; }
  .output-panel { padding: 24px 14px 40px; }
  .intro h1 { font-size: 3.7rem; }
  .gallery { columns: 2 145px; column-gap: 10px; }
  .art-card { margin-bottom: 10px; border-radius: 12px; }
  .reference-list { grid-template-columns: repeat(4, 1fr); }
  .preview-dialog[open] { display: block; overflow: auto; }
  .preview-image-shell { min-height: 0; max-height: 58vh; }
  .preview-image-shell img { max-height: 58vh; }
  .preview-copy { padding: 30px 22px; }
  .history-row { grid-template-columns: 10px minmax(0,1fr); }
  .history-time { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
