:root {
  color: #f5f8fa;
  background: #070b0d;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --panel: #0e1417;
  --panel-2: #131b1f;
  --line: #243036;
  --muted: #92a1a8;
  --accent: #69e2bd;
  --accent-soft: rgba(105, 226, 189, 0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body { display: grid; grid-template-columns: 320px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
button, input { font: inherit; }
button { color: inherit; }

.sidebar {
  display: grid;
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.brand { display: flex; align-items: center; gap: 13px; padding: 24px 20px 17px; }
.brand-mark {
  width: 31px;
  aspect-ratio: 1;
  border: 2px solid var(--accent);
  border-radius: 50% 48% 52% 46%;
  box-shadow: inset 0 0 0 6px var(--panel), inset 0 0 0 8px rgba(105, 226, 189, .4);
}
h1, h2, h3, p { margin: 0; }
.brand h1 { font-size: 17px; letter-spacing: .01em; }
.brand p { margin-top: 4px; color: var(--muted); font-size: 12px; }

.search { padding: 0 16px 14px; }
.search input {
  width: 100%;
  padding: 10px 12px;
  color: #eef5f3;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: #080d0f;
}
.search input:focus { border-color: #447a6d; box-shadow: 0 0 0 3px var(--accent-soft); }
.search input::placeholder { color: #718087; }

.series-list { padding: 0 9px 20px; overflow-y: auto; }
.series-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.series-item:hover { background: rgba(255, 255, 255, .035); }
.series-item.selected { border-color: #31574e; background: var(--accent-soft); }
.series-icon {
  flex: 0 0 auto;
  width: 29px;
  height: 34px;
  border: 1px solid #3f4e54;
  border-radius: 4px;
  background: repeating-linear-gradient(0deg, #172125 0 3px, #27363c 4px 5px);
  box-shadow: inset 0 0 0 5px #101719;
}
.series-copy { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.series-copy strong { overflow: hidden; font-size: 13px; font-weight: 560; text-overflow: ellipsis; white-space: nowrap; }
.series-copy span { color: var(--muted); font-size: 11px; }
.no-results { padding: 22px; color: var(--muted); font-size: 13px; text-align: center; }
.sidebar footer { padding: 12px 16px; color: #718087; border-top: 1px solid var(--line); font-size: 11px; }

.workspace { display: grid; min-width: 0; min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; background: #050809; }
.topbar {
  display: flex;
  min-height: 83px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 20, 23, .96);
}
.study-title { min-width: 0; }
.eyebrow { display: block; margin-bottom: 3px; color: var(--accent); font-size: 9px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }
.study-title h2 { overflow: hidden; font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
.study-title > span:last-child { display: block; overflow: hidden; margin-top: 5px; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.toolbar { display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.toolbar button, .dialog-header button {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #11191c;
  cursor: pointer;
}
.toolbar button:hover:not(:disabled), .dialog-header button:hover { border-color: #4a616a; background: #182226; }
.toolbar button.active { color: #07100d; border-color: var(--accent); background: var(--accent); }
.toolbar button:disabled { cursor: default; opacity: .38; }

.viewer-shell { position: relative; min-height: 0; overflow: hidden; background: radial-gradient(circle at center, #101719, #030506 70%); touch-action: none; overscroll-behavior: contain; -webkit-user-select: none; user-select: none; }
.layerGroup { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
.layer { position: absolute; inset: 0; }
.layerGroup canvas { vertical-align: middle; touch-action: none; -webkit-user-select: none; user-select: none; }
.empty-state { position: absolute; z-index: 2; top: 50%; left: 50%; width: min(460px, 70%); transform: translate(-50%, -50%); text-align: center; }
.scan-glyph {
  width: 86px;
  height: 86px;
  margin: 0 auto 22px;
  border: 1px solid #344348;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, #86a49a 0 11%, #273a3c 12% 25%, #0d1517 26% 40%, transparent 41%), linear-gradient(145deg, #192428, #090e10);
  box-shadow: 0 0 50px rgba(105, 226, 189, .08);
}
.empty-state h3 { font-size: 18px; }
.empty-state p { max-width: 390px; margin: 9px auto 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.viewer-hud { position: absolute; z-index: 4; right: 15px; bottom: 13px; left: 15px; display: flex; justify-content: space-between; color: #b7c3c8; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; pointer-events: none; text-shadow: 0 1px 3px #000; }
.loading-panel { position: absolute; z-index: 5; top: 50%; left: 50%; width: 280px; padding: 22px; transform: translate(-50%, -50%); border: 1px solid var(--line); border-radius: 12px; background: rgba(11, 17, 19, .94); box-shadow: 0 18px 80px #000; text-align: center; }
.loading-panel[hidden] { display: none; }
.loading-panel strong { display: block; overflow: hidden; margin: 13px 0 14px; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.loading-panel progress { width: 100%; height: 5px; border: none; border-radius: 5px; overflow: hidden; background: #273238; }
.loading-panel progress::-webkit-progress-bar { background: #273238; }
.loading-panel progress::-webkit-progress-value { background: var(--accent); }
.spinner { width: 24px; height: 24px; margin: auto; border: 2px solid #314047; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-banner { padding: 9px 14px; color: #ffd8d8; border-top: 1px solid #813f47; background: #481d23; font-size: 12px; }
.error-banner[hidden] { display: none; }

dialog { width: min(900px, calc(100% - 40px)); max-height: calc(100% - 40px); padding: 0; color: #ecf2f4; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: 0 25px 100px #000; }
dialog::backdrop { background: rgba(0, 0, 0, .72); backdrop-filter: blur(3px); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; padding: 17px 19px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { font-size: 17px; }
#metadataContent { max-height: 70vh; margin: 0; padding: 20px; overflow: auto; color: #b9c8ce; background: #080c0e; font-size: 11px; line-height: 1.5; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 850px) {
  body { grid-template-columns: 240px minmax(0, 1fr); }
  .topbar { align-items: flex-start; flex-direction: column; gap: 10px; }
  .toolbar { justify-content: flex-start; }
}
