:root {
  --bg: #0a0a0c;
  --surface: #131417;
  --surface-2: #17181c;
  --surface-3: #1d1e23;
  --border: #26272d;
  --text: #ececee;
  --body: #c4c5cc;
  --muted: #8b8c94;
  --dim: #5f6068;
  --accent: #6c93f2;
  --accent-2: #b98af2;
  --added: #3fb950;
  --removed: #f85149;
  --modified: #e3b341;
  --moved: #58a6ff;
  --renamed: #b98af2;
  --unchanged: #6e7079;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
body { display: flex; flex-direction: column; overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code, kbd { font-family: var(--mono); font-size: 12px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
input, textarea, select { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; }
select { padding: 5px 8px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0b0d14; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: .45; cursor: default; filter: none; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--removed); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; font: inherit; }
.icon-btn:hover { color: var(--text); background: var(--surface-3); }

/* brand */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); letter-spacing: .2px; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 26px; height: 26px; object-fit: contain; display: block; }
.brand-logo.big { width: 72px; height: 72px; margin: 0 auto; }

/* top bar */
.topbar { height: 52px; flex: 0 0 52px; display: flex; align-items: center; gap: 18px; padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); min-width: 0; }
.crumbs a { color: var(--muted); }
.crumbs .sep { color: var(--dim); }
.crumbs .cur { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--body); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0b0d14; display: grid; place-items: center; font-weight: 700; font-size: 12px; }

.screen { flex: 1; min-height: 0; }

/* login */
#screen-login { display: grid; place-items: center; }
.login-card { width: min(380px, 92vw); text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 36px 30px; }
.login-card h1 { margin: 16px 0 6px; font-size: 24px; }
.login-card p { margin: 0 0 24px; }
.message-page { display: grid; place-items: center; min-height: 100vh; }
.message-card { width: min(480px, 92vw); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; }
.message-card h1 { font-size: 20px; }

/* projects */
#screen-projects { overflow: auto; }
.projects-wrap { max-width: 1100px; margin: 0 auto; padding: 32px 20px; }
.projects-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.projects-head h1 { margin: 0; font-size: 22px; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.project-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; color: var(--text); transition: border-color .15s; }
.project-card:hover { border-color: var(--accent); text-decoration: none; }
.project-card h3 { margin: 0 0 6px; font-size: 16px; }
.project-card p { margin: 0 0 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.project-card .meta { display: flex; gap: 12px; font-size: 12px; color: var(--dim); }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }

/* project layout */
#screen-project { display: grid; grid-template-columns: 300px 1fr 330px; }
.timeline-pane, .side-pane { background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.timeline-pane { border-right: 1px solid var(--border); }
.side-pane { border-left: 1px solid var(--border); }
.pane-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 14px 12px; border-bottom: 1px solid var(--border); }
.pane-title { font-weight: 600; font-size: 15px; word-break: break-word; }
.pane-sub { font-size: 12px; margin-top: 2px; }
.pane-foot { padding: 8px 14px; border-top: 1px solid var(--border); font-size: 11px; }
.pane-foot kbd { font-size: 10px; padding: 0 4px; }

