:root,
[data-theme="light"] {
  --bg: #f3f4f8;
  --card: #ffffff;
  --card-2: #f7f8fb;
  --line: #e3e6ee;
  --line-2: #cfd4e0;
  --text: #11142a;
  --soft: #434a60;
  --muted: #6b7288;
  --ink: #0f1222;
  --ink-text: #ffffff;
  --accent: #2347d6;
  --accent-soft: #e7ecff;
  --badge-bg: #e8e9ff;
  --badge-fg: #3730a3;
  --ok-bg: #ecfdf3;
  --ok-fg: #046c3b;
  --ok-line: #8fd9b0;
  --blue-bg: #e7efff;
  --blue-fg: #1d4ed8;
  --blue-line: #a9c2ff;
  --red-bg: #fdeceb;
  --red-fg: #b42318;
  --red-line: #f3b4ae;
  --grey-bg: #eef0f5;
  --grey-fg: #4b5266;
  --grey-line: #cfd4e0;
  --violet-bg: #f1ebff;
  --violet-fg: #6d28d9;
  --kw-fg: #9a5b00;
  --kw-bg: #fff4d6;
  --kw-line: #f0c96b;
  --focus: #0f1222;
  --map-bg: #e9edf6;
  --land: #ffffff;
  --land-line: #b9c1d6;
  --pin: #2347d6;
  --pin-halo: rgba(35, 71, 214, 0.22);
  --shadow: 0 1px 2px rgba(17, 20, 42, 0.04);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0a0c13;
  --card: #131624;
  --card-2: #191d2f;
  --line: #272c42;
  --line-2: #394060;
  --text: #f1f3fb;
  --soft: #c0c6dc;
  --muted: #8f97b2;
  --ink: #f1f3fb;
  --ink-text: #0a0c13;
  --accent: #5b78ff;
  --accent-soft: #1f2750;
  --badge-bg: #2a2f66;
  --badge-fg: #c4caff;
  --ok-bg: #0e2a20;
  --ok-fg: #6ee7a8;
  --ok-line: #1f6b4b;
  --blue-bg: #14264f;
  --blue-fg: #9db8ff;
  --blue-line: #2c4a9a;
  --red-bg: #33151a;
  --red-fg: #ff9b92;
  --red-line: #7a2a31;
  --grey-bg: #20243a;
  --grey-fg: #c0c6dc;
  --grey-line: #394060;
  --violet-bg: #2a1f4d;
  --violet-fg: #c4a9ff;
  --kw-fg: #fbbf24;
  --kw-bg: #33270a;
  --kw-line: #7a5a12;
  --focus: #f1f3fb;
  --map-bg: #0d101b;
  --land: #252b44;
  --land-line: #3b4466;
  --pin: #8ea4ff;
  --pin-halo: rgba(142, 164, 255, 0.28);
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

button, input, select { font: inherit; color: inherit; }

.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.92em; }

/* ---------- top bar ---------- */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1040px; margin: 0 auto; height: 56px; padding: 0 20px; display: flex; align-items: center; gap: 10px; }
.brand { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-gap { flex: 1; }
.navpill { padding: 6px 12px; border-radius: 8px; background: var(--grey-bg); color: var(--text); font-size: 13px; font-weight: 600; text-decoration: none; }
.navpill:hover { background: var(--line); }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: var(--grey-bg); }
.icon-btn.wide { width: auto; padding: 0 12px; font-size: 13px; font-weight: 600; }
.i-sun { display: none; }
[data-theme="dark"] .i-sun { display: block; }
[data-theme="dark"] .i-moon { display: none; }
.link-btn { padding: 6px 8px; border: 0; background: none; color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; border-radius: 6px; }
.link-btn:hover { background: var(--grey-bg); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 24px 20px 56px; }

/* ---------- shared ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--grey-bg); }
.btn.primary { border-color: var(--ink); background: var(--ink); color: var(--ink-text); }
.btn.primary:hover { opacity: 0.9; background: var(--ink); }
.btn.small { padding: 6px 12px; font-size: 12px; }
.btn.danger { border-color: var(--red-line); color: var(--red-fg); background: var(--red-bg); }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.note { margin: 10px 2px; color: var(--muted); font-size: 13px; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border: 1px solid var(--grey-line);
  border-radius: 999px;
  background: var(--card);
  color: var(--grey-fg);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.pill.discord { border-color: var(--blue-line); background: var(--blue-bg); color: var(--blue-fg); }
.pill.roblox { border-color: var(--red-line); background: var(--red-bg); color: var(--red-fg); }
.pill.guest { border-color: var(--grey-line); background: var(--grey-bg); color: var(--grey-fg); }
.pill.member { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ok-fg); }
.pill.tag { background: var(--card-2); }

/* ---------- gate ---------- */
.gate { display: grid; place-items: center; padding: 48px 0; }
.gate-card { width: min(380px, 100%); padding: 28px; display: grid; gap: 14px; }
.gate-card h1 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.gate-card .sub { margin: -8px 0 4px; color: var(--muted); }
.gate-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.gate-card label { display: grid; gap: 6px; color: var(--soft); font-size: 12px; font-weight: 600; }
input, select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
}
input::placeholder { color: var(--muted); }
.msg { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--red-bg); color: var(--red-fg); font-size: 13px; }

