:root {
  --bg: #ffffff; --bg2: #f6f6f7; --bg3: #ececee; --line: #e5e5e8; --text: #18181b; --muted: #71717a; --faint: #a1a1aa;
  --accent: #111827; --accent-text: #fff; --blue: #2563eb; --red: #ef4444; --green: #16a34a; --amber: #d97706;
  --pin: #ef4444; --radius: 10px; --shadow: 0 8px 30px rgba(0,0,0,.12); --sidebar: 236px;
  color-scheme: light;
}
/* White by default. Dark only when chosen in Settings → Appearance. */
:root[data-theme="dark"] {
  --bg: #111113; --bg2: #19191c; --bg3: #232327; --line: #2c2c31; --text: #ededef; --muted: #a1a1aa; --faint: #6b6b74;
  --accent: #f4f4f5; --accent-text: #111; --shadow: 0 8px 30px rgba(0,0,0,.5); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body, #app { margin: 0; height: 100%; }
body { font: 14px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--bg2); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { opacity: .9; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg2); }
.btn.danger { color: var(--red); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn.icon { width: 34px; padding: 0; }
.btn:disabled { opacity: .5; cursor: default; }
.input, select.input, textarea.input { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); outline: none; }
textarea.input { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; }
.input:focus { border-color: var(--muted); }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 5px; }
.seg { display: inline-flex; background: var(--bg2); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; height: 28px; padding: 0 11px; border-radius: 7px; color: var(--muted); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--bg3); border-radius: 20px; transition: .15s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(16px); }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 11px; font-weight: 500; background: var(--bg3); color: var(--text); }
.avatar { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: #fff; flex: none; }
.err { color: var(--red); font-size: 13px; margin: 6px 0; min-height: 1px; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* auth pages */
.auth { min-height: 100%; display: flex; align-items: center; justify-content: center; background: var(--bg2); padding: 16px; }
.auth .card { width: 100%; max-width: 380px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.auth h1 { font-size: 20px; margin: 0 0 4px; }
.auth p { margin: 0 0 20px; color: var(--muted); }

/* shell */
.shell { display: flex; height: 100%; }
.sidebar { width: var(--sidebar); flex: none; background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; overflow-y: auto; }
.sidebar .ws { font-weight: 600; padding: 6px 10px 14px; display: flex; align-items: center; gap: 8px; }
.nav a, .nav .navbtn { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border-radius: 7px; color: var(--muted); font-weight: 500; width: 100%; border: 0; background: none; text-align: left; }
.nav a:hover, .nav .navbtn:hover { background: var(--bg3); color: var(--text); }
.nav a.on { background: var(--bg3); color: var(--text); }
.nav .badge { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; border-radius: 9px; padding: 0 6px; line-height: 18px; }
.nav-head { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--faint); padding: 18px 10px 6px; }
.nav-head button { border: 0; background: none; color: var(--muted); border-radius: 6px; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
.nav-head button:hover { background: var(--bg3); }
.nav .proj .hash { color: var(--faint); font-weight: 400; }
.nav .proj.dragging { opacity: .4; }
.sidebar .foot { margin-top: auto; padding-top: 12px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.topbar { height: 60px; flex: none; display: flex; align-items: center; gap: 14px; padding: 0 24px; border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 600; }
.tabs { display: flex; gap: 4px; }
.tabs a, .tabs button { height: 30px; padding: 0 10px; display: inline-flex; align-items: center; border-radius: 7px; color: var(--muted); font-weight: 500; border: 0; background: none; }
.tabs a.on, .tabs button.on { color: var(--text); background: var(--bg2); }
.content { flex: 1; overflow: auto; }
.menu-btn { display: none; }

/* board */
.board { display: flex; gap: 16px; padding: 18px 24px; height: 100%; align-items: flex-start; overflow-x: auto; }
.col { flex: 1 0 230px; max-width: 320px; display: flex; flex-direction: column; max-height: 100%; }
.onboard { max-width: 520px; margin: 40px auto; padding: 28px; border: 1px solid var(--line); border-radius: 14px; }
.onboard h2 { margin: 0 0 12px; font-size: 18px; }
.onboard ol { padding-left: 20px; margin: 0 0 20px; line-height: 1.7; }
.hint { position: sticky; top: 0; z-index: 6; display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; background: #eff6ff; color: #1e3a8a; padding: 8px 14px; font-size: 13px; border-bottom: 1px solid #dbeafe; }
.hint button { border: 0; background: none; color: inherit; text-decoration: underline; padding: 0; }
.cm.other { opacity: .6; }
.tour { position: fixed; inset: 0; z-index: 80; }
.tour-hole { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(15, 23, 42, .55); outline: 2px solid #fff; transition: all .25s; pointer-events: none; }
.tour-card { position: fixed; background: var(--bg); border-radius: 12px; box-shadow: var(--shadow); padding: 16px; transition: top .25s, left .25s; }
.tour-card h3 { margin: 4px 0 6px; font-size: 16px; }
.tour-card p { margin: 0 0 14px; color: var(--muted); }
.input.big { height: 46px; font-size: 16px; padding: 0 14px; }
.add-task { gap: 6px; }
.pagebar { display: flex; align-items: center; gap: 6px; padding: 7px 14px; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; scrollbar-width: thin; }
.ptab { flex: none; max-width: 220px; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 16px; border: 1px solid var(--line); background: var(--bg); color: var(--muted); font-weight: 500; }
.ptab:hover { color: var(--text); background: var(--bg2); }
.ptab.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.cnt { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--pin); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.col-head { display: flex; align-items: center; gap: 8px; height: 34px; font-weight: 500; }
.col-head .count { color: var(--faint); font-weight: 400; }
.col-head .add { margin-left: auto; }
.col-body { display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 40px; min-height: 120px; overflow-y: auto; border-radius: 10px; }
.col-body.over { background: var(--bg2); }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; transition: box-shadow .12s; }
.card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.card.dragging { opacity: .4; }
.card .thumb { height: 120px; background: var(--bg2) center top / cover no-repeat; border-bottom: 1px solid var(--line); }
.card .body { padding: 10px 12px; }
.card .title { font-weight: 500; }
.card .meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; color: var(--muted); font-size: 12px; }
.card .meta .right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.add-task { height: 38px; border: 1.5px dashed var(--faint); border-radius: 10px; background: none; color: var(--faint); display: flex; align-items: center; justify-content: center; gap: 8px; }
.add-task:hover { color: var(--text); border-color: var(--muted); }
kbd { font: 11px Inter, sans-serif; background: var(--bg3); border-radius: 4px; padding: 1px 5px; color: var(--muted); }
.status-dot { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid currentColor; flex: none; display: inline-block; }
.prio { font-size: 11px; font-weight: 600; }
.older-toggle { border: 0; background: none; color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-align: left; padding: 6px 2px; }

/* inbox */
.page { max-width: 780px; margin: 0 auto; padding: 24px; }
.feed-day { font-size: 12px; font-weight: 600; color: var(--faint); margin: 20px 0 6px; }
.feed-item { display: flex; gap: 12px; padding: 12px; border-radius: 10px; cursor: pointer; align-items: flex-start; }
.feed-item:hover { background: var(--bg2); }
.feed-item.unread .ftitle::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); margin-right: 7px; vertical-align: middle; }
.feed-item .ftitle { font-weight: 500; }
.feed-item .quote { color: var(--muted); margin-top: 2px; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; z-index: 50; overflow-y: auto; }
.modal { width: 100%; max-width: 640px; background: var(--bg); border-radius: 14px; box-shadow: var(--shadow); padding: 22px; }
.modal h2 { font-size: 17px; margin: 0 0 14px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; align-items: center; }
.title-input { border: 0; outline: none; font-size: 20px; font-weight: 600; width: 100%; background: none; padding: 0; }
.brief-input { border: 0; outline: none; width: 100%; resize: vertical; background: none; color: var(--text); min-height: 50px; padding: 6px 0; }
.props { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; }
.props select, .props input { height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 0 8px; }
.pagelist { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; }
.pagelist label { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pagelist label:last-child { border-bottom: 0; }
.pagelist input[type=text] { border: 0; background: none; outline: none; font-weight: 500; flex: 1; min-width: 0; }
.pagelist .url { color: var(--faint); font-size: 12px; max-width: 45%; }

/* popover menu */
.pop { position: fixed; z-index: 60; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 5px; min-width: 190px; max-height: 70vh; overflow-y: auto; }
.pop button, .pop a { display: flex; width: 100%; align-items: center; gap: 9px; border: 0; background: none; padding: 7px 10px; border-radius: 6px; text-align: left; }
.pop button:hover, .pop a:hover { background: var(--bg2); }
.pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.pop .sel::after { content: '✓'; margin-left: auto; color: var(--muted); }

/* settings */
.settings { display: flex; height: 100%; }
.settings nav { width: 210px; border-right: 1px solid var(--line); padding: 16px 10px; flex: none; }
.settings nav h4 { font-size: 11px; color: var(--faint); letter-spacing: .04em; margin: 14px 10px 6px; }
.settings section { flex: 1; overflow-y: auto; padding: 28px 36px; max-width: 760px; }
.settings section h2 { margin: 0 0 18px; font-size: 18px; }
.set-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.set-row .grow > div:first-child { font-weight: 500; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }

/* review screen */
.review { display: flex; flex-direction: column; height: 100%; }
.rv-top { height: 58px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--bg); }
.rv-top .left, .rv-top .right { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.rv-top .right { justify-content: flex-end; }
.rv-top .center { display: flex; align-items: center; gap: 8px; }
.rv-title { font-weight: 600; max-width: 280px; }
.vbtn { height: 28px; padding: 0 8px; border-radius: 7px; border: 0; background: var(--bg2); font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
.pagesel { height: 34px; max-width: 260px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.rv-body { flex: 1; display: flex; min-height: 0; }
.panel { width: 360px; flex: none; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.panel.collapsed { display: none; }
.panel-tabs { display: flex; align-items: center; gap: 2px; height: 48px; padding: 0 10px; border-bottom: 1px solid var(--line); flex: none; }
.panel-tabs .t { height: 48px; padding: 0 10px; border: 0; background: none; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; }
.panel-tabs .t.on { color: var(--text); border-bottom-color: var(--text); }
.panel-scroll { flex: 1; overflow-y: auto; padding: 12px 14px; }
.panel-foot { border-top: 1px solid var(--line); padding: 10px 14px; flex: none; }
.cm { display: flex; gap: 10px; padding: 10px 8px; border-radius: 10px; cursor: pointer; }
.cm:hover { background: var(--bg2); }
.cm.sel { background: var(--bg2); outline: 1.5px solid var(--line); }
.cm .num { width: 24px; height: 24px; border-radius: 50%; background: var(--pin); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.cm .num.done { background: var(--green); }
.cm .who { font-weight: 600; }
.cm .when { color: var(--faint); font-size: 12px; }
.cm .txt { margin-top: 3px; white-space: pre-wrap; word-wrap: break-word; }
.cm .where { margin-top: 4px; color: var(--faint); font-size: 12px; display: flex; gap: 6px; align-items: center; }
.replies { margin: 2px 0 6px 34px; border-left: 2px solid var(--line); padding-left: 12px; }
.reply { padding: 6px 0; }
.reply .who { font-weight: 600; font-size: 13px; }
.reply .txt { white-space: pre-wrap; word-wrap: break-word; }
.reply-box { display: flex; gap: 6px; margin: 6px 0 10px 34px; }
.reply-box textarea { min-height: 36px; height: 36px; }
.cm-actions { display: flex; gap: 4px; margin: 0 0 4px 34px; flex-wrap: wrap; }
.sysline { text-align: center; color: var(--faint); font-size: 12px; margin: 10px 0; }
.details-grid { display: grid; grid-template-columns: 110px 1fr; gap: 10px 10px; align-items: center; }
.details-grid > span { color: var(--muted); }
.details-grid select, .details-grid input { height: 32px; border: 1px solid transparent; background: none; border-radius: 7px; padding: 0 6px; width: 100%; }
.details-grid select:hover, .details-grid input:hover { border-color: var(--line); }
.stage { flex: 1; overflow: auto; background: var(--bg2); position: relative; }
.stage-inner { margin: 24px auto 60px; position: relative; }
.stage-inner.mobile { width: 390px; }
.shot-wrap { position: relative; box-shadow: 0 4px 24px rgba(0,0,0,.12); background: #fff; }
.stage-inner.mobile .shot-wrap { border-radius: 28px; border: 10px solid #18181b; overflow: hidden; }
.shot-wrap img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.stage.commenting .shot-wrap { cursor: crosshair; }
.pin { position: absolute; width: 30px; height: 30px; margin: -30px 0 0 -2px; border-radius: 50% 50% 50% 2px; background: var(--pin); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); cursor: pointer; z-index: 2; transform-origin: bottom left; }
.pin:hover, .pin.sel { transform: scale(1.15); z-index: 3; }
.pin.done { background: var(--green); }
.pin.draft { background: var(--blue); }
.composer { position: absolute; z-index: 5; width: 300px; background: var(--bg); color: var(--text); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); padding: 10px; }
.composer textarea { width: 100%; min-height: 70px; border: 0; outline: none; resize: vertical; background: none; }
.capture-note { max-width: 520px; margin: 80px auto; text-align: center; color: var(--muted); }
.progress { height: 6px; background: var(--bg3); border-radius: 6px; overflow: hidden; margin: 14px 0; }
.progress > div { height: 100%; background: var(--accent); transition: width .3s; }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--bg3); border-top-color: var(--text); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.approve-bar { display: flex; gap: 6px; align-items: center; }
.guest-chip { font-size: 12px; color: var(--muted); }

/* toasts */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--accent); color: var(--accent-text); padding: 9px 14px; border-radius: 9px; box-shadow: var(--shadow); font-weight: 500; }
.toast.error { background: var(--red); color: #fff; }

/* phones */
@media (max-width: 820px) {
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; gap: 8px; }
  .board { padding: 14px 16px; }
  .col { width: 82vw; }
  .settings { flex-direction: column; }
  .settings nav { width: auto; border-right: 0; border-bottom: 1px solid var(--line); display: flex; overflow-x: auto; gap: 2px; padding: 8px; }
  .settings nav h4 { display: none; }
  .settings section { padding: 20px 16px; }
  .rv-top { flex-wrap: wrap; height: auto; padding: 8px 10px; }
  .rv-top .center { order: 3; width: 100%; justify-content: space-between; }
  .rv-title { max-width: 140px; }
  .rv-body { flex-direction: column-reverse; }
  .panel { width: auto; height: 42%; border-right: 0; border-top: 1px solid var(--line); }
  .stage-inner { margin: 12px; }
  .stage-inner.mobile { width: min(390px, calc(100% - 24px)); margin: 12px auto; }
  .page { padding: 16px; }
  .hide-sm { display: none; }
  .guest-chip { display: none; }
}
