/* Honors Diploma Essay Atlas — visual redesign */
:root {
  color-scheme: light;
  --bg: #f4f5f8;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --ink: #1c2230;
  --ink-2: #424a5c;
  --muted: #707888;
  --faint: #9aa1b0;
  --line: #e9ebf0;
  --line-2: #dfe2e9;
  --accent: #2b3346;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(22,28,40,.04), 0 10px 30px rgba(22,28,40,.06);
  --shadow-sm: 0 1px 2px rgba(22,28,40,.05), 0 4px 14px rgba(22,28,40,.05);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
::selection { background: rgba(61,99,221,.18); }

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 12px;
}

/* ---------------- Masthead ---------------- */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.title-area { display: flex; align-items: center; gap: 13px; min-width: 0; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background:
    radial-gradient(circle at 30% 28%, #e34a8b 0 18%, transparent 19%),
    radial-gradient(circle at 70% 30%, #ef7d1a 0 16%, transparent 17%),
    radial-gradient(circle at 32% 72%, #16a34a 0 16%, transparent 17%),
    radial-gradient(circle at 72% 70%, #3d63dd 0 18%, transparent 19%),
    linear-gradient(135deg, #1c2230, #2b3346);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), var(--shadow-sm);
}
.title-text h1 {
  margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.015em;
  line-height: 1.1;
}
.title-text p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.masthead-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 11px; padding: 8px 11px; min-width: 220px;
  box-shadow: var(--shadow-sm);
  transition: border-color .18s, box-shadow .18s;
}
.search:focus-within { border-color: #b9c2d6; box-shadow: 0 0 0 3px rgba(61,99,221,.12); }
.search svg { width: 16px; height: 16px; flex: none; stroke: var(--muted); stroke-width: 2; fill: none; stroke-linecap: round; }
.search input {
  border: 0; outline: 0; background: transparent; font-size: 13.5px; color: var(--ink);
  width: 100%; min-width: 60px;
}
.search kbd {
  font-family: var(--mono); font-size: 10.5px; color: var(--faint);
  border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 5px; background: var(--panel-2);
}

.view-switch {
  display: flex; gap: 3px; background: var(--panel); padding: 3px;
  border-radius: 12px; border: 1px solid var(--line-2); box-shadow: var(--shadow-sm);
}
.view-switch button {
  border: 0; background: transparent; border-radius: 9px;
  padding: 6px 13px; color: var(--muted); line-height: 1.15;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0;
  transition: background .18s, color .18s;
}
.view-switch button b { font-size: 13px; font-weight: 700; color: inherit; }
.view-switch button span { font-size: 9.5px; letter-spacing: .03em; text-transform: uppercase; opacity: .7; }
.view-switch button:hover { color: var(--ink-2); }
.view-switch button.on { background: var(--accent); color: #fff; }
.view-switch button.on span { opacity: .65; }

/* ---------------- Layout ---------------- */
.layout {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 226px minmax(0, 1fr) 320px;
  gap: 12px;
}

/* ---------------- Filters ---------------- */
.filters {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-height: 0;
}
.filter-scroll { flex: 1; overflow-y: auto; padding: 16px 15px 8px; }
.fblock { margin-bottom: 18px; }
.fhead {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 9px;
}
.fhead > span:first-child { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.ftoggle {
  border: 0; background: transparent; color: var(--faint); font-size: 11px; padding: 0;
  transition: color .15s;
}
.ftoggle:hover { color: var(--ink); }
.frange-val { font-size: 11px; color: var(--muted); font-family: var(--mono); }

.chip-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.chip-col { display: flex; flex-direction: column; gap: 4px; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 5px; }

.ychip {
  border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 8px;
  padding: 5px 2px; font-size: 11.5px; font-weight: 600; color: var(--ink-2);
  display: flex; flex-direction: column; align-items: center; line-height: 1.15;
  transition: all .15s;
}
.ychip small { font-size: 8.5px; color: var(--faint); font-weight: 600; }
.ychip:hover { border-color: #c4cbd9; }
.ychip.off { opacity: .42; background: transparent; }
.ychip.off small { opacity: .6; }

.tchip {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 9px;
  padding: 6px 9px; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  transition: all .15s;
}
.tchip .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--c); transition: transform .15s; }
.tchip .nm { flex: 1; text-align: left; }
.tchip .ct { font-size: 10.5px; color: var(--faint); font-family: var(--mono); }
.tchip:hover { border-color: #c4cbd9; }
.tchip:hover .dot { transform: scale(1.2); }
.tchip.off { opacity: .4; }
.tchip.off .dot { background: var(--faint); }

.schip {
  border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 8px;
  padding: 5px 10px; font-size: 11.5px; font-weight: 600; color: var(--ink-2);
  transition: all .15s;
}
.schip:hover { border-color: #c4cbd9; }
.schip.off { opacity: .42; }

.range { position: relative; height: 26px; margin-top: 4px; }
.range-track {
  position: absolute; top: 11px; left: 0; right: 0; height: 4px;
  background: var(--line-2); border-radius: 4px;
}
.range-fill { position: absolute; top: 0; bottom: 0; background: var(--accent); border-radius: 4px; }
.range input[type=range] {
  position: absolute; top: 0; left: 0; width: 100%; height: 26px; margin: 0;
  background: transparent; pointer-events: none; -webkit-appearance: none; appearance: none;
}
.range input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; pointer-events: auto;
  width: 15px; height: 15px; border-radius: 50%; background: #fff;
  border: 2px solid var(--accent); box-shadow: var(--shadow-sm); cursor: grab;
}
.range input[type=range]::-moz-range-thumb {
  pointer-events: auto; width: 15px; height: 15px; border-radius: 50%; background: #fff;
  border: 2px solid var(--accent); box-shadow: var(--shadow-sm); cursor: grab;
}

.filter-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 15px; border-top: 1px solid var(--line);
}
.foot-stat { display: flex; flex-direction: column; line-height: 1.1; }
.foot-stat b { font-size: 16px; font-weight: 800; }
.foot-stat span { font-size: 10px; color: var(--faint); }
.reset {
  margin-left: auto; border: 1px solid var(--line-2); background: var(--panel-2);
  border-radius: 8px; padding: 6px 12px; font-size: 12px; color: var(--muted);
  transition: all .15s;
}
.reset:hover { color: var(--ink); border-color: #c4cbd9; }

/* ---------------- Stage ---------------- */
.stage { display: flex; flex-direction: column; gap: 12px; min-height: 0; min-width: 0; }

.timeline-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px 10px;
  flex: none;
}
.tl-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 9px; }
.tl-title { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.tl-hint { font-size: 11px; color: var(--faint); }
.timeline { display: flex; gap: 6px; align-items: stretch; }
.tl-node {
  flex: 1; border: 1px solid transparent; background: transparent; border-radius: 10px;
  padding: 6px 2px 5px; display: flex; flex-direction: column; align-items: center; gap: 5px;
  transition: background .15s, border-color .15s;
  min-width: 0;
}
.tl-node:hover { background: var(--panel-2); border-color: var(--line-2); }
.tl-node.on { background: #eef1fb; border-color: #c9d4f5; }
.tl-bar-wrap { width: 100%; height: 40px; display: flex; align-items: flex-end; justify-content: center; }
.tl-bar {
  width: 60%; max-width: 26px; min-height: 3px; border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, #56627e, #2b3346);
  transition: height .45s cubic-bezier(.4,0,.2,1), background .2s;
}
.tl-node.on .tl-bar { background: linear-gradient(180deg, #5d7df0, #3d63dd); }
.tl-node.excluded .tl-bar { background: var(--line-2); }
.tl-node.excluded { opacity: .5; }
.tl-year { font-size: 12px; font-weight: 700; color: var(--ink); line-height: 1; }
.tl-year small { font-size: 8.5px; color: var(--muted); font-weight: 600; margin-left: 1px; }
.tl-count { font-size: 10px; color: var(--faint); font-family: var(--mono); }
.tl-node.on .tl-year { color: #2c4bbd; }

.viz-card {
  flex: 1; min-height: 0;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.viz-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.viz-titles h2 { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.viz-titles p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 5px; justify-content: flex-end; max-width: 62%; }
.lchip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--line-2); background: var(--panel-2);
  border-radius: 999px; padding: 3px 9px 3px 7px; font-size: 11px; font-weight: 600; color: var(--ink-2);
  transition: all .15s;
}
.lchip .ldot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.lchip:hover { border-color: var(--c); }
.lchip.focus { background: var(--c); color: #fff; border-color: var(--c); }
.lchip.focus .ldot { background: rgba(255,255,255,.9); }
.lchip.dim { opacity: .4; }

.viz-body { position: relative; flex: 1; min-height: 0; padding: 8px; }
#chart { width: 100%; height: 100%; display: block; }
#chart text { font-family: var(--font); }

/* SVG element interactions */
.seg { transition: opacity .2s; cursor: pointer; }
.seg:hover { opacity: 1 !important; }
.band { transition: opacity .2s; cursor: pointer; }
.cell { transition: opacity .2s; cursor: pointer; }
.axis-label { cursor: pointer; transition: fill .15s, font-weight .15s; }
.axis-label.on { font-weight: 800; }
.trend-dot { cursor: pointer; }
.grid-line { stroke: var(--line); stroke-width: 1; }
.grid-zero { stroke: var(--line-2); stroke-width: 1; }

.tooltip {
  position: absolute; z-index: 30; pointer-events: none;
  background: rgba(28,34,48,.97); color: #fff; border-radius: 10px;
  padding: 8px 11px; font-size: 12px; line-height: 1.4; max-width: 240px;
  box-shadow: 0 8px 24px rgba(0,0,0,.22); backdrop-filter: blur(4px);
  transition: opacity .12s;
}
.tooltip .tt-title { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.tooltip .tt-title .ld { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.tooltip .tt-sub { color: rgba(255,255,255,.7); font-size: 11px; margin-top: 2px; }
.tooltip .tt-big { font-size: 13px; font-weight: 700; margin-top: 3px; }
.tooltip .tt-big small { font-weight: 500; color: rgba(255,255,255,.65); font-size: 11px; }

.viz-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--faint); font-size: 14px; font-weight: 600;
}
.viz-empty[hidden] { display: none; }

/* ---------------- Detail panel ---------------- */
.detail {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  min-height: 0; display: flex; flex-direction: column;
}
.detail-scroll { flex: 1; overflow-y: auto; padding: 16px; }

.d-kicker {
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--faint); display: flex; align-items: center; gap: 6px;
}
.d-kicker .kd { width: 9px; height: 9px; border-radius: 50%; }
.d-title { margin: 5px 0 0; font-size: 19px; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; }
.d-title small { font-size: 12px; color: var(--muted); font-weight: 600; margin-left: 6px; }

.d-stats { display: flex; gap: 8px; margin: 14px 0 4px; }
.d-stat {
  flex: 1; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 10px;
}
.d-stat b { display: block; font-size: 18px; font-weight: 800; line-height: 1; }
.d-stat span { font-size: 10.5px; color: var(--muted); }

.d-section { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); margin: 18px 0 8px; }

.minibars { display: flex; flex-direction: column; gap: 5px; }
.mbrow { display: grid; grid-template-columns: 42px 1fr 34px; align-items: center; gap: 7px; font-size: 11.5px; }
.mbrow .mbl { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mbtrack { height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; }
.mbfill { height: 100%; border-radius: 4px; background: var(--c); transition: width .5s cubic-bezier(.4,0,.2,1); }
.mbrow .mbv { text-align: right; font-family: var(--mono); font-size: 10.5px; color: var(--muted); }

.spark { width: 100%; height: 56px; display: block; margin: 2px 0 4px; }

.hint-list { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 9px; }
.hint-list li { display: flex; gap: 9px; font-size: 12.5px; color: var(--ink-2); line-height: 1.4; }
.hint-list .hn {
  flex: none; width: 19px; height: 19px; border-radius: 6px; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}

/* essay cards */
.cards { display: flex; flex-direction: column; gap: 8px; }
.card {
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel);
  overflow: hidden; transition: border-color .15s, box-shadow .15s;
  border-left: 3px solid var(--c);
}
.card:hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.card-head { padding: 9px 11px; cursor: pointer; }
.card-top { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.card-year {
  font-size: 10.5px; font-weight: 700; color: #fff; background: var(--c);
  border-radius: 5px; padding: 1px 6px; letter-spacing: .01em;
}
.card-theme { font-size: 11px; font-weight: 600; color: var(--c); }
.card-words { margin-left: auto; font-size: 10.5px; color: var(--faint); font-family: var(--mono); }
.card-excerpt { font-size: 12px; color: var(--ink-2); line-height: 1.5; }
.card.open .card-excerpt { display: none; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.card-tag { font-size: 9.5px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.card-body { display: none; padding: 0 11px 11px; }
.card.open .card-body { display: block; }
.card-body h4 { margin: 8px 0 4px; font-size: 12px; font-weight: 700; color: var(--ink); }
.card-body p { margin: 0 0 7px; font-size: 12px; line-height: 1.6; color: var(--ink-2); }
.card-loading { font-size: 11.5px; color: var(--faint); padding: 4px 0; }

.empty-note { font-size: 12.5px; color: var(--faint); text-align: center; padding: 30px 10px; }

/* scrollbars */
.filter-scroll::-webkit-scrollbar, .detail-scroll::-webkit-scrollbar { width: 8px; }
.filter-scroll::-webkit-scrollbar-thumb, .detail-scroll::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; }
.filter-scroll::-webkit-scrollbar-track, .detail-scroll::-webkit-scrollbar-track { background: transparent; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 200px minmax(0,1fr) 280px; }
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0,1fr) 300px; }
  .filters { display: none; }
  .legend { max-width: 100%; }
}
@media (max-width: 820px) {
  .app { padding: 10px; height: auto; min-height: 100vh; }
  .layout { grid-template-columns: 1fr; }
  .masthead-tools { width: 100%; }
  .search { flex: 1; }
  .stage { min-height: 70vh; }
  .viz-card { min-height: 420px; }
  .detail { min-height: 380px; }
  .timeline { overflow-x: auto; gap: 4px; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .tl-node { flex: 0 0 46px; }
  .tl-year { font-size: 11px; }
}
