:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1a1d23;
  --text-muted: #666d78;
  --accent: #0f6dff;
  --accent-soft: #e8f0ff;
  --tab-active-bg: #1a1d23;
  --tab-active-text: #ffffff;
  --badge-official-bg: #e6f6ec;
  --badge-official-text: #1c7a3d;
  --badge-discovered-bg: #fff3e0;
  --badge-discovered-text: #a15c00;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 22, 28, 0.06), 0 8px 24px rgba(20, 22, 28, 0.04);
  color-scheme: light dark;
}

/*
 * Theme resolution order:
 *  1. :root defaults above = light theme.
 *  2. OS-level dark preference applies automatically, UNLESS the visitor
 *     has explicitly picked "light" with the toggle (data-theme="light").
 *  3. An explicit choice from the toggle (data-theme="dark"/"light"),
 *     stored in localStorage, always wins over the OS preference.
 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --surface: #1c1f25;
    --border: #2b2f37;
    --text: #eef0f3;
    --text-muted: #9aa1ac;
    --accent: #5b9bff;
    --accent-soft: #1c2740;
    --tab-active-bg: #eef0f3;
    --tab-active-text: #14161a;
    --badge-official-bg: #123422;
    --badge-official-text: #6fdb96;
    --badge-discovered-bg: #3a2a10;
    --badge-discovered-text: #f0b054;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  }
}

:root[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1c1f25;
  --border: #2b2f37;
  --text: #eef0f3;
  --text-muted: #9aa1ac;
  --accent: #5b9bff;
  --accent-soft: #1c2740;
  --tab-active-bg: #eef0f3;
  --tab-active-text: #14161a;
  --badge-official-bg: #123422;
  --badge-official-text: #6fdb96;
  --badge-discovered-bg: #3a2a10;
  --badge-discovered-text: #f0b054;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.page-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 20px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
}

.title-block h1 {
  font-size: 1.35rem;
  margin: 0 0 4px;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.header-controls {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.search-wrap {
  position: relative;
  min-width: 260px;
  flex: 1 1 260px;
  max-width: 420px;
}

#search {
  width: 100%;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

#search:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.search-count {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
  min-height: 1em;
}

.theme-toggle {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle .icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .icon-moon {
  display: none;
  fill: currentColor;
  stroke: none;
}

/* Sun icon shown while in light mode; swap to the moon once dark is active. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: none;
  }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon {
    display: inline-flex;
  }
}
:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}
:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: inline-flex;
}

.tabs {
  max-width: 1100px;
  margin: 16px auto 0;
  padding: 0 20px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tab-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.88rem;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn[aria-selected="true"] {
  background: var(--tab-active-bg);
  color: var(--tab-active-text);
  border-color: var(--tab-active-bg);
}

.tab-count {
  opacity: 0.65;
  font-variant-numeric: tabular-nums;
}

main {
  max-width: 1100px;
  margin: 16px auto 60px;
  padding: 0 20px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel[hidden] {
  display: none;
}

.panel-meta {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
}

tbody tr {
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr.is-hidden {
  display: none;
}

td {
  padding: 14px 18px;
  vertical-align: top;
  font-size: 0.92rem;
}

td.col-version {
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

td.col-date {
  white-space: nowrap;
  color: var(--text-muted);
}

td.col-description :first-child {
  margin-top: 0;
}
td.col-description :last-child {
  margin-bottom: 0;
}
td.col-description ul {
  margin: 6px 0;
  padding-left: 1.1em;
}
td.col-description p {
  margin: 6px 0;
}
td.col-description mark {
  background: var(--accent-soft);
  color: inherit;
  border-radius: 3px;
}

.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 7px;
  border-radius: 999px;
  margin-top: 4px;
}

.badge-official {
  background: var(--badge-official-bg);
  color: var(--badge-official-text);
}

.badge-discovered {
  background: var(--badge-discovered-bg);
  color: var(--badge-discovered-text);
}

.empty-state,
.load-error {
  padding: 40px 18px;
  text-align: center;
  color: var(--text-muted);
}

.page-footer {
  max-width: 1100px;
  margin: 0 auto 40px;
  padding: 0 20px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.page-footer .badge {
  margin-top: 0;
  vertical-align: middle;
}

@media (max-width: 640px) {
  td, thead th {
    padding: 10px 12px;
  }
  .header-inner {
    align-items: stretch;
  }
  .search-wrap {
    max-width: none;
  }
}
