:root {
  color-scheme: light;
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #666;
  --border: #ccc;
  --accent: #0b5fa5;
  --input-bg: #ffffff;
  --notice-bg: #eef4fb;
  --notice-border: #cfe0f2;
  --error-bg: #fde8e8;
  --error-border: #b00020;
  --comment-private-bg: #fff8e6;
  --comment-private-border: #e6d28a;
  --code-bg: #f4f4f4;
  --tag-required-bg: #fde8e8;
  --tag-required-border: #b00020;
  --tag-required-fg: #7d0017;
  --tag-optional-bg: #f4f4f4;
  --tag-optional-border: #ccc;
  --tag-visible-bg: #eef4fb;
  --tag-visible-border: #cfe0f2;
  --tag-visible-fg: #24507d;
  --tag-private-bg: #eef5ef;
  --tag-private-border: #c8dbc9;
  --tag-private-fg: #285c32;
  --description-bg: #f8fafc;
  --metadata-label-bg: #f4f4f4;
}

/* Dark values, shared by the OS-preference fallback and the explicit choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #16181c;
    --fg: #e6e6e6;
    --muted: #9aa0a6;
    --border: #3a3f47;
    --accent: #4ea1e6;
    --input-bg: #1e2126;
    --notice-bg: #14263a;
    --notice-border: #24507d;
    --error-bg: #3a1b1e;
    --error-border: #e0707a;
    --comment-private-bg: #2e2a16;
    --comment-private-border: #6b5f2a;
    --code-bg: #22262c;
    --tag-required-bg: #3a1b1e;
    --tag-required-border: #e0707a;
    --tag-required-fg: #ffb1b7;
    --tag-optional-bg: #22262c;
    --tag-optional-border: #3a3f47;
    --tag-visible-bg: #14263a;
    --tag-visible-border: #24507d;
    --tag-visible-fg: #9acbff;
    --tag-private-bg: #193021;
    --tag-private-border: #356a43;
    --tag-private-fg: #a9ddae;
    --description-bg: #1e2126;
    --metadata-label-bg: #22262c;
  }
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16181c;
  --fg: #e6e6e6;
  --muted: #9aa0a6;
  --border: #3a3f47;
  --accent: #4ea1e6;
  --input-bg: #1e2126;
  --notice-bg: #14263a;
  --notice-border: #24507d;
  --error-bg: #3a1b1e;
  --error-border: #e0707a;
  --comment-private-bg: #2e2a16;
  --comment-private-border: #6b5f2a;
  --code-bg: #22262c;
  --tag-required-bg: #3a1b1e;
  --tag-required-border: #e0707a;
  --tag-required-fg: #ffb1b7;
  --tag-optional-bg: #22262c;
  --tag-optional-border: #3a3f47;
  --tag-visible-bg: #14263a;
  --tag-visible-border: #24507d;
  --tag-visible-fg: #9acbff;
  --tag-private-bg: #193021;
  --tag-private-border: #356a43;
  --tag-private-fg: #a9ddae;
  --description-bg: #1e2126;
  --metadata-label-bg: #22262c;
}

body {
  font-family: system-ui, -apple-system, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 2rem;
}

body.admin-list-page {
  max-width: 1500px;
}

.brand {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.4rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--fg);
}

.brand-logo {
  width: 2.75rem;
  height: 2.75rem;
  flex: none;
}

.brand-logo--dark {
  display: none;
}

/* Use the gold original only when dark mode is active. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo--light {
    display: none;
  }

  :root:not([data-theme="light"]) .brand-logo--dark {
    display: block;
  }
}

[data-theme="dark"] .brand-logo--light {
  display: none;
}

[data-theme="dark"] .brand-logo--dark {
  display: block;
}

.admin-user {
  font-size: 0.85rem;
  color: var(--muted);
}

header nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.nav-links {
  display: flex;
  gap: 1rem;
}

.theme-picker {
  font-size: 0.85rem;
  color: var(--muted);
}

.theme-picker a {
  margin-left: 0.5rem;
}

.theme-picker a.active {
  font-weight: 700;
  text-decoration: none;
  cursor: default;
}

a { color: var(--accent); }

h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; margin-top: 1.5rem; }

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.form-field > label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
}

.field-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.field-tag {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.35;
  padding: 0.08rem 0.45rem;
  white-space: nowrap;
}

.field-tag.required {
  background: var(--tag-required-bg);
  border-color: var(--tag-required-border);
  color: var(--tag-required-fg);
}

.field-tag.optional {
  background: var(--tag-optional-bg);
  border-color: var(--tag-optional-border);
}

.field-tag.visible {
  background: var(--tag-visible-bg);
  border-color: var(--tag-visible-border);
  color: var(--tag-visible-fg);
}

.field-tag.private {
  background: var(--tag-private-bg);
  border-color: var(--tag-private-border);
  color: var(--tag-private-fg);
}

input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--input-bg);
  color: var(--fg);
  font: inherit;
  box-sizing: border-box;
}

/* Keep long-form typing at a comfortable reading measure even on wide pages. */
textarea {
  max-width: 70ch;
}

