/* Twick brand: indigo #2E11DF fading to lavender, Space Grotesk, 10px corners (matches twick.net). */
:root {
  --bg: #f6f5fb;
  --surface: #ffffff;
  --surface-2: #f8f7fd;
  --border: #e4e2ee;
  --text: #242424;
  --muted: #767676;
  --hover: #f0eefb;
  --accent: #2e11df;
  --accent-text: #ffffff;
  --accent-weak: #ece8fe;
  --accent-grad: linear-gradient(170deg, #2e11df 50%, #d1b9ff 100%);
  --outline: #909090;
  --danger: #d83a52;
  --shadow: 0 10px 30px rgba(30, 17, 110, .12), 0 2px 6px rgba(30, 17, 110, .06);
  --radius: 10px;
  --radius-sm: 5px;
  --font: "Space Grotesk", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #100e24; --surface: #1a1735; --surface-2: #211d42; --border: #322d5c;
    --text: #eceaf7; --muted: #a29fbe; --hover: #2a2552; --accent: #8f7cff;
    --accent-weak: #2b2461; --outline: #5d5885; --danger: #f06b81;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .light-only { display: none; }
  :root:not([data-theme="light"]) .dark-only { display: inline-block; }
}
:root[data-theme="dark"] {
  --bg: #100e24; --surface: #1a1735; --surface-2: #211d42; --border: #322d5c;
  --text: #eceaf7; --muted: #a29fbe; --hover: #2a2552; --accent: #8f7cff;
  --accent-weak: #2b2461; --outline: #5d5885; --danger: #f06b81;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
  color-scheme: dark;
}
.dark-only { display: none; }
:root[data-theme="dark"] .light-only { display: none; }
:root[data-theme="dark"] .dark-only { display: inline-block; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 var(--font);
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.ic { width: 16px; height: 16px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.loading, .empty-state { padding: 60px; text-align: center; color: var(--muted); }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }

/* ---------- layout ---------- */
#app { display: grid; grid-template-columns: 250px minmax(0, 1fr); height: 100vh; }
#main { overflow: auto; min-width: 0; }

#sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 16px 10px; display: flex; flex-direction: column; gap: 2px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; }
.brand-logo { height: 30px; width: auto; }
.brand-tag {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-weak); padding: 3px 8px; border-radius: 99px; margin-top: 3px;
}
.nav-link, .board-link {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; border-radius: 7px; padding: 7px 10px; color: var(--text);
}
.nav-link:hover, .board-link:hover { background: var(--hover); }
.nav-link.active, .board-link.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 10px 4px; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.cat { font-size: 11.5px; color: var(--muted); padding: 10px 10px 3px; font-weight: 600; }
.board-link .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.board-link .count { margin-left: auto; font-size: 11px; color: var(--muted); }
.side-foot { margin-top: auto; padding: 14px 10px 0; font-size: 12px; }
.save-state.err { color: var(--danger); font-weight: 600; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border: 1px solid var(--outline); background: var(--surface); border-radius: var(--radius); white-space: nowrap; font-weight: 600;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent-grad); border: 0; color: var(--accent-text); padding: 0 16px; }
.btn.primary:hover { filter: brightness(1.12) saturate(1.05); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--danger); }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none;
  border: 0; background: none; border-radius: 6px; color: var(--muted);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }
