/* BugMachine 样式：移动优先，一套 CSS 同时伺候手机提交和电脑审批 */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #1c2024;
  --text-dim: #6b7280;
  --text-faint: #9aa1ab;
  --brand: #2f6bff;
  --brand-weak: #e8efff;
  --brand-dark: #1f4fd0;
  --ok: #16a34a;
  --ok-weak: #e7f7ed;
  --warn: #d97706;
  --warn-weak: #fdf3e3;
  --danger: #dc2626;
  --danger-weak: #fdeceb;
  --purple: #7c3aed;
  --purple-weak: #f1ebff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f24;
    --surface-2: #23272e;
    --border: #2d323a;
    --border-strong: #3c424c;
    --text: #e8eaed;
    --text-dim: #a1a8b3;
    --text-faint: #7b828d;
    --brand-weak: #1b2947;
    --ok-weak: #14301f;
    --warn-weak: #33260f;
    --danger-weak: #3a1a19;
    --purple-weak: #251a3d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

/*
 * 必须显式声明这条：
 * 浏览器的默认样式只有 [hidden] { display: none }，优先级极低，
 * 任何带 display 的类（.topbar { display:flex } 等）都会把它盖掉，
 * 导致 JS 设了 element.hidden = true 却依然显示 —— 这个坑非常隐蔽。
 */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.3; margin: 0 0 .5em; font-weight: 650; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0 0 .8em; }
code, pre { font-family: var(--mono); font-size: 13px; }
pre {
  background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm);
  overflow-x: auto; border: 1px solid var(--border);
}

/* ------------------------------- 顶栏 ------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 7px; font-weight: 700; color: var(--text); font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 18px; }
.nav { display: flex; gap: 2px; margin-left: 8px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 6px 12px; border-radius: 999px; color: var(--text-dim);
  font-size: 14px; white-space: nowrap; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--brand-weak); color: var(--brand); font-weight: 600; }
.nav a .pill-count {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 5px;
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 11px; line-height: 18px; text-align: center; font-weight: 600;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.who { color: var(--text-dim); font-size: 13px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.view { max-width: 1180px; margin: 0 auto; padding: 18px 16px 64px; }
@media (max-width: 560px) { .view { padding: 14px 12px 80px; } .brand-text { display: none; } .who { display: none; } }

/* ------------------------------- 卡片 ------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.card-tight { padding: 12px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { margin-left: auto; }
.grid { display: grid; gap: 14px; }
@media (min-width: 900px) {
  .grid-2 { grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); align-items: start; }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-tight { gap: 6px; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); font-size: 13px; }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.mt { margin-top: 12px; }
.mb0 { margin-bottom: 0; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }

/* ------------------------------- 表单 ------------------------------- */
label.field { display: block; margin-bottom: 14px; }
label.field > .label-text {
  display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 5px;
}
label.field > .label-text .req { color: var(--danger); margin-left: 2px; }
label.field .hint { font-size: 12px; color: var(--text-faint); font-weight: 400; margin-left: 6px; }
input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); outline: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%), linear-gradient(135deg, var(--text-faint) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
textarea { min-height: 90px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-weak); }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
.field-row { display: grid; gap: 12px; }
@media (min-width: 640px) { .field-row-2 { grid-template-columns: 1fr 1fr; } .field-row-3 { grid-template-columns: repeat(3, 1fr); } }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 14px; }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; accent-color: var(--brand); }

