:root {
  --bg: #f5f5f5;
  --ink: #2d3142;
  --muted: #4f5d75;
  --soft: #7a8399;
  --hairline: rgba(45,49,66,.14);
  --accent: #eb6c36;
  --font-sans: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, Consolas, Menlo, monospace;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  padding-bottom: 60px;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--hairline);
  background: white;
  color: var(--ink);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 14px;
}
button:hover { background: #eee; }

input, select {
  font-family: inherit;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 14px;
  background: white;
}

code { font-family: var(--font-mono); }

/* Top bar */
.top-bar {
  position: sticky;
  top: 0;
  background: rgba(245, 245, 245, 0.95);
  backdrop-filter: blur(8px);
  z-index: 100;
  border-bottom: 1px solid var(--hairline);
  padding: 12px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}
.top-bar h1 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.status-label { font-size: 13px; color: var(--soft); }
.drop-zone {
  border: 1px dashed var(--soft);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--soft);
  position: relative;
  overflow: hidden;
  background: white;
  cursor: pointer;
}
.drop-zone:hover, .drop-zone.dragover { background: var(--hairline); border-color: var(--ink); color: var(--ink); }
.drop-zone input[type="file"] {
  position: absolute; top: 0; left: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer;
}

/* Sections */
.section { padding: 24px; border-bottom: 1px solid var(--hairline); }

/* Headline */
.headline-strip { display: flex; gap: 32px; flex-wrap: wrap; }
.headline-stat { display: flex; flex-direction: column; }
.stat-val { font-family: var(--font-mono); font-size: 24px; font-weight: bold; }
.stat-val.accent { color: var(--accent); }
.stat-lbl { color: var(--soft); font-size: 11px; text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; }

/* UpSet */
.upset-container { display: flex; overflow-x: auto; padding: 24px; align-items: flex-start; border-bottom: 1px solid var(--hairline); }
.upset-left { display: flex; flex-direction: column; padding-right: 16px; border-right: 1px solid var(--hairline); padding-top: 132px; }
.upset-row { display: flex; align-items: center; justify-content: flex-end; height: 24px; cursor: pointer; outline: none; }
.upset-row:hover .row-label, .upset-row:focus .row-label { color: var(--accent); }
.row-label { font-size: 13px; margin-right: 12px; text-align: right; user-select: none; }
.row-bar-wrap { width: 120px; background: var(--hairline); height: 12px; border-radius: 2px; }
.row-bar { background: var(--muted); height: 100%; border-radius: 2px; }
.row-count { font-family: var(--font-mono); font-size: 12px; margin-left: 8px; color: var(--soft); width: 24px; }

.upset-right { display: flex; gap: 8px; padding-left: 16px; }
.upset-group { display: flex; flex-direction: column; align-items: center; border-radius: 6px; background: rgba(0,0,0,0.03); padding: 4px; }
.upset-group.alt { background: transparent; }
.group-label { height: 20px; line-height: 20px; margin-bottom: 4px; font-size: 10px; color: var(--soft); font-weight: bold; letter-spacing: 1px; }
.group-cols { display: flex; gap: 4px; padding: 0 4px; }

.combo-col { display: flex; flex-direction: column; align-items: center; cursor: pointer; outline: none; border-radius: 4px; padding: 0 2px; }
.combo-col:hover, .combo-col:focus { background: rgba(235,108,54,0.05); }
.col-top { height: 108px; width: 16px; position: relative; }
.col-bar { position: absolute; bottom: 0; left: 0; width: 100%; background: var(--muted); border-radius: 2px 2px 0 0; }
.combo-col:hover .col-bar { background: var(--accent); }
.col-count { position: absolute; bottom: calc(var(--h) + 4px); left: 0; width: 16px; text-align: center; font-family: var(--font-mono); font-size: 11px; color: var(--soft); writing-mode: vertical-rl; transform: rotate(180deg); }
.combo-col:hover .col-count { color: var(--accent); }

