/* ProgMuna stylesheet. 8px spacing grid, system fonts, one accent colour. */

:root {
  color-scheme: light;
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f1f1f3;
  --surface-3: #e8e8eb;
  --border: #e3e3e7;
  --border-strong: #cfcfd5;
  --text: #17171c;
  --text-2: #4b4b55;
  --text-3: #7a7a85;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-text: #3730a3;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --success: #16a34a;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --p-urgent: #dc2626;
  --p-high: #ea580c;
  --p-medium: #ca8a04;
  --p-low: #2563eb;
  --p-none: #9ca3af;
  --overlay: rgba(20, 20, 25, 0.35);
  --radius: 6px;
  --radius-lg: 10px;
  --sidebar-w: 232px;
  --panel-w: 560px;
  --topbar-h: 48px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121215;
    --surface: #1a1a1f;
    --surface-2: #222228;
    --surface-3: #2a2a31;
    --border: #2b2b33;
    --border-strong: #3d3d47;
    --text: #e8e8ec;
    --text-2: #b4b4bd;
    --text-3: #83838f;
    --accent: #8b85f5;
    --accent-hover: #a29df8;
    --accent-soft: #24244a;
    --accent-text: #c7c5ff;
    --danger: #f87171;
    --danger-soft: #3f1d1d;
    --success: #4ade80;
    --warning: #fbbf24;
    --warning-soft: #3d2e0d;
    --p-urgent: #f87171;
    --p-high: #fb923c;
    --p-medium: #facc15;
    --p-low: #60a5fa;
    --p-none: #6b6b76;
    --overlay: rgba(0, 0, 0, 0.55);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121215;
  --surface: #1a1a1f;
  --surface-2: #222228;
  --surface-3: #2a2a31;
  --border: #2b2b33;
  --border-strong: #3d3d47;
  --text: #e8e8ec;
  --text-2: #b4b4bd;
  --text-3: #83838f;
  --accent: #8b85f5;
  --accent-hover: #a29df8;
  --accent-soft: #24244a;
  --accent-text: #c7c5ff;
  --danger: #f87171;
  --danger-soft: #3f1d1d;
  --success: #4ade80;
  --warning: #fbbf24;
  --warning-soft: #3d2e0d;
  --p-urgent: #f87171;
  --p-high: #fb923c;
  --p-medium: #facc15;
  --p-low: #60a5fa;
  --p-none: #6b6b76;
  --overlay: rgba(0, 0, 0, 0.55);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.45 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }
h1 { font-size: 18px; } h2 { font-size: 15px; } h3 { font-size: 13px; }
p { margin: 0 0 8px; }
code, kbd, pre { font-family: var(--mono); font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
svg.icon.sm { width: 14px; height: 14px; }
svg.icon.xs { width: 12px; height: 12px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100vh; }
.content { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.main { flex: 1; min-height: 0; overflow: auto; position: relative; }
.main:focus { outline: none; }
.page { padding: 16px 24px 48px; max-width: 1400px; }
.page-wide { padding: 16px 24px 48px; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh; overflow-y: auto; padding: 8px;
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 12px; }
.sidebar-brand .brand { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; color: var(--text); }
.sidebar-brand .brand-mark { width: 20px; height: 20px; border-radius: 6px; background: var(--accent); display: inline-block; }
.nav-section { margin-top: 12px; }
.nav-heading { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); }
.nav-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border-radius: var(--radius);
  color: var(--text-2); background: none; border: 0; text-align: left; font-size: 13.5px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 500; }
