*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0f1117;
  --surface:      #1a1d27;
  --border:       #2d3148;
  --text:         #e2e8f0;
  --muted:        #94a3b8;
  --blue:         #3b82f6;
  --orange:       #f97316;
  --green:        #22c55e;
  --radius:       8px;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text',
               'PingFang HK', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
  flex-shrink: 0;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 14px;
}

header h1 {
  font-size: 17px;
  font-weight: 600;
}

header .subtitle {
  font-size: 12px;
  color: var(--muted);
}

/* ── Tab bar ─────────────────────────────────────────────────────────────── */
.tabs {
  flex-shrink: 0;
  display: flex;
  gap: 0;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

/* ── Tab panes ───────────────────────────────────────────────────────────── */
.tab-pane {
  display: none;
  flex: 1;
  overflow: hidden;
}

.tab-pane.active { display: flex; }

/* ── GPU tab layout ──────────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 14px 14px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Sidebar sections ────────────────────────────────────────────────────── */
.section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ── Series filter ───────────────────────────────────────────────────────── */
.series-filter {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.series-filter label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}

.series-filter input[type=checkbox] {
  width: 14px;
  height: 14px;
  accent-color: var(--blue);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Sliders ─────────────────────────────────────────────────────────────── */
.slider-row {
  margin-bottom: 12px;
}

.slider-row:last-child { margin-bottom: 0; }

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.dim-label {
  font-size: 13px;
  font-weight: 500;
  cursor: help;
}

.dim-pct {
  font-size: 12px;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: right;
  transition: color 0.2s;
}

.dim-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  cursor: pointer;
  outline: none;
}

.dim-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  transition: transform 0.15s;
}

.dim-slider::-webkit-slider-thumb:hover { transform: scale(1.25); }

.slider-desc {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}

/* ── Ranking table ───────────────────────────────────────────────────────── */
.table-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
}

#rank-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#rank-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 9px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

#rank-table td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(45, 49, 72, 0.6);
  vertical-align: middle;
}

#rank-table tbody tr { cursor: pointer; }
#rank-table tbody tr:hover { background: var(--surface); }

/* Row highlighted by hover/click sync with chart */
#rank-table tbody tr.row-highlighted {
  background: rgba(99, 179, 237, 0.18) !important;
  outline: 1px solid rgba(99, 179, 237, 0.45);
  outline-offset: -1px;
}
#rank-table tbody tr.row-highlighted .rank-num,
#rank-table tbody tr.row-highlighted .score-cell {
  color: #93c5fd;
}

/* ── Top-5 priority highlights ───────────────────────────────────────────── */
/* Left-border accent + background tint, fading with rank */
#rank-table tbody tr.rank-top-1 { background: rgba(245, 158,  11, 0.08); }
#rank-table tbody tr.rank-top-2 { background: rgba(148, 163, 184, 0.07); }
#rank-table tbody tr.rank-top-3 { background: rgba(205, 124,  58, 0.06); }
#rank-table tbody tr.rank-top-4 { background: rgba( 34, 197,  94, 0.04); }
#rank-table tbody tr.rank-top-5 { background: rgba( 34, 197,  94, 0.03); }

#rank-table tbody tr.rank-top-1:hover { background: rgba(245, 158,  11, 0.14); }
#rank-table tbody tr.rank-top-2:hover { background: rgba(148, 163, 184, 0.12); }
#rank-table tbody tr.rank-top-3:hover { background: rgba(205, 124,  58, 0.11); }
#rank-table tbody tr.rank-top-4:hover { background: rgba( 34, 197,  94, 0.09); }
#rank-table tbody tr.rank-top-5:hover { background: rgba( 34, 197,  94, 0.07); }

/* Left border on first cell (border on <tr> unreliable in collapsed tables) */
#rank-table tbody tr.rank-top-1 td:first-child { border-left: 3px solid #f59e0b; }
#rank-table tbody tr.rank-top-2 td:first-child { border-left: 3px solid rgba(148,163,184,0.75); }
#rank-table tbody tr.rank-top-3 td:first-child { border-left: 3px solid rgba(205,124, 58,0.75); }
#rank-table tbody tr.rank-top-4 td:first-child { border-left: 3px solid rgba( 34,197, 94,0.50); }
#rank-table tbody tr.rank-top-5 td:first-child { border-left: 3px solid rgba( 34,197, 94,0.30); }

