:root {
  --bg: #0f141b; --bg2: #161d26; --card: #1b232e; --line: #2a3542;
  --text: #e6edf3; --muted: #8b98a9; --accent: #4f8ef7; --accent2: #2f6fe0;
  --green: #3fb950; --amber: #d29922; --red: #e5534b; --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
#root { height: 100%; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent2); border-color: var(--accent2); }
button.primary.danger { background: var(--red); border-color: var(--red); color: #fff; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); border-color: var(--line); }
input, select { font: inherit; color: var(--text); background: var(--bg2);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
a { color: var(--accent); }

/* login */
#login-screen { margin: auto; max-width: 340px; padding: 24px; }
#login-screen h1 { display: flex; align-items: center; gap: 10px; font-size: 30px; }
#login-screen .pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
#login-screen .pinpad button { padding: 14px 0; font-size: 18px; }
.pin-field { font-size: 22px; letter-spacing: 8px; text-align: center; width: 100%; }
.muted { color: var(--muted); }
.err { color: var(--red); min-height: 18px; }

/* topbar */
#topbar { display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--bg2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
#topbar .logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
#topbar .spacer { flex: 1; }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; }

/* body layout */
#main { display: flex; flex: 1; min-height: 0; }
#sidebar { width: 230px; border-right: 1px solid var(--line); padding: 12px 8px; overflow-y: auto; flex-shrink: 0; }
#content { flex: 1; overflow-y: auto; padding: 16px 20px 80px; }
#sidebar .side-head { display: flex; justify-content: space-between; align-items: center;
  padding: 0 8px 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
#sidebar .list-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; }
#sidebar .list-item:hover { background: var(--bg2); }
#sidebar .list-item.active { background: var(--card); box-shadow: inset 2px 0 0 var(--accent); }
#sidebar .list-item .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* tasks */
.task-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px;
  border-radius: 8px; }
.task-row:hover { background: var(--card); }
.task-row .grip { display: flex; flex-direction: column; visibility: hidden; }
.task-row:hover .grip { visibility: visible; }
.task-row .grip button { padding: 0 4px; font-size: 10px; border: none; background: none; color: var(--muted); }
.chevron { border: 1px solid var(--line); background: transparent; color: var(--muted);
  width: 20px; height: 20px; border-radius: 5px; padding: 0; line-height: 1; font-size: 10px; }
.checkbox { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--muted);
  background: transparent; padding: 0; flex-shrink: 0; display: inline-flex;
  align-items: center; justify-content: center; font-size: 12px; line-height: 1; }
.checkbox.done { background: var(--green); border-color: var(--green); color: #fff; }
.checkbox.in_progress { border-color: var(--amber); color: var(--amber); }
.task-main { flex: 1; min-width: 0; }
.task-title { word-break: break-word; }
.task-title.done { text-decoration: line-through; color: var(--muted); }
.task-meta { display: flex; gap: 8px; align-items: center; margin-top: 2px; flex-wrap: wrap; }
.badge { font-size: 10px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); }
.badge.tier-MAIN { color: #fff; background: #2f6fe0; border-color: #2f6fe0; }
.badge.tier-SUB { color: var(--text); background: #234; border-color: #345; }
.badge.tier-STEP { color: var(--muted); }
.badge.due { border-color: var(--amber); color: var(--amber); }
.badge.due.overdue { border-color: var(--red); color: var(--red); }
.assignee { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.task-actions { display: flex; gap: 4px; visibility: hidden; }
.task-row:hover .task-actions { visibility: visible; }
.task-actions button { padding: 2px 8px; font-size: 12px; }
.children { margin-left: 26px; border-left: 1px solid var(--line); padding-left: 8px; }
.task-add { display: flex; gap: 8px; margin: 6px 0 4px; }
.task-add input { flex: 1; }
.progress-note { color: var(--muted); font-size: 11px; margin-left: 6px; }

/* sections / cards */
h2.section { font-size:15px; margin: 18px 0 6px; }
h2.section:first-child { margin-top: 2px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.member-item { display:flex; align-items:center; gap:8px; padding:6px 8px; border-radius:8px; }
.member-item:hover { background: var(--bg2); }
table { width: 100%; border-collapse: collapse; }
td, th { text-align:left; padding:6px 8px; border-bottom:1px solid var(--line); }
code { background: var(--bg2); padding: 2px 6px; border-radius: 6px; user-select: all; }

/* dialog */
#dialog-overlay { position: fixed; inset:0; background: rgba(0,0,0,.55); display:flex;
  align-items:center; justify-content:center; z-index: 50; }
#dialog { background: var(--card); border:1px solid var(--line); border-radius: var(--radius);
  padding: 18px; width: min(440px, calc(100vw - 32px)); max-height: 86vh; overflow-y:auto; }
#dialog h3 { margin: 0 0 12px; }
#dialog .form-row { margin-bottom: 10px; display:flex; flex-direction:column; gap:4px; }
#dialog label { font-size: 12px; color: var(--muted); }

/* toast */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--line); padding: 10px 16px;
  border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.4); opacity: 0;
  pointer-events: none; transition: opacity .18s; z-index: 99; max-width: 90vw; }
