:root {
  /* One dark theme. Greys carry the structure; the brand red marks what matters. */
  --font: "Segoe UI Variable", "Segoe UI", "Inter", "Noto Sans", Cantarell, system-ui, sans-serif;
  --sidebar: #161618;
  --surface: #1c1c1f;
  --details: #19191c;
  --card: #26262a;
  --card-hover: #2d2d32;
  --text: #ececee;
  --muted: #a1a1a9;
  --faint: #73737b;
  --border: rgba(255, 255, 255, 0.07);
  --hover: rgba(255, 255, 255, 0.055);
  --active: rgba(255, 255, 255, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.03);
  --popup: #29292e;
  --popup-shadow: 0 10px 32px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);

  --accent: #e0344a;         /* brand red: checks, buttons, focus, selection */
  --accent-strong: #c1203a;  /* pressed / filled surfaces */
  --accent-text: #ff6b79;    /* red text on dark (titles, links), readable at small sizes */
  --accent-soft: rgba(224, 52, 74, 0.14);
  --wine: #7a1324;           /* the glow */
  --danger: #ff5d5d;
  --overdue: #ffa25c;        /* amber, so overdue doesn't blend into the brand red */
  --today: var(--accent-text);

  /* main area: charcoal base; the red glow is drawn by #main::before / ::after */
  --main-bg: linear-gradient(180deg, #1d1d20 0%, #161618 100%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font: 14px/1.4 var(--font); color: var(--text); background: var(--sidebar); user-select: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.ico { width: 18px; height: 18px; flex: none; display: block; }
.icon-btn { width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); flex: none; }
@media (hover: hover) { .icon-btn:hover { background: var(--hover); color: var(--text); } }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(128, 128, 128, 0.35); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

#app { display: flex; height: 100vh; }

/* ------------------------------------------------ sidebar */
#sidebar { width: 280px; flex: none; display: flex; flex-direction: column; background: var(--sidebar); border-right: 1px solid var(--border); }
body.sidebar-collapsed #sidebar { display: none; }
.sidebar-top { display: flex; align-items: center; gap: 6px; padding: 12px 10px 8px; }
.search-box { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; background: var(--card); border-radius: 6px; padding: 0 8px; height: 32px; box-shadow: inset 0 0 0 1px var(--border); }
.search-box:focus-within { box-shadow: inset 0 0 0 1px var(--border), inset 0 -2px 0 var(--accent); }
.search-box .ico { width: 15px; height: 15px; color: var(--faint); }
#search { flex: 1; border: 0; outline: 0; background: transparent; min-width: 0; }
#nav { flex: 1; overflow-y: auto; padding: 4px 6px 12px; }
.nav-item { display: flex; align-items: center; gap: 12px; height: 36px; padding: 0 10px; border-radius: 6px; cursor: default; position: relative; }
@media (hover: hover) { .nav-item:hover { background: var(--hover); } }
.nav-item.active { background: var(--accent-soft); font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--accent); }
.nav-item .nav-ico { width: 20px; display: grid; place-items: center; color: var(--muted); font-size: 15px; }
.nav-item.active .nav-ico { color: var(--accent-text); }
.nav-item .nav-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .nav-count { font-size: 12px; color: var(--muted); min-width: 18px; text-align: center; }
.nav-sep { height: 1px; background: var(--border); margin: 8px 10px; }
.nav-group > .group-head { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 6px; color: var(--muted); font-weight: 600; font-size: 13px; }
@media (hover: hover) { .nav-group > .group-head:hover { background: var(--hover); } }
.nav-group > .group-head .chev { width: 14px; height: 14px; }
.nav-group > .group-body { padding-left: 14px; }
.nav-group.collapsed > .group-body { display: none; }
.group-empty { color: var(--faint); font-size: 12px; padding: 4px 10px 8px 36px; }
.nav-input { flex: 1; min-width: 0; border: 0; outline: 0; background: var(--card); border-radius: 4px; padding: 3px 6px; box-shadow: inset 0 -2px 0 var(--accent); font-weight: 600; }
.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.drop-into { background: color-mix(in srgb, var(--accent) 18%, transparent) !important; outline: 1px dashed var(--accent); }
#nav-end { min-height: 40px; }
/* counters above New list, divided by the same hairlines as the rest of the sidebar */
.sidebar-stats { display: flex; border-top: 1px solid var(--border); }
.sidebar-stats .stat { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px 9px; text-align: center; }
.sidebar-stats .stat + .stat { border-left: 1px solid var(--border); }
.sidebar-stats .stat-num { font-size: 18px; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--text); }
.sidebar-stats .stat.remaining .stat-num { color: var(--accent-text); }
.sidebar-stats .stat-label { font-size: 11px; line-height: 1.25; color: var(--muted); }
.sidebar-bottom { display: flex; align-items: center; gap: 4px; padding: 8px; border-top: 1px solid var(--border); }
.new-list-btn { flex: 1; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 6px; text-align: left; }
@media (hover: hover) { .new-list-btn:hover { background: var(--hover); } }
.new-list-btn .plus .ico { color: var(--accent); }

