@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,600;1,400&family=Source+Serif+4:ital,opsz,wght@0,8..60,300;0,8..60,400;0,8..60,600;1,8..60,400&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg:           #ffffff;
  --bg-off:       #f7f7f5;
  --bg-card:      #fafaf8;
  --bg-hover:     #f2f2ee;
  --border:       #e5e5df;
  --border-hi:    #d0d0c8;
  --accent:       #e8490f;
  --accent-dim:   #c73d0d;
  --accent-glow:  rgba(232,73,15,0.08);
  --text:         #1a1a18;
  --text-muted:   #6b6b5e;
  --text-dim:     #b0b0a0;
  --mono:         'IBM Plex Mono', monospace;
  --serif:        'Source Serif 4', serif;
  --sans:         'Inter', sans-serif;
  --panel-w:      460px;
  --timeline-gap: 1px;
  --radius:       6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* HEADER */
header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 24px;
  padding: 0 32px; height: 56px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--accent);
}

.logo {
  font-family: var(--sans); font-size: 15px; font-weight: 700;
  color: var(--text); text-decoration: none; white-space: nowrap;
}
.logo .logo-accent { color: var(--accent); }
.logo .logo-sep { color: var(--text-dim); margin: 0 4px; font-weight: 300; }

nav { display: flex; gap: 2px; }
nav a {
  padding: 6px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  color: var(--text-muted); text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
nav a:hover { color: var(--text); background: var(--bg-hover); }
nav a.active { color: var(--accent); background: var(--accent-glow); font-weight: 600; }

.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.record-count { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }

/* PAGES */
.page { display: none; }
.page.active { display: flex; flex-direction: column; min-height: calc(100vh - 56px); }

/* LAYOUT */
.timeline-layout { display: flex; flex: 1; position: relative; }

/* SIDEBAR */
.sidebar {
  width: 192px; flex-shrink: 0;
  padding: 24px 16px;
  border-right: 1px solid var(--border);
  background: var(--bg-off);
  position: sticky; top: 56px;
  height: calc(100vh - 56px); overflow-y: auto;
}
.sidebar-section { margin-bottom: 24px; }
.sidebar-label {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  color: var(--text-dim); letter-spacing: 0.1em; text-transform: uppercase;
  margin-bottom: 8px;
}
.tag-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-btn {
  padding: 3px 9px; border-radius: 3px;
  border: 1px solid var(--border-hi); background: var(--bg);
  color: var(--text-muted); font-family: var(--mono); font-size: 11px;
  cursor: pointer; transition: all 0.15s;
}
.tag-btn:hover { border-color: var(--accent); color: var(--accent); }
.tag-btn.active { border-color: var(--accent); color: var(--bg); background: var(--accent); }

/* MAIN TIMELINE */
.timeline-main {
  flex: 1; padding: 32px 40px; min-width: 0;
  transition: margin-right 0.3s ease;
}
.timeline-main.panel-open { margin-right: var(--panel-w); }
.timeline-header { margin-bottom: 32px; }
.timeline-title {
  font-family: var(--serif); font-size: 26px; font-weight: 600;
  color: var(--text); letter-spacing: -0.01em;
}
.timeline-title .cat-label { color: var(--accent); }
.timeline-subtitle { margin-top: 4px; font-size: 13px; color: var(--text-muted); }

/* DECADE GROUPS */
.decade-group { margin-bottom: 40px; }
.decade-label {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  color: var(--text-dim); letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}

/* RECORD ROWS */
.record-row {
  display: grid;
  grid-template-columns: 100px 140px 1fr 160px;
  align-items: center;
  padding: 9px 12px; border-radius: var(--radius);
  cursor: pointer; transition: background 0.1s;
  border: 1px solid transparent;
  margin-bottom: var(--timeline-gap);
  position: relative; overflow: hidden;
}
.record-row:hover { background: var(--bg-hover); border-color: var(--border); }
.record-row.selected { background: var(--accent-glow); border-color: var(--accent); }
.record-row.selected .rec-freq { color: var(--accent); }
.record-row::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: var(--bar-pct); background: rgba(232,73,15,0.04); pointer-events: none;
}

