:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border: #dce3ec;
  --border-strong: #cbd5e1;
  --accent: #3b6ea5;
  --accent-soft: rgba(59, 110, 165, 0.14);
  --shadow-sm: 0 0.125rem 0.375rem rgba(15, 23, 42, 0.05);
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e14;
  --surface: #121721;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #222b3b;
  --border-strong: #2e3a4f;
  --accent: #5b8cc4;
  --accent-soft: rgba(91, 140, 196, 0.16);
  --shadow-sm: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.35);
}

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

/* Fluid root size: exactly 16px at the 1280px-wide reference viewport (e.g. a 4K TV at 300% scaling) and below,
   scaling every rem-based size up proportionally on larger viewports (bound by width or height, so the whole
   layout keeps the reference proportions). */
html {
  font-size: max(16px, min(1.25vw, 2.6vh));
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: 72.5rem;
  margin: 0 auto;
  padding: 1.35rem 2rem 4.5rem;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 0.0625rem solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.1875rem;
  padding: 0.3125rem 0.4375rem;
  border-radius: 0.5rem;
  background: var(--surface);
  border: 0.0625rem solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  font-family: var(--mono);
  font-weight: 800;
  font-size: 0.8rem;
  text-decoration: none;
}

.brand-icon span {
  display: inline-block;
  padding: 0.125rem 0.3125rem;
  border-radius: 0.25rem;
  background: var(--bg);
  color: var(--text);
}

.brand-icon span:first-child {
  background: var(--accent);
  color: #fff;
}

.brand-title-row {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}

.brand-heading {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.brand-heading a {
  color: inherit;
  text-decoration: none;
}

.brand-author {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: normal;
  margin-left: 0.15rem;
}

.version-badge {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.1rem 0.45rem;
  border-radius: 0.25rem;
  background: var(--surface);
  border: 0.0625rem solid var(--border);
}

.brand-text p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.home-link {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.4rem 0.7rem;
  border-radius: 0.375rem;
  border: 0.0625rem solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.home-link:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--surface);
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin: 0 0 0.3rem;
  font-size: 1.6rem;
  font-weight: 800;
}

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

.entry {
  background: var(--surface);
  border: 0.0625rem solid var(--border);
  border-radius: 0.75rem;
  padding: 1.35rem 1.6rem;
  margin-bottom: 1.25rem;
}

.entry p,
.entry ul {
  margin: 0.5rem 0;
  font-size: 0.92rem;
}

.entry ul {
  padding-left: 1.3rem;
}

.entry li {
  margin-bottom: 0.35rem;
}

code {
  font-family: var(--mono);
  font-size: 0.82rem;
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  background: var(--bg);
  border: 0.0625rem solid var(--border);
}

.controls-dock {
  position: fixed;
  bottom: 1rem;
  right: 1.25rem;
  z-index: 50;
  display: flex;
  gap: 0.5rem;
}

.pill-group {
  display: inline-flex;
  background: var(--surface);
  border: 0.0625rem solid var(--border);
  border-radius: 624.9375rem;
  padding: 0.2rem;
}

.pill-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.25rem 0.65rem;
  border-radius: 624.9375rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.pill-btn.active {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

/* Match compact viewport padding from index.html so header alignment never shifts */
@media (max-height: 820px), (min-width: 1281px) and (min-height: 616px) and (min-aspect-ratio: 1280/820) {
  .container {
    padding: 1rem 1.5rem 4.5rem;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 1.15rem 1rem 2rem;
  }
  .controls-dock {
    position: static;
    margin-top: 1.5rem;
    justify-content: center;
  }
}