/* timeline */
.timeline { flex: 1; overflow-y: auto; padding: 8px 0; outline: none; }
.tl-item { position: relative; padding: 9px 12px 9px 44px; cursor: pointer; border-left: 2px solid transparent; }
.tl-item::before { content: ""; position: absolute; left: 23px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.tl-item:first-child::before { top: 18px; }
.tl-item:last-child::before { bottom: calc(100% - 18px); }
.tl-dot { position: absolute; left: 17px; top: 12px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--dim); }
.tl-item:hover { background: var(--surface-2); }
.tl-item.current { background: rgba(108, 147, 242, .1); border-left-color: var(--accent); }
.tl-item.current .tl-dot { border-color: var(--accent); background: var(--accent); }
.tl-item.base .tl-dot { border-color: var(--removed); background: var(--surface); }
.tl-row { display: flex; align-items: baseline; gap: 8px; }
.tl-seq { font-family: var(--mono); font-size: 12px; color: var(--accent); flex: 0 0 auto; }
.tl-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.tl-meta { font-size: 12px; color: var(--dim); margin-top: 1px; }
.tl-desc { font-size: 12px; color: var(--muted); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.tl-badge { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 99px; text-transform: uppercase; letter-spacing: .4px; }
.tl-badge.base { background: rgba(248, 81, 73, .15); color: var(--removed); }
.tl-badge.cur { background: rgba(108, 147, 242, .18); color: var(--accent); }
.tl-compare { visibility: hidden; font-size: 11px; color: var(--muted); background: none; border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; cursor: pointer; }
.tl-item:hover .tl-compare { visibility: visible; }
.tl-compare:hover { color: var(--text); border-color: var(--removed); }
.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--surface-3); color: var(--muted); }
.status-pill.failed { color: var(--removed); background: rgba(248, 81, 73, .12); }
.spinner { width: 10px; height: 10px; border: 2px solid var(--dim); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* viewport */
.viewport-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.toolbar-right { margin-left: auto; display: flex; gap: 6px; }
.diff-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.diff-controls.off { display: none; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg button { font: inherit; font-size: 13px; border: 0; background: none; color: var(--muted); padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.seg button.on { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.overlay-slider { display: inline-flex; align-items: center; gap: 6px; }
.overlay-slider input { width: 120px; padding: 0; accent-color: var(--accent-2); }
.viewport { position: relative; flex: 1; min-height: 0; background: radial-gradient(ellipse at 50% 35%, #1a1c22 0%, #0d0e11 70%); }
.viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.vp-status { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; color: var(--muted); pointer-events: none; max-width: 80%; }
.vp-status .big { font-size: 15px; color: var(--body); margin-bottom: 8px; }
.vp-status .bar { width: 220px; height: 4px; background: var(--surface-3); border-radius: 4px; overflow: hidden; margin: 10px auto 0; }
.vp-status .bar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); width: 0; transition: width .15s; }
.legend { position: absolute; left: 12px; top: 12px; background: rgba(19, 20, 23, .88); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 12px; display: grid; gap: 3px; backdrop-filter: blur(6px); }
.legend .lg { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.legend .lg.off { opacity: .4; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend .n { margin-left: auto; padding-left: 14px; color: var(--muted); font-family: var(--mono); }
.pick-card { position: absolute; right: 12px; bottom: 12px; max-width: 360px; background: rgba(19, 20, 23, .94); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 12px; backdrop-filter: blur(6px); }
.pick-card .pn { font-weight: 600; font-size: 13px; color: var(--text); word-break: break-word; }
.pick-card .pp { color: var(--dim); font-family: var(--mono); font-size: 11px; word-break: break-all; margin: 2px 0 6px; }
.pick-card table { border-collapse: collapse; }
.pick-card td { padding: 1px 10px 1px 0; color: var(--body); }
.pick-card td:first-child { color: var(--muted); }

/* scrubber */
.scrubber { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface); }
.scrub-track { position: relative; flex: 1; height: 24px; display: flex; align-items: center; }
.scrub-track input { width: 100%; position: relative; z-index: 2; background: transparent; padding: 0; border: 0; accent-color: var(--accent); }
.scrub-ticks { position: absolute; left: 8px; right: 8px; top: 50%; height: 0; z-index: 1; pointer-events: none; }
.scrub-ticks i { position: absolute; top: -7px; width: 2px; height: 14px; background: var(--dim); border-radius: 1px; transform: translateX(-1px); }
.scrub-ticks i.base { background: var(--removed); height: 18px; top: -9px; }

/* side pane */
.version-card { padding: 14px; border-bottom: 1px solid var(--border); max-height: 45%; overflow-y: auto; }
.version-card h2 { margin: 0; font-size: 16px; word-break: break-word; }
.version-card .vc-head { display: flex; align-items: flex-start; gap: 8px; }
.version-card .vc-head h2 { flex: 1; }
.version-card .vc-meta { font-size: 12px; color: var(--dim); margin: 4px 0 10px; }
.version-card .vc-desc { white-space: pre-wrap; color: var(--body); margin: 0 0 12px; word-break: break-word; }
.version-card .vc-desc.empty-desc { color: var(--dim); font-style: italic; }
.version-card .vc-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.version-card .vc-stats { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin: 0 0 12px; flex-wrap: wrap; }
.version-card .vc-error { color: var(--removed); font-family: var(--mono); font-size: 11px; white-space: pre-wrap; background: rgba(248, 81, 73, .08); border-radius: 6px; padding: 8px; margin-bottom: 10px; max-height: 120px; overflow: auto; }
.side-tabs { display: flex; border-bottom: 1px solid var(--border); }
.side-tabs button { flex: 1; font: inherit; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 9px; cursor: pointer; }
.side-tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.filter { margin: 8px 10px; }
.side-list { flex: 1; overflow-y: auto; padding: 0 0 10px; }
.li { display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.li:hover { background: var(--surface-2); }
.li.sel { background: rgba(108, 147, 242, .12); }
.li .sw { flex: 0 0 8px; height: 8px; border-radius: 50%; }
.li .txt { flex: 1; min-width: 0; }
.li .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .sub { font-size: 11px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .tag { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.list-note { padding: 14px; color: var(--muted); font-size: 13px; }
.group-head { padding: 10px 12px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--dim); }

/* modals */
.modal { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(520px, 94vw); }
.modal::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(2px); }
.modal form { padding: 22px; display: grid; gap: 14px; }
.modal h2 { margin: 0; font-size: 18px; }
.modal label { display: grid; gap: 6px; font-size: 13px; color: var(--body); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.drop { border: 2px dashed var(--border); border-radius: 12px; padding: 26px 16px; text-align: center; cursor: pointer; color: var(--muted); display: block !important; }
.drop:hover, .drop.over { border-color: var(--accent); color: var(--text); }
.drop.has-file { border-style: solid; border-color: var(--accent); color: var(--text); }
.progress { height: 6px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .1s; }
.error { color: var(--removed); margin: 0; min-height: 0; font-size: 13px; }
.error:empty { display: none; }
.drop-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(10, 10, 12, .75); display: grid; place-items: center; pointer-events: none; }
.drop-overlay div { border: 2px dashed var(--accent); border-radius: 18px; padding: 40px 60px; font-size: 18px; background: var(--surface); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--surface-3); border: 1px solid var(--border); padding: 10px 16px; border-radius: 10px; z-index: 60; box-shadow: 0 8px 30px rgba(0, 0, 0, .4); }
.toast.err { border-color: var(--removed); }

@media (max-width: 1100px) {
  #screen-project { grid-template-columns: 250px 1fr; }
  .side-pane { display: none; }
}
@media (max-width: 720px) {
  #screen-project { grid-template-columns: 1fr; grid-template-rows: 40% 1fr; }
  .timeline-pane { border-right: 0; border-bottom: 1px solid var(--border); }
}

/* project actions, sharing, uploaders */
.head-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; flex: 0 0 auto; max-width: 62%; }
.share-body { display: grid; gap: 12px; }
.share-body p { margin: 0; }
.share-row { display: flex; gap: 6px; align-items: center; }
.share-row input { flex: 1; min-width: 0; }
.share-url { font-family: var(--mono); font-size: 12px; }
label.check { display: flex !important; align-items: center; gap: 8px; cursor: pointer; }
label.check input { width: auto; }
.people { display: grid; gap: 4px; max-height: 260px; overflow-y: auto; }
.person { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 8px; }
.person:hover { background: var(--surface-2); }
.person .txt { flex: 1; }

/* section analysis */
.btn.on { border-color: var(--accent); color: var(--accent); }
.section-panel { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); width: min(620px, calc(100% - 24px)); background: rgba(19, 20, 23, .94); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; display: grid; gap: 8px; backdrop-filter: blur(6px); z-index: 4; }
.sec-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sec-title { font-weight: 600; font-size: 13px; margin-right: 2px; }
.sec-row .icon-btn { margin-left: auto; }
.sec-range { flex: 1; min-width: 140px; padding: 0; border: 0; background: transparent; accent-color: var(--accent); }
.sec-readout { font-family: var(--mono); font-size: 12px; color: var(--body); min-width: 150px; text-align: right; }
.seg.faces button { font-family: var(--mono); font-size: 12px; padding: 3px 7px; }
.pick-card { bottom: 120px; }

.card-thumb { aspect-ratio: 1200 / 630; margin: -16px -16px 12px; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; background: radial-gradient(ellipse at 50% 38%, #1a1c22 0%, #0d0e11 75%); display: grid; place-items: center; border-bottom: 1px solid var(--border); }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