.description-input {
  max-width: none;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 3px;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

.button-secondary {
  border-color: var(--border);
  background: var(--input-bg);
  color: var(--fg);
}

.button-danger {
  border-color: var(--error-border);
  background: var(--error-bg);
  color: var(--tag-required-fg);
}

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

.actions form {
  margin: 0;
}

.admin-bug-content {
  max-height: min(65vh, 48rem);
  overflow-y: auto;
  padding-right: 0.8rem;
  margin-bottom: 1.5rem;
}

/* Inline radio labels (e.g. comment visibility) rather than stacked blocks. */
label input[type="radio"] {
  margin-right: 0.35rem;
}
label:has(> input[type="radio"]) {
  display: inline-block;
  font-weight: normal;
  margin-right: 1rem;
}

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

th, td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
}

dt { font-weight: 600; color: var(--muted); }
dd { margin: 0; }

.description { white-space: pre-wrap; }

.bug-description {
  margin: 0;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 3px;
  background: var(--description-bg);
}

.bug-metadata {
  max-width: 48rem;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.bug-metadata dt,
.bug-metadata dd {
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid var(--border);
}

.bug-metadata dt {
  display: flex;
  align-items: center;
  background: var(--metadata-label-bg);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bug-metadata dd {
  padding-left: 0.9rem;
  border-left: 1px solid var(--border);
}

.bug-metadata dt:last-of-type,
.bug-metadata dd:last-of-type {
  border-bottom: 0;
}

.errors {
  border: 1px solid var(--error-border);
  background: var(--error-bg);
  padding: 0.5rem 1rem;
  border-radius: 3px;
}

.notice {
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  padding: 0.5rem 1rem;
  border-radius: 3px;
}

.comments {
  list-style: none;
  padding: 0;
}

.comment {
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.5rem 0.8rem;
  margin-bottom: 0.75rem;
}

.comment.private {
  background: var(--comment-private-bg);
  border-color: var(--comment-private-border);
}

.comment-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 0.4rem;
}

.comment-meta .visibility {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.comment-body :first-child { margin-top: 0; }
.comment-body :last-child { margin-bottom: 0; }
.comment-body pre {
  background: var(--code-bg);
  padding: 0.5rem;
  border-radius: 3px;
  overflow-x: auto;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  margin-top: 1.5rem;
}

.pagination a,
.pagination span {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  text-decoration: none;
  min-width: 1.2rem;
  text-align: center;
}

/* Clickable page links: accent color and a filled hover/focus state so they
   read as interactive rather than as static boxes. */
.pagination a {
  color: var(--accent);
  border-color: var(--accent);
  cursor: pointer;
}

.pagination a:hover,
.pagination a:focus {
  background: var(--accent);
  color: #fff;
}

.pagination .current {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

.pagination .disabled,
.pagination .ellipsis {
  color: var(--muted);
  border-color: transparent;
}

th a.sort {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

th a.sort:hover { text-decoration: underline; }
th a.sort.active { color: var(--accent); }
th a.sort .arrow { font-size: 0.75em; }

.submitted-at {
  white-space: nowrap;
}

.status-badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge.published {
  background: var(--tag-private-bg);
  border-color: var(--tag-private-border);
  color: var(--tag-private-fg);
}

.status-badge.private {
  background: var(--comment-private-bg);
  border-color: var(--comment-private-border);
}

form.search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

form.search input[type="search"] {
  flex: 1;
  min-width: 12rem;
  max-width: 30rem;
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--input-bg);
  color: var(--fg);
  font: inherit;
}

form.search select {
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--input-bg);
  color: var(--fg);
  font: inherit;
}

.search-summary {
  color: var(--muted);
  margin-top: 0;
}

.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.75rem;
  max-width: 48rem;
}

.stats-summary div {
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--metadata-label-bg);
}

.stats-summary dt {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stats-summary dd {
  margin-top: 0.2rem;
  color: var(--fg);
  font-size: 1.5rem;
  font-weight: 700;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0.75rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.chart-swatch {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  margin-right: 0.3rem;
  border-radius: 2px;
  vertical-align: -0.1rem;
}

.chart-swatch.submitted,
.chart-bar.submitted {
  background: var(--accent);
}

.chart-swatch.published,
.chart-bar.published {
  background: var(--tag-private-fg);
}

.stats-chart-scroll {
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.stats-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(3.5rem, 1fr));
  gap: 0.5rem;
  min-width: 44rem;
  max-width: 60rem;
}

.chart-period {
  min-width: 0;
  text-align: center;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.18rem;
  height: 12rem;
  border-bottom: 1px solid var(--border);
}

.chart-bar {
  width: min(1.1rem, 35%);
  min-height: 0;
  border-radius: 2px 2px 0 0;
}

.chart-label {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
  white-space: pre-line;
}

.stats-table {
  max-width: 40rem;
  margin-top: 1.5rem;
}

.admin-menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.75rem;
  max-width: 48rem;
}

.admin-menu a {
  display: block;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--metadata-label-bg);
  color: var(--fg);
  text-decoration: none;
}

.admin-menu a:hover,
.admin-menu a:focus {
  border-color: var(--accent);
}

.admin-menu strong,
.admin-menu span {
  display: block;
}

.admin-menu span {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}
