:root {
  --bg: #f6f6f3; --surface: #ffffff; --surface-2: #efefeb; --line: #e2e2dc;
  --text: #1c1d1b; --muted: #6b6d67; --accent: #1f6f5c; --accent-ink: #ffffff; --accent-soft: #e3efe9;
  --danger: #b3261e; --warn: #9a6700; --warn-soft: #fbf1d9; --danger-soft: #fbe6e4;
  --radius: 10px; --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 1px 1px rgb(0 0 0 / .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141514; --surface: #1d1f1d; --surface-2: #262926; --line: #323532;
    --text: #ecedea; --muted: #9a9d97; --accent: #4fb394; --accent-ink: #0d1f19; --accent-soft: #1f3a31;
    --danger: #f2877f; --warn: #e0b453; --warn-soft: #3a3120; --danger-soft: #3d2322;
    --shadow: 0 1px 2px rgb(0 0 0 / .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 13px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; }

/* controls */
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 4px 8px; font-size: 13px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
input, select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 10px;
}
textarea { resize: vertical; min-height: 72px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }

/* login / empty states */
.center { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px;
  width: 100%; max-width: 380px; box-shadow: var(--shadow);
}
.panel h1 { margin-bottom: 4px; }
.panel .btn.primary { width: 100%; margin-top: 18px; padding: 10px; }
.brandmark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-weight: 700; margin-bottom: 14px; }

/* shell */
.shell { display: grid; grid-template-columns: 240px 1fr; height: 100vh; height: 100dvh; }  /* sidebar spans the full window; main scrolls */
.side {
  border-right: 1px solid var(--line); background: var(--surface); padding: 14px 10px;
  display: flex; flex-direction: column; gap: 14px; overflow-y: auto;
}
.side .ws select { font-weight: 600; }
.nav a, .nav button.link {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; text-decoration: none;
  padding: 7px 10px; border-radius: 8px; border: 0; background: none; cursor: pointer;
}
.nav a:hover, .nav button.link:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .head { display: flex; justify-content: space-between; align-items: center; padding: 0 4px 0 10px; }
.nav .head h2 { margin: 0; }
.side .me { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; align-items: center; gap: 8px; }
.menu-toggle { display: none; }
main { overflow: auto; padding: 20px 24px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }

/* board */
.board { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 12px; min-height: calc(100vh - 110px); }
.col { flex: 0 0 280px; background: var(--surface-2); border-radius: var(--radius); padding: 10px; }
.col-head { display: flex; align-items: center; gap: 6px; padding: 2px 4px 8px; }
.col-head strong { flex: 1; }
.col-head .count { color: var(--muted); font-size: 12px; }
.cards { display: flex; flex-direction: column; gap: 8px; min-height: 12px; border-radius: 8px; transition: background .15s; }
.cards.over { background: var(--accent-soft); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 10px;
  box-shadow: var(--shadow); cursor: pointer; display: grid; grid-template-columns: auto 1fr; gap: 8px;
}
.card:hover { border-color: var(--muted); }
.card.dragging { opacity: .45; }
.card.done .title { text-decoration: line-through; color: var(--muted); }
.card .meta { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.check {
  width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--muted); background: none;
  cursor: pointer; padding: 0; display: grid; place-items: center; margin-top: 1px; flex: none;
}
.check.on { background: var(--accent); border-color: var(--accent); }
.check.on::after { content: ""; width: 8px; height: 4px; border: 2px solid var(--accent-ink); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.chip { font-size: 12px; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.chip.soon { background: var(--warn-soft); color: var(--warn); }
.chip.late { background: var(--danger-soft); color: var(--danger); }
.chip.ok { background: var(--accent-soft); color: var(--accent); }
.avatar {
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  font-size: 10px; font-weight: 700; display: inline-grid; place-items: center; flex: none;
}
.add-task { display: flex; gap: 6px; margin-top: 8px; }
.add-task input { background: transparent; border-style: dashed; padding: 6px 8px; }
.add-task input:focus { background: var(--surface); border-style: solid; }
.add-col { flex: 0 0 200px; }

/* lists */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.list .item { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.list .item:first-child { border-top: 0; }
.list .item.clickable { cursor: pointer; }
.list .item.clickable:hover { background: var(--surface-2); }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.cardbox { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; max-width: 560px; margin-bottom: 20px; }
.cardbox h2 { margin-bottom: 4px; }
.code { font: 600 18px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; background: var(--surface-2); padding: 8px 12px; border-radius: 8px; display: inline-block; margin: 8px 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

/* dialog */
dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgb(0 0 0 / .25);
}
dialog::backdrop { background: rgb(0 0 0 / .35); }
.dlg-body { padding: 20px 22px; max-height: calc(100vh - 80px); overflow-y: auto; }
.dlg-body .title-input { font-size: 18px; font-weight: 600; border-color: transparent; padding: 6px 8px; margin-left: -8px; }
.dlg-body .title-input:hover { border-color: var(--line); }
.saved { font-size: 12px; color: var(--accent); opacity: 0; transition: opacity .2s; }
.saved.show { opacity: 1; }
.comments { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 14px; }
.comment { padding: 8px 0; }
.comment .who { font-size: 12px; color: var(--muted); }
.comment .body { white-space: pre-wrap; }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; transition: all .2s;
  pointer-events: none; max-width: calc(100vw - 32px); z-index: 10;
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.error { background: var(--danger); color: #fff; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 5; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .side { transform: none; box-shadow: 0 0 40px rgb(0 0 0 / .3); }
  .menu-toggle { display: inline-block; }
  main { padding: 16px; }
  .col { flex-basis: 84vw; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
