:root {
  --bg: #0f172a;
  --panel: #111827;
  --ink: #e5e7eb;
  --muted: #9ca3af;
  --bar: #22d3ee;
  --grid: #1f2937;
  --barHover: #ffffff33;
}

#app {
  color: var(--ink);
  background: radial-gradient(1200px 800px at 10% -10%, #0b1224 0%, var(--bg) 40%, #0a0f1e 100%);
  margin: 0;
  font-family: Arial;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 12px;
  padding: 20px clamp(16px, 3vw, 36px);
}

#modal {
  margin: 0;
  font-family: Arial;
  color: var(--ink);
}

#legendText {
  display: none;
}

header { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }

.wrap { display:grid; grid-template-rows: auto 1fr; grid-template-columns: 1fr; gap: 14px; }
@media (max-width: 960px) { .wrap { grid-template-rows: auto 1fr; grid-template-columns: 1fr; } }

.panel {
  background: linear-gradient(180deg, #0e1426 0%, var(--panel) 100%);
  border: 1px solid #1f2a3d; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

#legendItems { display: flex; gap: 1rem; }
.legend { padding: 10px 14px; display:flex; flex-wrap:wrap; align-items:center; gap:10px 16px; position: static; top: auto; max-height: none; overflow: visible; }
.legend h2 { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing:.2px }
.legend-item { display:flex; align-items:center; gap:8px; font-size: 14px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; box-shadow: inset 0 0 0 2px #00000044; flex: 0 0 14px }
.count { color: var(--muted); font-variant-numeric: tabular-nums; }

.chart { position: relative; }
.svg-host { width: 100%; height: auto; display:block; }
.axis path, .axis line { stroke: #2a3348; }
.axis text { fill: var(--muted); font-size: 10px; }

.grid-v line { stroke: #1f2a3d; stroke-width: 1; }
.row-line { display: none; }

.bar { rx: 0; ry: 0; cursor: pointer; }
.bar:hover { filter: brightness(1.1); outline: 2px solid var(--barHover); }

.label { font-size: 9px; fill: #d1d5db; pointer-events: auto; cursor: pointer; text-shadow: 0 1px 0 #000; }

.overview { border-top: 1px solid #1f2a3d; }
.brush .overlay { pointer-events: none; }
.brush .selection { fill: #22d3ee22; stroke: var(--bar); pointer-events: all; cursor: grab; }
.brush .selection:active { cursor: grabbing; }
.brush .handle { fill: var(--bar); pointer-events: all; cursor: ew-resize; }
.brush .handle--e { display: block; }

.footer { color: var(--muted); font-size: 14px; display:flex; align-items:center; gap:8px; margin-top: -8px; }
.kbd { border: 1px solid #3b445a; border-bottom-width: 2px; border-radius: 6px; padding: 2px 6px; font-size: 12px; color:#cbd5e1 }

.modal-backdrop {
  position: fixed; inset: 0; display: none; place-items: center; background: rgba(2,8,23,.65); backdrop-filter: blur(2px); z-index: 50;
}
.modal { background: #0b1120; border: 1px solid #1e293b; border-radius: 16px; max-width: 860px; width: min(92vw, 860px); overflow: hidden; box-shadow: 0 30px 100px rgba(0,0,0,.55) }
.modal header { padding: 14px 16px; border-bottom: 1px solid #1e293b; justify-content: space-between }
.modal .content { display:grid; grid-template-columns: 220px 1fr; gap: 16px; padding: 16px; }
@media (max-width:720px){ .modal .content{ grid-template-columns: 1fr } }
.modal img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 10px; border: 1px solid #263246; background:#0a1020 }
.modal .meta { display:flex; flex-direction: column; gap: 10px }
.modal .title a { color: #e2e8f0; text-decoration: none; font-weight: 700; font-size: 18px }
.modal .title a:hover { text-decoration: underline; }
.modal .dates { color: var(--muted); }
.meta-extra dl { margin: 8px 0 0 0; }
.meta-extra dt { margin: 10px 0 2px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.meta-extra dd { margin: 0; line-height: 1.35; }
.meta-extra .desc { white-space: pre-line; max-height: 180px; overflow: auto; padding-right: 4px; }
.close { all: unset; cursor: pointer; padding: 6px 10px; border-radius: 8px; border: 1px solid #30415e; color: var(--ink); }

.error { color: #fca5a5; font-size: 14px }