.nav-item .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.nav-item .count { margin-left: auto; font-size: 11px; color: var(--text-3); }
.nav-item.archived { opacity: 0.6; }
.sidebar-footer { margin-top: auto; padding: 8px; font-size: 12px; color: var(--text-3); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-backdrop { display: none; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  min-height: var(--topbar-h); padding: 6px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; min-width: 0; }
.topbar-title .dot { width: 12px; height: 12px; border-radius: 4px; }
.topbar-spacer { flex: 1; }
.view-tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 2px; border-radius: var(--radius); }
.view-tab { padding: 4px 10px; border-radius: 4px; border: 0; background: none; color: var(--text-2); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.view-tab:hover { color: var(--text); text-decoration: none; }
.view-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.icon-btn.menu-btn { display: none; }

/* ---------- Filter bar ---------- */
.filterbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--bg); min-height: 44px; }
.filterbar .search { position: relative; }
.filterbar .search input { padding-left: 28px; width: 200px; }
.filterbar .search svg { position: absolute; left: 8px; top: 8px; color: var(--text-3); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-text); font-size: 12px; border: 1px solid transparent; max-width: 280px;
}
.chip .chip-x { border: 0; background: none; padding: 0 2px; color: inherit; display: inline-flex; border-radius: 50%; }
.chip .chip-x:hover { background: rgba(0,0,0,0.1); }
.chip b { font-weight: 600; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 13px; line-height: 20px;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 2px 8px; font-size: 12px; line-height: 18px; }
.btn-block { width: 100%; justify-content: center; }
.btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: var(--radius); border: 0; background: none; color: var(--text-2); padding: 0; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.input, .select, .textarea, input[type="text"], input[type="password"], input[type="date"], input[type="search"], input[type="number"], select, textarea {
  padding: 5px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); line-height: 20px; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px var(--accent-soft); }
textarea { resize: vertical; min-height: 80px; width: 100%; font-family: var(--font); }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
input[type="color"] { width: 32px; height: 28px; padding: 0 2px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; font-weight: 500; }
.field input, .field select, .field textarea { width: 100%; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.kbd { display: inline-block; padding: 0 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); font-size: 11px; line-height: 18px; color: var(--text-2); }
.alert { padding: 8px 12px; border-radius: var(--radius); margin-bottom: 12px; font-size: 13px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--accent-soft); color: var(--accent-text); }
.inline-edit { border: 1px solid transparent; border-radius: 4px; padding: 2px 4px; margin: -2px -4px; }
.inline-edit:hover { border-color: var(--border-strong); }
.inline-edit:focus { border-color: var(--accent); background: var(--surface); }

/* ---------- Tags (priority, status, label) ---------- */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 6px; border-radius: 4px; font-size: 11.5px; font-weight: 500; line-height: 16px; white-space: nowrap; border: 1px solid transparent; }
.tag-priority { color: var(--pc); background: color-mix(in srgb, var(--pc) 12%, transparent); }
.tag-priority svg { width: 12px; height: 12px; }
.tag-priority.urgent { --pc: var(--p-urgent); }
.tag-priority.high { --pc: var(--p-high); }
.tag-priority.medium { --pc: var(--p-medium); }
.tag-priority.low { --pc: var(--p-low); }
.tag-priority.none { --pc: var(--p-none); }
.tag-label { color: var(--lc); background: color-mix(in srgb, var(--lc) 14%, transparent); }
.tag-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--lc); }
.tag-status { color: var(--text-2); background: var(--surface-2); border-color: var(--border); }
.tag-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--sc, var(--text-3)); }
.tag-key { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.tag-date { color: var(--text-3); font-size: 12px; display: inline-flex; align-items: center; gap: 3px; }
.tag-date.overdue { color: var(--danger); font-weight: 500; }
.tag-date.today { color: var(--warning); font-weight: 500; }
.tag-progress { color: var(--text-3); font-size: 11.5px; display: inline-flex; align-items: center; gap: 3px; }
.progress { height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; flex: 1; }
.progress > span { display: block; height: 100%; background: var(--success); }

/* ---------- Menus / popovers ---------- */
.popover {
  position: fixed; z-index: 60; min-width: 180px; max-width: 320px; max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 4px;
}
.popover .menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; background: none; border-radius: var(--radius);
  text-align: left; color: var(--text); font-size: 13px;
}
.popover .menu-item:hover, .popover .menu-item:focus { background: var(--surface-2); outline: none; }
.popover .menu-item.selected { background: var(--accent-soft); color: var(--accent-text); }
.popover .menu-item.danger { color: var(--danger); }
.popover .menu-item .check { margin-left: auto; width: 14px; }
.popover .menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.popover .menu-heading { padding: 6px 8px 2px; font-size: 11px; text-transform: uppercase; color: var(--text-3); letter-spacing: 0.04em; }
.popover .menu-search { width: 100%; margin-bottom: 4px; }
.popover .menu-body { padding: 8px; }