/* Rank number color per priority level */
#rank-table tbody tr.rank-top-1 .rank-num { color: #f59e0b; font-weight: 700; }
#rank-table tbody tr.rank-top-2 .rank-num { color: #94a3b8; font-weight: 600; }
#rank-table tbody tr.rank-top-3 .rank-num { color: #cd7c3a; font-weight: 600; }
#rank-table tbody tr.rank-top-4 .rank-num { color: var(--blue); }
#rank-table tbody tr.rank-top-5 .rank-num { color: var(--blue); }

.rank-num {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  width: 32px;
  text-align: center;
}

.model-name {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 200px;
  max-width: 320px;
}

.series-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-cell {
  font-weight: 700;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.num-cell {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.price-flag {
  font-size: 11px;
  margin-left: 4px;
  color: #f59e0b;
  cursor: help;
  vertical-align: middle;
}

/* ── Resize handle ───────────────────────────────────────────────────────── */
.resize-handle {
  flex-shrink: 0;
  height: 6px;
  cursor: ns-resize;
  background: var(--border);
  transition: background 0.15s;
  position: relative;
}

.resize-handle::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 2px;
  border-radius: 1px;
  box-shadow: 0 -2px 0 var(--border), 0 2px 0 var(--border);
  background: transparent;
}

.resize-handle:hover,
.resize-handle.dragging {
  background: var(--blue);
}

/* ── Charts row ──────────────────────────────────────────────────────────── */
.charts-row {
  flex-shrink: 0;
  height: 50vh;
  display: flex;
  border-top: none;
  overflow: hidden;
}

.chart-slot {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-width: 0;
  overflow: hidden;
}

.chart-slot:last-child { border-right: none; }

/* ── Chart nav (prev / label / next) ─────────────────────────────────────── */
.chart-nav {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  background: rgba(26, 29, 39, 0.6);
  height: 32px;
}

.chart-nav-btn {
  flex-shrink: 0;
  width: 26px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.chart-nav-btn:hover  { color: var(--text); border-color: var(--blue); }
.chart-nav-btn:active { background: var(--border); }

.chart-nav-label {
  flex: 1;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--blue);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}

.chart-canvas {
  flex: 1;
  min-height: 0;
}

/* ── 机箱匹配 Tab ────────────────────────────────────────────────────────── */
#tab-case { flex-direction: row; overflow: hidden; }

.case-sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.case-gpu-select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 6px 8px;
  cursor: pointer;
  outline: none;
  appearance: none;
}

.case-gpu-select:focus { border-color: var(--blue); }

.gpu-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  margin-top: 6px;
}

.gpu-stat-label { color: var(--muted); }

.gpu-stat-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.gpu-stat-value.tight { color: #f59e0b; }

.case-compat-summary {
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.compat-count {
  font-size: 24px;
  font-weight: 700;
  color: var(--green);
  line-height: 1;
}

.compat-label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

.case-main {
  flex: 1;
  overflow: auto;
  min-width: 0;
}

.case-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 14px;
  opacity: 0.5;
}

/* ── Case table ─────────────────────────────────────────────────────────── */
#case-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#case-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 9px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

#case-table td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(45, 49, 72, 0.6);
  vertical-align: top;
}

#case-table tbody tr:hover { background: var(--surface); }

#case-table tbody tr.compat-row-no { opacity: 0.4; }

.compat-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.compat-ok   { background: rgba(34, 197,  94, 0.15); color: #22c55e; }
.compat-warn { background: rgba(245, 158, 11, 0.15);  color: #f59e0b; }
.compat-no   { background: rgba(239,  68,  68, 0.12); color: #ef4444; }

.compat-detail {
  font-size: 11px;
  color: #f59e0b;
  margin-top: 2px;
}

.case-name-cell { min-width: 180px; max-width: 260px; }

.case-name {
  font-weight: 500;
  line-height: 1.3;
}

.case-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.4;
  max-width: 240px;
}

.num-tight { color: #f59e0b !important; font-weight: 600; }

/* ── Case row: pointer cursor ────────────────────────────────────────────── */
#case-table tbody tr { cursor: pointer; }

/* ── Case hover tooltip ──────────────────────────────────────────────────── */
.case-tooltip {
  position: fixed;
  z-index: 400;
  pointer-events: none;
  display: none;
  width: 260px;
  background: #1e2235;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55);
  transition: opacity 0.12s;
}

.case-tooltip.visible { display: block; }

.case-tooltip-img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  object-position: top;
  display: block;
  background: var(--surface);
}

.case-tooltip-info {
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.6;
}

.case-tooltip-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
  line-height: 1.3;
}

.case-tooltip-row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.case-tooltip-row span:last-child {
  color: var(--text);
  font-weight: 500;
}

.case-tooltip-hint {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: #4a5270;
  text-align: center;
}

/* ── Case detail modal ───────────────────────────────────────────────────── */
.case-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.case-modal-overlay.open {
  display: flex;
}

.case-modal-card {
  position: relative;
  background: #1a1d27;
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 740px;
  max-height: 90vh;
  display: flex;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
}

.case-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15,17,23,0.75);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}

