/* M2P — styles */
:root, [data-theme="dark"] {
  --bg: #1b1b1d;
  --panel: #232326;
  --card: #2b2b2f;
  --card-2: #34343a;
  --hover: rgba(255,255,255,.06);
  --text: #ececee;
  --muted: #9b9ba3;
  --line: #3a3a41;
  --dot: #303035;
  --ink: #c9c9cf;
  --accent: #e8775a;
  --accent-ink: #fff;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.25);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
  --good: #6cbf84;
  --warn: #e8775a;
  --today: #e6b450;
  --st-todo: #8e8e96;
  --st-doing: #e6b450;
  --st-done: #6cbf84;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f3f1ec;
  --panel: #ffffff;
  --card: #ffffff;
  --card-2: #f4f2ed;
  --hover: rgba(0,0,0,.05);
  --text: #1d1d1f;
  --muted: #6c6c72;
  --line: #e3e0d9;
  --dot: #d6d2c8;
  --ink: #55555c;
  --accent: #d9603f;
  --shadow: 0 1px 2px rgba(40,30,20,.08), 0 4px 14px rgba(40,30,20,.08);
  --shadow-lg: 0 10px 40px rgba(40,30,20,.18);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }
.ic { width: 20px; height: 20px; flex: none; display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.pad { padding: 16px; }
kbd { font: 11px/1 ui-monospace, Menlo, Consolas, monospace; background: var(--card-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; }
body.is-dragging, body.is-dragging * { user-select: none !important; -webkit-user-select: none !important; cursor: grabbing !important; }

/* ---------- layout ---------- */
#app { height: 100%; display: flex; flex-direction: column; }
#view { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.topbar {
  height: 52px; flex: none; display: flex; align-items: center; gap: 12px;
  padding: 0 12px; padding-top: env(safe-area-inset-top); box-sizing: content-box;
  background: var(--panel); border-bottom: 1px solid var(--line); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.logo .ic { width: 16px; height: 16px; stroke-width: 2.2; }
.tabs { display: flex; gap: 2px; margin-left: 8px; }
.tab { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.tab .ic { width: 18px; height: 18px; }
.tab:hover { background: var(--hover); color: var(--text); }
.tab.on { background: var(--card-2); color: var(--text); }
.crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; overflow: hidden; white-space: nowrap; padding-left: 8px; border-left: 1px solid var(--line); }
.crumb { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; color: var(--muted); min-width: 0; }
.crumb span { overflow: hidden; text-overflow: ellipsis; }
.crumb .ic { width: 16px; height: 16px; }
a.crumb:hover { background: var(--hover); color: var(--text); }
.crumb.current { color: var(--text); font-weight: 600; }
.crumb-sep { color: var(--line); }
.top-actions { display: flex; gap: 2px; }
.icon-btn { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.tabbar { display: none; }
.sync-btn { position: relative; }
.sync-btn i { position: absolute; right: 7px; bottom: 8px; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--panel); box-sizing: content-box; background: transparent; }
.sync-synced i, .sync-dot.sync-synced { background: var(--good); }
.sync-pending i, .sync-dot.sync-pending { background: var(--today); }
.sync-syncing i, .sync-dot.sync-syncing { background: #5aa9e6; animation: pulse 1s infinite alternate; }
.sync-error i, .sync-dot.sync-error { background: #ef5f5f; }
.sync-error, .sync-offline { color: var(--muted); }
.sync-error .ic { color: #ef5f5f; }
@keyframes pulse { to { opacity: .3; } }
.sync-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--st-todo); }
.acct-row { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.acct-row > .ic { width: 36px; height: 36px; padding: 8px; border-radius: 50%; background: var(--card-2); }
.auth-msg { min-height: 18px; margin: 0 0 10px; color: var(--muted); }
.auth-msg.err, .err { color: #ef5f5f; }
.auth-msg.ok { color: var(--good); }
.item-image img[data-sb]:not([src]) { height: 160px; background: var(--card-2); }
.item-image img.img-missing { height: 120px; background: var(--card-2); }

/* ---------- buttons / inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px; background: var(--card-2); border: 1px solid var(--line); font-weight: 500; white-space: nowrap; }
.btn .ic { width: 18px; height: 18px; }
.btn:hover { filter: brightness(1.08); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.danger { color: #ef5f5f; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.input { width: 100%; height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--card-2); color: var(--text); font: inherit; outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
select.input { padding-right: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: none; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: inline-flex; background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 5px 10px; border-radius: 7px; color: var(--muted); font-weight: 500; }
.seg button .ic { width: 17px; height: 17px; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.seg.full { display: flex; }
.seg.full button { flex: 1; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.swatch.on { border-color: var(--text); }
.swatches.big { justify-content: center; padding: 8px 0 4px; }
.swatches.big .swatch { width: 40px; height: 40px; }

/* ---------- board view ---------- */
.board-view { position: absolute; inset: 0; display: flex; }
.tool-rail { width: 72px; flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 0; overflow-y: auto; z-index: 5; }
.tool { width: 62px; padding: 7px 0 5px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: 11px; touch-action: none; }
.tool .ic { width: 34px; height: 30px; padding: 5px 7px; border-radius: 7px; background: var(--card-2); color: var(--text); }
.tool:hover { background: var(--hover); color: var(--text); }
.tool:hover .ic { background: var(--accent); color: #fff; }
.tool-ghost { position: fixed; left: 0; top: 0; width: 56px; height: 56px; border-radius: 14px; background: var(--accent); color: #fff; display: grid; place-items: center; pointer-events: none; z-index: 100; box-shadow: var(--shadow-lg); opacity: .92; }
.tool-ghost .ic { width: 26px; height: 26px; }
.viewport {
  flex: 1; position: relative; overflow: hidden; touch-action: none; outline: none; cursor: default;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--dot) 1.2px, transparent 1.3px);
}
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.items { position: absolute; left: 0; top: 0; }
.lines { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.line-hit { stroke: transparent; stroke-width: 18; fill: none; pointer-events: stroke; cursor: move; }
.line-vis { stroke: var(--ink); stroke-width: 2.2; fill: none; pointer-events: none; stroke-linecap: round; }
.line.selected .line-vis { stroke: var(--accent); }
.arrow-head { fill: var(--ink); }
.lines.overlay { z-index: 2147483000; }
.line-handle { fill: var(--panel); stroke: var(--accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; pointer-events: all; cursor: crosshair; }
.line-handle.attached { fill: var(--accent); }
.anchor { fill: var(--panel); stroke: #5aa9e6; stroke-width: 2; vector-effect: non-scaling-stroke; }
.anchor.on { fill: #5aa9e6; }
.group-box { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 6 5; vector-effect: non-scaling-stroke; opacity: .9; }
.marquee { position: absolute; border: 1.5px solid #5aa9e6; background: rgba(90,169,230,.12); border-radius: 4px; pointer-events: none; z-index: 9; }
.item.multi .rz { display: none !important; }
.mode-select .viewport { cursor: crosshair; }
.space-pan .viewport, .space-pan .viewport * { cursor: grab !important; }
.mode-toggle { display: flex; flex-direction: column; gap: 2px; background: var(--card-2); border-radius: 10px; padding: 3px; }
.mode-btn { width: 40px; height: 34px; display: grid; place-items: center; border-radius: 7px; color: var(--muted); }
.mode-btn .ic { width: 19px; height: 19px; }
.mode-pan .mode-btn[data-mode="pan"], .mode-select .mode-btn[data-mode="select"] { background: var(--accent); color: #fff; }
.rail-sep { width: 36px; height: 1px; background: var(--line); margin: 6px 0; flex: none; }
.bar-count { font-size: 13px; font-weight: 600; padding: 0 6px; color: var(--muted); }
.empty-hint { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; color: var(--text); padding: 24px; }
.empty-hint .ic { width: 44px; height: 44px; color: var(--muted); opacity: .6; }
.empty-hint p { margin: 6px 0 0; max-width: 320px; }

.zoom-ctl { position: absolute; right: 16px; bottom: 16px; display: flex; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 2px; z-index: 6; }
.zoom-ctl button { height: 32px; min-width: 32px; display: grid; place-items: center; border-radius: 7px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.zoom-ctl button:hover { background: var(--hover); color: var(--text); }
.zoom-ctl .ic { width: 17px; height: 17px; }
.zoom-ctl .zl { min-width: 48px; }
.fab { display: none; }

/* ---------- cards ---------- */
.item { position: absolute; border-radius: 6px; touch-action: none; transition: box-shadow .15s; }
.item.selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.item.dragging { box-shadow: var(--shadow-lg) !important; transform: rotate(.6deg); }
.item.flash { animation: flash .9s ease; }
@keyframes flash { 0%, 100% { outline-color: var(--accent); } 50% { outline: 6px solid color-mix(in srgb, var(--accent) 40%, transparent); } }
.rz { position: absolute; right: -6px; bottom: -6px; width: 16px; height: 16px; cursor: nwse-resize; display: none; z-index: 2; }
.rz::after { content: ""; position: absolute; right: 4px; bottom: 4px; width: 9px; height: 9px; border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); border-radius: 0 0 3px 0; }
.item.selected .rz { display: block; }
[contenteditable] { outline: none; cursor: text; word-wrap: break-word; overflow-wrap: anywhere; }
[contenteditable]:empty::before { content: attr(data-ph); color: var(--muted); opacity: .7; pointer-events: none; }

.item-note, .item-todo, .item-link, .item-project, .item-image { background: var(--card); box-shadow: var(--shadow); }
.item-note { padding: 14px 16px; min-height: 52px; }
.item-note.has-accent { border-top: 4px solid var(--accent-c); padding-top: 11px; }
.rich { min-height: 22px; font-size: 14.5px; line-height: 1.55; }
.rich h1, .rich h2, .rich h3 { font-size: 17px; margin: 0 0 6px; line-height: 1.3; }
.rich ul, .rich ol { margin: 6px 0; padding-left: 22px; }
.rich p { margin: 0 0 6px; }
.rich a { color: var(--accent); text-decoration: underline; }
.rich blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }

.item-sticky { box-shadow: 0 1px 2px rgba(0,0,0,.18), 0 6px 16px rgba(0,0,0,.18); border-radius: 2px 2px 14px 2px; color: #2a2620; }
.sticky-body { width: 100%; height: 100%; padding: 16px; overflow: auto; font-size: 16px; line-height: 1.45; white-space: pre-wrap; font-weight: 500; }
.sticky-body:empty::before { color: rgba(0,0,0,.4); opacity: 1; }
.sticky-yellow { background: #fde68a; } .sticky-pink { background: #fbcfe8; } .sticky-green { background: #bbf7d0; }
.sticky-blue { background: #bfdbfe; } .sticky-purple { background: #ddd6fe; } .sticky-orange { background: #fed7aa; }

.item-todo { padding: 12px 14px 8px; }
.todo-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.todo-title { flex: 1; font-weight: 650; font-size: 15px; }
.todo-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress { height: 6px; border-radius: 99px; background: var(--card-2); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--pc, var(--good)); transition: width .3s; }
.progress.sm { height: 4px; margin-bottom: 8px; }
.progress.big { height: 10px; }
.todo-row { display: flex; align-items: flex-start; gap: 8px; padding: 3px 0; }
.chk { width: 20px; height: 20px; flex: none; border-radius: 6px; border: 1.8px solid var(--muted); display: grid; place-items: center; margin-top: 1px; color: transparent; transition: background .12s, border-color .12s; }
.chk .ic { width: 14px; height: 14px; stroke-width: 3; }
.chk:hover { border-color: var(--good); }
.done > .chk, .todo-row.done .chk, .task-card.done .chk, .task-row.done .chk { background: var(--good); border-color: var(--good); color: #fff; }
.todo-text { flex: 1; min-height: 21px; }
.todo-row.done .todo-text { color: var(--muted); text-decoration: line-through; }
.todo-add { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; padding: 6px 0 2px; }
.todo-add .ic { width: 16px; height: 16px; }
.todo-add:hover { color: var(--text); }

.item-board { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 6px 4px; border-radius: 12px; }
.item-board.selected { outline-offset: 0; }
.board-tile { width: 90px; height: 90px; border-radius: 16px; display: grid; place-items: center; color: #3a2a20; cursor: pointer; box-shadow: var(--shadow); transition: transform .15s; }
.board-tile .ic { width: 40px; height: 40px; stroke-width: 1.6; }
.board-tile:hover { transform: translateY(-2px); }
.item-board.drop-target .board-tile { transform: scale(1.1); box-shadow: 0 0 0 4px var(--accent), var(--shadow-lg); }
.board-name { margin-top: 10px; font-weight: 700; font-size: 15px; min-width: 40px; max-width: 100%; }
.board-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.item-link { padding: 12px 14px; }
.link-top { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.link-top .ic { width: 16px; height: 16px; }
.link-domain { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-open { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 6px; color: var(--accent); }
.link-open:hover { background: var(--hover); }
.link-title { font-weight: 650; font-size: 15px; margin: 4px 0 2px; }
.link-url { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.item-image { padding: 0; overflow: hidden; }
.item-image img { display: block; width: 100%; height: auto; pointer-events: none; }
.caption { padding: 8px 12px; font-size: 13px; color: var(--muted); }
.caption:empty { padding: 0 12px; height: 0; }
.item-image.selected .caption:empty { height: auto; padding: 8px 12px; }

.item-sketch { background: #fff; box-shadow: var(--shadow); overflow: hidden; }
.sketch-surface { position: absolute; inset: 0; }
.sketch-surface svg { width: 100%; height: 100%; display: block; }
.sketch-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #9a958c; font-size: 13px; pointer-events: none; }
.sketch-empty .ic { width: 28px; height: 28px; }

.item-project { padding: 14px 16px; }
.proj-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; cursor: pointer; margin-bottom: 10px; }
.proj-head .ic { width: 18px; height: 18px; color: var(--muted); margin-left: auto; }
.proj-head:hover .proj-name { text-decoration: underline; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pc, var(--accent)); flex: none; }
.proj-meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.proj-meta b { color: var(--text); }
.proj-next { list-style: none; margin: 10px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.proj-next li { display: flex; align-items: center; gap: 8px; }
.proj-next em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--muted); }
.proj-next em.late { color: var(--warn); }
.proj-missing { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.st { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.st-todo { background: var(--st-todo); } .st-doing { background: var(--st-doing); } .st-done { background: var(--st-done); }

/* floating toolbar for the selected card */
.item-bar { position: absolute; left: 0; top: 0; z-index: 8; display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 11px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-lg); white-space: nowrap; }
.item-bar button { height: 32px; min-width: 32px; padding: 0 7px; display: flex; align-items: center; gap: 5px; border-radius: 7px; color: var(--text); font-size: 13px; font-weight: 500; }
.item-bar button .ic { width: 18px; height: 18px; }
.item-bar button:not(.sw):hover, .item-bar button:not(.sw).on { background: var(--hover); }
.item-bar button.danger { color: #ef5f5f; }
.item-bar .sw { min-width: 22px; width: 22px; height: 22px; padding: 0; border-radius: 50%; margin: 0 2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.item-bar .sw.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text); }
.item-bar .sw-none { background: var(--card-2); position: relative; }
.item-bar .sw-none::after { content: ""; position: absolute; left: 50%; top: 3px; bottom: 3px; width: 2px; background: var(--muted); transform: rotate(45deg); }
.item-bar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

/* ---------- sketch editor ---------- */
.sketch-editor { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; }
.sk-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; flex-wrap: nowrap; }
.sk-group { display: flex; align-items: center; gap: 2px; flex: none; }
.sk-group + .sk-group { padding-left: 10px; border-left: 1px solid var(--line); }
.sk-group button:not(.btn) { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); }
.sk-group button:not(.btn).on { background: var(--card-2); color: var(--text); }
.sk-group button:not(.btn):hover { color: var(--text); }
.sk-color { position: relative; }
.sk-color::after { content: ""; width: 20px; height: 20px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(128,128,128,.5); }
.sk-color.on::after { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text); }
.sk-sizes i { display: block; border-radius: 50%; background: currentColor; }
.sk-spacer { flex: 1; }
.sk-stage { flex: 1; display: grid; place-items: center; overflow: hidden; }
.sk-svg { background: #fff; border-radius: 6px; box-shadow: var(--shadow-lg); touch-action: none; cursor: crosshair; }

/* ---------- pages (projects, tasks) ---------- */
.page { position: absolute; inset: 0; overflow: auto; padding: 28px 32px 60px; -webkit-overflow-scrolling: touch; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.page-head p { margin: 2px 0 0; }
.ph-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.ph-right { display: flex; align-items: center; gap: 8px; }
.editable { border-radius: 6px; padding: 2px 6px; margin-left: -6px; }
.editable:hover { background: var(--hover); }
.editable:focus { background: var(--card-2); }
.color-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--pc); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc) 30%, transparent); }
.project-page .desc { color: var(--muted); margin: -10px 0 18px; max-width: 720px; min-height: 22px; }

.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.proj-tile { display: flex; flex-direction: column; gap: 10px; background: var(--card); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); border-top: 4px solid var(--pc); transition: transform .15s, box-shadow .15s; text-align: left; }
.proj-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.pt-top { display: flex; align-items: center; gap: 10px; }
.pt-top h3 { margin: 0; font-size: 17px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-desc { margin: 0; color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.proj-tile .progress i { background: var(--pc); }
.pt-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.pt-meta b { color: var(--text); }
.pt-foot { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.pt-foot span { display: flex; align-items: center; gap: 6px; }
.pt-foot .late { color: var(--warn); }
.proj-new { border: 2px dashed var(--line); background: transparent; box-shadow: none; align-items: center; justify-content: center; color: var(--muted); min-height: 160px; border-top-width: 2px; }
.proj-new .ic { width: 28px; height: 28px; }

.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--card-2); color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
.chip .ic { width: 13px; height: 13px; }
.chip.due.late { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.chip.due.today { background: color-mix(in srgb, var(--today) 20%, transparent); color: var(--today); }
.chip.due.soon { color: var(--text); }
.chip.pri-high { color: #ef5f5f; } .chip.pri-med { color: var(--today); } .chip.pri-low { color: #5aa9e6; }
.proj-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--pc); }

.progress-card { display: flex; align-items: center; gap: 20px; background: var(--card); border-radius: 14px; padding: 16px 20px; box-shadow: var(--shadow); margin-bottom: 22px; flex-wrap: wrap; }
.pc-ring { --p: 0; width: 64px; height: 64px; border-radius: 50%; flex: none; display: grid; place-items: center; background: conic-gradient(var(--pc) calc(var(--p) * 1%), var(--card-2) 0); }
.pc-ring span { width: 50px; height: 50px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.pc-main { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 8px; }
.pc-main .progress i { background: var(--pc); }
.pc-stats { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.pc-stats span { display: flex; align-items: center; gap: 6px; }
.pc-due { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.pc-due .input { width: 160px; }

.kanban { display: grid; grid-template-columns: repeat(3, minmax(260px, 1fr)); gap: 16px; align-items: start; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 8px; transition: border-color .15s; }
.col.drop-col { border-color: var(--accent); }
.col header { display: flex; align-items: center; gap: 8px; font-weight: 650; padding: 2px 4px 4px; }
.col .count { margin-left: auto; color: var(--muted); font-size: 12px; background: var(--card-2); border-radius: 99px; padding: 1px 8px; font-weight: 600; }
.col-list { display: flex; flex-direction: column; gap: 8px; min-height: 12px; }
.task-card { display: flex; align-items: flex-start; gap: 10px; padding: 10px 8px 10px 12px; background: var(--card); border-radius: 10px; box-shadow: var(--shadow); cursor: pointer; }
.task-card:hover { box-shadow: 0 0 0 1px var(--line), var(--shadow); }
.task-card.done .tc-title { color: var(--muted); text-decoration: line-through; }
.task-card.drag-src { display: none; }
.task-ghost { position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; box-shadow: var(--shadow-lg); opacity: .95; }
.task-ph { border-radius: 10px; border: 2px dashed var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.tc-body { flex: 1; min-width: 0; }
.tc-title { font-weight: 500; overflow-wrap: anywhere; }
.tc-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.grip { color: var(--muted); opacity: .45; cursor: grab; touch-action: none; padding: 0 2px; }
.grip .ic { width: 18px; height: 18px; }
.task-card:hover .grip { opacity: 1; }
.add-task .input { background: transparent; border-style: dashed; }
.add-task .input:focus { background: var(--card-2); border-style: solid; }
.add-task.wide { margin-bottom: 12px; }

.task-rows { display: flex; flex-direction: column; background: var(--card); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.task-row { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; flex-wrap: wrap; }
.task-row:last-child { border-bottom: 0; }
.task-row:hover { background: var(--hover); }
.task-row .chk { margin-top: 0; }
.tr-title { flex: 1; min-width: 140px; font-weight: 500; }
.task-row.done .tr-title { color: var(--muted); text-decoration: line-through; }
.status-pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--card-2); color: var(--muted); }
.sp-doing { color: var(--st-doing); } .sp-done { color: var(--st-done); }

.tasks-page { max-width: 920px; margin: 0 auto; right: 0; left: 0; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.stat b { font-size: 24px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 12.5px; }
.stat.warn b { color: var(--warn); }
.stat.good b { color: var(--good); }
.quick-add { display: grid; grid-template-columns: 1fr 180px 150px auto; gap: 8px; margin-bottom: 22px; }
.task-group { margin-bottom: 20px; }
.task-group h2, .h2-btn { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.task-group h2.late { color: var(--warn); }
.task-group h2.today { color: var(--today); }
.task-group .count { background: var(--card-2); border-radius: 99px; padding: 0 8px; font-size: 11.5px; }
.done-group { margin: 6px 0 14px; }
.done-head { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 650; margin: 0 0 8px 2px; }
.done-head .count { margin-left: 2px; color: var(--muted); font-size: 12px; font-weight: 600; }
.chip.done-at { color: var(--good); }
.h2-btn .ic { width: 16px; height: 16px; transition: transform .15s; }
.h2-btn .ic.rot { transform: rotate(90deg); }
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 60px 20px; gap: 6px; }
.empty-state .ic { width: 44px; height: 44px; color: var(--muted); }
.empty-state h3 { margin: 6px 0 0; }
.empty-state p { margin: 0 0 12px; }

/* ---------- team ---------- */
.team-page { max-width: 920px; margin: 0 auto; right: 0; left: 0; }
.team-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 20px; }
.team-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.team-ic { width: 40px; height: 40px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); display: grid; place-items: center; flex: none; }
.th-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.th-main h2 { margin: 0; font-size: 18px; }
.assign-form { display: grid; grid-template-columns: 1fr 170px 150px auto; gap: 8px; margin-bottom: 16px; }
.member-block { margin-bottom: 14px; }
.member-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.avatar.pending { background: var(--card-2); color: var(--muted); border: 1.5px dashed var(--muted); }
.mh-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.mh-main b, .mh-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-block .progress.sm { margin: 0 0 8px; }
.mb-none { margin: 0 0 0 42px; }
.tr-notes { display: inline-flex; vertical-align: middle; margin-left: 6px; color: var(--muted); }
.tr-notes .ic { width: 14px; height: 14px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--card-2); margin-bottom: 16px; font-size: 13.5px; }
.notice .ic { flex: none; margin-top: 1px; }
.notice.warn { background: color-mix(in srgb, var(--warn) 14%, var(--card)); }
.notice.ok { background: color-mix(in srgb, var(--good) 16%, var(--card)); color: var(--text); }
.notice.ok .ic { color: var(--good); }
.notice code { font-size: 12px; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv span { color: var(--muted); }
.task-notes { white-space: pre-wrap; margin-top: 12px; padding: 12px; background: var(--card-2); border-radius: 10px; }
.invite-text { font-size: 13px; resize: none; }
.sheet-list { display: flex; flex-direction: column; gap: 4px; }
.sheet-list button { display: flex; align-items: center; gap: 12px; padding: 13px 12px; border-radius: 10px; text-align: left; font-weight: 500; }
.sheet-list button:hover { background: var(--hover); }
.sheet-list button.danger { color: #ef5f5f; }

/* ---------- drawer ---------- */
.drawer-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0); transition: background .2s; }
.drawer-wrap.in { background: rgba(0,0,0,.35); }
.drawer-wrap:not(.in), .modal-wrap.out, .sheet-wrap:not(.in) { pointer-events: none; }
.drawer { position: absolute; right: 0; top: 0; bottom: 0; width: min(440px, 100%); background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); padding: 16px 20px; padding-top: calc(16px + env(safe-area-inset-top)); display: flex; flex-direction: column; overflow-y: auto; transform: translateX(100%); transition: transform .22s ease; }
.drawer-wrap.in .drawer { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.drawer-head .spacer { flex: 1; }
.task-title-input { width: 100%; border: 0; background: transparent; color: var(--text); font-family: inherit; font-weight: 700; font-size: 21px; line-height: 1.3; resize: none; outline: none; padding: 6px 0; margin-bottom: 14px; overflow: hidden; }
.drawer .seg button { font-size: 13px; padding: 7px 6px; }
.field.grow { flex: 1; }
.field textarea.notes { flex: 1; min-height: 140px; }
.drawer-foot { font-size: 12px; padding-top: 6px; }

/* ---------- modal / sheet / toast ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; background: rgba(0,0,0,0); transition: background .16s; }
.modal-wrap.in { background: rgba(0,0,0,.45); }
.modal { width: min(460px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 18px 20px; transform: translateY(8px) scale(.98); opacity: 0; transition: transform .16s, opacity .16s; max-height: 80vh; overflow: auto; }
.modal-wrap.in .modal { transform: none; opacity: 1; }
.modal-wrap.out .modal { opacity: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body p { margin: 0 0 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.settings-modal { width: min(520px, 100%); }
.shortcuts { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.board-edit-preview { display: flex; justify-content: center; margin-bottom: 14px; }
.icon-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.icon-pick { aspect-ratio: 1; border-radius: 9px; display: grid; place-items: center; background: var(--card-2); color: var(--muted); border: 2px solid transparent; }
.icon-pick.on { border-color: var(--accent); color: var(--text); }
.pick-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; max-height: 300px; overflow: auto; }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; text-align: left; }
.pick-row:hover { background: var(--hover); }
.pick-row .grow { flex: 1; font-weight: 500; }
.pick-new { display: flex; gap: 8px; }

.search-modal { padding: 0; width: min(600px, 100%); overflow: hidden; display: flex; flex-direction: column; }
.search-box { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.search-input { flex: 1; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; outline: none; }
.search-results { max-height: 55vh; overflow: auto; padding: 6px; }
.sr { width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 9px; text-align: left; }
.sr.on, .sr:hover { background: var(--hover); }
.sr-ic { width: 32px; height: 32px; border-radius: 8px; background: var(--card-2); display: grid; place-items: center; color: var(--muted); flex: none; }
.sr-ic .ic { width: 17px; height: 17px; }
.sr-main { display: flex; flex-direction: column; min-width: 0; }
.sr-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.sr-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr.done .sr-title { text-decoration: line-through; color: var(--muted); }

.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0); transition: background .18s; display: flex; align-items: flex-end; justify-content: center; }
.sheet-wrap.in { background: rgba(0,0,0,.4); }
.sheet { width: min(520px, 100%); background: var(--panel); border-radius: 18px 18px 0 0; padding: 10px 16px calc(18px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .2s ease; }
.sheet-wrap.in .sheet { transform: none; }
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 10px; }
.sheet-title { font-weight: 700; margin-bottom: 12px; text-align: center; }
.add-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.add-grid button { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px; border-radius: 12px; background: var(--card-2); font-size: 13px; font-weight: 500; }
.add-grid .ic { width: 26px; height: 26px; color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; z-index: 70; display: flex; align-items: center; gap: 14px; background: #2f2f34; color: #fff; padding: 10px 12px 10px 16px; border-radius: 11px; box-shadow: var(--shadow-lg); transition: transform .2s, opacity .2s; font-size: 13.5px; }
.toast.in { transform: translate(-50%, 0); opacity: 1; }
.toast button { color: #ffb39e; font-weight: 600; padding: 4px 8px; border-radius: 6px; }
.toast button:hover { background: rgba(255,255,255,.08); }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .tabs, .brand-name, .hide-sm { display: none; }
  .crumbs { border-left: 0; padding-left: 0; }
  .topbar { gap: 6px; padding-left: 10px; padding-right: 6px; height: 50px; }
  .tabbar {
    display: flex; flex: none; background: var(--panel); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom); z-index: 20;
  }
  .tabbar a, .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 6px; font-size: 11px; color: var(--muted); }
  .tabbar .ic { width: 22px; height: 22px; }
  .tabbar .on { color: var(--accent); }
  .tool-rail { width: 54px; padding: 6px 0; gap: 0; }
  .tool { width: 48px; padding: 4px 0; font-size: 9.5px; gap: 2px; }
  .tool .ic { width: 32px; height: 28px; padding: 5px 6px; }
  .mode-btn { width: 38px; height: 32px; }
  .rail-sep { width: 30px; margin: 4px 0; }
  .zoom-ctl { right: 12px; bottom: 14px; }
  .zoom-ctl [data-z="in"], .zoom-ctl [data-z="out"] { display: none; }
  .item-bar { max-width: calc(100% - 16px); overflow-x: auto; }
  .page { padding: 18px 14px 40px; }
  .page-head h1 { font-size: 22px; }
  .kanban { grid-template-columns: repeat(3, 84%); overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -14px; padding: 0 14px 10px; }
  .col { scroll-snap-align: center; }
  .grip { opacity: 1; padding: 4px; margin: -4px -2px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .assign-form { grid-template-columns: 1fr 1fr; }
  .assign-form [name="title"], .assign-form .btn { grid-column: 1 / -1; }
  .team-head .btn span { display: none; }
  .mh-count { display: none; }
  .quick-add { grid-template-columns: 1fr 1fr; }
  .quick-add .qa-title { grid-column: 1 / -1; }
  .quick-add .btn { grid-column: 1 / -1; }
  .progress-card { gap: 14px; }
  .pc-due { width: 100%; }
  .pc-due .input { width: 100%; }
  .seg button span { display: none; }
  .modal-wrap { padding-top: 6vh; }
  .drawer { width: 100%; }
  .icon-grid { grid-template-columns: repeat(6, 1fr); }
  .sk-bar { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .sk-group + .sk-group { padding-left: 6px; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
@media (hover: none) {
  .item.selected .rz { width: 26px; height: 26px; right: -10px; bottom: -10px; }
  .rz::after { width: 12px; height: 12px; }
}

/* ---------------- sign in / create account ---------------- */
.auth-modal { width: min(400px, calc(100vw - 24px)); }
.auth-form .field { margin-bottom: 12px; }
.btn.block { display: flex; width: 100%; }
.btn.big { height: 46px; font-size: 15px; border-radius: 12px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.auth-forgot { display: flex; justify-content: flex-end; margin: -4px 0 8px; font-size: 13px; }
.auth-switch { text-align: center; margin: 16px 0 2px; }
.auth-done { text-align: center; padding: 6px 4px 2px; }
.auth-done > .ic { width: 44px; height: 44px; padding: 10px; border-radius: 50%; background: color-mix(in srgb, var(--good) 18%, var(--card)); color: var(--good); }
.auth-done h3 { margin: 10px 0 6px; font-size: 18px; }
.auth-done p { margin: 0 0 16px; }
.center { text-align: center; }

/* ---------------- get the app ---------------- */
.install-page { max-width: 820px; margin: 0 auto; }
.install-hero { display: flex; gap: 18px; align-items: center; margin-bottom: 20px; }
.install-logo { width: 72px; height: 72px; border-radius: 18px; flex: none; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.install-hero h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.02em; }
.install-hero p { margin: 0; }
.quick-get { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.store-btn { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-weight: 600; font-size: 16px; }
.store-btn .ic { width: 26px; height: 26px; flex: none; }
.store-btn small { display: block; font-size: 11.5px; font-weight: 500; color: var(--muted); }
.store-btn.on { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.store-btn.on small { color: inherit; opacity: .8; }
.install-link { margin-bottom: 20px; }
.copy-row { display: flex; gap: 8px; margin-top: 6px; }
.copy-row .input { flex: 1; min-width: 0; }
.install-cards { display: grid; gap: 14px; }
.install-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; scroll-margin-top: 16px; transition: box-shadow .3s; }
.install-card.here { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.install-card.flash { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }
.install-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.install-card-head h2 { margin: 0; font-size: 18px; display: inline; margin-right: 8px; }
.os-badge { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--card-2); flex: none; }
.install-card > .btn.big { margin-bottom: 6px; }
.steps { list-style: none; margin: 4px 0 6px; padding: 0; display: grid; gap: 10px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; line-height: 1.45; }
.step-n { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--card-2); font-size: 12.5px; font-weight: 700; }
.inline-ic, .steps .ic { width: 17px; height: 17px; vertical-align: -3px; display: inline-block; }
@media (max-width: 760px) {
  .install-hero { gap: 14px; }
  .install-logo { width: 56px; height: 56px; border-radius: 14px; }
  .install-hero h1 { font-size: 21px; }
  .install-card { padding: 16px; }
}
