
:root{
  --bg: #060716;
  --panel: rgba(18, 18, 28, .78);
  --panel2: rgba(18, 18, 28, .90);
  --text: #e9e9f3;
  --muted: #b9b9c8;
  --stroke: rgba(255,255,255,.12);
  --shadow: 0 10px 30px rgba(0,0,0,.40);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

*{ box-sizing: border-box; }
html, body{ height:100%; margin:0; font-family: var(--sans); background: var(--bg); color: var(--text); }
a{ color: inherit; text-decoration: underline; text-decoration-color: rgba(255,255,255,.35); }
a:hover{ text-decoration-color: rgba(255,255,255,.80); }

#app{
  height: 100%;
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: 70px 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar stage";
}

#topbar{
  grid-area: topbar;
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(10px);
  background: linear-gradient(180deg, rgba(12,12,22,.90), rgba(12,12,22,.55));
}

.brand{ display:flex; gap:12px; align-items:center; }
.brand .dot{
  width:12px; height:12px; border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.95), rgba(255,255,255,.25));
  box-shadow: 0 0 18px rgba(255,255,255,.25);
}
.title{ font-weight: 750; letter-spacing:.2px; }
.subtitle{ font-size: 12px; color: var(--muted); margin-top:2px; }

.controls{ display:flex; gap:10px; align-items:center; }
#search{
  width: 360px;
  max-width: 44vw;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.06);
  color: var(--text);
  outline: none;
}
#search:focus{ border-color: rgba(255,255,255,.28); }

.btn{
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.06);
  color: var(--text);
  cursor: pointer;
}
.btn:hover{ background: rgba(255,255,255,.10); }
.btn:active{ transform: translateY(1px); }

#sidebar{
  grid-area: sidebar;
  border-right: 1px solid var(--stroke);
  padding: 14px 14px 18px 14px;
  overflow: auto;
  background: linear-gradient(180deg, rgba(12,12,22,.72), rgba(8,8,16,.30));
  backdrop-filter: blur(12px);
}

.section{ margin-bottom: 14px; }
.section.small{ margin-top: 18px; }
.section-title{
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 10px 6px;
}

.legend{ display:flex; flex-direction: column; gap: 8px; padding: 4px; }
.legend-item{
  display:flex; gap:10px; align-items: center;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.06);
  cursor: pointer;
  user-select: none;
}
.legend-item:hover{ background: rgba(255,255,255,.06); }
.legend-item.active{ background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.14); }
.legend-swatch{
  width: 12px; height: 12px; border-radius: 4px;
  box-shadow: 0 0 14px rgba(255,255,255,.14);
  flex: 0 0 auto;
}
.legend-meta{ display:flex; flex-direction: column; gap: 2px; min-width:0; }
.legend-label{ font-size: 13px; white-space: nowrap; overflow:hidden; text-overflow: ellipsis; }
.legend-count{ font-size: 12px; color: var(--muted); }

.help{ margin: 0; padding-left: 20px; color: var(--muted); font-size: 13px; }
.help li{ margin: 6px 0; }
.note{
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
}

#stage{ grid-area: stage; position: relative; overflow: hidden; }
#container{ position:absolute; inset: 0; }

.tooltip{
  position: absolute;
  pointer-events: none;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(0,0,0,.70);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--text);
  font-size: 12px;
  box-shadow: var(--shadow);
  transform: translate(12px, 12px);
  max-width: 320px;
}
.hidden{ display:none; }

.panel{
  position:absolute;
  right: 16px;
  bottom: 16px;
  width: min(460px, calc(100% - 32px));
  max-height: min(64vh, 640px);
  overflow:auto;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,.12);
  background: var(--panel2);
  box-shadow: var(--shadow);
  padding: 14px 14px;
}

.panel-header{
  display:flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.panel-title{
  font-weight: 760;
  font-size: 18px;
}
.panel-sub{
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}
.panel-close{
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.panel-close:hover{ background: rgba(255,255,255,.10); }

.panel-body{
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  margin-top: 12px;
}
.thumb{
  width: 96px;
  height: 96px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
}
.extract{
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}
.meta{
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.10);
  font-size: 12px;
  color: var(--muted);
}
.badges{ margin-top: 8px; display:flex; flex-wrap: wrap; gap: 6px; }
.badge{
  font-size: 12px;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
}
.badge strong{ font-family: var(--mono); font-weight: 700; }
