:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --line: #e2ddd2;
  --line-strong: #cfc8b8;
  --ink: #1c1a17;
  --ink-2: #4a463f;
  --ink-3: #7a7468;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9df;
  --ok: #15803d;
  --ok-soft: #e3f3e8;
  --warn: #b45309;
  --warn-soft: #fbf0dc;
  --info: #1d4ed8;
  --info-soft: #e3eafb;
  --muted-soft: #ebe8e1;
  --danger: #b91c1c;
  --danger-soft: #fbe4e4;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(28, 26, 23, .06), 0 4px 16px rgba(28, 26, 23, .05);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141311; --surface: #1c1b18; --surface-2: #23221e; --line: #2f2d28; --line-strong: #3f3c35;
    --ink: #eeeae2; --ink-2: #c4bfb4; --ink-3: #8f897d;
    --accent: #f97316; --accent-ink: #1a0f06; --accent-soft: #3a2113;
    --ok: #4ade80; --ok-soft: #15291c; --warn: #fbbf24; --warn-soft: #2f2410; --info: #93b4ff; --info-soft: #1a2340;
    --muted-soft: #2a2925; --danger: #f87171; --danger-soft: #331a1a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141311; --surface: #1c1b18; --surface-2: #23221e; --line: #2f2d28; --line-strong: #3f3c35;
  --ink: #eeeae2; --ink-2: #c4bfb4; --ink-3: #8f897d;
  --accent: #f97316; --accent-ink: #1a0f06; --accent-soft: #3a2113;
  --ok: #4ade80; --ok-soft: #15291c; --warn: #fbbf24; --warn-soft: #2f2410; --info: #93b4ff; --info-soft: #1a2340;
  --muted-soft: #2a2925; --danger: #f87171; --danger-soft: #331a1a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 var(--sans); min-height: 100vh; display: flex; flex-direction: column; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.3; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* 顶栏 */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1080px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); position: relative; flex: none; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; left: 7px; height: 3px; border-radius: 2px; background: var(--accent-ink); }
.brand-mark::before { top: 9px; width: 16px; box-shadow: 0 6px 0 var(--accent-ink); }
.brand-mark::after { top: 21px; width: 9px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 16px; }
.brand-text small { color: var(--ink-3); font-size: 11px; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a:not(.btn) { text-decoration: none; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--ink-2); font-size: 14px; }
.nav a:not(.btn):hover { background: var(--surface-2); color: var(--ink); }
.nav a.active:not(.btn) { color: var(--ink); background: var(--surface-2); font-weight: 600; }
.who { max-width: 1080px; margin: 0 auto; padding: 0 16px 8px; font-size: 13px; color: var(--ink-3); display: flex; gap: 8px; align-items: center; }
.who b { color: var(--ink-2); }

.page { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 16px 48px; }
.foot { max-width: 1080px; width: 100%; margin: 0 auto; padding: 20px 16px 32px; color: var(--ink-3); font-size: 13px; display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); }
.foot-admin { color: var(--ink-3); text-decoration: none; }
.foot-admin:hover { color: var(--ink); }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); text-decoration: none; cursor: pointer; font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s; }
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.06); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-danger { color: var(--danger); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 首页 */
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: end; margin-bottom: 28px; }
.hero h1 { font-size: 30px; }
.hero p { color: var(--ink-2); margin: 8px 0 0; max-width: 520px; }
.hero-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stat { padding: 14px 16px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat span { font-size: 12px; color: var(--ink-3); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 4px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.filters select, .filters input { height: 34px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); font-size: 13px; }
.filters input { min-width: 180px; flex: 1; max-width: 280px; }
.spacer { flex: 1; }

/* 工单列表 */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: grid; grid-template-columns: 92px 1fr auto; gap: 14px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); text-decoration: none; transition: background .12s; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row .no { font-family: var(--mono); font-size: 13px; color: var(--ink-3); }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.row .right { display: flex; align-items: center; gap: 10px; }
.votes { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.empty { padding: 48px 16px; text-align: center; color: var(--ink-3); }
.empty b { display: block; color: var(--ink-2); font-size: 16px; margin-bottom: 4px; }
.pager { display: flex; justify-content: center; gap: 8px; margin-top: 16px; align-items: center; font-size: 13px; color: var(--ink-3); }

/* 标签 */
.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--muted-soft); color: var(--ink-2); }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.tag.plain::before { display: none; }
.st-pending, .st-need_info { background: var(--warn-soft); color: var(--warn); }
.st-confirmed, .st-planned, .st-doing, .st-testing { background: var(--info-soft); color: var(--info); }
.st-released, .st-answered { background: var(--ok-soft); color: var(--ok); }
.st-rejected, .st-duplicate, .st-cannot_reproduce, .st-closed { background: var(--muted-soft); color: var(--ink-3); }
.ty { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.ty-bug { color: var(--danger); }
.ty-feature { color: var(--accent); }
.pr { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--ink-3); }
.pr-P0 { border-color: var(--danger); color: var(--danger); }
.pr-P1 { border-color: var(--warn); color: var(--warn); }

