:root {
  --bg: #0e0e11; --panel: #16161a; --panel2: #1d1d23; --line: #2a2a31; --text: #ececf1; --muted: #8d8d99;
  --accent: #6e5bff; --accent2: #8a7bff; --danger: #f2555a; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 Inter, 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
#app { height: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { opacity: .4; cursor: default; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ic { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ic svg { width: 100%; height: 100%; }
.page { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.loading, .center-msg, .empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty { grid-column: 1 / -1; }
.center-msg h2 { color: var(--text); font-size: 18px; }

.topbar { display: flex; align-items: center; gap: 24px; height: 52px; padding: 0 18px; border-bottom: 1px solid var(--line); background: var(--panel); flex: none; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.brand b, .login-logo b { color: var(--accent2); font-weight: 600; }
.logo-mark { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, #ff7a2f, #e5372c); color: #fff; }
.logo-mark svg { width: 15px; height: 15px; }
.topnav { display: flex; gap: 4px; }
.topnav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.topnav a:hover, .topnav a.on { color: var(--text); background: var(--panel2); }
.dd { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 20px; }
.user-btn:hover { background: var(--panel2); }
.avatar { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-size: 12px; font-weight: 700; color: #fff; flex: none; }
.avatar.sm { width: 20px; height: 20px; font-size: 10px; }
.pop { position: absolute; top: calc(100% + 6px); left: 0; min-width: 210px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: 0 12px 32px rgba(0,0,0,.55); display: none; z-index: 50; }
.pop.right { left: auto; right: 0; }
.pop.open { display: block; }
.pop-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.pop-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 7px; text-align: left; white-space: nowrap; }
.pop-item:hover { background: #2a2a32; }
.pop-item.danger { color: var(--danger); }
.pop-item .dot { width: 9px; height: 9px; border-radius: 50%; }
.pop-item .ic { width: 16px; height: 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); font-weight: 500; white-space: nowrap; }
.btn:hover { background: #26262d; }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover, .btn.on { background: var(--panel2); }
.btn.on { color: var(--accent2); }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; }
.btn .ic { width: 16px; height: 16px; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; color: var(--muted); flex: none; }
.icon-btn:hover { color: var(--text); background: var(--panel2); }
.icon-btn.on { color: var(--accent2); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.icon-btn.small { width: 26px; height: 26px; }
.icon-btn.small .ic { width: 16px; height: 16px; }
.sel, .input { height: 34px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 0 10px; font: inherit; outline: none; }
.sel.small { height: 28px; font-size: 13px; padding: 0 6px; }
.input:focus, .sel:focus, textarea:focus { border-color: var(--accent) !important; }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; width: 100%; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 11px; font-size: 12px; font-weight: 500; white-space: nowrap; background: color-mix(in srgb, var(--c) 16%, transparent); color: color-mix(in srgb, var(--c) 75%, #fff); }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.pill-btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px 5px 5px; border-radius: 16px; }
.pill-btn:hover { background: var(--panel2); }
.caret { width: 0; height: 0; border: 4px solid transparent; border-top-color: var(--muted); margin-top: 4px; }

.grid-page { flex: 1; overflow: auto; padding: 26px 30px 60px; }
.grid-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.grid-head h1 { margin: 2px 0 2px; font-size: 22px; font-weight: 650; }
.search { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }
.search input { background: none; border: 0; outline: 0; color: var(--text); font: inherit; width: 190px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.chip { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--line); color: var(--muted); }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.chip .count { font-size: 12px; opacity: .7; }
.chip:hover { color: var(--text); }
.chip.on { background: var(--panel2); color: var(--text); border-color: #3c3c46; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 24px 18px; }
.card { display: block; }
.thumb { position: relative; aspect-ratio: 9 / 16; border-radius: 10px; overflow: hidden; background: #1b1b21; border: 1px solid var(--line); }
.card:hover .thumb { border-color: #55556a; }
.thumb img, .thumb .preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb .preview { opacity: 0; }
.thumb .preview.ready { opacity: 1; }
.thumb-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #44444e; }
.thumb-empty .ic { width: 44px; height: 44px; }
.scrub { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 4px rgba(0,0,0,.6); opacity: 0; z-index: 2; pointer-events: none; }
.scrub.on { opacity: .9; }
.badge { position: absolute; z-index: 3; display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 6px; background: rgba(10,10,12,.72); backdrop-filter: blur(6px); font-size: 11.5px; font-weight: 600; pointer-events: none; }
.badge .ic { width: 12px; height: 12px; }
.badge.tl { top: 8px; left: 8px; } .badge.br { bottom: 8px; right: 8px; } .badge.bl { bottom: 8px; left: 8px; }
.card-meta { padding: 9px 2px 0; }
.card-title { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 6px; }
.card-sub { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 6px; }
.card-sub .muted { white-space: nowrap; }

.phead { display: flex; align-items: center; gap: 8px; min-height: 58px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--panel); flex: none; }
.ptitle-wrap { min-width: 0; margin-right: 8px; }
.ptitle { margin: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: text; }
.title-input { width: 320px; }
.pbody { flex: 1; display: flex; min-height: 0; }
.viewer { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #09090b; }
.stage-wrap { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 16px; }
.stage { position: relative; background: #000; flex: none; border-radius: 4px; overflow: hidden; }
.stage .vid { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; cursor: pointer; }
.stage .ink { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; touch-action: none; }
.stage.drawing { outline: 2px solid var(--accent); }
.stage.drawing .ink { pointer-events: auto; cursor: crosshair; }
.stage-label { position: absolute; top: 8px; left: 8px; padding: 2px 8px; border-radius: 6px; background: rgba(0,0,0,.65); font-size: 12px; font-weight: 600; display: none; }
.compare .stage-label { display: block; }
.drawbar { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; padding: 5px; background: rgba(30,30,36,.96); border: 1px solid var(--line); border-radius: 10px; z-index: 5; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.tool { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 7px; color: var(--muted); }
.tool:hover { color: var(--text); background: #2b2b33; }
.tool.on { color: #fff; background: var(--accent); }
.swatch { width: 20px; height: 20px; border-radius: 50%; margin: 0 3px; border: 2px solid transparent; box-shadow: 0 0 0 1px rgba(255,255,255,.25); }
.swatch.on { border-color: #fff; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.transport { flex: none; padding: 4px 16px 10px; background: var(--panel); border-top: 1px solid var(--line); }
.timeline { position: relative; padding: 12px 0 0; }
.tl-track { position: relative; height: 6px; border-radius: 3px; background: #2b2b33; cursor: pointer; touch-action: none; }
.tl-track::before { content: ''; position: absolute; left: 0; right: 0; top: -8px; bottom: -8px; }
.tl-buffered { position: absolute; left: 0; top: 0; bottom: 0; background: #3d3d48; border-radius: 3px; pointer-events: none; }
.tl-progress { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 3px; pointer-events: none; }
.tl-progress::after { content: ''; position: absolute; right: -6px; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.tl-tip { position: absolute; top: -12px; transform: translateX(-50%); padding: 2px 6px; border-radius: 5px; background: #000; font: 11px Consolas, monospace; pointer-events: none; }
.tl-markers { position: relative; height: 22px; margin: 6px 0 2px; }
.marker { position: absolute; top: 0; transform: translateX(-50%); width: 20px; height: 20px; border-radius: 50%; background: var(--c); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--panel); transition: transform .1s; }
.marker:hover, .marker.active { transform: translateX(-50%) scale(1.25); z-index: 2; border-color: #fff; }
.marker.resolved { opacity: .35; }
.controls { display: flex; align-items: center; gap: 4px; }
.cbtn { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; color: #cfcfd6; }
.cbtn:hover { background: var(--panel2); color: #fff; }
.cbtn.on { color: var(--accent2); }
.cbtn .ic { width: 20px; height: 20px; }
.tc { font: 13px 'JetBrains Mono', Consolas, monospace; padding: 0 10px; height: 30px; border-radius: 7px; color: #dcdce3; }
.tc:hover { background: var(--panel2); }
.vol { width: 80px; accent-color: var(--accent); }
.vinfo { margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vinfo b { color: var(--text); }

.side { width: 370px; flex: none; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--panel); min-height: 0; }
.side-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.side-head .count { color: var(--muted); font-size: 12px; }
.cm-list { flex: 1; overflow: auto; padding: 8px; }
.cm { padding: 10px 10px 8px; border-radius: 9px; border: 1px solid transparent; cursor: pointer; margin-bottom: 4px; }
.cm:hover { background: var(--panel2); }
.cm.active { background: var(--panel2); border-color: #40405a; }
.cm.resolved > .cm-text, .cm.resolved > .cm-head b, .cm.resolved > .cm-meta { opacity: .5; }
.cm-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cm-head b { font-weight: 600; font-size: 13px; }
.cm-meta { display: flex; gap: 6px; margin-bottom: 6px; }
.tc-chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px; border-radius: 6px; background: color-mix(in srgb, var(--accent) 22%, transparent); color: #cbc4ff; font: 600 12px Consolas, monospace; }
.tc-chip .ic { width: 13px; height: 13px; }
.tc-chip.ghost { background: #26262d; color: var(--muted); font: 500 12px Inter, 'Segoe UI', sans-serif; }
.cm-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.resolve { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid #4a4a55; color: transparent; flex: none; }
.resolve .ic { width: 14px; height: 14px; }
.resolve:hover { border-color: #2fbf71; color: #2fbf71; }
.resolve.on { background: #2fbf71; border-color: #2fbf71; color: #fff; }
.replies { margin: 8px 0 0 10px; padding-left: 12px; border-left: 2px solid var(--line); }
.reply { padding: 6px 0; }
.reply .cm-head { margin-bottom: 3px; }
.link-btn { color: var(--muted); font-size: 12px; margin-top: 6px; }
.link-btn:hover { color: var(--text); }
.reply-box { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; align-items: center; gap: 6px; }
.reply-box .row { justify-content: flex-end; }
.cm-empty { padding: 30px 14px; text-align: center; color: var(--muted); }
.cm-other { padding: 10px; text-align: center; }
.resolved-by { margin-top: 4px; }
.composer { border-top: 1px solid var(--line); padding: 10px 12px 12px; }
.composer-input { width: 100%; min-height: 60px; max-height: 220px; resize: vertical; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; color: var(--text); font: inherit; padding: 9px 11px; outline: none; }
.composer .row { margin-top: 8px; }
.ts-toggle { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 9px; border-radius: 7px; color: var(--muted); font: 12.5px Consolas, monospace; border: 1px solid var(--line); }
.ts-toggle.on { color: #cbc4ff; border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.ts-toggle .ic { width: 14px; height: 14px; }
.hint { margin-right: 4px; }

.login-page { flex: 1; display: grid; place-items: center; padding: 30px; min-height: 100%; background: radial-gradient(1100px 560px at 50% -10%, #241e52 0, transparent 60%); }
.login-card { width: min(410px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 30px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-logo { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 18px; font-weight: 600; }
.login-card h1 { font-size: 20px; margin: 8px 0 0; }
.login-card p { margin: 0; }
.gbtn { display: flex; justify-content: center; min-height: 44px; }
.error { color: var(--danger); min-height: 1em; }
.dev-login { display: flex; gap: 6px; }
.dev-login .input { flex: 1; min-width: 0; }
.device-code { font: 600 30px/1 'JetBrains Mono', Consolas, monospace; letter-spacing: 4px; padding: 18px; border-radius: 10px; background: var(--panel2); border: 1px dashed #4a4a58; }

.team-page { flex: 1; overflow: auto; padding: 26px 30px 60px; max-width: 920px; width: 100%; margin: 0 auto; }
.team-page h1 { font-size: 22px; margin: 0 0 4px; }
.team-page h2 { font-size: 15px; margin: 34px 0 8px; }
.tbl { width: 100%; border-collapse: collapse; margin-top: 12px; }
.tbl td, .tbl th { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; font-weight: 400; }
.tbl th { color: var(--muted); font-size: 12px; }
.right { text-align: right !important; }
.who { display: flex; align-items: center; gap: 10px; }
.add-row { display: flex; gap: 8px; margin-top: 14px; }
.add-row .input { flex: 1; }
.code { display: block; font: 13px 'JetBrains Mono', Consolas, monospace; background: #0a0a0c; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; }

.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; pointer-events: none; }
.toast { padding: 9px 14px; border-radius: 9px; background: #26262e; border: 1px solid #3a3a44; box-shadow: 0 8px 24px rgba(0,0,0,.5); transition: opacity .3s; }
.toast.bad { border-color: var(--danger); }
.toast.good { border-color: #2fbf71; }
.toast.out { opacity: 0; }

@media (max-width: 900px) {
  .pbody { flex-direction: column; overflow: auto; }
  .viewer { min-height: 70vh; }
  .side { width: auto; border-left: 0; border-top: 1px solid var(--line); min-height: 50vh; }
  .phead { flex-wrap: wrap; padding: 8px; }
  .user-name, .hint, .vol, .keys { display: none; }
  .grid-page, .team-page { padding: 18px 14px 40px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px 12px; }
}
