/* Snappet Mobile — Knowledge Graph UI */

:root {
  --bg: #0b0b0f;
  --bg-elev: #16161d;
  --bg-elev2: #1f1f29;
  --border: #2c2c38;
  --text: #f5f5f7;
  --text-dim: #a1a1ab;
  --text-faint: #6e6e7a;
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.15);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

:root.light {
  --bg: #f2f2f7;
  --bg-elev: #ffffff;
  --bg-elev2: #f7f7fb;
  --border: #d9d9e0;
  --text: #1c1c1e;
  --text-dim: #545460;
  --text-faint: #8a8a96;
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.12);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ───────────── Top bar ───────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  z-index: 20;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #ff2d92, #0a84ff);
  display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 16px;
  flex-shrink: 0;
}
.brand h1 { font-size: 15px; font-weight: 700; white-space: nowrap; }
.brand .sub { font-size: 11px; color: var(--text-faint); white-space: nowrap; }

.search-wrap { position: relative; flex: 1; min-width: 180px; max-width: 460px; }
.search-wrap input {
  width: 100%;
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 9px 32px 9px 34px;
  font-size: 13px;
  font-family: var(--font);
  outline: none;
}
.search-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-wrap .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 14px; }
.search-wrap .clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: 16px;
  display: none;
}
.search-wrap.has-value .clear { display: block; }

.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; z-index: 50; display: none;
}
.search-results.open { display: block; }
.search-results .item { padding: 8px 12px; cursor: pointer; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.search-results .item:last-child { border-bottom: none; }
.search-results .item:hover, .search-results .item.active { background: var(--accent-soft); }
.search-results .item .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.search-results .item .label { font-size: 13px; }
.search-results .item .meta { font-size: 11px; color: var(--text-faint); margin-left: auto; }

.topbar .spacer { flex: 1; }
.toolbtns { display: flex; gap: 6px; align-items: center; }
.btn {
  background: var(--bg-elev2); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 8px 11px; font-size: 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-family: var(--font); transition: background .12s, border-color .12s;
  text-decoration: none;
}
.btn:hover { background: var(--border); }
.btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn .ic { font-size: 14px; }

/* ───────────── Main layout ───────────── */
.main { flex: 1; display: flex; position: relative; overflow: hidden; }

.sidebar {
  width: 256px; background: var(--bg-elev); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 14px; z-index: 10; transition: margin-left .2s;
  flex-shrink: 0;
}
.sidebar.collapsed { margin-left: -256px; }
.sidebar h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); margin: 16px 0 8px; }
.sidebar h3:first-child { margin-top: 0; }

