:root {
  --bg: #F6F3F4; --card: #FFFFFF; --ink: #1F1A1C; --muted: #6B6266; --line: #E6DFE2;
  --brand: #A4133C; --brand-ink: #FFFFFF; --rail: #1A1416; --chip: #F1E8EB;
  --p1: #B42318; --p2: #B54708; --p3: #475467; --ok: #067647; --warn: #B54708; --block: #B42318;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141012; --card: #1E191B; --ink: #F2ECEE; --muted: #A79DA1; --line: #332B2F;
          --chip: #2A2226; --rail: #0E0B0C; --shadow: none; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.top { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
       padding: 10px 16px; background: var(--rail); color: #fff; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-right: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.filters { display: flex; gap: 6px; }
.chip { border: 1px solid #4A3F44; background: transparent; color: #E9DDE2; border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
#search { flex: 1 1 160px; min-width: 120px; max-width: 320px; padding: 6px 10px; border-radius: 8px;
          border: 1px solid #4A3F44; background: #2A2226; color: #fff; }
.tools { display: flex; gap: 8px; margin-left: auto; align-items: center; }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.ghost { background: transparent; border-color: #4A3F44; color: inherit; }
.drawer .btn.ghost, .panel .btn.ghost { border-color: var(--line); }
.btn.small { padding: 3px 9px; font-size: 12px; }
.bell { position: relative; }
.bell b { position: absolute; top: -6px; right: -6px; background: var(--brand); color: #fff; border-radius: 999px;
          font-size: 11px; min-width: 18px; padding: 0 5px; text-align: center; }

.banner { margin: 12px 16px 0; padding: 10px 14px; border-radius: 10px; background: var(--chip); border: 1px solid var(--line); }

.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; padding: 16px; align-items: start; }
.col { background: transparent; }
.col h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px;
          display: flex; justify-content: space-between; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px;
        box-shadow: var(--shadow); cursor: pointer; text-align: left; width: 100%; }
.card:hover, .card:focus-visible { border-color: var(--brand); outline: none; }
.card .t { font-weight: 600; margin: 2px 0 6px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.tag { background: var(--chip); border-radius: 6px; padding: 1px 6px; }
.pri { font-weight: 700; } .pri.P1 { color: var(--p1); } .pri.P2 { color: var(--p2); } .pri.P3 { color: var(--p3); }
.dan { color: var(--brand); font-weight: 700; }
.new-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); display: inline-block; }
.empty { color: var(--muted); font-size: 12px; padding: 6px 2px; }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 9; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--card); z-index: 10;
          padding: 16px 18px 40px; overflow-y: auto; border-left: 1px solid var(--line); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.drawer h2 { margin: 6px 0 10px; font-size: 18px; }
.drawer h3 { font-size: 13px; margin: 18px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); flex: 1 1 120px; }
label.check { flex-direction: row; align-items: center; gap: 6px; flex: 0 0 auto; color: var(--ink); }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--bg); }
textarea { resize: vertical; width: 100%; }
.facts { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; margin: 14px 0; }
.facts dt { color: var(--muted); font-size: 12px; } .facts dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.facts a, .comments a { color: var(--brand); }
.addlink { display: flex; gap: 6px; } .addlink input { flex: 1; }
.comments { list-style: none; padding: 0; margin: 0; }
.comments li { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; }
.comments li.claude { border-color: var(--brand); }
.comments .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.comments .body { white-space: pre-wrap; word-break: break-word; }
.composer { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.form .btn { align-self: flex-end; }
.hist { margin-top: 14px; font-size: 12px; color: var(--muted); }
.hist ol { padding-left: 18px; }

.panel.feed { position: fixed; top: 56px; right: 12px; width: min(380px, calc(100% - 24px)); max-height: 70vh; overflow-y: auto;
              background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 8; padding: 10px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel-head h2 { font-size: 14px; margin: 4px 0; }
#feedList { list-style: none; padding: 0; margin: 6px 0 0; }
#feedList li { padding: 8px; border-radius: 8px; cursor: pointer; border-bottom: 1px solid var(--line); }
#feedList li.unread { background: var(--chip); }
#feedList time { display: block; font-size: 11px; color: var(--muted); }

.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--rail); color: #fff;
         padding: 8px 14px; border-radius: 8px; z-index: 20; max-width: calc(100% - 32px); }

@media (max-width: 1100px) { .board { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .board { grid-template-columns: 1fr; padding: 12px 16px; }
  .top { padding: 8px 16px; } #search { order: 5; max-width: none; flex-basis: 100%; }
}
