:root {
  --bg: #0b0c10;
  --card: #14171f;
  --card-2: #1a1e28;
  --line: rgba(255, 255, 255, .07);
  --text: #eef1f7;
  --muted: #9098a8;
  --accent: #ff7a45;
  --accent-2: #ff3f8e;
  --accent-3: #7c5cff;
  --ok: #38d39f;
  --warn: #ffc145;
  --err: #ff5c7a;
  --radius: 20px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
.bg-glow {
  position: fixed; inset: -20% -20% auto -20%; height: 60vh; z-index: 0; pointer-events: none;
  background:
    radial-gradient(42vmax 32vmax at 18% 8%, rgba(255, 122, 69, .20), transparent 62%),
    radial-gradient(38vmax 30vmax at 82% 4%, rgba(124, 92, 255, .18), transparent 64%);
  filter: blur(8px);
}
button, textarea, input { font-family: inherit; }
button { cursor: pointer; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 10px;
  background: linear-gradient(180deg, rgba(11, 12, 16, .96), rgba(11, 12, 16, .72) 70%, transparent);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 11px; }
.logo {
  width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center;
  font-size: 18px; color: #191008; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(255, 63, 142, .28);
}
.logo.big { width: 56px; height: 56px; border-radius: 18px; font-size: 26px; margin: 0 auto 14px; }
.brand-text h1 { margin: 0; font-size: 18px; letter-spacing: .4px; }
.brand-text p { margin: 1px 0 0; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(255, 193, 69, .14); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(56, 211, 159, .15); }
.dot.err { background: var(--err); box-shadow: 0 0 0 3px rgba(255, 92, 122, .15); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 13px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04); color: var(--muted);
  display: grid; place-items: center;
}
.icon-btn:active { transform: scale(.95); }

/* ---------- 标签 ---------- */
.tabs {
  position: relative; z-index: 10; display: flex; gap: 6px;
  margin: 4px 18px 8px; padding: 4px;
  background: rgba(255, 255, 255, .045); border: 1px solid var(--line);
  border-radius: 16px;
}
.tab {
  flex: 1; padding: 10px 0; border: 0; border-radius: 12px; background: transparent;
  color: var(--muted); font-size: 14.5px; font-weight: 500; transition: .18s;
}
.tab.active { background: #232837; color: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .25); }

main { position: relative; z-index: 5; padding: 6px 14px calc(140px + env(safe-area-inset-bottom)); max-width: 620px; margin: 0 auto; }
.panel { display: none; animation: fade .22s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 卡片 ---------- */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .015)), var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.label { display: block; font-size: 13px; color: #c6cddc; font-weight: 600; letter-spacing: .2px; }
.label-row { display: flex; align-items: center; justify-content: space-between; }
.mt { margin-top: 14px; }
.hint { font-size: 12px; color: var(--muted); }
.meta-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.model-tag {
  font-size: 11px; color: #ffd0bd; background: rgba(255, 122, 69, .12);
  border: 1px solid rgba(255, 122, 69, .22); padding: 3px 9px; border-radius: 999px;
}
.val { font-size: 12.5px; color: var(--accent); font-variant-numeric: tabular-nums; }

textarea, .input {
  width: 100%; margin-top: 10px; padding: 13px 14px;
  background: rgba(0, 0, 0, .28); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px;
  font-size: 16px; line-height: 1.55; resize: vertical; outline: none;
  transition: border-color .18s, background .18s;
}
textarea:focus, .input:focus { border-color: rgba(255, 122, 69, .55); background: rgba(0, 0, 0, .36); }
textarea::placeholder, .input::placeholder { color: #5f6675; }
.input { margin-top: 8px; }

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; margin-top: 10px; }
.chips.wrap { flex-wrap: wrap; }
.chip {
  flex: 1; min-width: 0; padding: 10px 8px; border-radius: 13px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .03);
  color: #c8cfdd; display: flex; flex-direction: column; gap: 2px; align-items: center;
  font-size: 14px; transition: .16s;
}
.chip b { font-weight: 600; font-size: 14px; }
.chip small { font-size: 10.5px; color: var(--muted); }
.chip.sm { flex: 0 0 auto; padding: 8px 13px; font-size: 13px; border-radius: 999px; }
.chip.active {
  border-color: rgba(255, 122, 69, .6); color: #fff;
  background: linear-gradient(145deg, rgba(255, 122, 69, .24), rgba(255, 63, 142, .16));
  box-shadow: 0 4px 16px rgba(255, 92, 90, .14);
}
.chip.active small { color: #ffc4b1; }
.chip:active { transform: scale(.97); }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 30px;
  margin: 6px 0 0; background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)) no-repeat,
              rgba(255, 255, 255, .08);
  background-size: var(--fill, 40%) 100%, 100% 100%;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px;
  border-radius: 50%; background: #fff; border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .08); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); }