#toast.show { opacity: 1; }

/* mobile */
@media (max-width: 760px) {
  #sidebar { position: fixed; left: 0; top: 51px; bottom: 0; width: 240px; background: var(--bg2);
    transform: translateX(-100%); transition: transform .2s; z-index: 20; }
  #sidebar.open { transform: translateX(0); box-shadow: 8px 0 30px rgba(0,0,0,.5); }
  #menu-btn { display: inline-block !important; }
  #content { padding: 12px 12px 90px; }
  .task-actions { visibility: visible; }
  .grid2 { grid-template-columns: 1fr; }
}
/* ---------- themes (Phase 2 design ideas) ---------- */
:root, [data-theme="signal"] {
  --bg: #ffffff; --bg2: #f2f4ff; --card: #f2f4ff; --line: #c9d2ff;
  --text: #101536; --muted: #5a639c; --accent: #2f3fd1; --accent2: #2f3fd1;
  --green: #0f7a3d; --amber: #9a6200; --red: #c81e1e; --radius: 6px;
}
[data-theme="paper"] {
  --bg: #faf6ee; --bg2: #fffdf7; --card: #fffdf7; --line: #e5dcc8;
  --text: #2b2620; --muted: #8a7f6a; --accent: #b3402e; --accent2: #b3402e;
  --green: #3d7a44; --amber: #b97a1a; --red: #b3402e; --radius: 8px;
}
[data-theme="paper"] body { font-family: Georgia, "Times New Roman", serif; }
[data-theme="midnight"] {
  --bg: #0d1117; --bg2: #161c26; --card: #161c26; --line: #2a3444;
  --text: #e8eef7; --muted: #8b98ac; --accent: #38e1c6; --accent2: #1fae98;
  --green: #38e1c6; --amber: #f2b234; --red: #ff6b6b; --radius: 10px;
}
[data-theme="forest"] {
  --bg: #f1f5ef; --bg2: #ffffff; --card: #ffffff; --line: #d7e2d2;
  --text: #22301f; --muted: #6d7f68; --accent: #2f6b3a; --accent2: #2f6b3a;
  --green: #2f6b3a; --amber: #9a6a00; --red: #b3402e; --radius: 14px;
}
[data-theme="ocean"] {
  --bg: #06222e; --bg2: #0a2e3d; --card: #0a2e3d; --line: #16485c;
  --text: #e6f4f8; --muted: #7fa6b5; --accent: #4fd1ff; --accent2: #2ba8d6;
  --green: #3ddc97; --amber: #ffd166; --red: #ff7a7a; --radius: 8px;
}
[data-theme="ember"] {
  --bg: #120d0d; --bg2: #1c1414; --card: #1c1414; --line: #3a2724;
  --text: #f6ece6; --muted: #ab938a; --accent: #ff5b39; --accent2: #c93a22;
  --green: #46d17c; --amber: #ffb020; --red: #ff5147; --radius: 8px;
}

/* ---------- bottom bar ---------- */
#bottombar { display: flex; border-top: 1px solid var(--line); background: var(--bg2);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); position: sticky; bottom: 0; z-index: 5; }
#bottombar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: transparent; border: none; color: var(--muted); padding: 6px 0 4px; font-size: 11px; }
#bottombar button.active { color: var(--accent); font-weight: 700; }
#bottombar .tab-ico { font-size: 20px; line-height: 1; }
#content { padding-bottom: 90px; }

