:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #172b4d;
  --muted: #6b778c;
  --line: #e2e4e9;
  --green: #22a06b;
  --red: #d1453b;
  --amber: #b98900;
  --blue: #1668dc;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(9,30,66,.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  display: flex; flex-direction: column;
}

/* ── header ── */
header { padding: 10px 16px 0; background: var(--bg); position: sticky; top: 0; z-index: 20; }
.topbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h1 { font-size: 20px; margin: 0 4px 0 0; }
.updated { color: var(--muted); font-size: 12px; }
.due-chips { display: flex; gap: 6px; }
.due-chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 20px;
  padding: 3px 10px; font-size: 12px; cursor: pointer; user-select: none;
}
.due-chip.overdue { color: var(--red); border-color: #f2c4c0; }
.due-chip.today { color: var(--amber); border-color: #ecdfae; }
.due-chip.week { color: var(--blue); border-color: #bcd4f6; }
.due-chip.on { outline: 2px solid currentColor; }
#search { flex: 1 1 120px; min-width: 110px; }
input, select, textarea {
  font: inherit; color: inherit; background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #a5c8f3; border-color: #a5c8f3; }
button { font: inherit; border: none; border-radius: 8px; padding: 7px 14px; cursor: pointer; }
.btn-primary { background: var(--green); color: #fff; font-weight: 600; }
.btn-ok { background: #e3fcef; color: var(--green); font-weight: 600; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #ebecf0; }

/* ── tabs ── */
.tabs { display: flex; gap: 6px; margin: 10px 0; overflow-x: auto; padding-bottom: 2px; }
.tab {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 20px; padding: 5px 14px; white-space: nowrap; font-size: 13px;
}
.tab .n { color: var(--muted); margin-left: 5px; font-size: 12px; }
.tab.on { background: #172b4d; color: #fff; border-color: #172b4d; }
.tab.on .n { color: #c3cad6; }

/* ── board ── */
.board {
  display: flex; gap: 12px; padding: 4px 16px 16px;
  overflow-x: auto; align-items: flex-start; flex: 1;
}
.column {
  background: #eef0f3; border-radius: var(--radius);
  min-width: 272px; max-width: 272px; display: flex; flex-direction: column;
  max-height: calc(100vh - 130px);
}
.col-head {
  padding: 10px 12px 8px; font-weight: 700; font-size: 13px;
  border-top: 3px solid var(--green); border-radius: var(--radius) var(--radius) 0 0;
  display: flex; justify-content: space-between; align-items: center;
}
.col-head .cnt { color: var(--muted); font-weight: 400; font-size: 12px; }
.col-body { padding: 4px 8px 8px; overflow-y: auto; min-height: 24px; }
.col-add {
  margin: 0 8px 8px; padding: 6px; text-align: left; color: var(--muted);
  background: transparent; border-radius: 8px; font-size: 13px;
}
.col-add:hover { background: #e2e4e9; }

/* ── card ── */
.card {
  background: var(--card); border-radius: 8px; box-shadow: var(--shadow);
  padding: 9px 10px 8px; margin-bottom: 8px; cursor: pointer; position: relative;
}
.card:hover { background: #fbfcfd; }
.card.dragging { opacity: .6; transform: rotate(2deg); }
.card .t { font-weight: 600; margin-bottom: 2px; padding-right: 18px; }
.card .a { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; white-space: pre-wrap; }
.card .chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chip {
  font-size: 11px; padding: 2px 7px; border-radius: 4px;
  background: #ebecf0; color: var(--muted);
}
.chip.people { background: #e9f2ff; color: var(--blue); }
.chip.dl { background: #eef7f1; color: var(--green); font-weight: 600; }
.chip.dl.overdue { background: #fdeeec; color: var(--red); }
.chip.dl.today { background: #fbf3d9; color: var(--amber); }
.chip.freq { background: #f3eefc; color: #6e4bd1; }
.prio { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.prio.urgent { background: var(--red); }
.prio.important { background: var(--amber); }
.prio.normal { background: #c1c7d0; }
.card .id { position: absolute; right: 8px; bottom: 6px; font-size: 10px; color: #b3bac5; }
.card .quick-done {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px;
  border-radius: 6px; background: transparent; color: #c1c7d0; padding: 0;
  font-size: 13px; line-height: 22px; display: none;
}
.card:hover .quick-done { display: block; }
.quick-done:hover { background: #e3fcef; color: var(--green); }

.ghost { opacity: .35; background: #dfe3ea; }

/* ── modal ── */
.modal-wrap {
  position: fixed; inset: 0; background: rgba(9,30,66,.45);
  display: flex; align-items: flex-start; justify-content: center; z-index: 50;
  padding: 4vh 12px;
}
.modal {
  background: var(--card); border-radius: 12px; padding: 18px;
  width: 520px; max-width: 100%; max-height: 90vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
}
.modal h2 { margin: 0 0 4px; font-size: 17px; }
.modal label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.modal input, .modal select, .modal textarea { font-size: 14px; color: var(--ink); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.modal-meta { color: #b3bac5; font-size: 11px; }
.hidden { display: none !important; }

/* ── toast ── */
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: #172b4d; color: #fff; padding: 9px 18px; border-radius: 8px;
  box-shadow: 0 4px 14px rgba(9,30,66,.35); z-index: 99; font-size: 13px;
}
.toast.err { background: var(--red); }

/* ── mobile ── */
@media (max-width: 640px) {
  .topbar { gap: 6px; }
  h1 { font-size: 17px; }
  .updated { display: none; }
  .column { min-width: 82vw; max-width: 82vw; }
  .board { scroll-snap-type: x mandatory; }
  .column { scroll-snap-align: start; }
}
