:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1d2129;
  --muted: #6b7280;
  --line: #e3e5e8;
  --primary: #1f6feb;
  --primary-ink: #ffffff;
  --must: #d93a3a;
  --must-bg: #fdecec;
  --suggest: #b7791f;
  --suggest-bg: #fdf4e3;
  --ok: #1f8a4c;
  --ok-bg: #e7f6ed;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --card: #1e2125;
    --text: #e6e8eb;
    --muted: #9aa1ab;
    --line: #30343a;
    --primary: #4c8dff;
    --must: #ff6b6b;
    --must-bg: #3a2224;
    --suggest: #e3a43c;
    --suggest-bg: #372c1b;
    --ok: #4cc27c;
    --ok-bg: #1c3226;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 16px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); white-space: nowrap; }
.topbar nav { display: flex; gap: 4px; overflow-x: auto; }
.topbar nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.topbar nav a.on { background: var(--bg); color: var(--text); font-weight: 600; }

.footer { text-align: center; padding: 16px; font-size: 12px; }
.footer a { color: var(--muted); }

h1 { font-size: 20px; margin: 4px 0 12px; }
h2 { font-size: 16px; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

button, .btn {
  font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
button.danger { color: var(--must); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.link { border: none; background: none; color: var(--primary); padding: 4px 6px; }

input[type=text], input[type=password], textarea, select {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
textarea.editor { min-height: 60vh; resize: vertical; line-height: 1.8; font-size: 16px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); }
.item:hover { border-color: var(--muted); }
.item .title { font-weight: 600; }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--bg);
  color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.drafting { color: var(--suggest); background: var(--suggest-bg); border-color: transparent; }
.badge.pending_owner { color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); border-color: transparent; }
.badge.final { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.badge.must { color: var(--must); background: var(--must-bg); border-color: transparent; }
.badge.suggest { color: var(--suggest); background: var(--suggest-bg); border-color: transparent; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.side { position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow: auto; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
  textarea.editor { min-height: 50vh; }
}

.issue { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--card); }
.issue.must { border-left: 4px solid var(--must); }
.issue.suggest { border-left: 4px solid var(--suggest); }
.issue.done { opacity: .55; }
.issue .quote { background: var(--bg); padding: 4px 8px; border-radius: 6px; margin: 6px 0; cursor: pointer; font-size: 14px; }
.issue .quote:hover { outline: 1px solid var(--primary); }
.issue .sugg { color: var(--ok); }
.issue .actions { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.banner { padding: 10px 12px; border-radius: var(--radius); background: var(--suggest-bg); color: var(--text); }
.banner.info { background: color-mix(in srgb, var(--primary) 12%, transparent); }

.readonly { white-space: pre-wrap; line-height: 1.9; font-size: 16px; }
.pair { padding: 10px 12px; }
.pair .b { color: var(--must); text-decoration: line-through; text-decoration-thickness: 1px; }
.pair .a { color: var(--ok); }
.pair .b, .pair .a { white-space: pre-wrap; }

.login { max-width: 360px; margin: 10vh auto 0; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; z-index: 99; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.loading { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 50; }
.loading .card { text-align: center; max-width: 300px; }
.spin { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%;
  animation: spin 1s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.hide-owner .owner-only { display: none !important; }
details summary { cursor: pointer; color: var(--muted); }
[hidden] { display: none !important; }