/* ---------- list tabs ---------- */
#list-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; }
.list-tab { display: flex; align-items: center; gap: 7px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--bg2); border-radius: 999px; padding: 7px 14px; }
.list-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.list-tab.active .count { color: inherit; opacity: .85; }
.list-tab .count { color: var(--muted); font-size: 12px; }
.list-tab.new { border-style: dashed; }
.badge.tier-LIST { color: #fff; background: var(--accent); border-color: var(--accent); font-weight: 700; }

/* ---------- statuses ---------- */
.status-btn { width: 28px; height: 28px; border: none; background: transparent; padding: 1px;
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--muted); }
.status-btn svg { width: 24px; height: 24px; }
.status-btn.st-in_progress { color: var(--amber); }
.status-btn.st-completed { color: var(--green); }
.status-btn.st-canceled { color: var(--red); }
/* ---------- svg icons (2px line set) ---------- */
.tab-ico svg { width: 23px; height: 23px; display: block; }
.logo-mark svg { width: 24px; height: 24px; display: block; color: var(--accent); }
#login-screen h1 .logo-mark svg { width: 30px; height: 30px; }
#login-screen h1 { display: flex; align-items: center; gap: 10px; }
.inline-ico svg { width: 15px; height: 15px; vertical-align: -2px; }
.task-actions svg { width: 15px; height: 15px; display: block; }
.task-actions button { display: inline-flex; align-items: center; gap: 4px; }
.grip svg { width: 11px; height: 11px; display: block; }
.badge.st-badge svg { width: 11px; height: 11px; vertical-align: -1px; }
.task-title.done { text-decoration: none; color: var(--text); }
.task-title.canceled { text-decoration: line-through; color: var(--muted); }
.task-title.backlogged { color: var(--muted); }
.badge.st-badge { text-transform: capitalize; }
.badge.st-completed { border-color: var(--green); color: var(--green); }
.badge.st-in_progress { border-color: var(--amber); color: var(--amber); }
.badge.st-canceled { border-color: var(--red); color: var(--red); }
.badge.st-backlogged { border-style: dashed; }

/* ---------- settings ---------- */
#theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-pick { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.theme-pick.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
/* Each theme card previews its OWN fixed colors, so names stay readable
   no matter which theme is currently active. */
