@font-face { font-family: Inter; font-weight: 400; font-display: swap; src: url(../fonts/inter-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 500; font-display: swap; src: url(../fonts/inter-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 600; font-display: swap; src: url(../fonts/inter-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 500; font-display: swap; src: url(../fonts/space-grotesk-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 600; font-display: swap; src: url(../fonts/space-grotesk-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-display: swap; src: url(../fonts/jetbrains-mono-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 500; font-display: swap; src: url(../fonts/jetbrains-mono-latin-500-normal.woff2) format('woff2'); }

:root {
  --bg: #0D0E10; --panel: #111316; --card: #121417; --raised: #1A1D21; --hover: #1E2227; --active: #23272D;
  --line: #23262B; --line2: #2A2E34; --line3: #2F3339;
  --text: #ECEEF1; --text2: #C9CED6; --muted: #A3A9B2; --faint: #858C96; --wave: #5B626C;
  --accent: #F5B544; --on-accent: #1A1204;
  --ok: #4CC38A; --ok-text: #6FD3A0; --ok-bg: #18291F;
  --warn-text: #FF9F6E; --warn-bg: #33221A;
  --bad: #FF6B5E; --bad-text: #FFB4AC; --bad-bg: #1E1312;
  --sans: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Space Grotesk', Inter, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.4 var(--sans); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
kbd { font-family: var(--mono); font-size: 12px; color: var(--text2); border: 1px solid var(--line3); border-radius: 5px; padding: 1px 6px; }
strong { color: #fff; font-weight: 600; }

/* text */
.h1 { margin: 0; font-family: var(--display); font-size: 28px; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
.h1-sm { font-size: 24px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.lead { margin: 0; font-size: 15px; line-height: 1.55; }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 13px; }
.center { text-align: center; }
.eyebrow { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.error-text { margin: 0; color: var(--bad-text); font-size: 13px; }
.max-620 { max-width: 620px; }
p { margin: 0; }

/* layout helpers */
.stack-3, .stack-8, .stack-10, .stack-12, .stack-14, .stack-16, .stack-22, .stack-28 { display: flex; flex-direction: column; }
.stack-3 { gap: 3px; } .stack-8 { gap: 8px; } .stack-10 { gap: 10px; } .stack-12 { gap: 12px; } .stack-14 { gap: 14px; } .stack-16 { gap: 16px; } .stack-22 { gap: 22px; } .stack-28 { gap: 28px; }
.row-8 { display: flex; gap: 8px; flex-wrap: wrap; } .row-10 { display: flex; gap: 10px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.split-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; }
.split-head.baseline { align-items: baseline; }
.split-head.center-v { align-items: center; }
.title-row { display: flex; align-items: baseline; gap: 12px; min-width: 0; }

/* screens */
.screen { min-height: 100vh; display: flex; flex-direction: column; }
.center-screen { align-items: center; justify-content: center; padding: 48px 20px; }
.center-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 48px 20px; }
.narrow { width: 100%; max-width: 560px; }

.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 600; font-size: 20px; letter-spacing: -0.01em; white-space: nowrap; }
.brand-lg { font-size: 26px; gap: 12px; }
.logo { width: 30px; height: 30px; background: url(../icons/icon.svg) center / contain no-repeat; flex: none; }
.brand-lg .logo { width: 40px; height: 40px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 32px; }
.inset { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.kv-grid { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 8px 12px; font-size: 13px; }
.note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: #1A1710; border: 1px solid #3A3220; border-radius: 12px; color: #E6D9BC; font-size: 13px; line-height: 1.5; }
.note svg { flex: none; margin-top: 1px; color: var(--accent); }
.row-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; }
.icon-tile { width: 52px; height: 52px; border-radius: 14px; background: #2A1715; color: var(--bad); display: flex; align-items: center; justify-content: center; }
.check-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; color: var(--text2); line-height: 1.45; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 500; white-space: nowrap; text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: #FFC45C; }
.btn-secondary { background: var(--raised); border-color: var(--line2); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--active); }
.btn-ghost { background: none; border-color: var(--line3); color: var(--text); }
.btn-ghost:hover { background: var(--raised); }
.btn-ok { background: var(--ok-bg); border-color: #3A4A3F; color: var(--ok-text); font-weight: 600; }
.btn-ok:hover { background: #1F3527; }
.btn-danger { background: var(--bad-bg); border-color: #4A2A27; color: var(--bad-text); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-lg { height: 48px; border-radius: 12px; }
.btn-xl { height: 52px; border-radius: 12px; font-size: 15px; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; background: var(--raised); border: 1px solid var(--line2); border-radius: 10px; color: var(--text); flex: none; }
.icon-btn:hover { background: var(--active); }
.link-btn { background: none; border: 0; color: var(--muted); font-size: 13px; padding: 0 6px; height: 34px; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--text); }

/* top bar */
.topbar { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
.topbar > .brand { min-width: 180px; }
#screen-scan .topbar, #screen-review .topbar, #screen-lost .topbar { justify-content: space-between; }
.search { flex: 1 1 360px; display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 14px; background: var(--raised); border: 1px solid var(--line2); border-radius: 10px; color: var(--muted); }
.search:focus-within { border-color: #4A4F57; }
.search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; color: var(--text); height: 40px; }
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { filter: invert(0.7); }
.status-pill { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border: 1px solid var(--line2); border-radius: 999px; background: none; color: var(--text); font-size: 13px; max-width: 420px; min-width: 0; }
.status-pill span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill-bad { border-color: #4A2A27; background: var(--bad-bg); color: var(--bad-text); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-ok { background: var(--ok); } .dot-bad { background: var(--bad); } .dot-warn { background: var(--accent); }
.scan-strip { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: transparent; }
.scan-strip div { height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }

/* indexing */
.scan-main, .review-main { flex: 1; width: 100%; margin: 0 auto; padding: 40px 24px; display: flex; flex-direction: column; gap: 26px; }
.scan-main { max-width: 960px; }
.review-main { max-width: 1120px; gap: 22px; }
.big-count { font-size: 24px; font-weight: 500; }
.big-count .faint { font-size: 16px; }
.progress { height: 10px; background: var(--active); border-radius: 999px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.3s; }
.stages { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stages li { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); }
.stages li[data-state="active"] { border-color: #5A4A22; background: #1A1710; }
.stage-state { font-size: 12px; font-weight: 600; color: var(--faint); }
.stages li[data-state="active"] .stage-state { color: var(--accent); }
.stages li[data-state="done"] .stage-state { color: var(--ok-text); }
.stage-name { font-weight: 600; }
.stage-detail { font-size: 12px; color: var(--muted); line-height: 1.45; }
.table-box { border: 1px solid var(--line); border-radius: 12px; background: var(--card); overflow: hidden; }
.feed-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) 110px; align-items: center; gap: 12px; min-height: 46px; padding: 0 16px; border-bottom: 1px solid #1E2125; }
.feed-row:last-child { border-bottom: 0; }
.feed-empty { padding: 20px 16px; color: var(--faint); font-size: 13px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; justify-self: start; }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-neutral { background: var(--active); color: var(--text2); }
.mono.badge { font-size: 12px; }

/* library */
#screen-library { height: 100vh; min-height: 0; }
.lib-body { flex: 1; display: flex; min-height: 0; }
.sidebar { width: 240px; flex: none; overflow-y: auto; padding: 18px 12px; border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; gap: 22px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-head { display: flex; align-items: center; justify-content: space-between; padding: 0 10px 8px; }
.nav-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: var(--text); text-align: left; font-size: 14px; width: 100%; }
.nav-item:hover { background: var(--hover); }
.nav-item[aria-current="true"] { background: var(--active); color: #fff; font-weight: 500; }
.nav-item .count { font-family: var(--mono); font-size: 12px; color: var(--faint); font-weight: 400; }
.nav-item .label { display: flex; align-items: center; gap: 10px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .label svg { flex: none; color: var(--muted); }
.nav-item.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.pill-count { font-size: 12px; font-weight: 600; color: var(--on-accent); background: var(--warn-text); border-radius: 999px; padding: 1px 8px; }
.tag-ucs { font-size: 11px; color: var(--faint); border: 1px solid var(--line3); border-radius: 4px; padding: 1px 5px; }
.nav-more { color: var(--muted); font-size: 13px; }

.lib-main { flex: 1; display: flex; min-width: 0; min-height: 0; }
.list-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; padding: 22px 24px 16px; min-height: 0; }
.sort { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
select { field-sizing: content; height: 36px; background: var(--raised); color: var(--text); border: 1px solid var(--line2); border-radius: 8px; padding: 0 10px; font-size: 13px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip-select { display: inline-flex; align-items: center; height: 34px; border: 1px solid var(--line2); border-radius: 999px; background: var(--raised); padding-left: 12px; font-size: 13px; color: var(--muted); }
.chip-select select { height: 32px; border: 0; background: transparent; color: var(--text); padding: 0 8px 0 6px; border-radius: 999px; }
.chip-select.on { border-color: #6B5626; background: #1F1B12; }
.chip-select.on select { color: var(--accent); }

.list-box { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-x: auto; }
.list-head, .row { display: grid; grid-template-columns: 60px minmax(200px, 1fr) 172px 78px 108px 52px; align-items: center; min-width: 700px; }
.list-head { height: 38px; padding: 0 8px; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); flex: none; }
.vlist { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; min-width: 700px; outline: none; }
.vlist-inner { position: relative; }
.row { position: absolute; left: 0; right: 0; height: 64px; padding: 0 8px; border-bottom: 1px solid #1E2125; cursor: default; user-select: none; }
.row:hover { background: #16191C; }
.row[aria-selected="true"] { background: #1E2227; }
.row[aria-selected="true"] .row-name { color: #fff; }
.row-name-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding-right: 12px; }
.row-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { display: flex; gap: 8px; font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; }
.row-sub .warn { color: var(--warn-text); }
.row canvas { width: 160px; height: 32px; display: block; cursor: pointer; }
.row .mono { color: var(--text2); }
.row .fmt { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.play-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--active); color: var(--text); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.play-btn:hover { background: #2C3138; }
.play-btn.on { background: var(--accent); color: var(--on-accent); }
.star-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; background: none; border: 0; border-radius: 8px; color: var(--wave); }
.star-btn:hover { background: var(--active); }
.star-btn.on { color: var(--accent); }
.star-btn.on svg path { fill: currentColor; }
.list-box .empty { margin: auto 0; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); line-height: 1.6; }
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.hints { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--faint); }

/* inspector */
.inspector { width: 380px; flex: none; overflow-y: auto; border-left: 1px solid var(--line); background: var(--panel); padding: 22px 20px; display: flex; flex-direction: column; gap: 18px; }
.insp-title { margin: 0; font-family: var(--display); font-size: 22px; line-height: 1.25; font-weight: 600; word-break: break-word; }
.wave-box { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 6px; }
.wave-box canvas { width: 100%; height: 120px; display: block; cursor: crosshair; touch-action: none; }
.ruler { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.transport { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.big-play { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.toggle-btn[aria-pressed="true"] { background: #2B2414; border-color: #6B5626; color: var(--accent); }
.region-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 110px; }
.meta-grid { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 9px 12px; margin: 0; font-size: 13px; }
.meta-grid dt { color: var(--faint); }
.meta-grid dd { margin: 0; font-family: var(--mono); font-size: 12.5px; word-break: break-word; }
.meta-grid dd.path { color: var(--muted); font-size: 12px; word-break: break-all; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 4px 0 10px; background: #1F2328; border-radius: 999px; font-size: 12px; }
.tag button { width: 22px; height: 22px; border: 0; border-radius: 50%; background: none; color: var(--faint); display: inline-flex; align-items: center; justify-content: center; }
.tag button:hover { background: var(--line3); color: var(--text); }
.tag-add { height: 28px; padding: 0 10px; background: none; border: 1px dashed #3A3F46; border-radius: 999px; color: var(--muted); font-size: 12px; }
.tag-input { height: 28px; width: 120px; padding: 0 10px; background: var(--raised); border: 1px solid var(--line2); border-radius: 999px; color: var(--text); font-size: 12px; outline: none; }
.sim-btn { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 8px; background: none; border: 0; border-radius: 8px; text-align: left; width: 100%; }
.sim-btn:hover { background: var(--hover); }
.sim-btn canvas { width: 56px; height: 22px; flex: none; }
.desc { color: var(--text2); line-height: 1.5; white-space: pre-line; word-break: break-word; }
.insp-empty { color: var(--muted); line-height: 1.6; padding-top: 40px; text-align: center; }

/* review */
.review-card { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 16px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); }
.review-card.resolved { background: #101411; }
.review-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 260px; }
.review-choice { display: flex; flex-direction: column; gap: 8px; flex: 1 1 380px; min-width: 0; }
.chip { height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line3); background: none; color: var(--text); font-size: 12px; }
.chip:hover { background: var(--raised); }
.chip-dashed { border-style: dashed; color: var(--muted); }
.suggest { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; border-radius: 8px; background: var(--active); font-weight: 500; }
.resolved-line { display: flex; align-items: center; gap: 10px; flex: 1 1 380px; color: var(--ok-text); }

/* dialog */
.dialog { background: var(--card); color: var(--text); border: 1px solid var(--line2); border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 48px)); box-shadow: 0 24px 64px rgba(0,0,0,0.5); }
.dialog::backdrop { background: rgba(5, 6, 8, 0.7); }
.dlg { display: flex; flex-direction: column; max-height: inherit; }
.dlg-head { padding: 20px 22px 12px; display: flex; flex-direction: column; gap: 6px; }
.dlg-head h2 { margin: 0; font-family: var(--display); font-size: 20px; font-weight: 600; }
.dlg-body { padding: 4px 22px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.dlg-foot { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.input { height: 42px; padding: 0 12px; background: var(--raised); border: 1px solid var(--line2); border-radius: 10px; color: var(--text); outline: none; width: 100%; }
.input:focus { border-color: #4A4F57; }
.pick-list { display: flex; flex-direction: column; gap: 2px; max-height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.pick-item { display: flex; align-items: center; justify-content: space-between; min-height: 38px; padding: 0 10px; border: 0; border-radius: 8px; background: none; text-align: left; color: var(--text); width: 100%; }
.pick-item:hover, .pick-item:focus-visible { background: var(--active); }
.radio-row { display: flex; gap: 10px; align-items: center; color: var(--text); font-size: 14px; min-height: 32px; }
.radio-row input { accent-color: var(--accent); width: 16px; height: 16px; }

/* toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 50; pointer-events: none; }
.toast { background: #24282E; border: 1px solid var(--line3); color: var(--text); padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); max-width: 520px; }
.toast.bad { border-color: #4A2A27; color: var(--bad-text); }

@media (max-width: 1180px) {
  .inspector { width: 330px; }
  .sidebar { width: 210px; }
}
@media (max-width: 960px) {
  #screen-library { height: auto; min-height: 100vh; }
  .lib-body, .lib-main { flex-direction: column; }
  .sidebar { width: auto; border-right: 0; border-bottom: 1px solid var(--line); max-height: 260px; }
  .list-pane { min-height: 70vh; }
  .inspector { width: auto; border-left: 0; border-top: 1px solid var(--line); }
  .stages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
