:root {
  --bg: #f5f6f8; --card: #fff; --col: #e9ecf1; --line: #e4e6eb; --text: #1b1f27; --muted: #7a8190;
  --accent: #3b6cf6; --accent-soft: #e8eefe; --red: #d9423a; --amber: #c27c0e; --green: #2e9d5b;
  --r: 12px; --shadow: 0 1px 2px rgba(20, 24, 34, .06), 0 1px 8px rgba(20, 24, 34, .04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #101216; --card: #1a1d24; --col: #161920; --line: #2a2e38; --text: #e8eaf0; --muted: #8d94a3;
    --accent: #6f93ff; --accent-soft: #232b45; --red: #ff6b61; --amber: #e0a23a; --green: #4cc380;
    --shadow: none;
  }
}
:root[data-theme=dark] {
  --bg: #101216; --card: #1a1d24; --col: #161920; --line: #2a2e38; --text: #e8eaf0; --muted: #8d94a3;
  --accent: #6f93ff; --accent-soft: #232b45; --red: #ff6b61; --amber: #e0a23a; --green: #4cc380;
  --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { color-scheme: light dark; }
:root[data-theme=light] { color-scheme: light; }
:root[data-theme=dark] { color-scheme: dark; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
input, select, textarea {
  width: 100%; padding: 8px 10px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 72px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.app { display: flex; flex-direction: column; height: 100%; }
.top {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); background: var(--card); flex-wrap: wrap;
}
.logo { font-weight: 700; letter-spacing: -.02em; margin-right: 4px; }
.spacer { flex: 1; }
.icon { padding: 6px 10px; border-radius: 8px; color: var(--muted); }
.icon:hover { background: var(--bg); }
.icon.on { color: var(--accent); background: var(--accent-soft); }
.btn { padding: 8px 14px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; white-space: nowrap; }
.btn.ghost { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
.btn.red { background: var(--red); }
.btn:disabled { opacity: .5; }

.board { flex: 1; display: flex; gap: 12px; padding: 4px 14px 14px; overflow-x: auto; scroll-snap-type: x proximity; }
.col { flex: 0 0 min(86vw, 300px); display: flex; flex-direction: column; min-height: 0; max-height: 100%; align-self: flex-start; scroll-snap-align: start; background: var(--col); border-radius: var(--r); border-top: 3px solid var(--c, var(--muted)); padding: 4px 8px 8px; }
.col h3 { display: flex; align-items: center; gap: 8px; margin: 8px 2px 10px; font-size: 14px; font-weight: 700; color: var(--text); }
.col h3 b { font-weight: 700; flex: 1; }
.col h3 span { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--card); border-radius: 999px; padding: 1px 8px; }
.col .list { flex: 0 1 auto; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 2px 2px 8px; border-radius: var(--r); }
.col.over { background: var(--accent-soft); }
.empty { color: var(--muted); text-align: center; padding: 20px 0; font-size: 13px; }

.card {
  background: var(--card); border-radius: var(--r); padding: 10px 12px; box-shadow: var(--shadow);
  border: 1px solid var(--line); cursor: pointer; text-align: left; width: 100%; display: block;
}
.card:hover { border-color: var(--accent); }
.card.drag { opacity: .4; }
.card .t { font-weight: 600; word-break: break-word; }
.card .p { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--amber); }
.card .p.p2 { background: var(--red); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.meta .late { color: var(--red); font-weight: 600; }
.meta .soon { color: var(--amber); font-weight: 600; }
.tag { background: var(--bg); border-radius: 6px; padding: 1px 6px; }
.who { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.ava { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; }
.pend { border-style: dashed; }

.veil { position: fixed; inset: 0; background: rgba(10, 12, 18, .45); display: flex; justify-content: center; align-items: flex-end; z-index: 10; }
.modal {
  background: var(--card); width: 100%; max-width: 560px; max-height: 94vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 16px 16px max(16px, env(safe-area-inset-bottom));
}
@media (min-width: 700px) { .veil { align-items: center; } .modal { border-radius: 18px; max-height: 90vh; } }
.modal .head { display: flex; align-items: center; gap: 8px; }
.modal .head input { font-size: 18px; font-weight: 700; border-color: transparent; background: transparent; padding: 4px; }
.modal .head input:focus { border-color: var(--accent); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0 2px; }
.seg button { padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; }
.seg button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input[type=checkbox] { width: auto; }
.sub { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.sub input[type=checkbox] { width: 18px; height: 18px; flex: none; }
.sub.done span { text-decoration: line-through; color: var(--muted); }
.sub span { flex: 1; word-break: break-word; }
.x { color: var(--muted); padding: 2px 8px; }
.x:hover { color: var(--red); }
.att { display: flex; gap: 8px; padding: 4px 0; align-items: center; word-break: break-all; }
.att a, .att button { color: var(--accent); text-align: left; }
.banner { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin-top: 12px; }
.banner .row { margin-top: 8px; }
.log { margin-top: 6px; }
.log div { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; word-break: break-word; }
.log .s { color: var(--muted); font-size: 12px; }
.log small { color: var(--muted); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: max(20px, env(safe-area-inset-bottom));
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: 90vw; white-space: pre-line;
}
.login { max-width: 360px; margin: 18vh auto 0; padding: 0 20px; text-align: center; }
.login h1 { margin-bottom: 8px; }
.login p { color: var(--muted); }
.h2 { margin: 22px 0 6px; font-size: 14px; font-weight: 700; }
.line { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.line input[type=text], .line input:not([type]) { flex: 1; }
.line input[type=checkbox] { width: auto; }

.seg2 { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg2 button { padding: 6px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-weight: 500; }
.seg2 button small { margin-left: 6px; font-size: 12px; opacity: .8; }
.seg2 button:hover { color: var(--text); }
.seg2 button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.seg2 button.on small { color: var(--accent); }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 14px 6px; }
.bar .seg2 button { padding: 4px 10px; font-size: 14px; }
.switch { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; cursor: pointer; margin: 0; white-space: nowrap; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i { width: 34px; height: 20px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(14px); }
.switch input:checked ~ span { color: var(--text); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.addcard { margin-top: 4px; padding: 8px 10px; border-radius: 10px; color: var(--muted); text-align: left; width: 100%; }
.addcard:hover { background: var(--line); color: var(--text); }
.composer { margin-top: 4px; }
.composer textarea { min-height: 64px; background: var(--card); }
.composer .row { margin-top: 6px; }

.cl { margin-top: 16px; }
.clh { display: flex; align-items: center; gap: 6px; }
.clh input { font-weight: 700; border-color: transparent; background: transparent; padding: 4px; }
.clh input:focus { border-color: var(--accent); background: var(--bg); }
.progrow { display: flex; align-items: center; gap: 8px; margin: 2px 0 6px; }
.progrow small { width: 34px; color: var(--muted); font-size: 12px; }
.prog { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .2s; }
.prog i.full { background: var(--green); }

.card.late { border-color: var(--red); background: color-mix(in srgb, var(--red) 9%, var(--card)); box-shadow: inset 4px 0 0 var(--red); }
.card.late .t { color: var(--red); }
.tag[role=button] { cursor: pointer; }
.tag[role=button]:hover { background: var(--accent-soft); color: var(--accent); }
.search { flex: 1 1 150px; min-width: 120px; max-width: 280px; width: auto; padding: 5px 10px; background: var(--card); }
.who-sel { width: auto; flex: none; padding: 5px 8px; background: var(--card); }

.chk { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--muted); border-radius: 50%; margin-right: 8px; vertical-align: -3px; cursor: pointer; position: relative; }
.chk:hover { border-color: var(--green); background: color-mix(in srgb, var(--green) 20%, transparent); }
.chk:hover::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: var(--green); font-weight: 700; }
.card.late .chk { border-color: var(--red); }
.donezone { flex-basis: 190px; min-height: 140px; border-top-style: dashed; justify-content: center; }
.donezone .dz { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: var(--muted); padding: 24px 8px; }
.donezone .dz b { color: var(--text); }
.donezone .dz span { font-size: 22px; }
.arow { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.atitle { flex: 1; text-align: left; font-weight: 600; word-break: break-word; }
.atitle small { display: block; font-weight: 400; color: var(--muted); }
.toastbtn { margin-left: 14px; font-weight: 700; color: var(--accent-soft); text-decoration: underline; }

.tgbox { margin: 20px 0 8px; min-height: 48px; display: flex; justify-content: center; }
.login .alt { margin-top: 4px; }