/* ------------------------------------------------ main */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--main-bg); background-color: var(--surface); position: relative; isolation: isolate; overflow: hidden; }
/*
 * The backdrop: bare branches over red smoke rising from the bottom right (art/backdrop.jpg,
 * generated locally with SDXL from our own composition sketch, then graded to this palette).
 * It is anchored bottom-right so the branches and smoke stay in view at any window size, and
 * fades into the charcoal toward the top left, where the tasks sit.
 */
#main::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: url("art/backdrop.jpg") right bottom / cover no-repeat;
}
/* Fine film grain over the glow, so the gradients don't band and the surface feels made rather than generated. */
#main::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0.04; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
#list-header { padding: 20px 24px 10px; color: var(--muted); display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.lh-left { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.lh-title { font-size: 26px; font-weight: 650; letter-spacing: -0.01em; color: var(--accent-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 2px 6px; border-radius: 6px; margin-left: -6px; display: flex; align-items: center; gap: 10px; }
.lh-title .ico { width: 26px; height: 26px; }
@media (hover: hover) { button.lh-title:hover { background: var(--hover); } }
.lh-title-input { font-size: 24px; font-weight: 600; border: 0; outline: 0; border-radius: 6px; padding: 2px 8px; background: var(--card); color: var(--accent-text); box-shadow: inset 0 -2px 0 var(--accent); min-width: 200px; flex: 1; max-width: 520px; }
.lh-sub { width: 100%; font-size: 13px; color: var(--muted); margin-top: -4px; padding-left: 1px; }
.lh-right { display: flex; gap: 4px; align-items: center; }
.hdr-btn { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 6px; color: var(--muted); }
@media (hover: hover) { .hdr-btn:hover { background: var(--hover); color: var(--text); } }
.hdr-btn.on { background: var(--accent-soft); color: var(--accent-text); }
.hdr-btn.icon-only { padding: 0; width: 32px; justify-content: center; }
.filter-chips { display: flex; gap: 6px; align-items: center; }
.filter-chip { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px 0 10px; border-radius: 15px; color: var(--muted); border: 1px solid var(--border); background: rgba(255, 255, 255, 0.02); font-size: 13px; transition: background 0.12s, color 0.12s, border-color 0.12s; }
.filter-chip .ico { width: 15px; height: 15px; }
@media (hover: hover) { .filter-chip:hover { background: var(--hover); color: var(--text); } }
.filter-chip.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent-text); }
.filter-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.filter-chip.warn.on { background: rgba(255, 162, 92, 0.12); border-color: rgba(255, 162, 92, 0.5); color: var(--overdue); }
.hdr-divider { width: 1px; height: 20px; background: var(--border); align-self: center; margin: 0 4px 0 6px; }
.hdr-btn .ico { width: 17px; height: 17px; }
.sort-chip { width: 100%; display: flex; justify-content: flex-end; }
.sort-chip span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; background: var(--card); color: var(--muted); box-shadow: var(--shadow); padding: 3px 4px 3px 10px; border-radius: 12px; }
.sort-chip button { display: grid; place-items: center; border-radius: 10px; width: 20px; height: 20px; color: inherit; }
@media (hover: hover) { .sort-chip button:hover { background: var(--hover); color: var(--text); } }
.sort-chip .ico { width: 13px; height: 13px; }