select, input[type="text"], input[type="password"], input[type="date"], input:not([type]), textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 9px; outline: none;
}
h1, h2, h3, h4, .board-title, .group-name, .p-title { font-weight: 600; letter-spacing: -.01em; }
select { height: 34px; padding: 0 8px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.mobile-only { display: none; }

/* ---------- page header ---------- */
.page { padding: 26px 32px 60px; max-width: 1280px; }
.page h1 { margin: 0; font-size: 26px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }

.board-header { padding: 20px 28px 0; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; left: 0; z-index: 5; }
.bh-top { display: flex; align-items: center; gap: 10px; }
.board-color { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.board-title { font-size: 22px; font-weight: 700; border: 1px solid transparent !important; background: none !important; padding: 2px 6px !important; min-width: 0; flex: 0 1 auto; width: min(520px, 50vw); }
.board-title:hover { border-color: var(--border) !important; }
.board-title:focus { border-color: var(--accent) !important; }
.board-desc { width: 100%; border: 1px solid transparent !important; background: none !important; color: var(--muted); margin: 2px 0 8px 18px; padding: 3px 6px !important; max-width: 760px; }
.board-desc:hover { border-color: var(--border) !important; }
.bh-bar { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; }
.tab { display: flex; align-items: center; gap: 6px; border: 0; background: none; padding: 9px 12px; border-bottom: 2px solid transparent; color: var(--muted); }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.filters { display: flex; align-items: center; gap: 8px; margin-left: auto; padding-bottom: 8px; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 7px; padding: 0 9px; height: 34px; background: var(--surface); color: var(--muted); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.search input { border: 0 !important; box-shadow: none !important; padding: 0; width: 160px; background: none; color: var(--text); }
.filters select { max-width: 150px; }

/* ---------- table view ---------- */
.table-wrap { padding: 20px 28px 80px; overflow-x: auto; }
.group { margin-bottom: 30px; min-width: 1180px; }
.group-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.group-head .caret { color: var(--gc); }
.group-head .caret .ic { transition: transform .15s; }
.group-head .caret.collapsed .ic { transform: rotate(-90deg); }
.group-name { font-size: 16px; font-weight: 600; color: var(--gc); border: 1px solid transparent !important; background: none !important; padding: 2px 6px !important; width: auto; min-width: 120px; field-sizing: content; }
.group-name:hover { border-color: var(--border) !important; }
.grid {
  --cols: 6px 26px minmax(260px, 1fr) 76px 150px 128px 132px 132px 170px 110px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.row { display: grid; grid-template-columns: var(--cols); min-height: 38px; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.row > div { border-right: 1px solid var(--border); display: flex; align-items: center; justify-content: center; min-width: 0; gap: 6px; }
.row > div:last-child { border-right: 0; }
.row > .c-bar { background: var(--gc); border-right: 0; }
.row > .c-drag { border-right: 0; color: var(--muted); cursor: grab; opacity: 0; font-size: 11px; letter-spacing: -2px; user-select: none; }
.row.item:hover > .c-drag { opacity: .8; }
.row > .c-name { justify-content: flex-start; padding: 0 6px 0 4px; }
.row.head { background: var(--surface-2); min-height: 34px; font-size: 12.5px; color: var(--muted); }
.row.head > div { font-weight: 500; }
.row.head .sortable { cursor: pointer; user-select: none; }
.row.head .sortable:hover { color: var(--text); }
.row.item:hover { background: var(--surface-2); }
.row.item.dragging { opacity: .4; }
.row.item.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.group.drop-on .grid { outline: 2px dashed var(--accent); }
.row.add > .c-name { grid-column: 3 / -1; border-right: 0; }
.row.summary { min-height: 32px; background: var(--surface-2); }
.row.summary > div { border-right: 0; }
.row.summary .sum-status { padding: 0 8px; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
.cell-input { border: 1px solid transparent !important; background: none !important; padding: 4px 6px !important; width: 100%; min-width: 0; border-radius: 5px; }
.cell-input:hover { border-color: var(--border) !important; }
.cell-input:focus { border-color: var(--accent) !important; background: var(--surface) !important; }
.cell-input.date { font-size: 12.5px; text-align: center; }
.cell-input.overdue { color: var(--danger); font-weight: 600; }
.add-input { border: 1px solid transparent !important; background: none !important; width: 100%; padding: 4px 6px !important; }
.add-input:focus { border-color: var(--accent) !important; background: var(--surface) !important; }
.open-btn { display: inline-flex; align-items: center; gap: 3px; border: 0; background: none; color: var(--muted); padding: 4px 6px; border-radius: 5px; font-size: 12px; flex: none; }
.open-btn:hover { background: var(--accent-weak); color: var(--accent); }
.open-btn.has { color: var(--accent); }
.cell-pill { width: 100%; height: 100%; border: 0; color: #fff; font-weight: 500; font-size: 13px; padding: 0 6px; text-shadow: 0 1px 1px rgba(0,0,0,.12); }
.cell-pill:hover { filter: brightness(1.06); }
.cell-pill.empty { background: transparent; }
.cell-pill.empty:hover { background: var(--hover); }
.row > .c-pill { padding: 0; align-items: stretch; }
.mini-progress { width: 52px; height: 6px; border-radius: 9px; background: var(--hover); overflow: hidden; }
.mini-progress > span { display: block; height: 100%; background: #00c875; }
.sbar { display: flex; width: 100%; height: 18px; border-radius: 4px; overflow: hidden; background: var(--hover); }
.sbar > span { display: block; height: 100%; }
.add-group { margin-top: -8px; }

.pill { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 99px; color: #fff; font-weight: 500; padding: 4px 14px; font-size: 13px; white-space: nowrap; }
.pill.sm { font-size: 11px; padding: 1px 8px; }
.pill.empty { background: var(--hover); color: var(--muted); }

/* avatars */
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; flex: none; }
.avatar.sm { width: 22px; height: 22px; font-size: 9.5px; }
.avatar.empty { background: var(--hover); color: var(--muted); }
.avatar.empty .ic { width: 14px; height: 14px; }
.avatar-btn { border: 0; background: none; padding: 2px; border-radius: 50%; display: inline-grid; }
.avatar-btn:hover { box-shadow: 0 0 0 2px var(--accent-weak); }

/* ---------- menus ---------- */
.menu {
  position: fixed; z-index: 100; min-width: 190px; max-height: 60vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow); padding: 5px;
}
.menu-opt { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 6px; }
.menu-opt:hover, .menu-opt:focus { background: var(--hover); outline: none; }
.menu-opt.danger { color: var(--danger); }
.menu-opt.current { font-weight: 600; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 2px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.menu.colors { display: grid; grid-template-columns: repeat(6, 28px); gap: 6px; padding: 10px; min-width: 0; }
.color-opt { width: 28px; height: 28px; border-radius: 7px; border: 2px solid transparent; }
.color-opt:hover { border-color: var(--text); }

/* ---------- kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 14px; padding: 20px 28px 60px; overflow-x: auto; align-items: start; }
.kcol { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 200px); }
.kcol.drop-on { outline: 2px dashed var(--accent); outline-offset: -2px; }
.kcol-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; font-weight: 600; border-top: 4px solid var(--sc); border-radius: var(--radius) var(--radius) 0 0; }
.kcol-head .count { font-size: 12px; color: var(--muted); background: var(--surface); padding: 0 8px; border-radius: 99px; }
.kcol-body { padding: 4px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.kadd { border: 0; background: none; color: var(--muted); padding: 10px; text-align: left; border-radius: 0 0 var(--radius) var(--radius); }
.kadd:hover { color: var(--accent); background: var(--hover); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card:hover { border-color: var(--accent); }
.card.dragging { opacity: .4; }
.card-group { font-size: 11px; font-weight: 600; margin-bottom: 3px; }
.card-title { font-weight: 500; margin-bottom: 8px; word-break: break-word; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--accent-weak); color: var(--accent); }
.card-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.card-meta .due { display: inline-flex; align-items: center; gap: 3px; }
.card-meta .ic { width: 13px; height: 13px; }
.overdue-text { color: var(--danger); font-weight: 600; }

/* ---------- calendar ---------- */
.cal { padding: 18px 28px 60px; }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cal-head h3 { margin: 0 8px; font-size: 18px; min-width: 170px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.cal-dow { padding: 8px 10px; font-size: 12px; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 600; }
.cal-day { min-height: 116px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.out { background: var(--surface-2); }
.cal-day.out .cal-num { opacity: .45; }
.cal-day.drop-on { background: var(--accent-weak); }
.cal-num { font-size: 12px; font-weight: 600; color: var(--muted); align-self: flex-start; padding: 1px 6px; border-radius: 99px; }
.cal-day.today .cal-num { background: var(--accent); color: #fff; }
.chip-item { font-size: 12px; padding: 3px 7px; border-radius: 5px; background: color-mix(in srgb, var(--sc) 18%, var(--surface)); border-left: 3px solid var(--sc); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-item:hover { filter: brightness(.96); }
.chip-item.done { text-decoration: line-through; opacity: .65; }

/* ---------- timeline ---------- */
.tl { padding: 18px 28px 60px; }
.tl-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.tl-inner { min-width: 1300px; }
.tl-row { display: grid; grid-template-columns: 240px 1fr; border-bottom: 1px solid var(--border); min-height: 36px; }
.tl-row:last-child { border-bottom: 0; }
.tl-label { padding: 7px 12px; border-right: 1px solid var(--border); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; position: sticky; left: 0; background: var(--surface); z-index: 2; }
.tl-label:hover { color: var(--accent); }
.tl-row.group-row .tl-label { font-weight: 600; color: var(--gc); cursor: default; background: var(--surface-2); }
.tl-row.group-row .tl-track { background: var(--surface-2); }
.tl-track { position: relative; }
.tl-days { display: grid; grid-template-columns: repeat(var(--span), 1fr); height: 100%; }
.tl-days > div { border-right: 1px solid color-mix(in srgb, var(--border) 55%, transparent); font-size: 10.5px; color: var(--muted); text-align: center; padding-top: 4px; }
.tl-days > .we { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.tl-days > .td { color: var(--accent); font-weight: 700; }
.tl-head .tl-days > div { padding: 4px 0; }
.tl-head .mon { display: block; font-weight: 600; color: var(--text); font-size: 10px; height: 13px; }
.tl-bar { position: absolute; top: 7px; bottom: 7px; border-radius: 6px; color: #fff; font-size: 11.5px; padding: 0 8px; display: flex; align-items: center; overflow: hidden; white-space: nowrap; cursor: pointer; z-index: 1; min-width: 6px; }
.tl-bar:hover { filter: brightness(1.08); }
.tl-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: .7; z-index: 1; pointer-events: none; }
.tl-none { position: absolute; left: 10px; top: 9px; font-size: 12px; color: var(--muted); }

/* ---------- home ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat b { display: block; font-size: 28px; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat.warn b { color: var(--danger); }
.home-cols { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: 15px; }
.box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.task-list { list-style: none; margin: 0; padding: 4px; }
.task-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.task-row:hover { background: var(--hover); }
.task-row .t-board { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.task-row .t-board .dot { width: 7px; height: 7px; border-radius: 2px; }
.task-row .t-due { font-size: 12px; width: 82px; text-align: right; }
.boards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.board-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer; text-align: left; border-top: 4px solid var(--bc); display: flex; flex-direction: column; gap: 8px; }
.board-card:hover { box-shadow: var(--shadow); }
.board-card h3 { margin: 0; font-size: 15px; }
.board-card .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.board-card.new { border: 2px dashed var(--border); align-items: center; justify-content: center; color: var(--muted); min-height: 130px; background: none; }
.board-card.new:hover { color: var(--accent); border-color: var(--accent); box-shadow: none; }

/* ---------- panel ---------- */
#scrim { position: fixed; inset: 0; background: rgba(10, 12, 30, .25); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; }
#scrim.show { opacity: 1; pointer-events: auto; }
#panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(580px, 100vw); z-index: 50;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow);
  transform: translateX(105%); transition: transform .22s ease; display: flex; flex-direction: column;
}
#panel.open { transform: none; }
.panel-head { display: flex; align-items: center; gap: 4px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-width: 0; }
.crumbs .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.panel-body { overflow-y: auto; padding: 16px 22px 40px; }
.p-title { width: 100%; font-size: 21px; font-weight: 700; border: 1px solid transparent !important; background: none !important; resize: none; padding: 4px 6px !important; field-sizing: content; overflow: hidden; }
.p-title:hover { border-color: var(--border) !important; }
.p-title:focus { border-color: var(--accent) !important; }
.props { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; align-items: center; margin: 14px 0 20px; }
.props > label { color: var(--muted); font-size: 13px; }
.props input, .props select { width: 100%; max-width: 280px; }
.owner-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 2px 12px 2px 2px; }
.owner-btn:hover { background: var(--hover); }
.panel-body h4 { margin: 22px 0 8px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.p-notes { width: 100%; min-height: 110px; resize: vertical; field-sizing: content; }
.progress { height: 6px; border-radius: 9px; background: var(--hover); overflow: hidden; margin-bottom: 6px; }
.progress > span { display: block; height: 100%; background: #00c875; transition: width .2s; }
.subtasks { list-style: none; margin: 0; padding: 0; }
.subtasks li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.subtasks input[type="checkbox"] { width: 16px; height: 16px; accent-color: #00c875; flex: none; }
.sub-text { flex: 1; border: 1px solid transparent !important; background: none !important; padding: 4px 6px !important; }
.sub-text:hover { border-color: var(--border) !important; }
.sub-text.done { text-decoration: line-through; color: var(--muted); }
.sub-add { width: 100%; margin-top: 4px; }
.update-box { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.update-box textarea { width: 100%; min-height: 70px; resize: vertical; }
.updates { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.update { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; position: relative; }
.update.system { border-style: dashed; padding: 6px 12px; font-size: 12.5px; color: var(--muted); }
.u-meta { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.u-text { white-space: pre-wrap; word-break: break-word; }
.update .icon-btn { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; opacity: 0; }
.update:hover .icon-btn { opacity: 1; }

/* ---------- settings ---------- */
.settings-grid { display: grid; gap: 22px; max-width: 760px; }
.settings-card { padding: 20px 22px; }
.settings-card h2 { margin: 0 0 4px; font-size: 16px; }
.settings-card p { margin: 0 0 14px; }
.person-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.person-row input[type="color"] { width: 34px; height: 34px; border: 0; padding: 0; background: none; border-radius: 50%; cursor: pointer; }
.person-row input[type="text"] { flex: 1; max-width: 300px; }
.add-person { display: flex; gap: 8px; margin-top: 10px; }
.add-person input { max-width: 300px; flex: 1; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- dialog ---------- */
#dlg { border: 0; border-radius: 14px; padding: 0; width: min(620px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
#dlg::backdrop { background: rgba(10, 12, 30, .45); }
.dlg-form { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.dlg-form h2 { margin: 0; font-size: 20px; }
.dlg-form > label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 13px; }
.tpl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tpl { display: flex; gap: 10px; border: 1px solid var(--border); border-radius: 9px; padding: 11px 12px; cursor: pointer; }
.tpl:has(input:checked) { border-color: var(--accent); background: var(--accent-weak); }
.tpl input { margin-top: 3px; accent-color: var(--accent); }
.tpl b { display: block; font-size: 13.5px; }
.tpl small { color: var(--muted); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------- hosted: login & account ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-card .brand { padding: 0 0 4px; }
.auth-card h1 { margin: 0; font-size: 22px; }
.auth-card p { margin: 0; }
.auth-card label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 13px; }
.auth-card .btn { justify-content: center; height: 40px; }
.auth-error { color: var(--danger); font-weight: 600; font-size: 13px; }
.pw-form { display: grid; gap: 8px; max-width: 320px; }
.pw-form .btn { justify-self: start; }
.logout-form { margin: 4px 0 0 -10px; }

/* ---------- hosted: accounts, team & sharing ---------- */
.me-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; font-weight: 500; min-width: 0; }
.me-row .chip { font-size: 10.5px; padding: 1px 7px; }
.sub-h { margin: 22px 0 10px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.chip.view-only { color: var(--accent); background: var(--accent-weak); border-color: transparent; }
.board-people { display: flex; padding-left: 8px; }
.board-people .avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--surface); }
.invite-form { display: grid; gap: 10px; margin-bottom: 6px; }
.invite-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 8px; }
.invite-form > .btn { justify-self: start; }
.invite-access summary { cursor: pointer; color: var(--accent); font-weight: 500; padding: 4px 0; }
.access-list { display: grid; gap: 4px; max-height: 50vh; overflow: auto; margin: 6px 0; }
.access-row { display: grid; grid-template-columns: auto minmax(0, 1fr) 140px; align-items: center; gap: 10px; padding: 5px 4px; border-radius: var(--radius-sm); font-size: 13.5px; }
.access-row:hover { background: var(--hover); }
.access-row .dot { width: 10px; height: 10px; border-radius: 3px; }
.access-row select { height: 32px; }
.invite-link { margin-top: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--accent-weak); display: grid; gap: 8px; font-size: 13.5px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-size: 12.5px; }
.team-list { display: grid; }
.team-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.team-row:last-child { border-bottom: 0; }
.team-row.disabled { opacity: .55; }

/* View-only projects: inputs stay readable, editing controls disappear. */
.readonly input:disabled, .readonly textarea:disabled, .readonly select:disabled { color: var(--text); -webkit-text-fill-color: var(--text); opacity: 1; cursor: default; }
.readonly button:disabled { cursor: default; filter: none; }
.readonly .c-drag { visibility: hidden; }   /* keep its grid column so the table stays aligned */
.readonly .row.add, .readonly .kadd, .readonly .add-group, .readonly .update-box, .readonly .sub-add,
.readonly [data-act="add-item"], .readonly [data-act="group-menu"], .readonly [data-act="del-item"], .readonly [data-act="dup-item"],
.readonly [data-act="sub-del"], .readonly [data-act="del-update"] { display: none !important; }
@media (max-width: 860px) {
  .invite-row { grid-template-columns: 1fr; }
  .board-people { display: none; }
}

#toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); background: #1a1735; color: #fff; padding: 9px 16px; border-radius: var(--radius); opacity: 0; transition: .2s; pointer-events: none; z-index: 200; font-size: 13px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .home-cols { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  #sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  #app.side-open #sidebar { transform: none; }
  .mobile-only { display: inline-grid; }
  .page { padding: 18px 16px 60px; }
  .board-header { padding: 14px 16px 0; }
  .table-wrap, .kanban, .cal, .tl { padding-left: 16px; padding-right: 16px; }
  .filters { margin-left: 0; }
  .search input { width: 110px; }
  .board-desc { margin-left: 0; }
  .cal-day { min-height: 80px; padding: 3px; }
  .chip-item { font-size: 10.5px; padding: 2px 4px; }
  .tpl-grid { grid-template-columns: 1fr; }
}