/* 提交：类型选择 */
.steps-head { margin-bottom: 20px; }
.steps-head h1 { font-size: 24px; }
.steps-head p { color: var(--ink-2); margin: 6px 0 0; }
.types { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.type-card { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; transition: border-color .15s, box-shadow .15s, transform .15s; }
.type-card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.type-card b { font-size: 17px; }
.type-card span { color: var(--ink-2); font-size: 14px; }
.type-card em { font-style: normal; font-size: 12px; color: var(--ink-3); margin-top: 6px; }

/* 表单 */
.form { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 16px; margin-bottom: 14px; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.f { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.f.wide { grid-column: 1 / -1; }
.f label { font-size: 13px; font-weight: 600; color: var(--ink-2); display: flex; gap: 6px; align-items: baseline; }
.f label .req { color: var(--accent); }
.f label .count { margin-left: auto; font-weight: 400; color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.f label .count.low { color: var(--warn); }
.f input, .f select, .f textarea { width: 100%; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 14px; transition: border-color .15s, box-shadow .15s; }
.f textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.f textarea.tall { min-height: 140px; }
.f input:focus, .f select:focus, .f textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.f .hint { font-size: 12px; color: var(--ink-3); }
.f.bad input, .f.bad select, .f.bad textarea { border-color: var(--danger); }
.f .err { font-size: 12px; color: var(--danger); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); }

.drop { border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 16px; text-align: center; color: var(--ink-3); font-size: 13px; cursor: pointer; transition: border-color .15s, background .15s; }
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--ink-2); }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumb { position: relative; width: 84px; height: 84px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; font-size: 14px; line-height: 1; }

.aside { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 12px; }
.aside .card { padding: 16px; }
.aside h3 { font-size: 14px; margin-bottom: 8px; }
.aside ol, .aside ul { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 13px; }
.aside li + li { margin-top: 4px; }
.similar a { display: block; font-size: 13px; padding: 6px 0; border-top: 1px solid var(--line); text-decoration: none; }
.similar a:hover { color: var(--accent); }
.similar .no { font-family: var(--mono); color: var(--ink-3); margin-right: 6px; }
.formbar { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 16px; }
.formerr { color: var(--danger); font-size: 14px; margin-right: auto; }

/* 提交成功 */
.done { max-width: 560px; margin: 24px auto; text-align: center; }
.done .seal { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; animation: pop .4s cubic-bezier(.2, 1.4, .4, 1); }
.done .seal svg { width: 30px; height: 30px; }
.ticket-slip { margin: 22px 0; display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-align: left; }
.ticket-slip div { padding: 14px 18px; }
.ticket-slip div + div { border-left: 1px dashed var(--line-strong); }
.ticket-slip span { display: block; font-size: 12px; color: var(--ink-3); }
.ticket-slip b { font-family: var(--mono); font-size: 22px; letter-spacing: .04em; }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; text-align: left; }

