:root {
  --bg: #f4f1ec; --surface: #ffffff; --surface-2: #f7f5f1; --ink: #1f1b18; --ink-2: #5c554f; --line: #e3ddd5;
  --accent: #2f6fed; --accent-ink: #fff; --danger: #c2372b; --amber: #d97706; --amber-bg: #fde68a; --red-bg: #fecaca;
  --note-ink: #2a2520; --shadow: 0 1px 2px rgba(40,30,20,.12), 0 4px 14px rgba(40,30,20,.10);
  --radius: 10px; --cork: #c9a678; --top-h: 56px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tile-w: 104px; --tile-h: 98px; --tile-font: 13px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1917; --surface: #262320; --surface-2: #2e2a26; --ink: #f1ece6; --ink-2: #b2a99f; --line: #3b3631;
    --accent: #6c9bff; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35); --cork: #5a4632;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1917; --surface: #262320; --surface-2: #2e2a26; --ink: #f1ece6; --ink-2: #b2a99f; --line: #3b3631;
  --accent: #6c9bff; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35); --cork: #5a4632; color-scheme: dark;
}
body[data-size="small"] { --tile-w: 88px; --tile-h: 84px; --tile-font: 12px; }
body[data-size="large"] { --tile-w: 132px; --tile-h: 124px; --tile-font: 15px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.4 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }
.pre { white-space: pre-line; }
[hidden] { display: none !important; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--ink-2); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app { display: flex; flex-direction: column; height: 100dvh; }