/* ---------- Modals ---------- */
.modal-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 70; display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); width: 100%; max-width: 520px; max-height: 80vh; overflow: auto; }
.modal.wide { max-width: 720px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 16px; right: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: var(--radius); font-size: 13px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; }
.toast.error { background: var(--danger); color: #fff; }
.toast button { background: none; border: 0; color: inherit; font-weight: 600; padding: 0; }

/* ---------- Board ---------- */
.board { display: flex; gap: 12px; padding: 16px; height: 100%; overflow-x: auto; align-items: flex-start; }
.board-col { flex: 0 0 280px; max-height: 100%; display: flex; flex-direction: column; background: var(--surface-2); border-radius: var(--radius-lg); border: 1px solid var(--border); }
.board-col-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 600; font-size: 13px; }
.board-col-head .dot { width: 8px; height: 8px; border-radius: 50%; }
.board-col-head .count { color: var(--text-3); font-weight: 400; }
.board-col-head .icon-btn { margin-left: auto; width: 24px; height: 24px; }
.board-cards { flex: 1; overflow-y: auto; padding: 0 8px 8px; min-height: 40px; display: flex; flex-direction: column; gap: 8px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
}
.card:hover { border-color: var(--border-strong); }
.card.completed .card-title { color: var(--text-3); text-decoration: line-through; }
.card-title { font-size: 13px; line-height: 1.35; }
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sortable-ghost { opacity: 0.4; }
.sortable-chosen { box-shadow: var(--shadow); }
.board-add { margin: 0 8px 8px; }
.board-add input { width: 100%; }
.col-add-btn { margin: 0 8px 8px; justify-content: flex-start; color: var(--text-3); }

