:root {
  color-scheme: dark;
  --bg: #11100e;
  --panel: #191714;
  --panel-2: #201d19;
  --line: rgba(242, 238, 229, 0.12);
  --text: #f2eee5;
  --muted: #9b958a;
  --gold: #c6a66a;
  --gold-2: #e2c991;
  --danger: #d96d5f;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 76% -10%, rgba(145, 104, 51, .18), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
}
button, textarea, input { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; }
.topbar {
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 16, 14, .86);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  border: 1px solid rgba(226, 201, 145, .45); color: var(--gold-2);
  font: 24px/1 "Songti SC", serif;
}
.brand h1 { margin: 0; font: 700 21px/1.15 "Songti SC", serif; letter-spacing: .12em; }
.brand p { margin: 5px 0 0; color: var(--muted); font-size: 12px; letter-spacing: .08em; }
.brand-link { color: var(--gold-2); text-decoration: none; }
.brand-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.top-actions { display: flex; gap: 10px; }
button { border: 0; cursor: pointer; }
.ghost-button, .primary-button {
  min-height: 42px; padding: 0 17px; border-radius: 4px; font-weight: 650; font-size: 14px;
}
.ghost-button { background: var(--panel-2); border: 1px solid var(--line); }
.ghost-button:hover { border-color: rgba(226, 201, 145, .4); }
.primary-button { color: #18140f; background: linear-gradient(135deg, var(--gold-2), #b58a47); box-shadow: 0 8px 24px rgba(174, 128, 56, .18); }
.primary-button:hover { filter: brightness(1.07); }

.workspace { display: grid; grid-template-columns: 360px minmax(0, 1fr); min-height: calc(100vh - 82px); }
.controls { border-right: 1px solid var(--line); background: rgba(24, 22, 19, .7); }
.control-section { padding: 26px 28px; border-top: 1px solid var(--line); }
.control-section.first { border-top: 0; }
.section-label { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.section-label span { color: var(--gold); font: 12px/1 Georgia, serif; }
.section-label h2 { margin: 0; font-size: 15px; letter-spacing: .12em; }
label { display: block; font-size: 13px; color: #d5d0c6; margin: 16px 0 8px; }
textarea {
  width: 100%; resize: vertical; min-height: 66px; padding: 12px 13px;
  color: var(--text); background: #12110f; border: 1px solid var(--line); border-radius: 4px;
  line-height: 1.5; outline: none;
}
textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(198, 166, 106, .1); }
.counter { display: flex; justify-content: space-between; margin-top: 6px; color: #777167; font-size: 12px; }
.theme-list { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 15px; }
.style-list { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.style-card { min-height: 67px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 5px; background: #fffefa; color: var(--muted); text-align: left; }
.style-card span { display: block; margin-bottom: 8px; font-size: 9px; letter-spacing: .14em; }
.style-card strong { color: var(--text); font-size: 14px; font-weight: 600; }
.style-card:hover { border-color: #999b91; }
.style-card.active { border-color: #ed512f; background: #252620; box-shadow: inset 0 0 0 1px #ed512f; }
.style-card.active span { color: #ff8068; }
.style-card.active strong { color: #fff; }
.theme-chip { padding: 7px 10px; border: 1px solid var(--line); background: transparent; border-radius: 99px; color: var(--muted); font-size: 12px; }
.theme-chip.active { color: #17130e; border-color: var(--gold-2); background: var(--gold-2); }
.online-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; margin-bottom: 7px; }
.online-search input {
  min-width: 0; height: 38px; padding: 0 10px; color: var(--text); background: #12110f;
  border: 1px solid var(--line); border-radius: 4px; outline: none; font-size: 13px;
}
.online-search input:focus { border-color: var(--gold); }
.online-search button { padding: 0 10px; border-radius: 4px; color: #18140f; background: var(--gold-2); font-size: 12px; font-weight: 700; }
.online-search button:disabled { opacity: .5; cursor: wait; }
.online-status { min-height: 17px; margin: 0 0 12px; color: #777167; font-size: 11px; line-height: 1.5; }
.online-status.error { color: var(--danger); }
.art-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.art-card { aspect-ratio: 1.35; padding: 0; border: 1px solid transparent; border-radius: 3px; overflow: hidden; background: #0b0a09; position: relative; }
.art-card img { width: 100%; height: 100%; object-fit: cover; display: block; filter: saturate(.82); }
.art-card:hover img { filter: saturate(1); transform: scale(1.03); }
.art-card.selected { border-color: var(--gold-2); box-shadow: 0 0 0 2px rgba(198, 166, 106, .2); }
.art-card.selected::after { content: "✓"; position: absolute; right: 5px; top: 5px; width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center; color: #17130e; background: var(--gold-2); font-size: 11px; font-weight: 900; }
.art-card .remote-badge { position: absolute; left: 5px; bottom: 5px; padding: 3px 5px; color: #eee7da; background: rgba(12,10,8,.72); font-size: 9px; letter-spacing: .08em; }
.upload-button { display: flex; justify-content: center; align-items: center; gap: 7px; margin: 12px 0 0; height: 40px; border: 1px dashed rgba(242, 238, 229, .2); border-radius: 4px; color: var(--muted); cursor: pointer; }
.upload-button:hover { color: var(--text); border-color: var(--gold); }
.upload-button input { display: none; }
.slider-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 5px 12px; margin-top: 16px; }
.slider-row label { margin: 0; }
.slider-row output { color: var(--gold-2); font: 12px/1 Georgia, serif; }
.slider-row input { grid-column: 1 / -1; width: 100%; accent-color: var(--gold); }
.toggle-row { display: flex; justify-content: space-between; align-items: center; margin-top: 23px; }
.toggle-row strong { font-size: 13px; display: block; }
.toggle-row small { display: block; color: var(--muted); margin-top: 4px; }
.switch { margin: 0; position: relative; }
.switch input { position: absolute; opacity: 0; }
.switch span { display: block; width: 42px; height: 24px; border-radius: 30px; background: #3b3833; position: relative; transition: .2s; }
.switch span::after { content: ""; width: 18px; height: 18px; border-radius: 50%; background: #aaa49a; position: absolute; top: 3px; left: 3px; transition: .2s; }
.switch input:checked + span { background: #7e683e; }
.switch input:checked + span::after { left: 21px; background: var(--gold-2); }

.stage { min-width: 0; padding: 34px 38px; display: flex; flex-direction: column; justify-content: center; }
.stage-heading, .stage-footer { display: flex; align-items: flex-end; justify-content: space-between; }
.stage-heading { margin-bottom: 17px; }
.eyebrow { color: var(--gold); font: 11px/1 Georgia, serif; letter-spacing: .16em; }
.stage h2 { margin: 7px 0 0; font: 600 19px/1.2 "Songti SC", serif; letter-spacing: .03em; }
.ratio-badge { border: 1px solid var(--line); color: var(--muted); padding: 6px 10px; font: 12px/1 Georgia, serif; }
.canvas-frame { width: 100%; background: #080706; border: 1px solid rgba(226, 201, 145, .2); box-shadow: 0 24px 80px rgba(0,0,0,.45); }
canvas { width: 100%; aspect-ratio: 5 / 2; display: block; }
.stage-footer { margin-top: 13px; color: var(--muted); font-size: 12px; }
.stage-footer strong { color: #cfc9bd; font-weight: 600; }
.text-button { color: var(--muted); background: none; text-decoration: underline; text-underline-offset: 4px; }
.text-button:hover { color: var(--gold-2); }

dialog { width: min(620px, calc(100vw - 32px)); border: 1px solid var(--line); background: #191714; color: var(--text); padding: 26px; box-shadow: 0 30px 100px #000; }
dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(6px); }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-head h2 { margin: 7px 0 20px; font: 24px/1.2 "Songti SC", serif; }
.dialog-head button { width: 34px; height: 34px; background: var(--panel-2); font-size: 24px; }
.credits-list { display: grid; gap: 9px; }
.credit { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 13px; }
.credit a { color: var(--gold-2); }
.credit em { color: var(--muted); font-size: 12px; font-style: normal; white-space: nowrap; }
.dialog-note { color: var(--muted); font-size: 12px; line-height: 1.7; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 18px); padding: 11px 17px; color: #18140f; background: var(--gold-2); border-radius: 3px; font-weight: 700; opacity: 0; pointer-events: none; transition: .22s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.site-footer {
  min-height: 58px; padding: 0 32px; display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--line); color: #777167; background: #0e0d0b; font-size: 12px;
}
.site-footer a { color: var(--gold-2); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; text-underline-offset: 4px; }

@media (max-width: 900px) {
  .topbar { height: auto; padding: 15px 18px; gap: 16px; align-items: flex-start; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .workspace { grid-template-columns: 1fr; }
  .controls { border-right: 0; order: 2; }
  .stage { order: 1; padding: 25px 18px; position: sticky; top: 74px; z-index: 3; background: var(--bg); border-bottom: 1px solid var(--line); }
}
@media (max-width: 560px) {
  .brand p, .ghost-button { display: none; }
  .primary-button { font-size: 12px; padding: 0 11px; }
  .stage-heading h2 { font-size: 15px; }
  .stage { top: 72px; }
  .site-footer { padding: 16px 18px; gap: 12px; flex-wrap: wrap; }
}
