/* Base theme tokens */
:root {
  --bg: #ffffff;
  --fg: #111827;
  --muted: #6b7280;
  --card: #ffffff;
  --border: #e5e7eb;
  --accent: #eef2ff;
  --accent-strong: #e0e7ff;
  --brand: #0f766e;
  --brand-strong: #0b5f58;
  --shadow: 0 1px 6px rgba(0,0,0,.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14;
    --fg: #e5e7eb;
    --muted: #9ca3af;
    --card: #11161d;
    --border: #1f2937;
    --accent: #0f172a;
    --accent-strong: #111827;
    --brand: #0ea5e9;
    --brand-strong: #0284c7;
    --shadow: 0 1px 10px rgba(0,0,0,.4);
  }
}

/* Manual override via data-theme */
[data-theme="light"] {
  --bg: #ffffff;
  --fg: #111827;
  --muted: #6b7280;
  --card: #ffffff;
  --border: #e5e7eb;
  --accent: #eef2ff;
  --accent-strong: #e0e7ff;
  --brand: #0f766e;
  --brand-strong: #0b5f58;
  --shadow: 0 1px 6px rgba(0,0,0,.06);
}
[data-theme="dark"] {
  --bg: #0b0f14;
  --fg: #e5e7eb;
  --muted: #9ca3af;
  --card: #11161d;
  --border: #1f2937;
  --accent: #0f172a;
  --accent-strong: #111827;
  --brand: #0ea5e9;
  --brand-strong: #0284c7;
  --shadow: 0 1px 10px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin:0; padding:0; background: var(--bg); color: var(--fg); font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; }
a { color: inherit; }
header, main, footer { max-width: 1100px; margin: 0 auto; padding: 1rem; }

h1 { margin: .2rem 0 .4rem; font-size: clamp(1.25rem, 2.8vw, 1.8rem); }
h2 { margin: 1rem 0 .5rem; font-size: clamp(1.05rem, 2.4vw, 1.3rem); }

.toolbar { display:flex; gap:1rem; align-items:flex-end; flex-wrap:wrap; }
.searchbox { display:flex; flex-direction:column; gap:.35rem; min-width:260px; }
.searchline { display:flex; gap:.4rem; align-items:center; }
.searchbox input { padding:.6rem .8rem; border:1px solid var(--border); background: var(--card); color: var(--fg); border-radius:8px; width: clamp(260px, 42vw, 520px); }
.btn, .btn-ghost {
  display:inline-block; padding:.5rem .75rem; border-radius:8px; text-decoration:none;
  border:1px solid var(--border); background: var(--accent); color: var(--fg);
}
.btn:hover, .btn-ghost:hover { background: var(--accent-strong); }
.muted { color: var(--muted); }

/* Year blocks */
.year-block { background: var(--card); border-radius:12px; margin:.75rem 0; box-shadow: var(--shadow); padding:.25rem .25rem .75rem; border:1px solid var(--border); }
.year-block > summary { cursor:pointer; padding: .75rem 1rem; font-weight:700; list-style:none; }
.year-block > summary::-webkit-details-marker { display:none; }
.year-block .year { font-size:1.1rem; }
.year-block .count { color: var(--muted); font-weight:500; margin-left:.5rem; }

table.events { width:100%; border-collapse: collapse; table-layout: fixed; }
table.events thead th { text-align:left; font-weight:700; padding:.6rem 1rem; border-bottom:1px solid var(--border); }
table.events tbody td { padding:.6rem 1rem; border-bottom:1px solid var(--border); }
table.events td:nth-child(2), table.events th:nth-child(2) { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.clickrow { cursor: pointer; }
.clickrow:hover { background: var(--accent); }

.hidden { display:none !important; }

/* Breadcrumb */
.breadcrumb { margin:.2rem 0 .6rem; font-size:.95rem; color: var(--muted); }
.breadcrumb a { color: inherit; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* PDF tiles shared */
.pdf-grid { display:flex; flex-direction:column; gap:.5rem; margin:.5rem 0 1rem; padding-left:.75rem; }
.pdf-card {
  width: 420px; display:flex; align-items:center; gap:.75rem;
  background: var(--card); border-radius:12px; box-shadow: var(--shadow);
  padding:.9rem 1rem; text-decoration:none; color:inherit; border:1px solid var(--border);
  transition: transform .06s ease, box-shadow .06s ease, border-color .06s ease, background .06s ease;
}
.pdf-card:hover { transform: translateY(-1px); box-shadow: 0 2px 10px rgba(0,0,0,.08); border-color: var(--border); background: var(--accent); }
.pdf-icon { font-size: 1.2rem; }
.pdf-title { font-weight: 600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* Overlay viewer */
#pdfOverlay { position: fixed; inset:0; background: rgba(0,0,0,.6); display:none; align-items: center; justify-content: center; padding: 2vh; z-index: 1000; }
#pdfOverlay.open { display:flex; }
.viewer { width: min(85vw, 1200px); height: min(90vh, 1000px); background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); display:flex; flex-direction: column; overflow: hidden; }
.viewer-bar { display:flex; align-items:center; justify-content: space-between; gap:.5rem; padding:.5rem .75rem; border-bottom:1px solid var(--border); background: var(--bg); }
.viewer-title { font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.viewer-actions { display:flex; gap:.5rem; }
.viewer-actions a, .viewer-actions button { padding:.4rem .6rem; border-radius:8px; border:1px solid var(--border); background: var(--accent); color: var(--fg); text-decoration:none; }
.viewer-actions a:hover, .viewer-actions button:hover { background: var(--accent-strong); }
.viewer-body { flex:1; }
.viewer-body embed { width:100%; height:100%; border:0; }

/* Theme toggle */
.theme-toggle { margin-left:auto; }
.theme-toggle button { padding:.35rem .6rem; border-radius: 8px; border:1px solid var(--border); background: var(--accent); color: var(--fg); }
.theme-toggle button:hover { background: var(--accent-strong); }

/* New badge for recent PDFs */
.badge-new {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  padding: .08rem .4rem;
  border-radius: 999px;
  background: #ef4444; /* red-500 */
  color: #fff;
  vertical-align: middle;
  margin-left: .4rem;
}
/* place title + badge nicely */
.pdf-titlewrap { display:flex; align-items:center; gap:.35rem; min-width:0; }

/* pdf card width buffer */
.pdf-card { min-width: 280px; max-width: 95%; }

.empty-notice {
  margin: 1.2rem auto;
  text-align: center;
  max-width: 720px;
  background: var(--accent);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow);
}
.empty-notice .icon { font-size: 1.6rem; display:block; margin-bottom:.3rem; }
.empty-notice .headline { font-weight: 700; margin-bottom:.2rem; }
.empty-notice .subline { color: var(--muted); }