#task-scroll { flex: 1; overflow-y: auto; padding: 4px 24px 40px; }
#add-task { background: var(--card); border-radius: 6px; box-shadow: var(--shadow); margin-bottom: 10px; position: sticky; top: 0; z-index: 2; }
.add-row { display: flex; align-items: center; gap: 14px; height: 52px; padding: 0 16px; }
.add-plus .ico { color: var(--accent); width: 20px; height: 20px; }
#add-input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 14px; }
#add-input::placeholder { color: var(--accent-text); }
#add-input:focus::placeholder { color: var(--faint); }
.add-actions { display: none; align-items: center; gap: 4px; padding: 0 10px 8px 46px; border-top: 1px solid var(--border); padding-top: 6px; }
#add-task.focused .add-actions, #add-task.has-pending .add-actions { display: flex; }
.add-actions .chip { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; border-radius: 4px; color: var(--muted); font-size: 12px; }
@media (hover: hover) { .add-actions .chip:hover { background: var(--hover); } }
.add-actions .chip.set { color: var(--accent-text); background: var(--accent-soft); }
.add-actions .chip .ico { width: 16px; height: 16px; }
.add-actions .spacer { flex: 1; }
.add-actions .add-btn { height: 28px; padding: 0 12px; border-radius: 4px; border: 1px solid var(--border); font-size: 12px; }
@media (hover: hover) { .add-actions .add-btn:not(:disabled):hover { background: var(--hover); } }
.add-actions .add-btn:disabled { opacity: 0.45; cursor: default; }

.group-title { display: flex; align-items: center; gap: 8px; margin: 14px 0 6px; padding: 4px 8px; border-radius: 6px; font-weight: 600; color: var(--accent-text); width: fit-content; }
@media (hover: hover) { .group-title:hover { background: var(--hover); } }
.group-title .ico { width: 14px; height: 14px; }
.group-title .count { font-weight: 400; color: var(--muted); }
.task { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 12px 6px 16px; background: var(--card); border-radius: 6px; margin-bottom: 2px; box-shadow: var(--shadow); cursor: default; }
@media (hover: hover) { .task:hover { background: var(--card-hover); } }
.task.selected { background: color-mix(in srgb, var(--accent) 16%, var(--card)); box-shadow: var(--shadow), inset 3px 0 0 var(--accent); }
.task.dragging { opacity: 0.4; }
.task.drop-before { box-shadow: var(--shadow), 0 -2px 0 var(--accent); }
.task.drop-after { box-shadow: var(--shadow), 0 2px 0 var(--accent); }
.task-body { flex: 1; min-width: 0; padding: 4px 0; }
.task-title { overflow-wrap: anywhere; user-select: text; }
.task.completed .task-title { text-decoration: line-through; color: var(--muted); }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; font-size: 12px; color: var(--muted); margin-top: 1px; }
.task-meta > span { display: inline-flex; align-items: center; gap: 3px; }
.task-meta > span + span::before { content: "•"; margin: 0 6px; color: var(--faint); }
.task-meta .ico { width: 13px; height: 13px; }
.task-meta .overdue { color: var(--overdue); }
.task-meta .today { color: var(--today); }
.check { width: 22px; height: 22px; border-radius: 50%; border: 1.6px solid var(--muted); display: grid; place-items: center; flex: none; color: transparent; transition: background 0.12s; }
.check .ico { width: 13px; height: 13px; stroke-width: 2.6; }
@media (hover: hover) { .check:hover { color: var(--muted); border-color: var(--accent); } }
.check.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.check.small { width: 18px; height: 18px; }
.check.small .ico { width: 11px; height: 11px; }
.check.pop { animation: pop 0.25s ease; }
@keyframes pop { 50% { transform: scale(1.3); } }
.star { width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); flex: none; }
@media (hover: hover) { .star:hover { color: var(--accent-text); } }
.star.on { color: var(--accent); }
.star .ico { width: 19px; height: 19px; }