.dots { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; position: relative; }
.dot { width: 16px; height: 16px; border-radius: 50%; background: var(--bg); border: 2px solid var(--hairline); z-index: 2; box-sizing: border-box; outline: none; }
.dot:focus { box-shadow: 0 0 0 2px rgba(235,108,54,0.5); }
.dot.filled { background: var(--ink); border-color: var(--ink); }
.combo-col:hover .dot.filled { background: var(--accent); border-color: var(--accent); }
.dot-line { position: absolute; width: 2px; background: var(--ink); left: 7px; z-index: 1; }
.combo-col:hover .dot-line { background: var(--accent); }

/* Thesis column */
.combo-col.thesis .col-bar { background: transparent; border: 1px dashed var(--accent); width: 14px; left: 1px; }
.combo-col.thesis .dot.filled { background: var(--accent); border-color: var(--accent); }
.combo-col.thesis .dot-line { background: var(--accent); }
.thesis-lbl { color: var(--accent); font-weight: bold; font-size: 10px; writing-mode: vertical-rl; transform: rotate(180deg); position: absolute; bottom: calc(var(--h) + 4px); left: 0; white-space: nowrap; margin-bottom: 4px; }

/* Filter Bar */
.filter-bar { padding: 16px 24px; border-bottom: 1px solid var(--hairline); display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.chip { display: inline-flex; align-items: center; background: white; border: 1px solid var(--hairline); border-radius: 16px; padding: 4px 12px; font-size: 13px; cursor: pointer; user-select: none; outline: none; }
.chip:focus { border-color: var(--accent); }
.chip.active { background: rgba(235,108,54,0.1); border-color: var(--accent); color: var(--accent); font-weight: 500; }
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; border-right: 1px solid var(--hairline); padding-right: 12px; }

.active-filters { padding: 0 24px 16px; display: flex; gap: 8px; flex-wrap: wrap; border-bottom: 1px solid var(--hairline); }

/* Table */
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 12px 16px; border-bottom: 2px solid var(--hairline); font-size: 11px; color: var(--soft); text-transform: uppercase; cursor: pointer; user-select: none; font-weight: 600; letter-spacing: 0.5px; }
th:hover { color: var(--ink); }
td { padding: 12px 16px; border-bottom: 1px solid var(--hairline); font-size: 14px; vertical-align: top; }
tr.paper-row { cursor: pointer; outline: none; }
tr.paper-row:hover, tr.paper-row:focus { background: rgba(0,0,0,0.02); }
tr.expanded { background: rgba(0,0,0,0.02); }
.col-dims { width: 60px; font-weight: bold; font-family: var(--font-mono); }
.col-dims.high { color: var(--accent); }
.col-cit { width: 35%; }
.col-year { width: 60px; }
.col-type { width: 120px; }
.col-matrix { width: 120px; }
.matrix-wrap { display: flex; gap: 3px; }
.dim-sq { width: 12px; height: 12px; border: 1px solid var(--hairline); box-sizing: border-box; background: white; }
.dim-sq.f { background: var(--ink); border-color: var(--ink); }
.col-rel { width: 60px; }
.col-spk { width: 60px; }
.col-d3 { width: 80px; }

/* Detail Panel */
.detail-panel { background: white; padding: 24px; border-bottom: 1px solid var(--hairline); box-shadow: inset 0 4px 6px rgba(0,0,0,0.02); margin: 0; }
.detail-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; margin-bottom: 24px; }
.detail-meta > div { font-size: 14px; }
.detail-meta label { display: block; color: var(--soft); font-size: 11px; text-transform: uppercase; margin-bottom: 4px; font-weight: 600; }
.abstract-box { background: var(--bg); padding: 16px; border-radius: 6px; font-size: 14px; margin-bottom: 24px; border: 1px solid var(--hairline); line-height: 1.6; }
.links { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.links a { color: var(--accent); text-decoration: none; font-size: 14px; font-weight: 500; }
.links a:hover { text-decoration: underline; }

.error-msg { background: #fee; color: #c00; padding: 12px 24px; font-size: 14px; font-weight: 500; border-bottom: 1px solid #fcc; }
footer { padding: 32px 24px; text-align: center; color: var(--soft); font-size: 12px; }
