:root {
  --bg: #f4f5f8; --card: #ffffff; --text: #1b1f2a; --muted: #5f6672; --line: #d9dce4;
  --accent: #2f5fd0; --accent-text: #ffffff; --danger: #c0392b;
  --high: #d9534f; --med: #e0a31a; --low: #4a9d6a;
}
:root[data-theme="dark"] {
  --bg: #12151c; --card: #1c212c; --text: #e6e8ee; --muted: #9aa3b2; --line: #2e3544;
  --accent: #6b92f0; --accent-text: #0b1020; --danger: #ef6b5b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151c; --card: #1c212c; --text: #e6e8ee; --muted: #9aa3b2; --line: #2e3544;
    --accent: #6b92f0; --accent-text: #0b1020; --danger: #ef6b5b;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--danger); border-color: var(--danger); }
button.ghost { background: transparent; }
input, select, textarea { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.spacer { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }

.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; }
.bar input[type="search"] { width: 170px; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 8px 0 0 8px; }
.seg button:last-child { border-radius: 0 8px 8px 0; border-left: 0; }
.seg button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.banner { margin: 10px 12px 0; padding: 10px 12px; border: 1px solid var(--med); border-radius: 8px; background: var(--card); }
.stats { display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 14px; color: var(--muted); font-size: 13px; }
.stats b { color: var(--text); }

main { padding: 8px 12px 96px; }
.board { display: grid; grid-template-columns: repeat(3, minmax(240px, 1fr)); gap: 12px; align-items: start; overflow-x: auto; }
.col { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-height: 120px; }
.col.over { outline: 2px dashed var(--accent); }
.col h3 { margin: 4px 6px 8px; font-size: 14px; display: flex; justify-content: space-between; }
.card { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--low);
  border-radius: 8px; padding: 9px 10px; margin-bottom: 8px; cursor: grab; }
.card.p1 { border-left-color: var(--med); }
.card.p2 { border-left-color: var(--high); }
.card.dragging { opacity: .4; }
.card .title { font-weight: 600; word-break: break-word; }
.card.done .title { text-decoration: line-through; color: var(--muted); }
.meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--muted); align-items: center; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.overdue { color: var(--danger); font-weight: 600; }
.move { margin-left: auto; display: flex; gap: 4px; }
.move button { padding: 1px 8px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list .card { cursor: pointer; border-left-width: 4px; }
.empty { text-align: center; color: var(--muted); padding: 40px 12px; }

.fab { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 56px; height: 56px;
  border-radius: 50%; background: var(--accent); color: var(--accent-text); font-size: 30px; line-height: 1;
  border: 0; box-shadow: 0 4px 14px rgba(0,0,0,.3); padding: 0; }

dialog { width: min(560px, 94vw); border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); padding: 16px; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin: 0 0 10px; font-size: 18px; }
dialog label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 13px; color: var(--muted); flex: 1; }
dialog label input, dialog label select, dialog label textarea { color: var(--text); font-size: 15px; }
.row { display: flex; gap: 10px; }
.actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 10px; padding: 8px 10px; }
legend { color: var(--muted); font-size: 13px; padding: 0 4px; }
.checklist { list-style: none; margin: 0 0 8px; padding: 0; }
.checklist li { display: flex; gap: 8px; align-items: center; padding: 3px 0; }
.checklist li span { flex: 1; word-break: break-word; }
.checklist li.done span { text-decoration: line-through; color: var(--muted); }
.checklist button { padding: 0 8px; }
.worklog { list-style: none; margin: 0 0 8px; padding: 0; max-height: 180px; overflow-y: auto; }
.worklog li { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; border-bottom: 1px solid var(--line); }
.worklog li .d { color: var(--muted); font-size: 12px; white-space: nowrap; }
.worklog li .n { flex: 1; word-break: break-word; }
.worklog button { padding: 0 8px; }
fieldset .row { margin-bottom: 8px; }
fieldset .row input { flex: 1; min-width: 0; }
.logview { max-width: 760px; margin: 0 auto; }
.logform { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 14px; }
.logform .row { margin-bottom: 8px; flex-wrap: wrap; }
.logform .row > * { flex: 1; min-width: 120px; }
.logday { margin-bottom: 14px; }
.logday h3 { display: flex; justify-content: space-between; font-size: 14px; margin: 0 4px 6px; }
.logentry { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; cursor: pointer; }
.logentry .t { font-weight: 600; word-break: break-word; }
.logentry .n { color: var(--muted); font-size: 13px; word-break: break-word; }
.logbtns { align-items: center; }
.timerbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin: 10px 12px 0; padding: 8px 12px;
  border: 1px solid var(--accent); border-radius: 8px; background: var(--card); font-weight: 600; }
.timerbar span { word-break: break-word; font-variant-numeric: tabular-nums; }
.move button.running { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.repout { white-space: pre-wrap; word-break: break-word; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; max-height: 40vh; overflow: auto; font: 13px/1.45 ui-monospace, Menlo, Consolas, monospace; }
.toast button { margin-left: 8px; padding: 1px 10px; }
.menu-list { display: flex; flex-direction: column; gap: 8px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; background: var(--text); color: var(--bg);
  padding: 8px 14px; border-radius: 8px; z-index: 20; }

@media (max-width: 760px) {
  .board { grid-template-columns: 1fr; }
  .bar input[type="search"] { width: 100%; order: 10; }
}

.card.archived { opacity: .6; border-style: dashed; }
.snaprow { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.snaprow span { flex: 1; font-size: 14px; }

.reflink { text-decoration: none; color: var(--muted); font-size: 20px; line-height: 1; padding: 6px 8px; border-radius: 6px; }
.reflink:hover, .reflink:focus-visible { color: var(--text); background: var(--line); }

.callout { border: 1px solid var(--accent); border-radius: 8px; padding: 8px 10px; }
.helptext ul { padding-left: 1.2em; margin: 4px 0 8px; }
.helptext h3 { margin: 12px 0 4px; font-size: 14px; }
#menuDialog h3 { margin: 14px 0 4px; font-size: 14px; }
[hidden] { display: none !important; }

/* About and FAQ text for search engines and first-time visitors; hidden in the installed app and when printing */
.about { max-width: 760px; margin: 0 auto; padding: 8px 16px 96px; color: var(--text); }
.about h2 { font-size: 1.2rem; margin: 1.4em 0 .4em; }
.about h3 { font-size: 1rem; margin: 1.1em 0 .3em; }
.about p, .about li { color: var(--muted); line-height: 1.55; }
.about ol { padding-left: 1.2em; }
.about details { border-top: 1px solid var(--line); padding: .6em 0; }
.about summary { cursor: pointer; font-weight: 600; color: var(--text); }
.about a { color: inherit; }
@media (display-mode: standalone) { .about { display: none; } }
@media print { .about { display: none !important; } }
/* shown only once the app has drawn its first screen (the app adds .ready), so it never flashes at the top while loading */
html:not(.ready) .about { display: none; }

/* keep the shell invisible until the app has drawn its first screen, so nothing shifts as banners and lists are filled in */
html:not(.ready) body > :not(script):not(style):not(link) { visibility: hidden; }

.sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

.seg button { white-space: nowrap; }
#printArea { display: none; }
.printlist { list-style: none; padding-left: 0; }
.printlist .printlist { padding-left: 24px; }
.printlist li { margin: 4px 0; }
@media print {
  body.printing > *:not(#printArea) { display: none !important; }
  body.printing #printArea { display: block; color: #000; background: #fff; }
}
