:root {
  color-scheme: light dark;
  --paper: #f3f6f1;
  --surface: #ffffff;
  --surface-soft: #edf2ec;
  --ink: #14251f;
  --muted: #617069;
  --line: #d4ded6;
  --line-strong: #aabbb0;
  --accent: #0d694e;
  --accent-strong: #07533d;
  --accent-soft: #dbeee5;
  --on-accent: #ffffff;
  --warning: #78541a;
  --warning-soft: #f5ead1;
  --danger: #9a342d;
  --danger-soft: #f7e3df;
  --blue: #245b78;
  --blue-soft: #dfedf4;
  --shadow: 0 12px 32px rgb(24 52 40 / 0.09);
  --topbar-height: 110px;
  --progress-height: 68px;
  font-family: "Noto Sans SC Variable", "Noto Sans SC", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; min-height: 100vh; background: var(--paper); }
body.drawer-open, body.detail-open { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button, select, input { min-height: 44px; }
button { cursor: pointer; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: 0.48; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgb(13 105 78 / 0.28); outline-offset: 2px; }
[hidden] { display: none !important; }
.mobile-action, .mobile-progress-summary, .mobile-filter-title, .mobile-bulk-bar, .mobile-save-state { display: none; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 10px 14px; transform: translateY(-160%); border-radius: 7px; background: var(--ink); color: white; }
.skip-link:focus { transform: none; }
.eyebrow { color: var(--accent-strong); font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }

.login-layer { position: fixed; inset: 0; z-index: 80; padding: 24px; display: grid; place-items: center; background: radial-gradient(circle at 18% 8%, #d9ebe1, transparent 38%), var(--paper); }
.login-card { width: min(460px, 100%); padding: 30px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.login-card h1 { margin: 8px 0; font-size: 28px; letter-spacing: -0.04em; }
.login-card p { color: var(--muted); line-height: 1.65; }
.login-card label { display: block; margin: 22px 0 7px; font-size: 13px; font-weight: 760; }
.login-card input { width: 100%; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); letter-spacing: 0.03em; }
.login-card > button { width: 100%; margin-top: 12px; }
.login-card aside { margin-top: 22px; padding: 12px; border: 1px solid #cdbb8c; border-radius: 8px; background: var(--warning-soft); color: var(--warning); font-size: 12px; line-height: 1.6; }
.login-status { min-height: 24px; margin: 8px 0 0 !important; color: var(--danger) !important; font-size: 13px; }

.topbar { position: sticky; top: 0; z-index: 30; min-height: var(--topbar-height); padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line-strong); background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(14px); }
.brand-block h1 { margin: 2px 0; font-size: 24px; letter-spacing: -0.03em; }
.brand-block p { margin: 0; max-width: 720px; color: var(--muted); font-size: 13px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.role-badge { min-height: 30px; padding: 4px 10px; display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--accent-strong); font-size: 12px; font-weight: 760; white-space: nowrap; }
.save-state { color: var(--muted); font-size: 13px; white-space: nowrap; }
.save-state[data-tone="success"] { color: var(--accent-strong); }
.save-state[data-tone="error"] { color: var(--danger); }
.complete-button, .primary-button { padding: 0 16px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); color: var(--on-accent); font-weight: 760; white-space: nowrap; }
.secondary-button, .menu-button { padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); white-space: nowrap; }

.progress-strip { position: sticky; top: var(--topbar-height); z-index: 25; min-height: var(--progress-height); padding: 10px 24px; display: grid; grid-template-columns: minmax(540px, auto) minmax(220px, 1fr); align-items: center; gap: 22px; border-bottom: 1px solid var(--line); background: var(--surface); }
.desktop-progress-metrics { display: grid; grid-template-columns: repeat(6, minmax(72px, 105px)); gap: 12px; }
.desktop-progress-metrics > div { display: flex; align-items: baseline; gap: 5px; }
.progress-strip strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.progress-strip span { color: var(--muted); font-size: 12px; }
.remaining strong { color: var(--warning); }
.team-progress { display: grid; gap: 6px; }
.progress-meter { height: 5px; overflow: hidden; border-radius: 999px; background: var(--line); }
.progress-meter i { display: block; width: 0; height: 100%; background: var(--accent); transition: width 160ms ease; }

.workspace { min-height: calc(100vh - var(--topbar-height) - var(--progress-height)); display: grid; grid-template-columns: 260px minmax(460px, 1fr) minmax(340px, 420px); }
.filters, .detail-panel { position: sticky; top: calc(var(--topbar-height) + var(--progress-height)); height: calc(100vh - var(--topbar-height) - var(--progress-height)); overflow: auto; }
.filters { padding: 20px; border-right: 1px solid var(--line); background: var(--surface-soft); }
.filter-heading { margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }
.filter-fields label { margin-bottom: 14px; display: grid; gap: 6px; }
.filter-fields label > span { color: var(--muted); font-size: 12px; font-weight: 720; }
.filter-fields input, .filter-fields select, .detail-panel textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: var(--ink); }
.filter-fields input, .filter-fields select { padding: 0 11px; }
.text-button { min-height: 44px; padding: 0 8px; border: 0; background: transparent; color: var(--accent-strong); font-weight: 720; }
.truth-box { margin-top: 20px; padding: 13px; border: 1px solid #cdbb8c; border-radius: 8px; background: var(--warning-soft); color: var(--warning); }
.truth-box p { margin: 6px 0 0; font-size: 12px; line-height: 1.6; }

.review-column { min-width: 0; padding: 18px 20px 28px; }
.list-toolbar { min-height: 52px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#result-count { font-size: 18px; }
.bulk-controls { display: flex; align-items: center; gap: 7px; }
.bulk-controls button, .pagination button { padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); }
.select-all { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.select-all input, .card-select { width: 18px; height: 18px; accent-color: var(--accent); }
.review-list { display: grid; gap: 9px; }
.review-card { padding: 13px 14px; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); transition: border-color 120ms ease, box-shadow 120ms ease; }
.review-card:hover, .review-card.is-active { border-color: var(--accent); box-shadow: var(--shadow); }
.review-card.is-selected { box-shadow: inset 3px 0 0 var(--accent); }
.card-main { min-width: 0; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; }
.card-kicker { margin-bottom: 4px; display: flex; flex-wrap: wrap; gap: 6px; }
.badge { min-height: 23px; padding: 3px 7px; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; font-weight: 720; }
.badge.public { background: var(--blue-soft); color: var(--blue); }
.badge.hypothesis { background: var(--warning-soft); color: var(--warning); }
.badge.featured { background: var(--accent-soft); color: var(--accent-strong); }
.badge.owner { background: var(--surface-soft); color: var(--ink); }
.card-main h2 { margin: 0; font-size: 16px; line-height: 1.45; }
.card-main p { margin: 5px 0 0; overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.card-status { min-width: 76px; align-self: center; text-align: right; font-size: 12px; font-weight: 800; }
.status-approved { color: var(--accent-strong); }
.status-needs_revision { color: var(--warning); }
.status-rejected { color: var(--danger); }
.status-deferred { color: var(--blue); }
.status-unreviewed { color: var(--muted); }
.pagination { min-height: 58px; display: flex; justify-content: center; align-items: center; gap: 12px; }
.pagination span { color: var(--muted); font-size: 13px; }

.detail-panel { padding: 20px; border-left: 1px solid var(--line); background: var(--surface); }
.detail-panel[aria-hidden="true"] { visibility: visible; }
.empty-detail { margin-top: 40px; color: var(--muted); }
.empty-detail h2 { color: var(--ink); font-size: 22px; }
.mobile-detail-nav { display: none; }
.detail-head { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.detail-head h2 { margin: 8px 0; font-size: 23px; line-height: 1.42; letter-spacing: -0.02em; }
.detail-head p, .detail-section p, .detail-section li { color: var(--muted); font-size: 13px; line-height: 1.65; }
.detail-section { padding: 15px 0; border-bottom: 1px solid var(--line); }
.detail-section h3 { margin: 0 0 7px; font-size: 13px; }
.detail-section p { margin: 0; }
.detail-section ul { margin: 0; padding-left: 20px; }
.source-link { color: var(--accent-strong); font-size: 13px; font-weight: 720; text-underline-offset: 3px; }
.source-limit { margin-top: 6px !important; }
.detail-panel textarea { min-height: 88px; padding: 10px; resize: vertical; }
.decision-hint { min-height: 20px; margin: 5px 0 0 !important; color: var(--danger) !important; }
.decision-actions { padding-top: 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.decision-actions button { border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: var(--ink); font-weight: 740; }
.decision-actions .approve { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.decision-actions .revision { background: var(--warning-soft); color: var(--warning); }
.decision-actions .reject { background: var(--danger-soft); color: var(--danger); }
.decision-actions .defer { background: var(--blue-soft); color: var(--blue); }
.decision-actions .clear { grid-column: 1 / -1; }
.mobile-label { display: none; }

dialog { max-width: 460px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--ink); }
dialog::backdrop { background: rgb(10 25 19 / 0.58); backdrop-filter: blur(2px); }
.dialog-card { padding: 24px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.dialog-card h2 { margin: 7px 0; }
.dialog-card p { color: var(--muted); line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }
.account-actions { display: grid; gap: 8px; }
.account-actions button { width: 100%; }
.error-banner { padding: 16px; border: 1px solid #d6a19b; border-radius: 8px; background: var(--danger-soft); color: var(--danger); }

@media (max-width: 1080px) and (min-width: 1024px) {
  .workspace { grid-template-columns: 230px minmax(430px, 1fr); }
  .detail-panel { position: fixed; inset: calc(var(--topbar-height) + var(--progress-height)) 0 0 auto; z-index: 35; width: min(420px, 92vw); height: auto; box-shadow: -16px 0 36px rgb(10 25 19 / 0.2); transform: translateX(105%); transition: transform 140ms ease; }
  .detail-panel.is-open { transform: none; }
}

@media (max-width: 1023px) {
  :root { --topbar-height: 64px; --progress-height: 99px; }
  .mobile-action, .mobile-progress-summary, .mobile-filter-title { display: initial; }
  .desktop-action, .desktop-progress-metrics, .desktop-bulk, .desktop-reset { display: none !important; }
  .topbar { min-height: var(--topbar-height); padding: 9px 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .brand-block .eyebrow, .brand-block p { display: none; }
  .brand-block h1 { margin: 0; overflow: hidden; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
  .header-actions { display: flex; align-items: center; gap: 7px; }
  .role-badge { min-height: 26px; padding: 2px 8px; font-size: 11px; }
  .menu-button { min-height: 44px; padding: 0 11px; }
  .save-state { display: none; }

  .progress-strip { min-height: var(--progress-height); padding: 9px 12px; display: grid; grid-template-columns: 1fr; gap: 7px; }
  .mobile-progress-summary { display: grid; grid-template-columns: minmax(72px, 1fr) minmax(72px, 1fr) auto; align-items: end; gap: 8px; }
  .mobile-progress-summary > div { display: grid; gap: 1px; }
  .mobile-progress-summary strong { font-size: 16px; }
  .mobile-progress-summary span { font-size: 10px; }
  .mobile-progress-summary button { min-height: 44px; padding: 0 12px; border: 1px solid var(--accent); border-radius: 7px; background: var(--surface); color: var(--accent-strong); font-weight: 760; }
  #active-filter-count { min-width: 20px; min-height: 20px; margin-left: 3px; padding: 1px 5px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 10px; }
  .team-progress { gap: 0; }
  .team-progress > span:first-child { display: none; }
  .mobile-save-state { display: block; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-save-state[data-tone="success"] { color: var(--accent-strong); }
  .mobile-save-state[data-tone="error"] { color: var(--danger); }

  .workspace { min-height: calc(100vh - var(--topbar-height) - var(--progress-height)); display: block; }
  .filter-scrim { position: fixed; inset: 0; z-index: 49; border: 0; background: rgb(10 25 19 / 0.52); }
  .filters { position: fixed; inset: auto 0 0; z-index: 50; width: 100%; height: min(78dvh, 700px); padding: 18px 16px max(16px, env(safe-area-inset-bottom)); overflow: auto; border: 1px solid var(--line-strong); border-bottom: 0; border-radius: 12px 12px 0 0; background: var(--surface-soft); box-shadow: 0 -18px 40px rgb(10 25 19 / 0.22); transform: translateY(105%); visibility: hidden; transition: transform 160ms ease, visibility 160ms ease; }
  .filters.is-open { transform: none; visibility: visible; }
  .filter-heading { position: sticky; top: -18px; z-index: 2; margin: -18px -16px 14px; padding: 16px; border-bottom: 1px solid var(--line); background: var(--surface-soft); }
  .filter-heading > div { display: grid; gap: 3px; }
  .mobile-filter-title { font-size: 17px; }
  .close-filter { min-height: 44px; padding: 0 10px; border: 0; background: transparent; color: var(--accent-strong); font-weight: 760; }
  .filter-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
  .filter-fields label { min-width: 0; margin: 0; }
  .filter-fields label:first-child { grid-column: 1 / -1; }
  .filter-fields input, .filter-fields select { min-width: 0; }
  .truth-box { margin: 14px 0 0; }
  .filter-footer { position: sticky; bottom: calc(-1 * max(16px, env(safe-area-inset-bottom))); z-index: 2; margin: 14px -16px calc(-1 * max(16px, env(safe-area-inset-bottom))); padding: 12px 16px max(12px, env(safe-area-inset-bottom)); grid-template-columns: 1fr 1.5fr; gap: 8px; border-top: 1px solid var(--line); background: var(--surface); }
  .filters.is-open .filter-footer { display: grid; }

  .review-column { padding: 10px 12px 24px; }
  .list-toolbar { position: sticky; top: calc(var(--topbar-height) + var(--progress-height)); z-index: 18; min-height: 52px; margin: 0 -12px 10px; padding: 4px 12px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 96%, transparent); backdrop-filter: blur(10px); }
  .mobile-select-toggle { min-height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: var(--accent-strong); font-weight: 760; }
  .review-list { gap: 8px; }
  .review-card { grid-template-columns: minmax(0, 1fr) auto; padding: 12px; gap: 7px 10px; }
  .card-select { display: none; }
  body.multi-select-mode .review-card { grid-template-columns: 24px minmax(0, 1fr) auto; }
  body.multi-select-mode .card-select { display: block; align-self: center; }
  .card-main { min-height: 44px; }
  .card-kicker { gap: 4px; }
  .badge { min-height: 21px; padding: 2px 6px; font-size: 10px; }
  .card-main h2 { font-size: 15px; }
  .card-main p { margin-top: 4px; }
  .card-status { min-width: auto; align-self: start; padding-top: 3px; font-size: 11px; text-align: right; white-space: nowrap; }
  .pagination { padding-bottom: 16px; }

  .detail-panel { position: fixed; inset: 0; z-index: 70; width: 100%; height: 100dvh; padding: 0 16px calc(144px + env(safe-area-inset-bottom)); overflow: auto; border: 0; background: var(--surface); transform: translateX(105%); visibility: hidden; transition: transform 160ms ease, visibility 160ms ease; }
  .detail-panel[aria-hidden="true"] { visibility: hidden; }
  .detail-panel.is-open { transform: none; visibility: visible; }
  .mobile-detail-nav { position: sticky; top: 0; z-index: 4; margin: 0 -16px 12px; padding: 8px 12px; display: grid; grid-template-columns: 1fr auto auto; gap: 7px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(10px); }
  .mobile-detail-nav button { min-height: 44px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); }
  .mobile-detail-nav .close-detail { justify-self: start; border-color: var(--accent); color: var(--accent-strong); font-weight: 760; }
  .detail-head > .close-detail { display: none; }
  .detail-head h2 { font-size: 22px; }
  .detail-section { padding: 14px 0; }
  .decision-actions { position: fixed; inset: auto 0 0; z-index: 5; padding: 9px 12px max(9px, env(safe-area-inset-bottom)); grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; border-top: 1px solid var(--line-strong); background: color-mix(in srgb, var(--surface) 96%, transparent); box-shadow: 0 -10px 28px rgb(10 25 19 / 0.12); backdrop-filter: blur(12px); }
  .decision-actions button { min-width: 0; min-height: 48px; padding: 0 4px; font-size: 13px; }
  .decision-actions .save-note { grid-column: 1 / 3; }
  .decision-actions .clear { grid-column: 3 / 5; }
  .desktop-label { display: none; }
  .mobile-label { display: inline; }

  .mobile-bulk-bar { position: fixed; inset: auto 0 0; z-index: 45; padding: 9px 12px max(9px, env(safe-area-inset-bottom)); grid-template-columns: auto 1fr auto; gap: 7px; border-top: 1px solid var(--line-strong); background: var(--surface); box-shadow: 0 -10px 28px rgb(10 25 19 / 0.14); }
  .mobile-bulk-bar:not([hidden]) { display: grid; }
  .mobile-bulk-bar strong { align-self: center; font-size: 12px; }
  .mobile-bulk-bar button { min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); white-space: nowrap; }
  #mobile-clear-selection { grid-column: 3; grid-row: 1; }
  #mobile-bulk-approved { grid-column: 1 / 3; grid-row: 2; border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
  #mobile-bulk-deferred { grid-column: 3; grid-row: 2; background: var(--blue-soft); color: var(--blue); }
  body.multi-select-mode .review-column { padding-bottom: 126px; }

  dialog { width: calc(100% - 28px); max-width: 460px; }
  .dialog-card { padding: 20px; }
  .dialog-actions { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (prefers-color-scheme: dark) {
  :root { --paper: #07140f; --surface: #0e2119; --surface-soft: #10291f; --ink: #edf7f0; --muted: #9fb3a8; --line: #254438; --line-strong: #416456; --accent: #62c7a3; --accent-strong: #86ddbe; --accent-soft: #183f31; --on-accent: #07140f; --warning: #e6c47e; --warning-soft: #493919; --danger: #f0a39a; --danger-soft: #48231f; --blue: #9acbe5; --blue-soft: #153445; --shadow: 0 14px 36px rgb(0 0 0 / 0.32); }
  .login-layer { background: radial-gradient(circle at 18% 8%, #143c2d, transparent 38%), var(--paper); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