/* ---------- Table / list ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; white-space: nowrap; }
.table th { font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.03em; position: sticky; top: 0; background: var(--bg); z-index: 1; user-select: none; }
.table th.sortable { cursor: pointer; }
.table th.sortable:hover { color: var(--text); }
.table th .sort-ind { margin-left: 4px; }
.table td.title-cell { white-space: normal; min-width: 240px; max-width: 520px; }
.table tr.task-row { cursor: pointer; }
.table tr.task-row:hover { background: var(--surface-2); }
.table tr.task-row.selected { background: var(--accent-soft); }
.table tr.completed .title-text { color: var(--text-3); text-decoration: line-through; }
.table tr.group-row td { background: var(--surface-2); font-weight: 600; padding: 8px 10px; }
.table .cell-btn { background: none; border: 0; padding: 2px 4px; margin: -2px -4px; border-radius: 4px; color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table .cell-btn:hover { background: var(--surface-3); }
.table td.check-cell, .table th.check-cell { width: 28px; padding-right: 0; }
.table .subtask-indent { display: inline-block; width: 16px; color: var(--text-3); }
.empty { padding: 48px 16px; text-align: center; color: var(--text-3); }
.empty h3 { color: var(--text-2); margin-bottom: 4px; }
.bulkbar { position: sticky; bottom: 0; display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: var(--surface); border-top: 1px solid var(--border); flex-wrap: wrap; z-index: 2; }

/* ---------- Task detail panel ---------- */
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--panel-w); max-width: 100vw; z-index: 50;
  background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.panel-header { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.panel-body { flex: 1; overflow-y: auto; padding: 16px 20px 32px; }
.panel-title { width: 100%; font-size: 18px; font-weight: 600; border: 1px solid transparent; border-radius: var(--radius); padding: 4px 6px; margin: 0 -6px 8px; background: none; resize: none; min-height: 0; line-height: 1.3; overflow: hidden; }
.panel-title:hover { border-color: var(--border-strong); }
.panel-title:focus { border-color: var(--accent); background: var(--surface); }
.props { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; align-items: center; margin: 8px 0 16px; font-size: 13px; }
.props > .prop-label { color: var(--text-3); }
.props .prop-value { min-height: 26px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.prop-btn { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px; margin: 0 -6px; border: 1px solid transparent; border-radius: var(--radius); background: none; color: var(--text); font-size: 13px; }
.prop-btn:hover { border-color: var(--border-strong); }
.prop-btn.placeholder { color: var(--text-3); }
.section { margin-top: 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.section-head h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); }
.md { font-size: 13.5px; line-height: 1.55; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 8px; }
.md h1, .md h2, .md h3 { margin: 12px 0 6px; } .md h1 { font-size: 17px; } .md h2 { font-size: 15px; } .md h3 { font-size: 14px; }
.md ul, .md ol { margin: 0 0 8px; padding-left: 22px; }
.md li { margin: 2px 0; } .md li.task { list-style: none; margin-left: -18px; }
.md pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; overflow-x: auto; margin: 0 0 8px; }
.md code { background: var(--surface-2); padding: 1px 4px; border-radius: 3px; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 0 0 8px; padding: 2px 12px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.md a { word-break: break-all; }
.md table { border-collapse: collapse; margin: 0 0 8px; } .md th, .md td { border: 1px solid var(--border); padding: 3px 8px; }
.md-placeholder { color: var(--text-3); cursor: text; padding: 6px; margin: -6px; border-radius: var(--radius); }
.md-placeholder:hover, .md-view:hover { background: var(--surface-2); }
.md-view { padding: 6px; margin: -6px; border-radius: var(--radius); cursor: text; }
.md-editor textarea { min-height: 140px; font-family: var(--mono); font-size: 13px; }
.md-editor .md-toolbar { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.checklist li.done .cl-text { color: var(--text-3); text-decoration: line-through; }
.checklist .cl-text { flex: 1; border: 1px solid transparent; padding: 2px 4px; border-radius: 4px; background: none; }
.checklist .cl-text:focus { border-color: var(--accent); background: var(--surface); }
.checklist .cl-handle { color: var(--text-3); cursor: grab; }
.checklist .icon-btn { opacity: 0; width: 24px; height: 24px; }
.checklist li:hover .icon-btn, .checklist li:focus-within .icon-btn { opacity: 1; }
.subtasks { list-style: none; margin: 0; padding: 0; }
.subtasks li { display: flex; align-items: center; gap: 8px; padding: 5px 6px; margin: 0 -6px; border-radius: var(--radius); cursor: pointer; }
.subtasks li:hover { background: var(--surface-2); }
.subtasks li.completed .st-title { color: var(--text-3); text-decoration: line-through; }
.subtasks .st-title { flex: 1; }
.quick-add { display: flex; gap: 6px; margin-top: 6px; }
.quick-add input { flex: 1; }
.tabs { display: flex; gap: 16px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tab { padding: 6px 0; border: 0; background: none; color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tab.active { color: var(--text); border-color: var(--accent); }
.comment { padding: 10px 0; border-bottom: 1px solid var(--border); }
.comment-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.comment-head .icon-btn { width: 22px; height: 22px; opacity: 0; }
.comment:hover .comment-head .icon-btn { opacity: 1; }
.activity { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.activity li { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); color: var(--text-2); }
.activity li time { color: var(--text-3); margin-left: auto; white-space: nowrap; }
.activity b { font-weight: 500; color: var(--text); }
.panel-backdrop { display: none; }

/* ---------- Home ---------- */
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 16px; }
@media (max-width: 600px) { .home-grid { grid-template-columns: 1fr; } .task-list .tl-project { display: none; } }
.home-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.home-section h2 { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.home-section h2 .count { color: var(--text-3); font-weight: 400; }
.task-list { list-style: none; margin: 0; padding: 4px 0; }
.task-list li { display: flex; align-items: center; gap: 8px; padding: 6px 14px; cursor: pointer; }
.task-list li:hover { background: var(--surface-2); }
.task-list li.completed .tl-title { color: var(--text-3); text-decoration: line-through; }
.task-list .tl-title { flex: 1; min-width: 0; }
.task-list .tl-project { font-size: 11px; color: var(--text-3); white-space: nowrap; max-width: 30%; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Palette ---------- */
.palette { max-width: 560px; }
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 12px 16px; font-size: 15px; background: none; }
.palette input:focus { box-shadow: none; }
.palette-results { max-height: 50vh; overflow-y: auto; padding: 4px; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius); cursor: pointer; }
.palette-item.active { background: var(--accent-soft); }
.palette-item .pi-sub { font-size: 12px; color: var(--text-3); margin-left: auto; }
.palette-heading { padding: 8px 12px 2px; font-size: 11px; text-transform: uppercase; color: var(--text-3); letter-spacing: 0.04em; }

/* ---------- Settings ---------- */
.settings-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 16px; max-width: 720px; }
.settings-section h2 { margin-bottom: 12px; }
.status-list, .label-list { list-style: none; margin: 0; padding: 0; }
.status-list li, .label-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.status-list .drag { color: var(--text-3); cursor: grab; }
.status-list input[type="text"], .label-list input[type="text"] { flex: 1; }
.status-list select { width: 110px; }
.shortcut-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; align-items: center; }

/* ---------- Login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; }
.login-title { text-align: center; margin-bottom: 20px; font-size: 20px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 80; transform: translateX(-100%); transition: transform 0.15s ease; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 75; }
  .icon-btn.menu-btn { display: inline-flex; }
  .page, .page-wide { padding: 12px 16px 48px; }
  .props { grid-template-columns: 96px 1fr; }
}
@media (max-width: 700px) {
  :root { --panel-w: 100vw; }
  .topbar { padding: 6px 8px; }
  .view-tab span { display: none; }
  .filterbar { padding: 8px; }
  .filterbar .search input { width: 140px; }
  .board { padding: 8px; gap: 8px; scroll-snap-type: x mandatory; }
  .board-col { flex-basis: 85vw; scroll-snap-align: start; }
  .modal-backdrop { padding: 8px; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Calendar ---------- */
.calendar { display: flex; flex-direction: column; height: 100%; padding: 12px 16px 16px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.cal-title { font-size: 15px; margin-left: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: auto; grid-auto-rows: minmax(96px, 1fr); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--border); gap: 1px; flex: 1; min-height: 0; }
.cal-grid.week { grid-template-rows: auto 1fr; }
.cal-dow { background: var(--surface-2); padding: 4px 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-3); letter-spacing: 0.04em; }
.cal-cell { background: var(--surface); padding: 4px; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.cal-cell.other { background: var(--bg); color: var(--text-3); }
.cal-cell.weekend:not(.other) { background: color-mix(in srgb, var(--surface) 70%, var(--surface-2)); }
.cal-cell.today .cal-daynum { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 6px; }
.cal-cell.drop { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-day { display: flex; align-items: center; justify-content: space-between; font-size: 12px; margin-bottom: 2px; }
.cal-add { width: 20px; height: 20px; opacity: 0; }
.cal-cell:hover .cal-add, .cal-cell:focus-within .cal-add { opacity: 1; }
.cal-tasks { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; min-height: 0; }
.cal-task { display: flex; align-items: center; gap: 4px; padding: 2px 4px 2px 6px; border-radius: 4px; background: var(--surface-2); border-left: 3px solid var(--pc, var(--border-strong)); font-size: 12px; cursor: grab; touch-action: none; min-width: 0; }
.cal-task.urgent { --pc: var(--p-urgent); } .cal-task.high { --pc: var(--p-high); } .cal-task.medium { --pc: var(--p-medium); } .cal-task.low { --pc: var(--p-low); }
.cal-task:hover { background: var(--surface-3); }
.cal-task.overdue { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
.cal-task.completed .cal-task-title { text-decoration: line-through; color: var(--text-3); }
.cal-task .tag-key { font-size: 10.5px; }
.cal-task-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.cal-task-proj { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.cal-ghost { position: fixed; z-index: 100; pointer-events: none; opacity: 0.85; box-shadow: var(--shadow); }
.is-dragging { user-select: none; cursor: grabbing; }
.cal-grid.week .cal-task { padding: 4px 6px; font-size: 13px; }
.cal-grid.week .cal-task-title { white-space: normal; }

/* ---------- Gantt ---------- */
:root { --gantt-names: 260px; --gantt-weekend: color-mix(in srgb, var(--text) 4%, transparent); }
.gantt { display: flex; height: 100%; min-height: 0; }
.gantt-scroll { flex: 1; overflow: auto; min-width: 0; position: relative; }
.gantt-grid { display: grid; grid-template-rows: auto 1fr; position: relative; width: max-content; min-width: 100%; }
.gantt-corner { position: sticky; left: 0; top: 0; z-index: 5; background: var(--bg); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; align-items: flex-end; padding: 6px 12px; }
.gantt-header { position: sticky; top: 0; z-index: 4; background: var(--bg); border-bottom: 1px solid var(--border); }
.gantt-months, .gantt-units { display: flex; white-space: nowrap; }
.gantt-month { font-size: 12px; font-weight: 600; color: var(--text-2); padding: 4px 6px; border-right: 1px solid var(--border); overflow: hidden; box-sizing: border-box; }
.gantt-unit { font-size: 11px; color: var(--text-3); padding: 2px 4px; border-right: 1px solid var(--border); overflow: hidden; box-sizing: border-box; text-align: center; }
.gantt-unit.today { color: var(--accent); font-weight: 600; }
.gantt-names { position: sticky; left: 0; z-index: 3; background: var(--surface); border-right: 1px solid var(--border); }
.gantt-name { display: flex; align-items: center; gap: 6px; padding: 0 12px; border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer; min-width: 0; }
.gantt-name.depth-1 { padding-left: 24px; }
.gantt-name:hover { background: var(--surface-2); }
.gantt-name.completed .truncate { text-decoration: line-through; color: var(--text-3); }
.gantt-proj { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-left: auto; }
.gantt-body { position: relative; }
.gantt-row { position: relative; border-bottom: 1px solid var(--border); }
.gantt-bar { position: absolute; top: 6px; height: 22px; border-radius: 5px; background: color-mix(in srgb, var(--bar) 75%, var(--surface)); color: #fff; font-size: 12px; display: flex; align-items: center; cursor: grab; touch-action: none; overflow: hidden; box-sizing: border-box; border: 1px solid color-mix(in srgb, var(--bar) 85%, black); }
.gantt-bar.dragging { cursor: grabbing; opacity: 0.9; box-shadow: var(--shadow); z-index: 2; }
.gantt-bar.completed { opacity: 0.45; }
.gantt-bar.overdue { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.gantt-bar.summary { height: 8px; top: 13px; background: var(--text-3); border: 0; border-radius: 2px; cursor: pointer; }
.gantt-bar.summary .gantt-bar-label { display: none; }
.gantt-bar-label { padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; pointer-events: none; text-shadow: 0 1px 1px rgba(0,0,0,0.3); }
.gantt-handle { width: 8px; align-self: stretch; cursor: ew-resize; flex: none; }
.gantt-handle:hover { background: rgba(255,255,255,0.35); }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); z-index: 1; pointer-events: none; opacity: 0.8; }
.gantt-side { width: 260px; flex: none; border-left: 1px solid var(--border); overflow-y: auto; padding: 12px; background: var(--surface); }
.gantt-side h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); margin-bottom: 8px; }
.gantt-side-row { display: flex; align-items: center; gap: 6px; padding: 6px 4px; border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer; }
.gantt-side-row:hover { background: var(--surface-2); }
@media (max-width: 900px) {
  :root { --gantt-names: 160px; }
  .gantt { flex-direction: column; }
  .gantt-side { width: auto; max-height: 35%; border-left: 0; border-top: 1px solid var(--border); }
  .gantt-name .tag-key { display: none; }
}
.table .promote { opacity: 0; margin-left: 4px; padding: 0 6px; }
.table tr:hover .promote, .table tr:focus-within .promote { opacity: 1; }
.cal-task-title { min-width: 0; }
@media (max-width: 1300px) { .cal-grid.month .cal-task .tag-key { display: none; } }
.cal-grid.week .cal-task { flex-wrap: wrap; align-items: flex-start; }
.cal-grid.week .cal-task .tag-key { width: 100%; }
.cal-grid.week .cal-task-proj { position: absolute; }
.cal-grid.week .cal-task { position: relative; padding-right: 12px; }
.cal-grid.week .cal-task-proj { right: 4px; top: 6px; }