/* ---------- controls ---------- */
.btn { border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; border-radius: 8px; font-weight: 550; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn.wide { width: 100%; justify-content: center; padding: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; padding: 6px; border-radius: 8px; line-height: 1; font-size: 17px; position: relative; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.small { font-size: 12px; padding: 4px 6px; color: var(--ink-2); }
.icon-btn[aria-pressed="true"] { background: var(--accent); }
input:not([type=checkbox]):not([type=color]):not([type=file]), select, textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 9px; min-width: 0;
}
input[type=color] { width: 42px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
textarea { resize: vertical; width: 100%; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.check { display: flex !important; flex-direction: row !important; gap: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; color: var(--note-ink); }
.chip.person { background: var(--surface); color: var(--ink); }
.chip .x { border: 0; background: none; padding: 0 0 0 4px; font-size: 15px; line-height: 1; color: inherit; opacity: .6; }
.chip.personal { background: #ede9fe; }
.chip.due { background: var(--amber-bg); }
.chip.muted { color: var(--ink-2); background: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-add { padding: 3px 6px !important; font-size: 12.5px; border-style: dashed !important; border-radius: 999px !important; max-width: 140px; }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; box-shadow: 0 0 0 2px rgba(255,255,255,.85); letter-spacing: -.02em; }
.ring { display: inline-flex; align-items: center; gap: 3px; color: #15803d; }
.ring b { font-size: 11px; color: var(--note-ink); font-weight: 600; }
.badge { position: absolute; top: 0; right: 0; background: var(--danger); color: #fff; border-radius: 999px; font-size: 10px; min-width: 16px; height: 16px; padding: 0 4px; display: grid; place-items: center; font-weight: 700; }

/* ---------- auth ---------- */
.auth-page { min-height: 100dvh; display: grid; place-items: center; padding: 16px; background: var(--cork); }
.auth-card { background: var(--surface); padding: 28px; border-radius: 14px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.auth-card label { display: flex; flex-direction: column; gap: 5px; font-weight: 550; font-size: 13px; }
.auth-card h1 { margin: 0; font-size: 22px; }
.form-error { color: var(--danger); margin: 0; min-height: 1em; }

/* ---------- top bar ---------- */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; font-size: 16px; letter-spacing: -.01em; }
.brand.big { font-size: 22px; margin-bottom: 6px; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: url(/icons/icon.svg) center/cover; flex: none; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line); min-height: var(--top-h); position: relative; z-index: 20; }
.qa-wrap { flex: 1; min-width: 0; max-width: 820px; position: relative; }
.quickadd { display: flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 4px 4px 4px 10px; }
.quickadd:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.qa-plus { color: var(--ink-2); font-size: 18px; }
.qa-input { flex: 1; border: 0 !important; background: transparent !important; padding: 7px 4px !important; font-size: 15px; outline: none; }
.qa-company { border: 0 !important; background: var(--surface) !important; font-size: 12.5px; max-width: 150px; }
.qa-preview { position: absolute; top: 100%; left: 0; right: 0; display: flex; gap: 6px; padding: 5px 2px 0; flex-wrap: wrap; pointer-events: none; }
.qa-preview:empty { display: none; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.search { width: 150px; }
.present-banner { background: #1f2937; color: #fff; text-align: center; padding: 6px; font-weight: 600; display: flex; justify-content: center; gap: 12px; align-items: center; }
.present-banner button { background: #fff; color: #111; border: 0; border-radius: 6px; padding: 2px 10px; }
body.presenting .icon-btn.present { background: #1f2937; }

.toolbar { display: flex; align-items: center; gap: 10px; padding: 18px 14px 8px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.views { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; min-width: 0; }
.view-tab { border: 1px solid transparent; background: transparent; border-radius: 999px; padding: 5px 12px; font-weight: 550; color: var(--ink-2); }
.view-tab:hover { background: var(--surface-2); }
.view-tab.on { background: var(--ink); color: var(--bg); }
.view-tab.add { color: var(--accent); }
.tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tool { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.tool select { padding: 5px 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 10px; font-size: 12.5px; font-weight: 550; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: var(--bg); }
.seg.zoom button { min-width: 30px; }
.push-bar { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 8px 14px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-bottom: 1px solid var(--line); }

.today-strip { display: flex; gap: 8px; align-items: center; padding: 8px 14px; overflow-x: auto; background: var(--surface-2); border-bottom: 1px solid var(--line); scrollbar-width: thin; min-height: 44px; }
.strip-label { font-weight: 750; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin-right: 4px; }
.strip-chip { display: inline-flex; gap: 8px; align-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 10px 4px 4px; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.strip-chip .when { background: var(--red-bg); color: #7f1d1d; border-radius: 5px; padding: 1px 6px; font-size: 11.5px; font-weight: 700; }
.strip-chip.overdue { border-color: #f87171; }

/* ---------- board ---------- */
.board-wrap { flex: 1; overflow: auto; position: relative; padding: 16px; overscroll-behavior: contain; }
body[data-bg="cork"] .board-wrap { background: var(--cork) radial-gradient(rgba(0,0,0,.08) 1px, transparent 1.4px) 0 0/7px 7px; }
body[data-bg="grid"] .board-wrap { background: var(--bg) linear-gradient(var(--line) 1px, transparent 1px) 0 0/24px 24px, linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0/24px 24px; }
body[data-bg="dark"] .board-wrap { background: #191b22; }
body[data-bg="plain"] .board-wrap { background: var(--bg); }
.canvas { position: relative; transform-origin: 0 0; }
.canvas.auto { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.scroll-size { position: absolute; top: 0; left: 0; pointer-events: none; visibility: hidden; }
.empty-msg { position: absolute; inset: 40% 0 auto; text-align: center; color: #fff; font-size: 17px; text-shadow: 0 1px 3px rgba(0,0,0,.4); padding: 0 16px; }
body[data-bg="plain"] .empty-msg, body[data-bg="grid"] .empty-msg { color: var(--ink-2); text-shadow: none; }

.zone { position: absolute; background: color-mix(in srgb, var(--zc) 30%, rgba(255,255,255,.55)); border: 1.5px solid color-mix(in srgb, var(--zc) 70%, rgba(0,0,0,.18)); border-radius: 14px; backdrop-filter: blur(2px); transition: box-shadow .15s, outline-color .15s; }
body[data-bg="dark"] .zone { background: color-mix(in srgb, var(--zc) 16%, rgba(30,32,40,.85)); }
.canvas.auto .zone { position: relative; width: calc(var(--tile-w) * 3 + 70px); min-height: 150px; }
.zone.special { border-style: dashed; border-width: 2px; }
.zone.drop-hover { outline: 3px solid var(--accent); outline-offset: 2px; box-shadow: 0 0 0 9px color-mix(in srgb, var(--accent) 18%, transparent); }
.zone.moving { opacity: .85; z-index: 50; box-shadow: var(--shadow); }
.zone-h { display: flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px; font-weight: 700; color: #2a2520; cursor: grab; user-select: none; touch-action: none; }
body[data-bg="dark"] .zone-h { color: #f2efe9; }
.canvas.auto .zone-h { cursor: default; }
.zone-icon { font-size: 16px; }
.zone-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone-count { font-size: 11.5px; background: rgba(0,0,0,.08); border-radius: 999px; padding: 0 7px; font-weight: 650; }
.zone-count:empty { display: none; }
.zone-lock { font-size: 12px; margin-left: auto; }
.zone-body { position: relative; margin: 0 12px 12px; }
.canvas.auto .zone-body { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.zone-resize { position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; cursor: nwse-resize; touch-action: none;
  background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,.25) 50%, rgba(0,0,0,.25) 60%, transparent 60%, transparent 70%, rgba(0,0,0,.25) 70%, rgba(0,0,0,.25) 80%, transparent 80%); border-bottom-right-radius: 12px; }

/* ---------- tiles ---------- */
.tile { position: absolute; width: var(--tile-w); min-height: var(--tile-h); background: var(--note); color: var(--note-ink); border-radius: 4px 4px 10px 4px;
  padding: 8px 7px 6px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center;
  cursor: grab; user-select: none; touch-action: none; transition: box-shadow .15s, transform .15s; font-size: var(--tile-font); }
.canvas.auto .tile { position: relative; }
.tile:hover { box-shadow: 0 2px 4px rgba(40,30,20,.15), 0 10px 24px rgba(40,30,20,.18); z-index: 5; }
.tile:focus-visible { z-index: 6; }
.tile.expanded { width: calc(var(--tile-w) * 2 + 8px); align-items: stretch; text-align: left; z-index: 3; }
.tile.overdue { box-shadow: inset 0 0 0 2.5px #dc2626, var(--shadow); }
.tile.personal { background-image: repeating-linear-gradient(135deg, transparent 0 10px, rgba(124,58,237,.05) 10px 20px); }
.tile.is-done { opacity: .5; }
.tile.is-done .tile-title { text-decoration: line-through; }
.tile.stack { box-shadow: 3px 3px 0 -1px color-mix(in srgb, var(--note) 85%, #000), 3px 3px 0 0 rgba(0,0,0,.1), 6px 6px 0 -1px color-mix(in srgb, var(--note) 75%, #000), 6px 6px 0 0 rgba(0,0,0,.08), var(--shadow); }
.tile.stack.overdue { box-shadow: inset 0 0 0 2.5px #dc2626, 3px 3px 0 -1px color-mix(in srgb, var(--note) 85%, #000), 6px 6px 0 -1px color-mix(in srgb, var(--note) 75%, #000), var(--shadow); }
.tile-icon { font-size: calc(var(--tile-font) * 2); line-height: 1.1; }
.tile.expanded .tile-icon { font-size: 22px; }
.tile-title { font-weight: 620; line-height: 1.22; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.tile.expanded .tile-title { -webkit-line-clamp: 4; font-size: calc(var(--tile-font) + 1px); }
.tile-parent { font-size: 10.5px; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tile-meta { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; justify-content: center; margin-top: auto; padding-top: 2px; }
.tile.expanded .tile-meta { justify-content: flex-start; }
.due-badge { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: rgba(0,0,0,.07); white-space: nowrap; color: var(--note-ink); }
.due-badge.soon { background: #f59e0b; color: #1f1300; }
.due-badge.today { background: #dc2626; color: #fff; }
.due-badge.overdue { background: #7f1d1d; color: #fff; }
.mini { font-size: 11px; }
.avatars { display: inline-flex; }
.avatars .avatar + .avatar { margin-left: -6px; }
.co-badge { font-size: 9.5px; font-weight: 800; color: #fff; padding: 1px 5px; border-radius: 4px; letter-spacing: .03em; }
.co-badge.personal { background: none; padding: 0; font-size: 11px; }
.tick { position: absolute; top: -7px; left: -7px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(0,0,0,.25); background: #fff; color: transparent; font-size: 12px; font-weight: 900; padding: 0; opacity: 0; transition: opacity .12s; display: grid; place-items: center; }
.tile:hover .tick, .tile:focus-within .tick, .tick.on { opacity: 1; }
.tick:hover:not(:disabled), .tick.on { background: #16a34a; border-color: #16a34a; color: #fff; }
.expand { position: absolute; top: 2px; right: 2px; border: 0; background: transparent; font-size: 11px; opacity: 0; padding: 2px 4px; color: var(--note-ink); }
.tile:hover .expand, .tile.expanded .expand, .tile:focus-within .expand { opacity: .6; }
.place-btn { margin-top: 4px; border: 0; background: #be185d; color: #fff; border-radius: 6px; font-size: 11px; padding: 3px 6px; font-weight: 650; }
.tile.drag-src { opacity: .25; }
.tile.ghost { position: fixed; z-index: 1000; pointer-events: none; box-shadow: 0 18px 40px rgba(0,0,0,.3); }
body.dragging, body.dragging * { cursor: grabbing !important; }
.tile.completing { animation: fly .4s cubic-bezier(.5,0,.75,0) forwards; pointer-events: none; z-index: 100; }
@keyframes fly { to { transform: translate(var(--fly-x), var(--fly-y)) scale(.2) rotate(18deg); opacity: 0; } }
.tile.flash { animation: flash 1.5s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 4px var(--accent), var(--shadow); transform: scale(1.06); } 100% { box-shadow: var(--shadow); } }

.tile-body { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; font-size: 12.5px; cursor: default; }
.steps, .checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.steps li { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.55); border-radius: 5px; padding: 3px 5px; animation: fan .3s backwards; animation-delay: calc(var(--i) * 40ms); }
@keyframes fan { from { transform: translateY(-8px) rotate(-2deg); opacity: 0; } }
.steps li.done .step-title { text-decoration: line-through; opacity: .55; }
.steps li.locked { opacity: .6; }
.step-title { flex: 1; min-width: 0; }
.checklist li { display: flex; align-items: center; gap: 6px; }
.checklist li.done { opacity: .55; text-decoration: line-through; }
.cb { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid rgba(0,0,0,.35); background: rgba(255,255,255,.8); padding: 0; font-size: 11px; font-weight: 900; display: grid; place-items: center; flex: none; color: #fff; }
.cb.small { width: 16px; height: 16px; border-radius: 4px; }
li.done > .cb { background: #16a34a; border-color: #16a34a; }
.cb:disabled { border-style: dashed; background: transparent; font-size: 10px; cursor: not-allowed; }
.tile-line { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-notes { font-size: 12px; opacity: .8; white-space: pre-line; border-top: 1px dashed rgba(0,0,0,.15); padding-top: 4px; }

svg.links { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 2; }
svg.links path { fill: none; stroke: #1e3a8a; stroke-width: 2; stroke-dasharray: 5 5; opacity: .45; }
svg.links path.hot { opacity: 1; stroke-width: 3; stroke: var(--accent); }

.done-tray { position: fixed; right: 18px; bottom: 18px; width: 58px; height: 58px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); font-size: 26px; display: grid; place-items: center; z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
.tray-count { position: absolute; top: -6px; right: -6px; background: #16a34a; color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 6px; }
.tray-count:empty { display: none; }
.done-tray.bump { animation: bump .5s .3s; }
@keyframes bump { 50% { transform: scale(1.18) rotate(-6deg); } }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20,15,10,.45); display: grid; place-items: center; z-index: 200; padding: 16px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); color: var(--ink); border-radius: 14px; width: min(460px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(760px, 100%); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.modal h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 8px 16px 18px; overflow: auto; }
.modal h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); margin: 18px 0 6px; }
.form-grid { display: flex; flex-direction: column; gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 550; }
fieldset { border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; }
legend { font-size: 12px; font-weight: 650; color: var(--ink-2); padding: 0 4px; }
.done-list, .notif-list, .members, .groups-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.done-list li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.done-title { flex: 1; text-decoration: line-through; color: var(--ink-2); }
.notif { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; border: 0; background: none; padding: 10px 8px; border-radius: 8px; }
.notif:hover { background: var(--surface-2); }
.notif-list li.unread .notif { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.members li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.members li > span:nth-child(2) { flex: 1; min-width: 140px; }
.role { font-size: 12px; color: var(--ink-2); }
.group-row { display: flex; gap: 6px; align-items: center; padding: 4px 0; }
.group-row input:nth-child(2) { flex: 1; }
.emoji { width: 46px; text-align: center; }
.set-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.set-tabs button { border: 0; background: none; padding: 6px 10px; border-radius: 8px; font-weight: 600; color: var(--ink-2); }
.set-tabs button.on { background: var(--ink); color: var(--bg); }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); background: #1f1b18; color: #fff; padding: 10px 14px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 300; display: flex; gap: 12px; align-items: center; max-width: calc(100vw - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.3); }
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast.error { background: var(--danger); }
#toast button { background: none; border: 0; color: #93c5fd; font-weight: 700; padding: 0; }

/* ---------- detail drawer ---------- */
.detail { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--surface); border-left: 1px solid var(--line); box-shadow: -10px 0 40px rgba(0,0,0,.12); z-index: 100; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .2s ease; }
.detail.open { transform: none; }
.d-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); padding-top: max(10px, env(safe-area-inset-top)); }
.d-head .crumb { border: 0; background: none; color: var(--accent); font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1; text-align: left; }
.d-head > span { flex: 1; }
.d-head-actions { display: flex; gap: 6px; }
.d-scroll { overflow: auto; padding: 14px 16px 40px; flex: 1; display: flex; flex-direction: column; gap: 14px; padding-bottom: max(40px, env(safe-area-inset-bottom)); }
.d-title-row { display: flex; gap: 8px; align-items: flex-start; position: relative; }
.d-icon { font-size: 26px; border: 0; background: var(--surface-2); border-radius: 10px; width: 44px; height: 44px; flex: none; }
.d-title { font-size: 19px; font-weight: 700; border: 1px solid transparent !important; background: transparent !important; resize: none; overflow: hidden; padding: 6px 6px !important; line-height: 1.3; }
.d-title:hover, .d-title:focus { border-color: var(--line) !important; }
.icon-pick { position: absolute; top: 48px; left: 0; z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.icon-pick button { border: 0; background: none; font-size: 20px; padding: 4px; border-radius: 6px; }
.icon-pick button:hover { background: var(--surface-2); }
.d-due-line { font-weight: 650; padding: 6px 10px; border-radius: 8px; background: var(--surface-2); }
.d-due-line.today, .d-due-line.overdue { background: var(--red-bg); color: #7f1d1d; }
.d-due-line.soon { background: var(--amber-bg); color: #713f12; }
.d-props { display: flex; flex-direction: column; gap: 10px; }
.d-prop { display: grid; grid-template-columns: 82px 1fr; gap: 10px; align-items: start; }
.d-label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; padding-top: 6px; }
.d-sec { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.d-sec-h { display: flex; align-items: center; gap: 8px; }
.d-sec-h h3 { margin: 0; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); flex: 1; }
.d-steps, .d-check, .d-links { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.d-steps li, .d-check li, .d-links li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.d-steps li.done .step-open, .d-check li.done input { text-decoration: line-through; color: var(--ink-2); }
.d-steps li.locked .step-open { color: var(--ink-2); }
.d-steps .cb, .d-check .cb { border-color: var(--line); background: var(--surface); }
.step-open { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 4px 0; display: flex; gap: 8px; align-items: center; color: var(--ink); }
.step-open:hover { color: var(--accent); }
.reorder { display: flex; }
input.inline { flex: 1; border-color: transparent !important; background: transparent !important; padding: 4px !important; }
input.inline:hover, input.inline:focus { border-color: var(--line) !important; }
.d-sec input:not([type=checkbox]):not([type=file]):not([type=date]):not([type=time]):not(.inline) { width: 100%; }
.d-sec .row input { width: auto !important; flex: 1; }
.d-notes { min-height: 90px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; }
.photos figure { margin: 0; position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .file { display: grid; place-items: center; height: 100%; font-size: 11px; padding: 6px; text-align: center; word-break: break-all; }
.photos .x { position: absolute; top: 3px; right: 3px; border: 0; background: rgba(0,0,0,.55); color: #fff; border-radius: 50%; width: 20px; height: 20px; padding: 0; line-height: 1; }
.link-results { list-style: none; padding: 0; margin: 4px 0 0; }
.link-results button { border: 0; background: none; text-align: left; padding: 6px 4px; width: 100%; border-radius: 6px; color: var(--ink); }
.link-results button:hover { background: var(--surface-2); }
.d-add { position: relative; }
.add-menu summary { list-style: none; display: inline-flex; }
.add-menu summary::-webkit-details-marker { display: none; }
.add-menu[open] summary { background: var(--ink); color: var(--bg); }
.add-items { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.add-items button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 6px 12px; font-weight: 550; color: var(--ink); }
.add-items button:hover { border-color: var(--accent); }
.d-activity summary { cursor: pointer; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.d-activity ul { padding-left: 16px; font-size: 12.5px; }
.d-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }

/* ---------- phone ---------- */
.phone-list { display: flex; flex-direction: column; gap: 6px; padding-bottom: 90px; }
.list-h { margin: 12px 2px 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.35); display: flex; gap: 8px; }
body[data-bg="plain"] .list-h, body[data-bg="grid"] .list-h { color: var(--ink-2); text-shadow: none; }
.list-h span { opacity: .7; }
.list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.list-grid .tile { position: relative; width: auto; touch-action: auto; cursor: pointer; }
.list-grid .tile .tick { opacity: 1; }
.list-grid .tile.expanded { grid-column: span 2; width: auto; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  .brand-name { display: none; }
  .qa-wrap { order: 3; flex-basis: 100%; max-width: none; margin-bottom: 20px; }
  .qa-company { max-width: 92px; }
  .qa-go { display: none; }
  .top-actions { margin-left: auto; }
  .search { width: 110px; }
  .toolbar { padding: 8px 12px; flex-wrap: nowrap; }
  .views { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .view-tab { white-space: nowrap; }
  .board-wrap { padding: 4px 12px; }
  .today-strip { padding: 6px 12px; }
  .detail { width: 100vw; border-left: 0; }
  .d-prop { grid-template-columns: 70px 1fr; }
  .done-tray { right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); width: 52px; height: 52px; }
  .modal-back { padding: 0; place-items: end stretch; }
  .modal, .modal.wide { width: 100%; border-radius: 16px 16px 0 0; max-height: 92dvh; }
  .tick { width: 26px; height: 26px; }
}

/* ---------- wall display (TV) ---------- */
body.tv { --tv-scale: 1.4; background: #15171c; color: #f4f1ec; overflow: hidden; cursor: none; }
#tv { height: 100vh; display: flex; flex-direction: column; }
.tv-head { display: flex; align-items: center; gap: 3vw; padding: 1.6vh 2.2vw; border-bottom: 3px solid var(--co); }
.tv-co { font-size: 2.6vh; font-weight: 800; display: flex; gap: .7vw; align-items: center; letter-spacing: -.01em; }
.tv-dot { width: 1.6vh; height: 1.6vh; border-radius: 50%; background: var(--co); }
.tv-stats { display: flex; gap: 2.4vw; flex: 1; justify-content: center; }
.tv-stat { display: flex; align-items: baseline; gap: .5vw; font-size: 2vh; color: #b9b2a8; }
.tv-stat b { font-size: 4.2vh; color: #fff; font-variant-numeric: tabular-nums; }
.tv-stat.overdue b { color: #f87171; } .tv-stat.today b { color: #fbbf24; } .tv-stat.done b { color: #4ade80; }
.tv-stat.zero b { color: #6b6560; }
.tv-clock { text-align: right; display: flex; flex-direction: column; }
.tv-clock b { font-size: 4.2vh; font-variant-numeric: tabular-nums; line-height: 1; }
.tv-clock span { font-size: 1.8vh; color: #b9b2a8; }
.tv-grid { flex: 1; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 1.2vw; padding: 1.6vh 1.6vw; overflow: hidden; align-content: start; }
.tv-zone { background: color-mix(in srgb, var(--zc) 14%, #1e2128); border: 2px solid color-mix(in srgb, var(--zc) 55%, #1e2128); border-radius: 1.4vh; padding: 1vh .8vw; min-width: 0; }
.tv-zone h2 { margin: 0 0 1vh; font-size: calc(1.5vh * var(--tv-scale)); display: flex; align-items: center; gap: .6vw; }
.tv-zone h2 .n { margin-left: auto; background: rgba(255,255,255,.12); border-radius: 999px; padding: 0 .8vw; font-size: .8em; }
.tv-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(10vw * var(--tv-scale)), 1fr)); gap: .8vh .6vw; }
.tv-tile { background: var(--note); color: #241f1a; border-radius: .5vh .5vh 1.2vh .5vh; padding: calc(.7vh * var(--tv-scale)) calc(.6vw * var(--tv-scale)); display: flex; flex-direction: column; gap: .5vh; box-shadow: 0 .4vh 1.4vh rgba(0,0,0,.35); font-size: calc(1.15vh * var(--tv-scale)); min-width: 0; }
.tv-tile.overdue { box-shadow: inset 0 0 0 .35vh #dc2626, 0 .4vh 1.4vh rgba(0,0,0,.35); }
.tv-t-top { display: flex; justify-content: space-between; align-items: center; gap: .4vw; }
.tv-icon { font-size: 1.6em; }
.tv-tile .due-badge { font-size: .85em; padding: .1em .5em; }
.tv-title { font-weight: 700; line-height: 1.2; font-size: 1.1em; word-break: break-word; }
.tv-next, .tv-loc { font-size: .85em; opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-foot { display: flex; align-items: center; gap: .4vw; margin-top: auto; flex-wrap: wrap; }
.tv-people { display: flex; gap: .5vw; flex-wrap: wrap; }
.tv-person { display: inline-flex; gap: .25vw; align-items: center; font-weight: 600; font-size: .9em; }
.tv-grid.crawl { overflow: hidden; }
.tv-empty, .tv-error { grid-column: 1 / -1; display: grid; place-items: center; font-size: 4vh; color: #8a837b; padding: 10vh; text-align: center; }
.tv-error { height: 100vh; align-content: center; }
.tv-error h1 { margin: 0; color: #f4f1ec; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
