:root {
  --bg: #f6f7f9; --card: #fff; --ink: #1d2433; --muted: #6b7385; --line: #e3e6ec;
  --brand: #2f6fde; --brand-ink: #fff; --ok: #1f8a4c; --warn: #b26b00; --late: #c62f2f; --wa: #1fa855;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12151b; --card: #1b2029; --ink: #e8ebf1; --muted: #9aa3b5; --line: #2c3340; --brand: #5b8ff0; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); padding-bottom: 76px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: .4rem 0 .8rem; }
h2 { font-size: 1.1rem; margin: 1.2rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
h2.late { color: var(--late); } h2.warn { color: var(--warn); }
main { max-width: 820px; margin: 0 auto; padding: 12px 14px 24px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--ink); }
.topright { display: flex; gap: 14px; align-items: center; font-size: .92rem; }
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.nav a { display: flex; flex-direction: column; align-items: center; font-size: .72rem; color: var(--muted); min-width: 60px; text-decoration: none; }
.nav a.on { color: var(--brand); font-weight: 600; }
.nav .ico { font-size: 1.25rem; line-height: 1.2; }
.nav a.add .ico { background: var(--brand); color: var(--brand-ink); border-radius: 50%; width: 34px; height: 34px; display: grid; place-items: center; margin-top: -10px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; }
.card h2:first-child { margin-top: 0; }
.narrow { max-width: 420px; margin: 40px auto; }
.okbox { border-color: var(--ok); } .warnbox { border-color: var(--warn); }
.flash { background: #e8f1ff; color: #13315f; border: 1px solid #bcd3fb; padding: 10px 12px; border-radius: 10px; margin: 8px 0; }
@media (prefers-color-scheme: dark) { .flash { background: #1c2b45; color: #d7e4ff; border-color: #2d4a7a; } }

.tabs, .seg { display: flex; gap: 6px; overflow-x: auto; margin: 6px 0; }
.tabs.wrap { flex-wrap: wrap; }
.tabs a, .seg a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); white-space: nowrap; background: var(--card); font-size: .9rem; }
.tabs a.on, .seg a.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); text-decoration: none; }

.list { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 10px; margin: 6px 0; padding: 10px 10px 10px 12px; flex-wrap: wrap; }
.task > a { flex: 1; min-width: 0; color: var(--ink); text-decoration: none; }
.task.p2 { border-left-color: #e3a008; } .task.p3 { border-left-color: var(--late); } .task.p0 { border-left-color: #9aa3b5; }
.task.isdone .t1 { text-decoration: line-through; color: var(--muted); }
.t1 { font-weight: 600; overflow-wrap: anywhere; }
.t2 { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; font-size: .8rem; align-items: center; }
.quick { margin: 0; }
.tick { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--line); background: transparent; color: var(--muted); font-size: 1.05rem; cursor: pointer; }
.tick:hover { border-color: var(--ok); color: var(--ok); }
.due { color: var(--muted); } .due.late { color: var(--late); font-weight: 600; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: .78rem; }
.pill.deleg { border-color: #b18cf0; color: #7a4fd0; }
.pill.p3 { border-color: var(--late); color: var(--late); } .pill.p2 { border-color: #e3a008; color: #a87400; }
.tag { color: var(--brand); font-size: .8rem; }
.count { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: .75rem; text-align: center; color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; } .right { margin-left: auto; }
.empty { color: var(--muted); text-align: center; padding: 30px 0; }
.struck { text-decoration: line-through; color: var(--muted); }

.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.head h1 { margin: 0 0 .5rem; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .9rem; margin-bottom: 8px; }
.desc { white-space: normal; margin: 10px 0; padding: 10px 12px; background: var(--bg); border-radius: 8px; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.actions.small { margin-top: 0; width: 100%; padding-left: 2px; }
.actions.small .btn { padding: 4px 10px; font-size: .8rem; }

form.stack { display: flex; flex-direction: column; gap: 10px; }
form.compact { gap: 8px; margin-top: 10px; }
form.inline { display: inline; margin: 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--muted); flex: 1; min-width: 140px; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); min-width: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; }
input[type=checkbox] { width: auto; }
input[type=file] { padding: 7px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 4px; }
legend { color: var(--muted); font-size: .85rem; padding: 0 4px; }
details summary { cursor: pointer; color: var(--brand); margin: 6px 0; }

.btn { display: inline-block; font: inherit; font-size: .92rem; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:hover { text-decoration: none; border-color: var(--brand); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.wa { background: var(--wa); color: #fff; border-color: var(--wa); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--late); border-color: var(--late); background: transparent; }
.btn.small { padding: 5px 10px; font-size: .82rem; }
.linkbtn { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }
.linkbtn.small { font-size: .8rem; color: var(--muted); }
.linkbox { font-family: ui-monospace, monospace; font-size: .85rem; }
.statusform select { width: auto; padding: 7px 8px; }

.files, .docs { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.file { display: flex; flex-direction: column; width: 120px; font-size: .8rem; }
.file a { display: flex; flex-direction: column; gap: 4px; color: var(--ink); }
.file img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.fileico { width: 120px; height: 90px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); font-weight: 700; color: var(--late); }
.fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px; width: 140px; }
.del { margin-left: -6px; align-self: flex-end; }

.thread { list-style: none; padding: 0; margin: 0; }
.thread li { padding: 8px 10px; border-radius: 10px; background: var(--bg); margin: 6px 0; overflow-wrap: anywhere; }
.thread li.delegate { background: #f3edff; }
@media (prefers-color-scheme: dark) { .thread li.delegate { background: #2a2340; } }
.who { font-weight: 600; font-size: .88rem; margin-bottom: 2px; }
.plain { list-style: none; padding: 0; margin: 4px 0; }
.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.linkrow { display: flex; flex-direction: column; gap: 4px; }

.tree { list-style: none; padding: 0; margin: 6px 0; }
.tree li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.tree li.d1 { padding-left: 18px; }
.tree li.d2 { padding-left: 36px; }
.tree li.d3 { padding-left: 54px; }
.tree li.d4 { padding-left: 72px; }
.tree li.d5 { padding-left: 90px; }
.tree li.d6 { padding-left: 108px; }
.searchbar { display: flex; gap: 8px; margin: 8px 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin: 0; }
.public { padding-top: 6px; }

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .nav { position: sticky; top: 49px; bottom: auto; justify-content: center; gap: 18px; border-top: 0; border-bottom: 1px solid var(--line); }
  .nav a { flex-direction: row; gap: 6px; font-size: .92rem; }
  .nav a.add .ico { margin-top: 0; width: 24px; height: 24px; font-size: 1rem; }
  body > .nav { order: -1; }
}