/* ---------- profile + tabs ---------- */
.profile { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.avatar { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 18px; font-weight: 700; }
.profile-copy { flex: 1; min-width: 0; }
.profile-name { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.badge { padding: 2px 8px; border-radius: 6px; background: var(--badge-bg); color: var(--badge-fg); font-size: 10px; font-weight: 700; letter-spacing: 0.04em; }
.profile-sub { color: var(--muted); font-size: 12px; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.tab {
  padding: 9px 18px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.tab:hover { background: var(--grey-bg); }
.tab.active { border-color: var(--ink); background: var(--ink); color: var(--ink-text); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 16px; }
.stat { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 16px 20px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat-icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 10px; }
.stat-icon.violet { background: var(--violet-bg); color: var(--violet-fg); }
.stat-icon.red { background: var(--red-bg); color: var(--red-fg); }
.stat-icon.blue { background: var(--blue-bg); color: var(--blue-fg); }
.stat-icon.green { background: var(--ok-bg); color: var(--ok-fg); }
.stat-icon.amber { background: var(--kw-bg); color: var(--kw-fg); }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.stat-sub { color: var(--muted); font-size: 11px; }

/* ---------- filters + list ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.search { flex: 1; min-width: 220px; }
.filters select { cursor: pointer; }
.list-head { display: flex; align-items: center; justify-content: space-between; margin: 14px 2px 10px; color: var(--muted); font-size: 12px; }
.list { display: grid; gap: 8px; }

.row { border: 1px solid var(--line); border-radius: 12px; background: var(--card); box-shadow: var(--shadow); overflow: hidden; }
.row.open { border-color: var(--line-2); }
.row-head {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto 20px;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.row-head:hover { background: var(--card-2); }
.row-head.static { grid-template-columns: 92px minmax(0, 1fr) auto; cursor: default; }
.row-head.static:hover { background: none; }
.row-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { display: grid; justify-items: end; gap: 1px; text-align: right; min-width: 0; }
.row-where { display: inline-flex; align-items: center; gap: 5px; color: var(--soft); font-size: 12px; font-weight: 500; }
.row-where svg { color: var(--muted); }
.row-ip { color: var(--muted); font-size: 12px; }
.chev { color: var(--muted); transition: transform 0.15s ease; }
.row.open .chev { transform: rotate(180deg); }

.detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; padding: 4px 16px 16px; border-top: 1px solid var(--line); background: var(--card-2); }
.detail > .wide { grid-column: 1 / -1; }
.d-section { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.d-section h3 { margin: 0 0 8px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.kv { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv > span:first-child { color: var(--muted); }
.kv .val { display: inline-flex; align-items: center; gap: 8px; min-width: 0; text-align: right; word-break: break-all; }
.copy { padding: 2px 8px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--card); color: var(--soft); font-size: 11px; font-weight: 600; cursor: pointer; }
.copy:hover { background: var(--grey-bg); }
.link { color: var(--accent); font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mini { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.mini th { padding: 6px 8px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; font-weight: 600; text-align: left; }
.mini td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.mini tr:last-child td { border-bottom: 0; }
.geo-info { margin-top: 8px; }
.d-note { margin: 0; color: var(--muted); font-size: 13px; }
.d-actions { display: flex; justify-content: flex-end; }

/* ---------- map ---------- */
.map-card { position: relative; overflow: hidden; }
.map-box { position: relative; height: 440px; background: var(--map-bg); cursor: grab; touch-action: none; }
.map-box.small { height: 220px; cursor: default; }
.map-box.dragging { cursor: grabbing; }
.map-box svg { display: block; width: 100%; height: 100%; }
.map-land { fill: var(--land); stroke: var(--land-line); stroke-width: 0.6px; }
.map-halo { fill: var(--pin-halo); }
.map-pin { fill: var(--pin); stroke: var(--card); stroke-width: 1.5px; cursor: pointer; }
.map-pin:hover { stroke: var(--text); }
.map-tools { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; }
.map-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; color: var(--muted); text-align: center; pointer-events: none; }

.spot-pin { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.row-head.spot { grid-template-columns: 34px minmax(0, 1fr) auto; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .row-head { grid-template-columns: minmax(0, 1fr) 20px; grid-template-areas: "pill chev" "name name" "side side"; gap: 6px 10px; }
  .row-head .pill { justify-self: start; grid-area: pill; }
  .row-head .row-copy { grid-area: name; }
  .row-head .row-side { grid-area: side; justify-items: start; text-align: left; }
  .row-head .chev { grid-area: chev; }
  .row-head.static, .row-head.spot { grid-template-columns: minmax(0, 1fr); grid-template-areas: none; }
  .row-head.static .pill, .row-head.static .row-copy, .row-head.static .row-side { grid-area: auto; }
  .detail { grid-template-columns: minmax(0, 1fr); }
  .map-box { height: 320px; }
  .profile { flex-wrap: wrap; }
}

/* ---------- voice transcripts ---------- */
.tx-status { padding: 14px 16px; margin-bottom: 14px; }
.tx-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.tx-title { font-weight: 700; }
.tx-sub { color: var(--muted); font-size: 12px; }
.tx-play { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tx-play #tx-playing { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tx-controls select { cursor: pointer; }
.tx-warn { margin: 10px 0 0; color: var(--red-fg); font-size: 12px; }
.tx-card { padding: 4px 16px 14px; margin-bottom: 14px; }
.tx-card-head { margin: 12px 2px 10px; }
.tx-card-title { font-weight: 600; }
.tx-note { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.tx-channels { display: grid; gap: 6px; }
.tx-guild { border: 1px solid var(--line); border-radius: 10px; background: var(--card); overflow: hidden; }
.tx-guild-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer; list-style: none; user-select: none; }
.tx-guild-head::-webkit-details-marker { display: none; }
.tx-guild-head::before { content: "▸"; color: var(--muted); font-size: 11px; line-height: 1; transition: transform 0.15s ease; }
.tx-guild[open] .tx-guild-head::before { transform: rotate(90deg); }
.tx-guild-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-guild-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.tx-guild-body { display: grid; gap: 6px; padding: 0 10px 10px; }
.tx-ch { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card-2); }
.tx-ch-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.tx-ch input { width: 16px; height: 16px; accent-color: var(--ink); cursor: pointer; flex: none; }
.tx-ch-copy { display: grid; gap: 1px; min-width: 0; }
.tx-ch-name { font-weight: 600; }
.tx-ch-guild { color: var(--muted); font-size: 12px; }
.tx-clip-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 16px 14px; }
.tx-audio { flex: 1; min-width: 220px; max-width: 520px; height: 34px; }
.tx-notes { border-top: 1px solid var(--line); padding: 0 16px 12px; }
.tx-notes-head { cursor: pointer; list-style: none; padding: 10px 0 6px; font-weight: 600; font-size: 13px; color: var(--muted); }
.tx-notes-head::-webkit-details-marker { display: none; }
.tx-notes-head::before { content: "▸"; display: inline-block; margin-right: 6px; font-size: 10px; transition: transform 0.15s ease; }
.tx-notes[open] .tx-notes-head::before { transform: rotate(90deg); }
.tx-notes-list { display: grid; gap: 6px; max-height: 220px; overflow: auto; padding-right: 4px; }
.tx-note { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.tx-note-name { font-weight: 600; font-size: 13px; }
.tx-note-times { display: flex; flex-wrap: wrap; gap: 4px; }
.tx-note-time { border: 1px solid var(--line); background: var(--card-2); color: var(--ink); border-radius: 999px; padding: 2px 8px; font-size: 12px; font-variant-numeric: tabular-nums; cursor: pointer; }
.tx-note-time:hover { border-color: var(--ink); }
.tx-note-time.has-keyword { color: var(--kw-fg); border-color: var(--kw-line); background: var(--kw-bg); }
.tx-note-keyword { color: var(--kw-fg); background: var(--kw-bg); border: 1px solid var(--kw-line); border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 700; }
.tx-mentions { border-top: 1px solid var(--line); padding: 0 16px 12px; }
.tx-mentions-head { cursor: pointer; list-style: none; padding: 10px 0 6px; font-weight: 600; font-size: 13px; color: var(--kw-fg); }
.tx-mentions-head::-webkit-details-marker { display: none; }
.tx-mentions-head::before { content: "▸"; display: inline-block; margin-right: 6px; font-size: 10px; transition: transform 0.15s ease; }
.tx-mentions[open] .tx-mentions-head::before { transform: rotate(90deg); }
.tx-mentions-list { display: grid; gap: 6px; max-height: 240px; overflow: auto; padding-right: 4px; }
.tx-mention { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tx-mention-word { color: var(--kw-fg); background: var(--kw-bg); border: 1px solid var(--kw-line); border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 700; }
.tx-mention-time { border: 1px solid var(--kw-line); background: transparent; color: var(--kw-fg); border-radius: 999px; padding: 2px 8px; font-size: 12px; font-variant-numeric: tabular-nums; cursor: pointer; }
.tx-mention-time:hover { background: var(--kw-bg); }
.tx-mention-speaker { color: var(--text); font-size: 12px; font-weight: 600; }
.tx-mention-context { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.tx-scan { margin: 0 16px 12px; color: var(--muted); font-size: 12px; }
.row-name .pill { margin-left: 8px; vertical-align: middle; }
.row-head.tx-line { grid-template-columns: minmax(0, 1fr) auto auto; align-items: start; gap: 10px; }
.row-head.tx-line .row-sub { white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .row-head.tx-line { grid-template-columns: minmax(0, 1fr) auto; }
  .row-head.tx-line .row-side { grid-column: 1 / -1; justify-items: start; text-align: left; }
  .list-head { flex-wrap: wrap; gap: 6px; }
  .tx-play #tx-playing { max-width: 160px; }
}