/* ---------- 上传 ---------- */
.uploader {
  position: relative; margin-top: 10px; border-radius: 16px; overflow: hidden;
  border: 1px dashed rgba(255, 255, 255, .18); background: rgba(0, 0, 0, .22);
  min-height: 168px; display: grid; place-items: center;
}
.uploader.has-img { border-style: solid; border-color: rgba(255, 122, 69, .3); min-height: 0; }
.uploader img { display: block; width: 100%; max-height: 46vh; object-fit: contain; background: #08090c; }
.uploader-empty { text-align: center; padding: 26px 10px; color: var(--muted); }
.uploader-empty p { margin: 8px 0 2px; color: #d4dae6; font-size: 15px; }
.uploader-empty small { font-size: 11.5px; }
.up-ico {
  width: 46px; height: 46px; margin: 0 auto; border-radius: 15px; display: grid; place-items: center;
  font-size: 24px; color: #ffb28f; background: rgba(255, 122, 69, .12); border: 1px solid rgba(255, 122, 69, .2);
}
.clear-btn {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .6); color: #fff; font-size: 15px; backdrop-filter: blur(6px);
}

/* ---------- 按钮 ---------- */
.primary {
  width: 100%; height: 56px; border: 0; border-radius: 18px;
  font-size: 17px; font-weight: 600; color: #1a0e08; letter-spacing: .3px;
  background: linear-gradient(135deg, #ffa06b, var(--accent) 45%, var(--accent-2));
  box-shadow: 0 10px 26px rgba(255, 74, 100, .3), inset 0 1px 0 rgba(255, 255, 255, .35);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s, filter .2s;
}
.primary:active { transform: scale(.985); }
.primary[disabled] { filter: grayscale(.35) brightness(.75); box-shadow: none; }
.ghost {
  flex: 1; height: 46px; border-radius: 14px; font-size: 15px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .04); color: #dbe1ec;
}
.ghost:active { background: rgba(255, 255, 255, .08); }
.ghost.sm-btn { height: 42px; font-size: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.two > * { flex: 1; }
.mini-btn {
  border: 1px solid var(--line); background: rgba(255, 255, 255, .05);
  color: #c9d0dd; font-size: 12.5px; padding: 6px 11px; border-radius: 999px;
}
.btn-cost { font-size: 12px; font-weight: 500; opacity: .62; }
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(11, 12, 16, 0), rgba(11, 12, 16, .92) 26%, #0b0c10);
  max-width: 620px; margin: 0 auto;
}
.dock-hint { text-align: center; font-size: 12px; color: var(--muted); min-height: 18px; margin-bottom: 6px; }

/* ---------- 作品 ---------- */
.works-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 10px; }
.works-head h2 { font-size: 16px; margin: 0; font-weight: 600; }
.lock-tag { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.works { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.work {
  position: relative; border-radius: 16px; overflow: hidden; background: var(--card);
  border: 1px solid var(--line); aspect-ratio: 3 / 4;
}
.work img { width: 100%; height: 100%; object-fit: cover; display: block; }
.work .work-meta {
  position: absolute; inset: auto 0 0 0; padding: 24px 10px 9px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .78));
  font-size: 11px; color: #e5e9f2; display: flex; justify-content: space-between; gap: 6px;
}
.work .work-meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }
.empty-ico { font-size: 34px; opacity: .5; }
.empty p { margin: 10px 0 2px; color: #cfd6e3; }

/* ---------- 遮罩 / 弹层 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(7, 8, 11, .88); backdrop-filter: blur(14px);
}
.progress-wrap { text-align: center; padding: 0 28px; }
.ring {
  width: 168px; height: 168px; border-radius: 50%; margin: 0 auto 26px;
  background: conic-gradient(var(--accent) calc(var(--p, 0) * 1%), rgba(255, 255, 255, .07) 0);
  display: grid; place-items: center; position: relative;
  transition: background .4s linear;
}
.ring::after {
  content: ""; position: absolute; inset: -14px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 122, 69, .18), transparent 65%);
  animation: pulse 2.4s ease-in-out infinite; z-index: -1;
}
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: .7; } 50% { transform: scale(1.08); opacity: 1; } }
.ring-inner {
  width: 146px; height: 146px; border-radius: 50%; background: #0d0f15;
  display: grid; place-items: center; font-size: 30px; font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: -.5px;
}
.stage { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.sub { font-size: 13px; color: var(--muted); margin-bottom: 26px; font-variant-numeric: tabular-nums; }

.modal {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(4, 5, 8, .72); backdrop-filter: blur(10px);
}
.sheet {
  width: 100%; max-width: 620px; max-height: 90dvh; overflow-y: auto;
  background: #12151d; border: 1px solid var(--line); border-bottom: 0;
  border-radius: 26px 26px 0 0; padding: 18px 18px calc(20px + env(safe-area-inset-bottom));
  animation: slideUp .26s cubic-bezier(.2, .9, .3, 1);
}
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head b { font-size: 16px; }
.result-grid { display: grid; gap: 10px; }
.result-grid img { width: 100%; border-radius: 14px; display: block; background: #08090c; }
.result-grid.multi { grid-template-columns: 1fr 1fr; }
.actions { display: flex; gap: 10px; margin-top: 14px; }
.center { text-align: center; }
.mt { margin-top: 12px; }
.viewer-img-wrap { border-radius: 16px; overflow: hidden; background: #08090c; max-height: 58vh; display: grid; place-items: center; }
.viewer-img-wrap img { max-width: 100%; max-height: 58vh; object-fit: contain; }
.viewer-prompt { font-size: 13px; color: #c2cad8; background: rgba(255, 255, 255, .04); border-radius: 12px; padding: 10px 12px; word-break: break-word; }
.center-sheet { text-align: center; padding-top: 34px; }
.center-sheet h2 { margin: 0 0 8px; font-size: 20px; }

.setting { padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting-title { font-size: 12px; color: var(--muted); letter-spacing: .6px; text-transform: uppercase; margin-bottom: 8px; }
.setting-line { font-size: 13.5px; color: #c8cfdd; margin: 6px 0; line-height: 1.6; }
.link-list { display: flex; flex-direction: column; gap: 8px; }
.link-item {
  display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .045);
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px;
}
.link-item span { flex: 1; font-size: 12.5px; color: #aeb7c8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-item a { color: var(--accent); text-decoration: none; font-size: 12.5px; }
.token-box { display: flex; align-items: center; gap: 10px; background: rgba(0, 0, 0, .25); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.token-box span { flex: 1; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; letter-spacing: 1px; color: #ffcaae; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(56, 211, 159, .14); color: #6de7bb; border: 1px solid rgba(56, 211, 159, .25); }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 200; max-width: 86vw; padding: 11px 16px; border-radius: 14px;
  background: rgba(28, 32, 42, .96); border: 1px solid rgba(255, 255, 255, .1);
  color: #ecf0f7; font-size: 13.5px; text-align: center; box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
  animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
details.details summary { font-size: 13.5px; color: #c6cddc; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
details.details summary::after { content: "＋"; color: var(--muted); font-weight: 400; }
details.details[open] summary::after { content: "－"; }