.empty { text-align: center; color: var(--muted); margin-top: 60px; }
.empty h3 { color: var(--text); }
.empty .ico { width: 64px; height: 64px; margin: 0 auto 12px; color: var(--accent-text); opacity: 0.8; stroke-width: 1.2; }
.empty h3 { margin: 0 0 4px; font-weight: 600; }
.empty p { margin: 0; opacity: 0.85; }

/* ------------------------------------------------ details */
#details { width: 360px; flex: none; background: var(--details); border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.d-scroll { flex: 1; overflow-y: auto; padding: 16px 16px 24px; display: flex; flex-direction: column; gap: 8px; }
.d-card { background: var(--card); border-radius: 6px; box-shadow: var(--shadow); }
.d-title-row { display: flex; align-items: flex-start; gap: 12px; padding: 14px 8px 10px 16px; }
.d-title-row .check { margin-top: 4px; }
.d-title { flex: 1; border: 0; outline: 0; resize: none; background: transparent; font-size: 18px; font-weight: 600; line-height: 1.35; padding: 2px 4px; border-radius: 4px; overflow: hidden; user-select: text; }
.d-title:focus { box-shadow: inset 0 -2px 0 var(--accent); }
.d-title.done { text-decoration: line-through; color: var(--muted); }
.step { display: flex; align-items: center; gap: 12px; padding: 0 8px 0 18px; min-height: 40px; border-top: 1px solid var(--border); }
.step:first-child { border-top: 0; }
.step input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 8px 0; }
.step.done input { text-decoration: line-through; color: var(--muted); }
.step .icon-btn { width: 28px; height: 28px; opacity: 0; }
@media (hover: hover) { .step:hover .icon-btn, .step .icon-btn:focus { opacity: 1; } }
.step .icon-btn .ico { width: 15px; height: 15px; }
.step.add .add-plus .ico { width: 18px; height: 18px; }
.step.add input::placeholder { color: var(--accent-text); }
.step.add input:focus::placeholder { color: var(--faint); }
.step.dragging { opacity: 0.4; }
.row-btn { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 48px; padding: 6px 8px 6px 18px; text-align: left; color: var(--muted); border-top: 1px solid var(--border); }
.d-card > .row-btn:first-child, .d-card > .row-wrap:first-child > .row-btn { border-top: 0; }
@media (hover: hover) { .row-btn:hover { background: var(--hover); } }
.row-btn.set { color: var(--accent-text); }
.row-btn .row-label { flex: 1; display: flex; flex-direction: column; }
.row-btn .row-sub { font-size: 12px; color: var(--muted); }
.row-btn .row-sub.overdue, .row-btn.overdue { color: var(--overdue); }
.row-wrap { position: relative; }
.row-wrap .row-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.row-wrap .row-clear .ico { width: 15px; height: 15px; }
.file { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 18px; border-top: 1px solid var(--border); }
.file:first-child { border-top: 0; }
.file-badge { width: 36px; height: 36px; border-radius: 4px; background: var(--accent-strong); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; text-transform: uppercase; flex: none; overflow: hidden; }
.file-info { flex: 1; min-width: 0; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: hover) { .file-name:hover { text-decoration: underline; cursor: pointer; } }
.file-size { font-size: 12px; color: var(--muted); }
.d-note { width: 100%; min-height: 110px; border: 0; outline: 0; resize: vertical; background: transparent; padding: 14px 16px; border-radius: 6px; user-select: text; display: block; }
.d-note:focus { box-shadow: inset 0 -2px 0 var(--accent); }
.d-note-view { min-height: 110px; padding: 14px 16px; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; user-select: text; outline: 0; }
.d-note-view:focus-visible { box-shadow: inset 0 -2px 0 var(--accent); }
.note-link { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
@media (hover: hover) { .note-link:hover { filter: brightness(1.15); } }
.canvas-offer { display: flex; align-items: center; gap: 10px; padding: 6px 12px 8px 18px; font-size: 12px; color: var(--muted); }
.canvas-offer span { flex: 1; }
.canvas-offer .btn.small { margin-top: 0; }
.note-updated { font-size: 11px; color: var(--faint); padding: 0 16px 10px; margin-top: -6px; }
.d-footer { display: flex; align-items: center; gap: 8px; padding: 8px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.d-footer span { flex: 1; text-align: center; }
@media (hover: hover) { .d-footer .danger:hover { color: var(--danger); } }

.sug-head { display: flex; align-items: center; gap: 8px; padding: 18px 16px 4px; }
.sug-head h2 { flex: 1; margin: 0; font-size: 18px; }
.sug-section h4 { margin: 14px 4px 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.sug-item { display: flex; align-items: center; gap: 10px; padding: 10px 6px 10px 14px; background: var(--card); border-radius: 6px; box-shadow: var(--shadow); margin-bottom: 4px; }
.sug-item .task-body { padding: 0; }
@media (hover: hover) { .sug-item .task-body:hover .task-title { text-decoration: underline; cursor: pointer; } }
.sug-empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.sug-empty .ico { width: 48px; height: 48px; margin: 0 auto 10px; stroke-width: 1.2; }

/* ------------------------------------------------ popups */
#menu-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.menu { position: fixed; pointer-events: auto; background: var(--popup); border-radius: 8px; box-shadow: var(--popup-shadow); padding: 4px; min-width: 220px; max-width: 340px; max-height: calc(100vh - 16px); overflow-y: auto; animation: fadein 0.08s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(-3px); } }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; height: 34px; padding: 0 10px; border-radius: 4px; text-align: left; white-space: nowrap; }
.menu-item.hl { background: var(--hover); }
@media (hover: hover) { .menu-item:hover { background: var(--hover); } }
.menu-item:disabled { opacity: 0.45; cursor: default; background: none; }
.menu-item .ico { width: 16px; height: 16px; color: var(--muted); }
.menu-item .mi-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.menu-item .mi-hint { color: var(--faint); font-size: 12px; }
.menu-item .mi-check { width: 16px; color: var(--accent); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .ico { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.menu-header { padding: 6px 10px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.menu-emoji { width: 16px; text-align: center; }

.pop-form { padding: 10px; display: flex; flex-direction: column; gap: 10px; min-width: 260px; }
.pop-form h4 { margin: 0; font-size: 13px; }
.pop-form .row { display: flex; gap: 8px; align-items: center; }
.pop-form .actions { display: flex; justify-content: flex-end; gap: 8px; }
.field { border: 1px solid var(--border); background: var(--card); border-radius: 4px; padding: 5px 8px; outline: 0; min-width: 0; }
.field:focus { border-color: var(--accent); }
.btn { height: 30px; padding: 0 14px; border-radius: 4px; border: 1px solid var(--border); background: var(--card); }
@media (hover: hover) { .btn:hover { background: var(--card-hover); } }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (hover: hover) { .btn.primary:hover { filter: brightness(1.1); } }
.btn.primary:active { background: var(--accent-strong); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
@media (hover: hover) { .btn.danger:hover { background: rgba(255, 93, 93, 0.12); } }
.weekday-toggles { display: flex; gap: 4px; }
.weekday-toggles button { width: 32px; height: 28px; border-radius: 4px; border: 1px solid var(--border); font-size: 12px; }
.weekday-toggles button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ------------------------------------------------ modal */
#modal-layer:empty { display: none; }
#modal-layer { position: fixed; inset: 0; z-index: 60; background: rgba(8, 8, 10, 0.6); display: grid; place-items: center; }
.modal { background: var(--popup); border-radius: 10px; box-shadow: var(--popup-shadow); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); display: flex; flex-direction: column; animation: fadein 0.12s ease; }
.modal.small { width: min(400px, calc(100vw - 32px)); }
.modal-head { display: flex; align-items: center; padding: 18px 20px 10px; }
.modal-head h2 { flex: 1; margin: 0; font-size: 20px; }
.modal-body { padding: 4px 20px 16px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.set-section { margin-bottom: 18px; }
.set-section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 10px 0 6px; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.set-row label { flex: 1; }
.set-row .desc { display: block; font-size: 12px; color: var(--muted); }
.toggle { appearance: none; width: 40px; height: 20px; border-radius: 10px; border: 1px solid var(--muted); position: relative; cursor: pointer; flex: none; transition: background 0.15s; margin: 0; }
.toggle::after { content: ""; position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); top: 3px; left: 4px; transition: left 0.15s; }
.toggle:checked { background: var(--accent); border-color: var(--accent); }
.toggle:checked::after { left: 22px; background: #fff; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { padding: 5px 12px; }
.seg button.on { background: var(--accent); color: #fff; }
.kbd-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kbd-table td { padding: 4px 0; border-bottom: 1px solid var(--border); }
.kbd-table td:last-child { text-align: right; }
kbd { font: 12px var(--font); background: var(--hover); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }

/* ------------------------------------------------ sync + setup */
.sync-btn .ico { width: 17px; height: 17px; }
.sync-syncing .ico { animation: spin 1s linear infinite; color: var(--accent); }
.sync-error { color: var(--danger) !important; }
.sync-disabled { opacity: 0.6; }
.sync-offline { opacity: 0.75; }
.sync-btn { position: relative; }
.sync-btn.has-pending::after { content: ''; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.setup-field .desc { font-weight: 400; font-size: 12px; color: var(--muted); }
.set-row .desc.error, .setup-field .desc.error, .modal .desc.error { color: var(--danger); }
.ms-steps { padding-left: 20px; margin: 0 0 12px; }
.ms-steps li { margin-bottom: 6px; }
.ms-steps a { color: var(--accent); }
.ms-token { width: 100%; box-sizing: border-box; resize: vertical; }
.check-row { display: block; margin-top: 12px; }
.check-row .desc { display: block; font-size: 12px; color: var(--muted); margin-left: 22px; }
.conflict.row-flex { display: flex; align-items: center; gap: 10px; }
.conflict.row-flex > span { flex: 1; }
.conflict.row-flex .btn.small { margin-top: 0; }
.local-tag { display: inline-block; margin-left: 8px; padding: 0 6px; border-radius: 8px; font-size: 11px; line-height: 16px; color: var(--muted); border: 1px solid var(--border); vertical-align: 1px; }
.btn.small { height: 24px; padding: 0 10px; font-size: 12px; margin-top: 4px; }
.conflicts { margin: 6px 0 10px; }
.conflicts summary { cursor: pointer; padding: 6px 0; }
.conflicts .conflict { padding: 8px 0; border-top: 1px solid var(--border); }
.conflicts .desc { font-size: 12px; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }
.mono { font-family: ui-monospace, "JetBrains Mono", "Fira Code", monospace; word-break: break-all; user-select: text; }
.setup p { margin: 0 0 14px; color: var(--muted); }
.setup-modes { margin-bottom: 16px; width: fit-content; }
.setup-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-weight: 600; font-size: 13px; }
.setup-field .field { font-weight: 400; width: 100%; }
.setup-field .row { display: flex; gap: 8px; }
.setup-hint { font-size: 12px; }
.setup-error { color: var(--danger) !important; user-select: text; }

/* ------------------------------------------------ toast */
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #313137; color: var(--text); border: 1px solid var(--border); padding: 10px 10px 10px 16px; border-radius: 8px; display: flex; align-items: center; gap: 14px; z-index: 70; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); max-width: 80vw; }
#toast button { color: var(--accent-text); font-weight: 600; padding: 4px 8px; border-radius: 4px; }
@media (hover: hover) { #toast button:hover { background: rgba(128, 128, 128, 0.2); } }

/* ------------------------------------------------ narrow window */
@media (max-width: 900px) {
  #details { position: absolute; right: 0; top: 0; bottom: 0; z-index: 20; box-shadow: -8px 0 24px rgba(0, 0, 0, 0.2); }
}
@media (max-width: 700px) {
  #sidebar { position: absolute; z-index: 25; height: 100%; box-shadow: 8px 0 24px rgba(0, 0, 0, 0.2); }
}

/* ------------------------------------------------ phone (the Android app sets html.mobile) */
/* Capacitor reports the system bars as --safe-area-inset-* (and newer WebViews as env()). */
html.mobile {
  --sa-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --sa-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}
html.mobile body { font-size: 16px; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
html.mobile input, html.mobile textarea, html.mobile select { font-size: 16px; }
html.mobile textarea { resize: none; }
/* touch feedback in place of hover */
html.mobile :is(.menu-item, .nav-item, .group-head, .row-btn, .icon-btn, .hdr-btn, .filter-chip, .group-title, .new-list-btn):active { background: var(--hover); }
html.mobile .task:active { background: var(--card-hover); }
html.mobile #app { height: 100dvh; }
html.mobile #main { padding-top: var(--sa-top); padding-bottom: var(--sa-bottom); }
html.mobile #main::after { display: none; } /* the film grain's blend mode is costly on phones */
html.mobile #list-header { padding: 12px 12px 6px 16px; }
html.mobile .lh-title { font-size: 24px; }
html.mobile .lh-right .hdr-btn span { display: none; }
/* All's filter chips get their own row under the title, so the title isn't squeezed out */
html.mobile .lh-right { display: contents; }
html.mobile .lh-right .hdr-divider { display: none; }
html.mobile .filter-chips { order: 1; width: 100%; margin: 2px 7px 0 -7px; } /* lines up with the cards below */
html.mobile .filter-chip { flex: 1; justify-content: center; height: 36px; padding: 0 8px; border-radius: 18px; font-size: 14px; }
html.mobile .hdr-btn, html.mobile .icon-btn { min-width: 40px; height: 40px; justify-content: center; }
html.mobile #task-scroll { padding: 4px 10px calc(24px + var(--sa-bottom)); }
html.mobile .task { min-height: 58px; padding: 6px 4px 6px 14px; }
html.mobile .star { width: 44px; height: 44px; }
html.mobile .check { width: 26px; height: 26px; }
html.mobile .step .icon-btn { opacity: 1; }
html.mobile .row-btn { min-height: 54px; }

/* the sidebar is a drawer over the list */
html.mobile #sidebar {
  position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(330px, 86vw); height: auto;
  padding-top: var(--sa-top); padding-bottom: var(--sa-bottom);
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5); transition: transform 0.2s ease;
}
html.mobile body.sidebar-collapsed #sidebar { display: flex; transform: translateX(-105%); box-shadow: none; }
html.mobile #app::after { content: ""; position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, 0.5); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
html.mobile body:not(.sidebar-collapsed) #app::after { opacity: 1; }
/* while a swipe drags the drawer, it follows the finger (mobile-ui.js sets --drawer-x and --drawer-p) */
html.mobile body.drawer-drag #sidebar { display: flex; transition: none; transform: translateX(var(--drawer-x)); box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5); }
html.mobile body.drawer-drag #app::after { transition: none; opacity: var(--drawer-p); }
html.mobile .nav-item { min-height: 48px; }
html.mobile #btn-toggle-sidebar { display: none; }

/* task details and suggestions take the whole screen; their close button goes on top */
html.mobile #details { position: fixed; inset: 0; width: auto; z-index: 30; border-left: 0; padding-top: var(--sa-top); padding-bottom: var(--sa-bottom); }
html.mobile #details .d-footer { order: -1; border-top: 0; border-bottom: 1px solid var(--border); }

/* menus are bottom sheets over a scrim */
html.mobile #menu-layer:has(.menu) { pointer-events: auto; background: rgba(0, 0, 0, 0.45); }
html.mobile .menu {
  left: 0 !important; right: 0; top: auto !important; bottom: 0; width: 100%; max-width: none; min-width: 0;
  max-height: 80dvh; border-radius: 14px 14px 0 0; padding: 8px 8px calc(10px + var(--sa-bottom)); animation: sheetin 0.16s ease;
}
@keyframes sheetin { from { transform: translateY(24px); opacity: 0; } }
html.mobile .menu-item { height: 50px; font-size: 16px; gap: 16px; }
html.mobile .menu-item .ico { width: 20px; height: 20px; }
html.mobile .menu-item .mi-hint { display: none; }
html.mobile .pop-form .field { height: 44px; }

/* dialogs: settings and setup fill the screen; small confirmations stay cards */
html.mobile .modal { width: 100vw; height: 100dvh; max-height: none; border-radius: 0; padding-top: var(--sa-top); padding-bottom: var(--sa-bottom); }
html.mobile .modal.small { width: calc(100vw - 32px); height: auto; border-radius: 12px; padding: 0; }
html.mobile .modal-body { flex: 1; }
html.mobile .btn { height: 42px; }
html.mobile .btn.big { display: block; width: 100%; height: 50px; margin: 10px 0; font-size: 16px; }
html.mobile .set-row { min-height: 52px; }
html.mobile .toggle { width: 48px; height: 26px; border-radius: 13px; }
html.mobile .toggle::after { width: 16px; height: 16px; top: 4px; left: 5px; }
html.mobile .toggle:checked::after { left: 26px; }
/* update dialog (updates.js) */
.update-notes { white-space: pre-wrap; max-height: 40vh; overflow-y: auto; margin: 10px 0 0; padding: 10px 12px; border-radius: 8px; background: rgba(255, 255, 255, 0.04); color: var(--muted); font-size: 14px; }
.update-track { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
#update-bar { width: 0; height: 100%; background: var(--accent); transition: width 0.2s; }
html.mobile #toast { bottom: calc(16px + var(--sa-bottom)); max-width: calc(100vw - 24px); width: max-content; }
.m-setup p { line-height: 1.5; }
.m-code { font: 600 32px/1.2 ui-monospace, "Roboto Mono", monospace; letter-spacing: 0.14em; text-align: center; padding: 18px; background: var(--card); border-radius: 8px; margin: 12px 0; user-select: text; }
.m-repos { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; max-height: 45dvh; overflow-y: auto; }
.m-repo { display: flex; gap: 12px; align-items: center; padding: 12px; background: var(--card); border-radius: 8px; }
.m-repo input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.m-advanced { margin: 10px 0; color: var(--muted); }
.m-advanced summary { padding: 8px 0; }

/* ------------------------------------------------ print */
@media print {
  body, #main { background: #fff !important; color: #000 !important; overflow: visible; height: auto; }
  html, #app, #task-scroll { height: auto; overflow: visible; display: block; }
  #sidebar, #details, #add-task, .lh-right, .sort-chip, #toast, #menu-layer, .star { display: none !important; }
  #list-header, .group-title, .empty { color: #000 !important; }
  .task { box-shadow: none; border-bottom: 1px solid #ccc; border-radius: 0; break-inside: avoid; background: #fff !important; }
  .task-meta, .task.completed .task-title { color: #555 !important; }
  .check { border-color: #555 !important; background: #fff !important; color: #000 !important; }
}

/* ============================================================ web app (src/renderer/web-ui.js) */
.w-setup { max-width: 520px; }
.w-setup p { line-height: 1.5; }
.w-setup a { color: var(--accent); }
.w-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 14px; }
html.web .btn.big { height: 40px; padding: 0 20px; font-size: 14px; }
html.web .m-repos { max-height: 40vh; }
