:root {
  --bg: #0d0e12;
  --bg2: #14161c;
  --panel: rgba(24, 26, 33, .78);
  --panel-solid: #181a21;
  --line: rgba(255, 255, 255, .07);
  --line2: rgba(255, 255, 255, .12);
  --text: #e9e7e3;
  --muted: #8d8f99;
  --faint: #5d606b;
  --accent: #f0a868;
  --accent2: #e7795d;
  --accent-soft: rgba(240, 168, 104, .13);
  --ok: #7fcf9b;
  --err: #ef7d7d;
  --radius: 16px;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  background-image:
    radial-gradient(900px 520px at 8% -10%, rgba(240, 168, 104, .10), transparent 60%),
    radial-gradient(800px 600px at 105% 110%, rgba(231, 121, 93, .08), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.55 "Inter", "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: rgba(240, 168, 104, .35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .08); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, .16); }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: .2px; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 6px 20px -6px rgba(240, 140, 90, .7);
}
.brand .logo svg { width: 17px; height: 17px; color: #1a1210; }
.brand small { color: var(--muted); font-weight: 450; margin-left: 2px; }

/* ---------- 通用控件 ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 12px; color: var(--muted); letter-spacing: .3px; display: flex; justify-content: space-between; align-items: center; }
.input, textarea.input, select.input {
  width: 100%; background: rgba(255, 255, 255, .035); border: 1px solid var(--line2);
  border-radius: 12px; padding: 11px 13px; outline: none; transition: border-color .15s, background .15s, box-shadow .15s;
}
.input:focus { border-color: rgba(240, 168, 104, .55); background: rgba(255, 255, 255, .05); box-shadow: 0 0 0 4px rgba(240, 168, 104, .10); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238d8f99' stroke-width='2.4'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
select.input option { background: var(--panel-solid); }
.btn {
  border: 1px solid var(--line2); background: rgba(255, 255, 255, .04); border-radius: 11px;
  padding: 8px 13px; display: inline-flex; align-items: center; gap: 7px; transition: all .15s; white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .2); }
.btn svg { width: 15px; height: 15px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.btn.primary {
  border: 0; color: #1d130d; font-weight: 650; padding: 13px 18px; justify-content: center; border-radius: 13px;
  background: linear-gradient(135deg, #f6b97d, var(--accent) 40%, var(--accent2));
  box-shadow: 0 10px 30px -10px rgba(240, 130, 85, .75), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.btn.primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn.primary:active { transform: translateY(0); }
.btn.primary:disabled { filter: grayscale(.6) brightness(.7); cursor: not-allowed; transform: none; }
.btn.danger:hover { color: var(--err); border-color: rgba(239, 125, 125, .4); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line2); background: rgba(255, 255, 255, .03); border-radius: 10px;
  padding: 6px 11px; font-size: 13px; color: var(--muted); transition: all .15s; display: inline-flex; align-items: center; gap: 7px;
}
.chip:hover { color: var(--text); border-color: rgba(255, 255, 255, .22); }
.chip.on { color: var(--accent); border-color: rgba(240, 168, 104, .5); background: var(--accent-soft); }
.chip .shape { display: inline-block; border: 1.6px solid currentColor; border-radius: 2.5px; opacity: .85; }
.chip small { font-size: 11px; opacity: .7; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: rgba(0, 0, 0, .25); border: 1px solid var(--line); border-radius: 13px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 9px 10px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 7px; transition: all .15s; }
.seg button svg { width: 16px; height: 16px; }
.seg button.on { background: rgba(255, 255, 255, .08); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 4px 14px -6px rgba(0, 0, 0, .6); }

.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: rgba(30, 32, 40, .96); border: 1px solid var(--line2); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); animation: pop .25s ease; max-width: min(560px, 92vw); }
.toast.err { border-color: rgba(239, 125, 125, .45); color: #ffc9c9; }
@keyframes pop { from { opacity: 0; transform: translateY(-8px) scale(.98); } }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(400px, 100%); background: var(--panel); backdrop-filter: blur(18px); border: 1px solid var(--line);
  border-radius: 22px; padding: 34px 30px 30px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 18px;
}
.login-card h1 { margin: 6px 0 0; font-size: 22px; font-weight: 650; }
.login-card p.sub { margin: -10px 0 4px; color: var(--muted); }
.login-card .err { color: var(--err); font-size: 13px; min-height: 18px; margin-top: -6px; }

/* ---------- 主界面 ---------- */
.app { display: grid; grid-template-columns: 400px 1fr; height: 100%; }
.side {
  border-right: 1px solid var(--line); background: rgba(16, 17, 22, .72); backdrop-filter: blur(14px);
  display: flex; flex-direction: column; min-height: 0;
}
.side-head { padding: 18px 22px 14px; display: flex; justify-content: space-between; align-items: center; }
.side-body { padding: 4px 22px 18px; display: flex; flex-direction: column; gap: 20px; overflow-y: auto; flex: 1; }
.side-foot { padding: 14px 22px 20px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.side-foot .est { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }

textarea.prompt { min-height: 132px; resize: vertical; line-height: 1.6; }
.prompt-hint { font-size: 12px; color: var(--faint); margin-top: -2px; }
.prompt-hint b { color: var(--accent); font-weight: 600; }

.drop {
  border: 1.5px dashed rgba(255, 255, 255, .14); border-radius: 14px; padding: 14px; text-align: center; color: var(--muted);
  transition: all .15s; cursor: pointer; font-size: 13px; background: rgba(255, 255, 255, .015);
}
.drop:hover, .drop.over { border-color: rgba(240, 168, 104, .6); color: var(--text); background: var(--accent-soft); }
.drop svg { width: 22px; height: 22px; display: block; margin: 2px auto 6px; opacity: .8; }
.refs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.refs:empty { display: none; }
.ref { position: relative; aspect-ratio: 1; border-radius: 11px; overflow: hidden; border: 1px solid var(--line2); background: #000; }
.ref img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 7px; border: 0; background: rgba(0, 0, 0, .65); color: #fff; display: grid; place-items: center; padding: 0; opacity: 0; transition: opacity .15s; }
.ref:hover button { opacity: 1; }
.ref button svg { width: 12px; height: 12px; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); }
.switch input { display: none; }
.switch .track { width: 36px; height: 21px; border-radius: 20px; background: rgba(255, 255, 255, .12); position: relative; transition: background .2s; flex: none; cursor: pointer; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(15px); }

/* 模型选择 */
.mp-btn, .mp-item { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; border: 0; background: transparent; }
.mp-btn {
  padding: 9px 12px 9px 9px; border-radius: 14px; border: 1px solid var(--line2); background: rgba(255, 255, 255, .035);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.mp-btn:hover { background: rgba(255, 255, 255, .055); border-color: rgba(255, 255, 255, .2); }
.mpick.open .mp-btn { border-color: rgba(240, 168, 104, .55); box-shadow: 0 0 0 4px rgba(240, 168, 104, .10); }
.mp-ico {
  flex: none; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  font: 700 12.5px/1 "Inter", system-ui, sans-serif; letter-spacing: .3px;
  background: rgba(255, 255, 255, .06); color: var(--muted); border: 1px solid var(--line);
}
.mp-ico.v26 { background: linear-gradient(135deg, #f6b97d, var(--accent) 45%, var(--accent2)); color: #1d130d; border-color: transparent; box-shadow: 0 6px 16px -8px rgba(240, 130, 85, .8); }
.mp-ico.v25 { background: var(--accent-soft); color: var(--accent); border-color: rgba(240, 168, 104, .22); }
.mp-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.mp-txt b { font-weight: 600; font-size: 14px; display: flex; align-items: center; }
.mp-txt small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-badge { font-size: 10.5px; font-weight: 550; padding: 1px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); margin-left: 7px; }
.mp-chev { flex: none; width: 16px; height: 16px; color: var(--muted); transition: transform .2s; }
.mpick.open .mp-chev { transform: rotate(180deg); }
.mp-menu {
  margin-top: 6px; padding: 5px; border-radius: 15px; border: 1px solid var(--line2);
  background: rgba(22, 23, 29, .92); display: flex; flex-direction: column; gap: 2px;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .7); animation: mpdrop .18s ease;
}
@keyframes mpdrop { from { opacity: 0; transform: translateY(-4px); } }
.mp-item { padding: 7px 10px 7px 7px; border-radius: 11px; transition: background .12s; }
.mp-item:hover { background: rgba(255, 255, 255, .05); }
.mp-item.on { background: var(--accent-soft); }
.mp-item .mp-ico { width: 34px; height: 34px; border-radius: 9px; font-size: 11.5px; }
.mp-item .chk { flex: none; width: 16px; height: 16px; color: var(--accent); opacity: 0; }
.mp-item.on .chk { opacity: 1; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; border-bottom: 1px solid var(--line); gap: 12px; }
.topbar h2 { margin: 0; font-size: 16px; font-weight: 600; }
.topbar .stat { color: var(--muted); font-size: 13px; }
.topbar .tools { display: flex; gap: 6px; align-items: center; }
.gallery { flex: 1; overflow-y: auto; padding: 24px 28px 60px; display: flex; flex-direction: column; gap: 22px; }

.job { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 16px; box-shadow: var(--shadow); }
.job.new { animation: rise .35s ease; }
.shot img.fresh { animation: fade .4s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.job-head { display: flex; gap: 14px; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.job-prompt { font-size: 14px; line-height: 1.6; color: #d8d6d1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.job-prompt.open { -webkit-line-clamp: unset; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 7px; background: rgba(255, 255, 255, .05); color: var(--muted); border: 1px solid var(--line); }
.tag.acc { color: var(--accent); background: var(--accent-soft); border-color: rgba(240, 168, 104, .25); }
.tag.ok { color: var(--ok); }
.tag.err { color: var(--err); }
.job-actions { display: flex; gap: 4px; flex: none; }
.imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.shot { position: relative; border-radius: 14px; overflow: hidden; background: #08090b; border: 1px solid var(--line); }
.shot img { display: block; width: 100%; height: auto; cursor: zoom-in; transition: transform .4s ease; }
.shot:hover img { transform: scale(1.015); }
.shot .bar {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 10px 9px; display: flex; justify-content: space-between; align-items: flex-end; gap: 6px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .78)); opacity: 0; transition: opacity .2s;
}
.shot:hover .bar { opacity: 1; }
.shot .bar .dim { font-size: 11.5px; color: #ddd; text-shadow: 0 1px 2px #000; }
.shot .bar .acts { display: flex; gap: 4px; }
.icon-btn { width: 30px; height: 30px; border-radius: 9px; border: 1px solid rgba(255, 255, 255, .15); background: rgba(20, 20, 24, .7); backdrop-filter: blur(6px); display: grid; place-items: center; color: #eee; padding: 0; transition: all .15s; }
.icon-btn:hover { background: rgba(240, 168, 104, .9); color: #1d130d; border-color: transparent; }
.icon-btn svg { width: 15px; height: 15px; }

.pending { aspect-ratio: var(--ar, 1); border-radius: 14px; border: 1px solid var(--line); position: relative; overflow: hidden; background: #111318; display: grid; place-items: center; }
.pending::before { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(240, 168, 104, .08) 50%, transparent 70%); background-size: 250% 100%; animation: shimmer 1.8s linear infinite; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -100% 0; } }
.pending .inner { position: relative; text-align: center; color: var(--muted); font-size: 12.5px; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid rgba(240, 168, 104, .2); border-top-color: var(--accent); animation: spin .9s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.errbox { font-size: 12.5px; color: #ffbcbc; background: rgba(239, 125, 125, .08); border: 1px solid rgba(239, 125, 125, .25); border-radius: 11px; padding: 9px 12px; margin-top: 10px; word-break: break-all; }

.empty { margin: auto; text-align: center; color: var(--muted); padding: 60px 20px; }
.empty .art { width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 24px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty .art svg { width: 38px; height: 38px; }
.empty h3 { color: var(--text); margin: 0 0 6px; font-weight: 600; }

/* 灯箱 */
.lb { position: fixed; inset: 0; z-index: 50; background: rgba(5, 5, 8, .92); backdrop-filter: blur(8px); display: none; flex-direction: column; }
.lb.show { display: flex; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.lb-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; gap: 12px; color: var(--muted); font-size: 13px; }
.lb-stage { flex: 1; overflow: auto; display: grid; place-items: center; padding: 0 20px 20px; cursor: zoom-in; }
.lb-stage.full { cursor: zoom-out; place-items: start center; }
.lb-stage img { max-width: 100%; max-height: calc(100vh - 90px); border-radius: 8px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
.lb-stage.full img { max-width: none; max-height: none; }
.lb .seg { width: 210px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; height: auto; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .side-body { overflow: visible; }
  .gallery { overflow: visible; padding: 18px 16px 50px; }
  .topbar { padding: 14px 16px; }
  .imgs { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ---------- 多用户 / 管理 ---------- */
.tb-left { display: flex; align-items: center; gap: 18px; min-width: 0; flex-wrap: wrap; }
.tb-title.compact h2 { font-size: 14px; color: var(--muted); font-weight: 500; }
.views { width: auto; display: inline-grid; }
.views button { padding: 7px 14px; font-size: 13px; }
.topbar .tools { flex-wrap: wrap; justify-content: flex-end; }
.input.sm { padding: 7px 34px 7px 11px; border-radius: 10px; font-size: 13px; width: auto; min-width: 130px; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn.primary.sm { padding: 9px 16px; font-size: 13.5px; border-radius: 11px; }

.tag.who { color: #cfd6ff; background: rgba(140, 160, 255, .12); border-color: rgba(140, 160, 255, .28); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.tag.who:hover { background: rgba(140, 160, 255, .22); }
.tag.ip { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 11px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }
.card-title { font-weight: 600; margin-bottom: 12px; }
.newuser { display: grid; grid-template-columns: 1.2fr 1.2fr 1fr 110px auto; gap: 10px; align-items: center; }
.newuser .input { padding: 9px 12px; }
.tbl-wrap { overflow-x: auto; margin: -4px; padding: 4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: rgba(255, 255, 255, .02); }
.tbl tr.off td { opacity: .55; }
.tbl .ops { white-space: nowrap; text-align: right; }
.tbl .ips { font-size: 12px; line-height: 1.7; }
.uname { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.pill { display: inline-block; font-size: 11px; font-weight: 500; padding: 1px 7px; border-radius: 6px; background: rgba(255, 255, 255, .06); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.acc { color: var(--accent); background: var(--accent-soft); border-color: rgba(240, 168, 104, .25); }
.pill.ok { color: var(--ok); background: rgba(127, 207, 155, .1); border-color: rgba(127, 207, 155, .25); }
.pill.err { color: var(--err); background: rgba(239, 125, 125, .1); border-color: rgba(239, 125, 125, .25); }
.lnk { color: var(--text); text-decoration: none; border-bottom: 1px dashed rgba(255, 255, 255, .25); }
.lnk:hover { color: var(--accent); border-color: var(--accent); }

.modal { position: fixed; inset: 0; z-index: 60; background: rgba(5, 5, 8, .7); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; animation: fade .15s ease; }
.modal-card { width: min(420px, 100%); background: var(--panel-solid); border: 1px solid var(--line2); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); animation: pop .2s ease; }
.modal-card h3 { margin: 0 0 6px; font-size: 17px; }
.modal-card .muted { color: var(--muted); margin: 0 0 16px; font-size: 13px; }
.mform { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.modal-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.cred { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; padding: 14px 16px; border-radius: 14px; background: rgba(0, 0, 0, .25); border: 1px solid var(--line); align-items: center; }
.cred span { color: var(--muted); font-size: 12.5px; }
.cred b { font-size: 15px; word-break: break-all; user-select: all; }

@media (max-width: 900px) {
  .newuser { grid-template-columns: 1fr 1fr; }
  .newuser .btn { grid-column: 1 / -1; }
  .tb-left { gap: 10px; }
  .views button { padding: 7px 9px; }
}