.rec-date { font-family: var(--mono); font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.rec-freq { font-family: var(--mono); font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; }
.rec-freq .unit { font-size: 10px; font-weight: 400; color: var(--text-dim); margin-left: 3px; }
.rec-cpu { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-oc { font-family: var(--mono); font-size: 11px; color: var(--text-muted); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* DETAIL PANEL */
.detail-panel {
  position: fixed; top: 56px; right: 0;
  width: var(--panel-w); height: calc(100vh - 56px);
  background: var(--bg); border-left: 1px solid var(--border);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50; box-shadow: -4px 0 24px rgba(0,0,0,0.06);
}
.detail-panel.open { transform: translateX(0); }

.panel-close {
  position: absolute; top: 16px; right: 16px;
  width: 28px; height: 28px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-off);
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; transition: all 0.15s; line-height: 1;
}
.panel-close:hover { border-color: var(--accent); color: var(--accent); }

.panel-inner { padding: 32px 28px; }

.panel-rank {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  color: var(--text-dim); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 10px;
}
.panel-freq {
  font-family: var(--mono); font-size: 38px; font-weight: 600;
  color: var(--accent); line-height: 1; letter-spacing: -0.02em;
}
.panel-freq .unit { font-size: 16px; font-weight: 400; color: var(--accent-dim); margin-left: 6px; }
.panel-date { font-family: var(--mono); font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.panel-divider { height: 1px; background: var(--border); margin: 20px 0; }
.panel-section-label {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  color: var(--text-dim); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 10px;
}
.panel-hardware-grid { display: grid; gap: 10px; }
.hw-row { display: flex; flex-direction: column; gap: 2px; }
.hw-label { font-family: var(--mono); font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.hw-value { font-size: 13px; color: var(--text); }
.hw-value.unknown { color: var(--text-dim); font-style: italic; }

.panel-overclockers { display: flex; flex-direction: column; gap: 8px; }
.oc-card { padding: 12px; border-radius: var(--radius); background: var(--bg-off); border: 1px solid var(--border); }
.oc-handle { font-weight: 600; font-size: 14px; color: var(--text); }
.oc-real-name { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.oc-aliases { font-family: var(--mono); font-size: 11px; color: var(--text-dim); margin-top: 4px; }

.panel-sources { display: flex; flex-direction: column; gap: 6px; }
.source-link {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-off);
  color: var(--text); text-decoration: none; font-size: 13px; transition: all 0.15s;
}
.source-link:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.source-link .source-icon { color: var(--text-dim); font-size: 12px; }

.panel-tags-list { display: flex; flex-wrap: wrap; gap: 6px; }
.panel-tag {
  padding: 3px 9px; border-radius: 3px;
  border: 1px solid var(--border-hi); font-family: var(--mono); font-size: 11px;
  color: var(--text-muted); background: var(--bg-off);
}

.panel-notes { font-size: 13px; color: var(--text-muted); line-height: 1.7; font-style: italic; }

.panel-nav { display: flex; gap: 8px; margin-top: 28px; }
.panel-nav-btn {
  flex: 1; padding: 8px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-off);
  color: var(--text-muted); font-family: var(--mono); font-size: 11px;
  cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.panel-nav-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.panel-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ABOUT */
.about-content { max-width: 680px; margin: 60px auto; padding: 0 32px; }
.about-content h1 { font-family: var(--serif); font-size: 28px; color: var(--text); margin-bottom: 16px; }
.about-content h2 {
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  color: var(--text-dim); letter-spacing: 0.1em; text-transform: uppercase; margin: 28px 0 10px;
}
.about-content p { color: var(--text-muted); line-height: 1.8; margin-bottom: 14px; font-size: 15px; }
.about-content a { color: var(--accent); text-decoration: none; }
.about-content a:hover { text-decoration: underline; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 3px; }

/* RESPONSIVE */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .record-row { grid-template-columns: 90px 120px 1fr; }
  .rec-oc { display: none; }
}
@media (max-width: 600px) {
  .timeline-main { padding: 20px 16px; }
  .detail-panel { width: 100%; }
  .record-row { grid-template-columns: 80px 1fr; }
  .rec-cpu { display: none; }
}

/* ── CHART ───────────────────────────────────────────── */
.chart-wrap {
  margin-bottom: 40px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-off);
}

#record-chart {
  width: 100%;
  height: 200px;
  display: block;
  cursor: default;
}

/* ── PANEL HERO ──────────────────────────────────────── */
.panel-hero {
  margin: -32px -28px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-off);
  overflow: hidden;
}
.panel-hero img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 220px;
  object-fit: cover;
}

/* ── COUNTRY BLOCK ───────────────────────────────────── */
.oc-country {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.oc-flag {
  font-size: 32px;
  line-height: 1;
}
.oc-country-code {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── PROFILE LINK ────────────────────────────────────── */
.oc-profile-link {
  display: inline-block;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
}
.oc-profile-link:hover { text-decoration: underline; }

/* ── ARCHIVED SOURCE ─────────────────────────────────── */
.source-archived {
  opacity: 0.75;
  font-style: italic;
}

/* ── DISCUSS LINK ────────────────────────────────────── */
.panel-discuss {
  margin-top: 16px;
  text-align: center;
}
.panel-discuss a {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: none;
}
.panel-discuss a:hover { color: var(--accent); }