/* 分段选择（报障/想法、判定类型） */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label {
  position: relative; cursor: pointer; border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 500;
  color: var(--text-dim); background: var(--surface); user-select: none;
  transition: all .12s;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:hover { border-color: var(--brand); color: var(--brand); }
.seg input:checked + span { color: var(--brand); }
.seg label:has(input:checked) { background: var(--brand-weak); border-color: var(--brand); color: var(--brand); font-weight: 600; }

/* ------------------------------- 按钮 ------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; font: inherit; font-weight: 600; font-size: 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: background .12s, border-color .12s, transform .06s;
  min-height: 38px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); background: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 13px; min-height: 30px; }
.btn-lg { padding: 12px 22px; font-size: 16px; min-height: 46px; }
.btn-block { width: 100%; }
@media (max-width: 560px) { .btn-submit { width: 100%; } }

/* ------------------------------- 徽标 ------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--text-dim); border: 1px solid transparent;
  white-space: nowrap;
}
.badge-bug { background: var(--danger-weak); color: var(--danger); }
.badge-mechanism { background: var(--surface-2); color: var(--text-dim); }
.badge-suggestion { background: var(--purple-weak); color: var(--purple); }
.badge-pending { background: var(--warn-weak); color: var(--warn); }
.badge-duplicate, .badge-unclear { background: var(--surface-2); color: var(--text-dim); }
.badge-P0 { background: var(--danger); color: #fff; }
.badge-P1 { background: #ea580c; color: #fff; }
.badge-P2 { background: #ca8a04; color: #fff; }
.badge-P3 { background: var(--surface-2); color: var(--text-dim); }
.badge-idea { background: var(--warn-weak); color: var(--warn); }
.badge-new { background: var(--brand-weak); color: var(--brand); }
.badge-planned { background: var(--purple-weak); color: var(--purple); }
.badge-fixed, .badge-verified { background: var(--ok-weak); color: var(--ok); }
.badge-closed, .badge-rejected { background: var(--surface-2); color: var(--text-faint); }
.badge-reviewing { background: var(--warn-weak); color: var(--warn); }
.badge-sev-blocker { background: var(--danger); color: #fff; }
.badge-sev-high { background: var(--danger-weak); color: var(--danger); }

/* ------------------------------- 统计 ------------------------------- */
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; text-align: center;
}
.stat .n { font-size: 26px; font-weight: 700; line-height: 1.15; display: block; }
.stat .k { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.stat.is-action { cursor: pointer; }
.stat.is-action:hover { border-color: var(--brand); }

/* ------------------------------- 列表 ------------------------------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.item-row {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: border-color .12s, box-shadow .12s;
}
.item-row:hover { border-color: var(--brand); box-shadow: var(--shadow); text-decoration: none; }
.item-row .code { font-family: var(--mono); font-size: 12px; color: var(--text-faint); flex: none; padding-top: 2px; }
.item-row .main { min-width: 0; flex: 1; }
.item-row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row .meta { font-size: 12.5px; color: var(--text-dim); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 3px; }
.item-row .badges { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; flex: none; max-width: 45%; }
.item-row .advice-hint { font-size: 12.5px; color: var(--text-dim); margin-top: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
@media (max-width: 560px) {
  .item-row { flex-wrap: wrap; }
  .item-row .badges { max-width: 100%; justify-content: flex-start; }
}
.empty { text-align: center; padding: 40px 16px; color: var(--text-faint); }
.empty .big { font-size: 34px; display: block; margin-bottom: 8px; }

/* ------------------------------- 详情 ------------------------------- */
.kv { margin: 0 0 14px; }
.kv dt { font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 3px; }
.kv dd { margin: 0 0 12px; white-space: pre-wrap; word-break: break-word; }
.advice-box {
  border-left: 3px solid var(--brand); background: var(--brand-weak);
  padding: 12px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-bottom: 12px;
}
.advice-box.verdict-bug { border-left-color: var(--danger); background: var(--danger-weak); }
.advice-box.verdict-mechanism { border-left-color: var(--text-faint); background: var(--surface-2); }
.advice-box.verdict-suggestion { border-left-color: var(--purple); background: var(--purple-weak); }
.advice-box h4 { margin: 0 0 6px; font-size: 14px; }
.advice-box .body { white-space: pre-wrap; word-break: break-word; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.thumb {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-2); cursor: zoom-in; aspect-ratio: 4/3;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.thumb .tag {
  position: absolute; left: 4px; bottom: 4px; right: 4px;
  background: rgba(0, 0, 0, .62); color: #fff; font-size: 11px; padding: 2px 6px;
  border-radius: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.filelist { display: flex; flex-direction: column; gap: 6px; }
.filelist a {
  display: flex; gap: 8px; align-items: center; font-size: 13.5px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text);
}
.filelist a:hover { border-color: var(--brand); text-decoration: none; }

/* 评论区 */
.comment { display: flex; gap: 10px; padding: 11px 0; border-top: 1px solid var(--border); }
.comment .avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: var(--brand-weak); color: var(--brand);
}
.comment .avatar.is-admin { background: var(--warn-weak); color: var(--warn); }
.comment .body { flex: 1; min-width: 0; }
.comment .head { font-size: 13px; color: var(--text-dim); margin-bottom: 3px; display: flex; gap: 8px; align-items: center; }
.comment .head strong { color: var(--text); }
.comment .text { white-space: pre-wrap; word-break: break-word; }

/* 附件选择区 */
.attach-zone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  padding: 16px; text-align: center; color: var(--text-dim); background: var(--surface);
  cursor: pointer; transition: border-color .12s, background .12s;
}
.attach-zone:hover, .attach-zone.dragover { border-color: var(--brand); background: var(--brand-weak); }
.attach-zone .big { font-size: 22px; display: block; margin-bottom: 4px; }
.pending-files { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.pending-file {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: 13.5px;
}
.pending-file img { width: 40px; height: 40px; object-fit: cover; border-radius: 5px; flex: none; }
.pending-file .pf-main { flex: 1; min-width: 0; }
.pending-file .pf-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-file .pf-size { font-size: 12px; color: var(--text-faint); }
.progress { height: 3px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.progress > i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .15s; }

/* 弹层 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(12, 15, 20, .6); z-index: 100;
  display: grid; place-items: center; padding: 16px; backdrop-filter: blur(3px);
}
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-width: 900px; width: 100%; max-height: 92vh; overflow: auto; border: 1px solid var(--border);
}
.modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h3 { margin: 0; flex: 1; }
.modal-body { padding: 16px; }
.lightbox { position: fixed; inset: 0; z-index: 110; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 16px; }
.lightbox img, .lightbox video { max-width: 100%; max-height: 88vh; border-radius: 6px; }
.lightbox .lb-close { position: absolute; top: 14px; right: 14px; }
.lightbox .lb-name { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: #fff; font-size: 13px; opacity: .8; }

/* 工具条 */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.toolbar .tb-field { min-width: 130px; flex: 1 1 130px; }
.toolbar .tb-field > .label-text { font-size: 12px; }
.toolbar .tb-search { flex: 2 1 200px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  padding: 4px 11px; border-radius: 999px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--border-strong); cursor: pointer; background: var(--surface); color: var(--text-dim);
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.chip .c { opacity: .75; margin-left: 4px; font-size: 12px; }

/* 提示条 */
.toast-root { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #1c2024; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow-lg); max-width: 90vw; animation: toastIn .18s ease-out;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* 登录页 */
.auth-wrap { max-width: 420px; margin: 6vh auto 0; }
.auth-hero { text-align: center; margin-bottom: 18px; }
.auth-hero .logo { font-size: 42px; }
.auth-hero h1 { margin: 8px 0 4px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 16px; }
.tabs button {
  flex: 1; padding: 8px; border: 0; background: transparent; font: inherit; font-weight: 600;
  font-size: 14px; color: var(--text-dim); border-radius: 6px; cursor: pointer;
}
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* 导出页 */
.structure { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; font-family: var(--mono); font-size: 12.5px; line-height: 1.75; white-space: pre; overflow-x: auto; }
.export-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.export-item .ei-main { flex: 1; min-width: 0; }
.export-item .ei-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.export-item.no-advice { opacity: .72; }
.export-list { max-height: 420px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }

.banner {
  padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px;
  background: var(--warn-weak); color: var(--warn); font-size: 13.5px; border: 1px solid transparent;
}
.banner.info { background: var(--brand-weak); color: var(--brand); }
.banner.err { background: var(--danger-weak); color: var(--danger); }
.banner.ok { background: var(--ok-weak); color: var(--ok); }

kbd { background: var(--surface-2); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; font-size: 12px; font-family: var(--mono); }