/* 工单详情 */
.detail { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
.dhead { margin-bottom: 18px; }
.dhead .meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--ink-3); margin-bottom: 8px; }
.dhead .meta .no { font-family: var(--mono); }
.dhead h1 { font-size: 24px; }
.track { display: grid; grid-template-columns: repeat(6, 1fr); margin: 18px 0 4px; }
.track .s { position: relative; padding-top: 18px; font-size: 12px; color: var(--ink-3); text-align: center; }
.track .s::before { content: ""; position: absolute; top: 5px; left: 0; right: 0; height: 2px; background: var(--line); }
.track .s:first-child::before { left: 50%; }
.track .s:last-child::before { right: 50%; }
.track .s::after { content: ""; position: absolute; top: 0; left: calc(50% - 6px); width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong); }
.track .s.done { color: var(--ink-2); }
.track .s.done::before { background: var(--accent); }
.track .s.done::after { background: var(--accent); border-color: var(--accent); }
.track .s.now { color: var(--ink); font-weight: 600; }
.track .s.now::after { box-shadow: 0 0 0 4px var(--accent-soft); }
.track .s.done + .s:not(.done)::before { background: linear-gradient(90deg, var(--accent) 50%, var(--line) 50%); }
.endnote { margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13px; color: var(--ink-2); }

.fields dl { margin: 0; display: grid; gap: 14px; }
.fields dt { font-size: 12px; font-weight: 600; color: var(--ink-3); margin-bottom: 3px; }
.fields dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.fields .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.locked { display: flex; gap: 12px; align-items: center; color: var(--ink-2); font-size: 14px; }
.locked svg { flex: none; color: var(--ink-3); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; left: 0; top: 5px; width: 15px; height: 15px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong); }
.timeline .dot.admin { border-color: var(--accent); background: var(--accent-soft); }
.timeline .dot.sys { border-color: var(--info); }
.timeline .head { font-size: 13px; color: var(--ink-3); }
.timeline .head b { color: var(--ink-2); }
.timeline .body { margin-top: 6px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.timeline .body.admin { background: var(--accent-soft); }
.timeline .body.internal { background: transparent; border: 1px dashed var(--line-strong); }
.timeline .imgs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.timeline .imgs a { display: block; width: 120px; height: 84px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); }
.timeline .imgs img { width: 100%; height: 100%; object-fit: cover; }

.side-meta { display: grid; gap: 10px; font-size: 13px; }
.side-meta div { display: flex; justify-content: space-between; gap: 8px; }
.side-meta span { color: var(--ink-3); }
.side-meta b { font-weight: 600; text-align: right; }
.vote { width: 100%; }
.vote.on { border-color: var(--accent); color: var(--accent); }

.keybox { display: flex; gap: 8px; }
.keybox input { flex: 1; text-transform: uppercase; font-family: var(--mono); letter-spacing: .05em; }

.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 14px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.login { max-width: 360px; margin: 40px auto; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-sm); font-size: 14px; box-shadow: var(--shadow); z-index: 50; animation: rise .2s ease-out; max-width: calc(100% - 32px); }
.toast.bad { background: var(--danger); color: #fff; }

.skeleton { height: 60px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }

.view { animation: fadein .18s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media (max-width: 860px) {
  .hero, .form, .detail { grid-template-columns: 1fr; }
  .aside { position: static; }
}
@media (max-width: 600px) {
  .page { padding-top: 20px; }
  .hero h1 { font-size: 24px; }
  .types, .fgrid, .fields .pair, .admin-grid { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr auto; }
  .row .no { grid-column: 1 / -1; }
  .brand-text small { display: none; }
  .top-inner { gap: 8px; }
  .brand-text b, .nav a { white-space: nowrap; }
  .nav a:not(.btn) { padding: 6px 7px; }
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg button { white-space: nowrap; flex: none; }
  .filters select { flex: none; }
  .filters input { max-width: none; }
  .track .s { font-size: 11px; }
  .ticket-slip { grid-template-columns: 1fr; }
  .ticket-slip div + div { border-left: 0; border-top: 1px dashed var(--line-strong); }
  .foot { flex-direction: column; }
}