.theme-pick[data-theme="signal"] { background: #f2f4ff; color: #101536; border-color: #c9d2ff; }
.theme-pick[data-theme="paper"] { background: #fffdf7; color: #2b2620; border-color: #e5dcc8; }
.theme-pick[data-theme="midnight"] { background: #161c26; color: #e8eef7; border-color: #2a3444; }
.theme-pick[data-theme="forest"] { background: #ffffff; color: #22301f; border-color: #d7e2d2; }
.theme-pick[data-theme="ocean"] { background: #0a2e3d; color: #e6f4f8; border-color: #16485c; }
.theme-pick[data-theme="ember"] { background: #1c1414; color: #f6ece6; border-color: #3a2724; }
.theme-swatch { width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0; border: 1px solid var(--line); }
.theme-swatch[data-swatch="signal"] { background: linear-gradient(135deg, #fff 50%, #2f3fd1 50%); }
.theme-swatch[data-swatch="paper"] { background: linear-gradient(135deg, #faf6ee 50%, #b3402e 50%); }
.theme-swatch[data-swatch="midnight"] { background: linear-gradient(135deg, #0d1117 50%, #38e1c6 50%); }
.theme-swatch[data-swatch="forest"] { background: linear-gradient(135deg, #f1f5ef 50%, #2f6b3a 50%); }
.theme-swatch[data-swatch="ocean"] { background: linear-gradient(135deg, #06222e 50%, #4fd1ff 50%); }
.theme-swatch[data-swatch="ember"] { background: linear-gradient(135deg, #120d0d 50%, #ff5b39 50%); }
@media (max-width: 760px) { #theme-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- priority ---------- */
.task-row { border-left: 3px solid transparent; }
.task-row.prio-high { border-left-color: var(--red); }
.task-row.prio-medium { border-left-color: transparent; }
.task-row.prio-low { border-left-color: transparent; opacity: .92; }
.task-row.prio-high .task-title { font-weight: 700; }
.prio-flag { border: none; background: transparent; padding: 2px; cursor: pointer;
  color: var(--muted); display: inline-flex; align-items: center; }
.prio-flag svg { width: 15px; height: 15px; }
.prio-flag.prio-high { color: var(--red); }
.prio-flag.prio-medium { color: var(--muted); opacity: .7; }
.prio-flag.prio-low { color: var(--muted); opacity: .4; }

/* ---------- overdue stand-out ---------- */
.overdue-tag { font-size: 10px; font-weight: 800; letter-spacing: .05em;
  color: #fff; background: var(--red); border-radius: 6px; padding: 2px 7px;
  animation: overdue-pulse 1.6s ease-in-out infinite; white-space: nowrap; }
@keyframes overdue-pulse { 50% { filter: brightness(1.25); } }
@media (prefers-reduced-motion: reduce) { .overdue-tag { animation: none; } }
.task-row.is-overdue { background: color-mix(in srgb, var(--red) 7%, transparent); border-radius: 8px; }
.task-row.flash { animation: rowflash 1.8s ease-out; border-radius: 8px; }
@keyframes rowflash { 0%, 40% { background: color-mix(in srgb, var(--accent) 30%, transparent); } 100% { background: transparent; } }
.badge.prio-high-badge { border-color: var(--red); color: #fff; background: var(--red); font-weight: 800; letter-spacing: .04em; }
.task-row.prio-high[data-task] { box-shadow: inset 0 1px 0 color-mix(in srgb, var(--red) 55%, transparent), inset 0 -1px 0 color-mix(in srgb, var(--red) 55%, transparent); }

/* ---------- drag & drop ---------- */
.task-row[draggable="true"] { cursor: grab; }
.task-row[draggable="true"]:active { cursor: grabbing; }
.task-row.dragging { opacity: .45; }
.task-row.drop-nest { outline: 2px solid var(--accent); outline-offset: -2px;
  background: var(--card); border-radius: 8px; }
.task-row.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.task-row.drop-after { box-shadow: 0 3px 0 var(--accent); }
#task-tree.drop-root { outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: 8px; }
.drag-ghost { position: fixed; z-index: 99; pointer-events: none; opacity: .93;
  box-shadow: 0 10px 32px rgba(0,0,0,.55); background: var(--card); border-radius: 8px; }
body.dnd-active, body.dnd-active #content { overscroll-behavior: none; }
.dnd-hint { user-select: none; }

/* ---------- list color + swatches + deadline chips ---------- */
.color-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line);
  padding: 0; cursor: pointer; flex-shrink: 0; }
.swatch-row { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 9px; border: 2px solid transparent; padding: 0; cursor: pointer; }
.swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg2), 0 0 0 3px var(--text); }
.badge.sched { border-color: var(--accent); color: var(--accent); }
.due-chips { margin-top: 6px; }
.due-chips button { font-size: 12px; padding: 3px 10px; }
#d-recur-dow button, #d-recur-presets button { font-size: 12px; padding: 3px 10px; }
#d-recur-dow button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.badge.recur-badge { border-color: var(--vio, #bc8cff); color: var(--vio, #bc8cff); }
kbd { background: var(--bg2, #222b38); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; font-size: 12px; font-family: inherit; }
#bulkbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 14px; z-index: 60;
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center;
  background: var(--card); border: 1px solid var(--accent); border-radius: 12px; padding: 8px 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); max-width: 96vw; font-size: 13px; }
#bulkbar button, #bulkbar select { font-size: 12px; padding: 4px 10px; }
#bulkbar button.danger { background: var(--red); border-color: var(--red); color: #fff; }
.bulk-check { width: 18px; height: 18px; flex-shrink: 0; }
#toast button { font: inherit; }
#list-tabs .list-tab svg { width: 14px; height: 14px; }

/* ---------- more tabs ---------- */
#more-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px; }
.more-tab { white-space: nowrap; border-radius: 999px; padding: 7px 16px; }
.more-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }

/* ---------- templates + database editor ---------- */
.tpl-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.tpl-row input.tt { flex: 1; min-width: 90px; }
.tpl-row select.tp { max-width: 96px; }
.tpl-row input.td { max-width: 140px; }
.tpl-row button { padding: 4px 9px; font-size: 13px; }
.db-warn { border: 1px solid var(--red); border-radius: 8px; padding: 8px 10px; }
.db-grid input, .db-grid textarea { font-size: 12px; padding: 4px 6px; max-width: 170px;
  font-family: ui-monospace, monospace; }
.db-grid td, .db-grid th { font-size: 12px; vertical-align: top; }
.db-grid td code { font-size: 11px; }

/* ---------- logo ideas gallery ---------- */
#logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.logo-card { position: relative; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; background: var(--bg2); }
.logo-art { height: 72px; display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
.logo-art svg { width: 46px; height: 46px; color: var(--text); }
.logo-num { position: absolute; top: 14px; left: 14px; font-size: 11px; font-weight: 800;
  background: var(--accent); color: #fff; border-radius: 999px;
  min-width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }
.logo-name { font-weight: 700; font-size: 13px; }
.logo-tag { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }
.logo-blurb { font-size: 12px; color: var(--muted); }