.case-modal-close:hover { color: var(--text); background: var(--border); }

.case-modal-photo-wrap {
  width: 220px;
  flex-shrink: 0;
  background: #12141e;
  overflow: hidden;
}

.case-modal-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  display: block;
}

.case-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
  min-width: 0;
}

.case-modal-header {
  margin-bottom: 10px;
}

.case-modal-brand {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--blue);
  margin-bottom: 3px;
}

.case-modal-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.case-modal-vol {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.case-modal-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.case-modal-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin-bottom: 12px;
}

.spec-item {}

.spec-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #4a5270;
  margin-bottom: 2px;
}

.spec-value {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.3;
}

.spec-value.warn { color: #f59e0b; }

.case-modal-notes {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(45,49,72,0.35);
  border-radius: var(--radius);
  border-left: 3px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.7;
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3d4468; }

/* ── Desktop-only elements (hidden on mobile) ────────────────────────────── */
.sidebar-toggle  { display: none; }
.mobile-toolbar  { display: none; }
.drawer-overlay  {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 199;
}
.drawer-overlay.visible { display: block; }

/* Desktop: sidebar-body is a transparent flex pass-through */
.sidebar-body { display: contents; }

/* ── Mobile (≤ 768px) ────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Sidebar → fixed left drawer (removed from normal flow) */
  .sidebar {
    position: fixed;
    top: 0;
    left: -284px;
    width: 280px;
    height: 100%;
    z-index: 200;
    background: var(--bg);
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.6);
    transition: left 0.24s ease;
    padding: 0;
    gap: 0;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .sidebar.drawer-open { left: 0; }

  /* sidebar-toggle → close button at top of drawer */
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 16px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }

  .sidebar-toggle-icon { font-size: 14px; color: var(--muted); }

  /* sidebar-body → always visible inside drawer */
  .sidebar-body {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 16px;
  }

  /* GPU tab: column (sidebar is fixed, out of flex flow) */
  #tab-gpu { flex-direction: column; }

  /* Mobile toolbar */
  .mobile-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
  }

  .toolbar-btn {
    flex-shrink: 0;
    padding: 5px 12px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.12s;
    -webkit-tap-highlight-color: transparent;
  }

  .toolbar-btn:active { background: var(--border); }
  .toolbar-btn.active { color: var(--blue); border-color: var(--blue); }

  /* Pinned model name display (between toolbar buttons) */
  .pinned-name {
    flex: 1;
    min-width: 0;
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 4px;
  }

  /* Model name column: toggled off via .hide-name on table-wrap */
  .hide-name #rank-table th:nth-child(2),
  .hide-name #rank-table td:nth-child(2) { display: none; }

  /* Resize handle: taller touch target */
  .resize-handle { height: 20px; }
  .resize-handle::after { width: 48px; }

  /* Charts: single chart, full width, touch-resizable */
  .charts-row { height: 40vh; flex-direction: column; }

  .chart-slot {
    border-right: none;
    border-top: 1px solid var(--border);
    height: 100%;
  }

  /* Hide second chart on mobile */
  .chart-slot:last-child { display: none; }

  /* Case tab: stack vertically on mobile */
  #tab-case { flex-direction: column; overflow-y: auto; }

  .case-sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    gap: 10px;
  }

  .case-sidebar > div { flex: 1; min-width: 140px; }

  .case-main { overflow: visible; min-height: 300px; }

  /* Tooltip: disabled on mobile (click modal only) */
  .case-tooltip { display: none !important; }

  /* Modal: full screen on mobile */
  .case-modal-overlay { padding: 0; align-items: flex-end; }

  .case-modal-card {
    flex-direction: column;
    max-width: 100%;
    max-height: 88vh;
    border-radius: 16px 16px 0 0;
  }

  .case-modal-photo-wrap {
    width: 100%;
    height: 180px;
    flex-shrink: 0;
  }

  .case-modal-photo { object-position: center 15%; }

}


