:root {
  --bg: #f5f2ec;
  --panel: #fffdf9;
  --panel-2: #efebe3;
  --line: #e2ddd2;
  --line-strong: #cfc8ba;
  --ink: #1d1b16;
  --ink-2: #5d584d;
  --ink-3: #8f897c;
  --accent: #c2410c;
  --accent-ink: #fff;
  --accent-soft: #fbe6da;
  --ok: #3f7d4e;
  --bad: #b42318;
  --shadow: 0 1px 2px rgba(40, 30, 10, .05), 0 6px 24px rgba(40, 30, 10, .06);
  --radius: 14px;
  --radius-s: 9px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16150f;
    --panel: #1e1d17;
    --panel-2: #26241d;
    --line: #322f27;
    --line-strong: #464236;
    --ink: #efeae0;
    --ink-2: #b9b2a3;
    --ink-3: #847e70;
    --accent: #f0743a;
    --accent-ink: #1a0d05;
    --accent-soft: #3a2316;
    --ok: #7cc28d;
    --bad: #f0846f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.center { text-align: center; }
.error { color: var(--bad); margin: 8px 0 0; font-size: 13px; }
em { font-style: normal; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--panel); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn.block { width: 100%; height: 44px; font-size: 15px; }
.icon-btn { width: 30px; height: 30px; padding: 0; border-radius: 8px; }

/* 品牌 */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; letter-spacing: .04em; }
.brand-mark { display: block; width: 26px; height: 30px; object-fit: contain; flex: none; }
.brand.big { font-size: 24px; justify-content: center; }
.brand.big .brand-mark { width: 36px; height: 42px; }

/* 登录 */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(340px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 32px 26px; box-shadow: var(--shadow); text-align: center; display: grid; gap: 14px; }
.login-card p { margin: 0; }
.login-card input { height: 44px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg); padding: 0 14px; text-align: center; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px;
  height: 58px; padding: 0 20px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 4px; background: var(--panel-2); padding: 3px; border-radius: 10px; }
.tab { border: 0; background: transparent; padding: 5px 16px; border-radius: 8px; cursor: pointer; color: var(--ink-2); }
.tab.active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.queue { font-size: 12px; color: var(--ink-2); background: var(--accent-soft); padding: 3px 10px; border-radius: 99px; }

/* 创作页 */
.create { display: grid; grid-template-columns: 400px 1fr; gap: 20px; padding: 20px; max-width: 1680px; margin: 0 auto; align-items: start; }
.composer {
  position: sticky; top: 78px; max-height: calc(100vh - 98px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  display: grid; gap: 14px; scrollbar-width: thin;
}
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mode {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 6px 8px; cursor: pointer;
  display: grid; justify-items: center; gap: 2px; color: var(--ink-2); transition: all .15s;
}
.mode i { font-style: normal; font-size: 17px; line-height: 1.2; color: var(--ink-3); }
.mode span { font-size: 13px; }
.mode:hover { border-color: var(--line-strong); }
.mode.active { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.mode.active i { color: var(--accent); }
.mode-desc { margin: -4px 0 0; color: var(--ink-3); font-size: 12.5px; }

.field { display: grid; gap: 6px; }
.label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.label em { font-weight: 400; margin-left: 4px; }
textarea, select, input[type=text] {
  width: 100%; border: 1px solid var(--line-strong); background: var(--bg); border-radius: var(--radius-s);
  padding: 9px 11px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 64px; }
textarea:focus, select:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { height: 36px; padding: 0 30px 0 10px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }

.refzone { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; border: 1px dashed var(--line-strong); border-radius: var(--radius-s); min-height: 64px; outline: none; }
.refzone.drag, .refzone:focus { border-color: var(--accent); background: var(--accent-soft); }
.ref-list { display: contents; }
.ref { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; background: var(--panel-2); }
.ref img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref b { position: absolute; left: 4px; top: 3px; font-size: 10px; background: rgba(0,0,0,.55); color: #fff; padding: 0 5px; border-radius: 5px; font-weight: 600; }
.ref button { position: absolute; right: 2px; top: 2px; width: 20px; height: 20px; border: 0; border-radius: 6px; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 11px; line-height: 1; }
.ref-add { width: 64px; height: 64px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink-3); font-size: 22px; cursor: pointer; }
.ref-add:hover { color: var(--accent); border-color: var(--accent); }

.dims { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 10px; }
.dims .field.wide { grid-column: 1 / -1; }
.more summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 2px 0; }
.more textarea { margin-top: 8px; }
.switches { display: grid; gap: 8px; }
.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.switch input { width: 16px; height: 16px; accent-color: var(--accent); }

/* 右侧 */
.stage { min-width: 0; }
.empty { min-height: calc(100vh - 140px); display: grid; place-content: center; text-align: center; max-width: 460px; margin: 0 auto; padding: 40px 0; }
.empty h2 { margin: 26px 0 8px; font-size: 20px; }
.empty p { margin: 0; }
.empty-art { position: relative; width: 150px; height: 110px; margin: 0 auto; }
.empty-art span { position: absolute; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--panel); box-shadow: var(--shadow); }
.empty-art span:nth-child(1) { width: 70px; height: 92px; left: 8px; top: 14px; transform: rotate(-8deg); }
.empty-art span:nth-child(2) { width: 70px; height: 92px; right: 8px; top: 10px; transform: rotate(7deg); }
.empty-art span:nth-child(3) { width: 78px; height: 100px; left: 36px; top: 0; background: var(--accent-soft); border-color: var(--accent); }