.filter-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 7px; cursor: pointer; font-size: 12.5px; }
.filter-row:hover { background: var(--bg-elev2); }
.filter-row .swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.filter-row .swatch.dot { border-radius: 50%; }
.filter-row .count { margin-left: auto; font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.filter-row.off { opacity: .38; }
.filter-row.off .name { text-decoration: line-through; }

.seg { display: flex; background: var(--bg-elev2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 3px; }
.seg button { flex: 1; background: none; border: none; color: var(--text-dim); padding: 7px 4px; border-radius: 7px; font-size: 11.5px; cursor: pointer; font-family: var(--font); }
.seg button.active { background: var(--accent); color: #fff; }

.mini-actions { display: flex; flex-direction: column; gap: 6px; }
.mini-actions .btn { justify-content: flex-start; width: 100%; }

.legend-edges { display: flex; flex-direction: column; gap: 5px; }
.legend-edges .er { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--text-dim); }
.legend-edges .line { width: 26px; height: 0; border-top-width: 2px; border-top-style: solid; flex-shrink: 0; }

/* ───────────── Canvas stage ───────────── */
.stage { flex: 1; position: relative; overflow: hidden; }
#graph { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#graph.dragging { cursor: grabbing; }
#graph.grabbing-node { cursor: grabbing; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 30;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 11px; font-size: 12px; max-width: 260px; box-shadow: var(--shadow);
  display: none; line-height: 1.45;
}
.tooltip .tt-title { font-weight: 700; margin-bottom: 2px; }
.tooltip .tt-type { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; }

/* Floating controls bottom-right of stage */
.stage-controls { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 15; }
.stage-controls .btn { width: 38px; height: 38px; justify-content: center; padding: 0; font-size: 16px; }

.hint { position: absolute; left: 14px; bottom: 14px; z-index: 15; font-size: 11px; color: var(--text-faint); background: var(--bg-elev); border: 1px solid var(--border); padding: 6px 10px; border-radius: 8px; max-width: 340px; }
.hint kbd { background: var(--bg-elev2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-family: var(--mono); font-size: 10px; }

.stats-pill {
  position: absolute; left: 14px; top: 14px; z-index: 15; font-size: 11.5px; color: var(--text-dim);
  background: var(--bg-elev); border: 1px solid var(--border); padding: 6px 11px; border-radius: 20px;
  font-variant-numeric: tabular-nums;
}
.path-banner {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 16;
  background: var(--bg-elev); border: 1px solid var(--accent); padding: 7px 14px; border-radius: 20px;
  font-size: 12px; box-shadow: var(--shadow); display: none; align-items: center; gap: 10px;
}
.path-banner.show { display: flex; }
.path-banner b { color: var(--accent); }
.path-banner .x { cursor: pointer; color: var(--text-faint); }

/* ───────────── Detail panel ───────────── */
.detail {
  width: 320px; background: var(--bg-elev); border-left: 1px solid var(--border);
  overflow-y: auto; z-index: 10; transition: margin-right .2s; flex-shrink: 0;
}
.detail.collapsed { margin-right: -320px; }
.detail .head { padding: 16px; border-bottom: 1px solid var(--border); position: relative; }
.detail .head .typebadge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-faint); margin-bottom: 8px;
}
.detail .head .typebadge .dot { width: 9px; height: 9px; border-radius: 50%; }
.detail .head h2 { font-size: 18px; font-weight: 700; line-height: 1.25; }
.detail .head .close { position: absolute; top: 12px; right: 12px; background: none; border: none; color: var(--text-faint); font-size: 20px; cursor: pointer; line-height: 1; }
.detail .body { padding: 16px; }
.detail .shot, .detail .shot-video {
  display: block; width: 100%; max-height: 420px;
  object-fit: contain; object-position: top;
  background: var(--bg-elev2);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.detail .shot-video { max-height: 480px; }
/* Light + dark screenshot pair, shown side by side. */
.detail .shots { display: flex; gap: 10px; margin-bottom: 16px; }
.detail .shotfig { flex: 1 1 0; min-width: 0; margin: 0; }
.detail .shotfig .shot { margin-bottom: 6px; max-height: 360px; }
.detail .shotfig figcaption { text-align: center; font-size: 11px; color: var(--text-faint); letter-spacing: 0.04em; text-transform: uppercase; }
.detail .desc { font-size: 13.5px; line-height: 1.55; color: var(--text-dim); margin-bottom: 16px; }
.detail .kv { display: flex; gap: 8px; font-size: 12.5px; margin-bottom: 9px; }
.detail .kv .k { color: var(--text-faint); min-width: 64px; flex-shrink: 0; }
.detail .kv .v { color: var(--text); word-break: break-word; }
.detail .kv .v.file { font-family: var(--mono); font-size: 11.5px; }
.detail .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.detail .tag { font-size: 10.5px; background: var(--bg-elev2); border: 1px solid var(--border); border-radius: 20px; padding: 3px 9px; color: var(--text-dim); }
.detail .section-t { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin: 18px 0 8px; }
.conn { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 7px; cursor: pointer; font-size: 12.5px; }
.conn:hover { background: var(--bg-elev2); }
.conn .arrow { font-size: 11px; color: var(--text-faint); width: 38px; flex-shrink: 0; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.conn .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn .et { margin-left: auto; font-size: 10px; color: var(--text-faint); flex-shrink: 0; }

.detail .empty-state, .detail-placeholder { padding: 40px 20px; text-align: center; color: var(--text-faint); font-size: 13px; }
.detail-placeholder .big { font-size: 34px; margin-bottom: 10px; opacity: .5; }

.detail .pathbtn { width: 100%; margin-top: 6px; }

/* ───────────── Help modal ───────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px;
  max-width: 540px; width: 100%; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow);
}
.modal .mh { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal .mh h2 { font-size: 17px; }
.modal .mh .close { background: none; border: none; color: var(--text-faint); font-size: 22px; cursor: pointer; }
.modal .mb { padding: 20px; }
.modal .mb h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); margin: 16px 0 8px; }
.modal .mb h4:first-child { margin-top: 0; }
.modal .mb p { font-size: 13.5px; line-height: 1.6; color: var(--text-dim); margin-bottom: 10px; }
.kbtable { width: 100%; border-collapse: collapse; }
.kbtable td { padding: 6px 4px; font-size: 13px; border-bottom: 1px solid var(--border); }
.kbtable td:first-child { width: 130px; }
.kbtable kbd { background: var(--bg-elev2); border: 1px solid var(--border); border-radius: 5px; padding: 2px 7px; font-family: var(--mono); font-size: 11px; }

/* mobile */
@media (max-width: 880px) {
  .sidebar { position: absolute; height: 100%; box-shadow: var(--shadow); }
  .detail { position: absolute; right: 0; height: 100%; box-shadow: var(--shadow); }
  .brand .sub { display: none; }
}