.work-head { display: flex; align-items: flex-start; gap: 12px; margin: 2px 0 14px; }
.work-head h2 { margin: 0; font-size: 19px; line-height: 1.35; word-break: break-all; }
.work-head .meta { color: var(--ink-3); font-size: 12.5px; margin-top: 3px; }
.work-head .actions { margin-left: auto; display: flex; gap: 6px; flex-shrink: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.plan { margin-bottom: 16px; }
.plan-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.plan-head h3 { margin: 0; font-size: 14px; }
.plan-summary { margin: 0 0 10px; color: var(--ink-2); }
.choices { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.choice { font-size: 12px; background: var(--panel-2); border-radius: 99px; padding: 3px 10px; color: var(--ink-2); cursor: help; }
.choice b { color: var(--ink); font-weight: 600; }
.prompts { display: grid; gap: 8px; }
.prompt-item { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.prompt-item summary { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; background: var(--bg); list-style: none; }
.prompt-item summary::-webkit-details-marker { display: none; }
.prompt-item summary::before { content: '›'; color: var(--ink-3); transition: transform .15s; display: inline-block; width: 8px; }
.prompt-item[open] summary::before { transform: rotate(90deg); }
.prompt-item .t { font-weight: 600; font-size: 13px; }
.prompt-item .a { font-size: 11.5px; color: var(--ink-3); }
.prompt-item .go { margin-left: auto; }
.prompt-item textarea { border: 0; border-top: 1px solid var(--line); border-radius: 0; font: 12.5px/1.6 var(--mono); min-height: 180px; background: var(--panel); box-shadow: none; }
.plan-foot { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.planning { display: flex; align-items: center; gap: 12px; padding: 22px 18px; }
.planning p { margin: 0; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 图片 */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; align-items: start; }
.gallery[data-n="1"] { grid-template-columns: minmax(0, 860px); }
.shot {background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.shot-img { position: relative; background: var(--panel-2); cursor: zoom-in; display: block; width: 100%; }
.shot-img img { display: block; width: 100%; height: auto; }
.shot-ph { aspect-ratio: var(--ar, 1); display: grid; place-items: center; gap: 8px; color: var(--ink-3); font-size: 12.5px; text-align: center; padding: 14px; cursor: default; }
.shot-ph .bar { width: 60%; height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; position: relative; }
.shot-ph .bar::after { content: ''; position: absolute; inset: 0; width: 40%; background: var(--accent); border-radius: 3px; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
.shot-ph.failed { color: var(--bad); }
.shot-ph.failed .err { color: var(--ink-3); font-size: 11.5px; max-height: 5.5em; overflow: hidden; }
.shot-foot { display: flex; align-items: center; gap: 4px; padding: 7px 8px 7px 12px; }
.shot-foot .t { font-size: 12.5px; color: var(--ink-2); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot-foot .btn { height: 28px; min-width: 28px; padding: 0 7px; border-color: transparent; background: transparent; color: var(--ink-2); font-size: 12px; }
.shot-foot .btn:hover { background: var(--panel-2); }
.shot-foot .star.on { color: var(--accent); }
.badge { position: absolute; left: 8px; top: 8px; font-size: 11px; background: rgba(0,0,0,.6); color: #fff; padding: 1px 8px; border-radius: 99px; }

/* 作品页 */
.works { padding: 20px; max-width: 1680px; margin: 0 auto; }
.works-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.works-head h2 { margin: 0; font-size: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 4px 12px; font-size: 12.5px; cursor: pointer; color: var(--ink-2); }
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.works-grid { columns: 5 220px; column-gap: 14px; }
.work-card { break-inside: avoid; margin-bottom: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; box-shadow: var(--shadow); transition: transform .15s; }
.work-card:hover { transform: translateY(-2px); }
.work-card img { display: block; width: 100%; height: auto; background: var(--panel-2); }
.work-card .noimg { aspect-ratio: 4/3; display: grid; place-items: center; color: var(--ink-3); background: var(--panel-2); font-size: 12px; }
.work-card .info { padding: 9px 12px 11px; }
.work-card .t { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work-card .m { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

/* 大图 */
.viewer { position: fixed; inset: 0; z-index: 50; background: rgba(12, 11, 8, .86); display: flex; backdrop-filter: blur(6px); }
.viewer-close { position: absolute; right: 14px; top: 12px; z-index: 2; width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; font-size: 16px; cursor: pointer; }
.viewer-body { display: grid; grid-template-columns: 1fr 360px; width: 100%; min-height: 0; }
.viewer-img { display: grid; place-items: center; padding: 24px; min-height: 0; min-width: 0; }
.viewer-img img { max-width: 100%; max-height: calc(100vh - 48px); object-fit: contain; border-radius: 6px; box-shadow: 0 10px 50px rgba(0,0,0,.5); }
.viewer-side { background: var(--panel); padding: 22px 18px; overflow: auto; display: grid; gap: 14px; align-content: start; }
.viewer-side h3 { margin: 0; font-size: 16px; padding-right: 40px; }
.viewer-side p { margin: -8px 0 0; }
.viewer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.prompt-box summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.prompt-box pre { white-space: pre-wrap; word-break: break-word; font: 12px/1.6 var(--mono); background: var(--bg); border-radius: 8px; padding: 10px; margin: 8px 0 0; max-height: 40vh; overflow: auto; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--bg); padding: 9px 18px; border-radius: 99px; font-size: 13px; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

/* 窄屏 */
@media (max-width: 960px) {
  .create { grid-template-columns: 1fr; padding: 12px 16px; gap: 16px; }
  .composer { position: static; max-height: none; }
  .empty { min-height: 0; padding: 20px 0 40px; }
  .viewer-body { grid-template-columns: 1fr; overflow: auto; }
  .viewer-img { padding: 56px 12px 12px; }
  .viewer-img img { max-height: 70vh; }
  .viewer-side { border-radius: 16px 16px 0 0; }
}
@media (max-width: 600px) {
  .topbar { padding: 0 16px; gap: 12px; }
  .brand { font-size: 15px; }
  .tab { padding: 5px 12px; }
  .works { padding: 12px 16px; }
  .gallery { grid-template-columns: 1fr 1fr; gap: 10px; }
  .gallery[data-n="1"] { grid-template-columns: 1fr; }
  .works-grid { columns: 2 140px; column-gap: 10px; }
  .work-head { flex-wrap: wrap; }
  .work-head .actions { margin-left: 0; }
  .shot-foot .t { display: none; }
}
