:root {
  color-scheme: light dark;
  --maxw: 880px;

  /* ---- light tokens (default) ---- */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --header-bg: rgba(244, 245, 247, .82);
  --ink: #1b2430;
  --muted: #5d6b7a;
  --hairline: rgba(15, 23, 42, .07);
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 18px rgba(16, 24, 40, .06);
  --shadow-hover: 0 2px 4px rgba(16, 24, 40, .08), 0 12px 28px rgba(16, 24, 40, .11);

  --accent: #0c52a0;          /* Integrity brand blue — change to re-brand */
  --focus: rgba(12, 82, 160, .30);
  --target: rgba(12, 82, 160, .10);

  --b-summary-bg: rgba(12, 82, 160, .12); --b-summary-fg: #0c52a0;
  --b-improve-bg: rgba(22, 163, 74, .12);  --b-improve-fg: #157f3b;
  --b-fix-bg:     rgba(217, 119, 6, .15);  --b-fix-fg:     #b45309;
  --b-admin-bg:   rgba(100, 116, 139, .15);--b-admin-fg:   #475569;
  --b-migrate-bg: rgba(124, 58, 237, .14); --b-migrate-fg: #6d28d9;
  --b-info-bg:    rgba(37, 99, 235, .12);  --b-info-fg:    #1d4ed8;
  --b-neutral-bg: rgba(100, 116, 139, .12);--b-neutral-fg: #475569;
}

/* ---- dark tokens: auto (OS) unless the user forced light ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e131a;
    --surface: #161d27;
    --surface-2: #1d2632;
    --header-bg: rgba(14, 19, 26, .82);
    --ink: #e7ebf0;
    --muted: #93a1b2;
    --hairline: rgba(255, 255, 255, .08);
    --shadow: 0 1px 2px rgba(0, 0, 0, .40), 0 8px 22px rgba(0, 0, 0, .38);
    --shadow-hover: 0 2px 6px rgba(0, 0, 0, .50), 0 16px 34px rgba(0, 0, 0, .46);

    --accent: #3d9be9;
    --focus: rgba(61, 155, 233, .34);
    --target: rgba(61, 155, 233, .13);

    --b-summary-bg: rgba(61, 155, 233, .18); --b-summary-fg: #9fd0f7;
    --b-improve-bg: rgba(34, 197, 94, .16);  --b-improve-fg: #5ad07f;
    --b-fix-bg:     rgba(245, 158, 11, .16); --b-fix-fg:     #fbbf24;
    --b-admin-bg:   rgba(148, 163, 184, .16);--b-admin-fg:   #cbd5e1;
    --b-migrate-bg: rgba(167, 139, 250, .20);--b-migrate-fg: #c9b8fd;
    --b-info-bg:    rgba(96, 165, 250, .16); --b-info-fg:    #93c5fd;
    --b-neutral-bg: rgba(148, 163, 184, .14);--b-neutral-fg: #cbd5e1;
  }
}

/* ---- dark tokens: forced via the toggle (mirrors the block above) ---- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e131a;
  --surface: #161d27;
  --surface-2: #1d2632;
  --header-bg: rgba(14, 19, 26, .82);
  --ink: #e7ebf0;
  --muted: #93a1b2;
  --hairline: rgba(255, 255, 255, .08);
  --shadow: 0 1px 2px rgba(0, 0, 0, .40), 0 8px 22px rgba(0, 0, 0, .38);
  --shadow-hover: 0 2px 6px rgba(0, 0, 0, .50), 0 16px 34px rgba(0, 0, 0, .46);

  --accent: #3d9be9;
  --focus: rgba(61, 155, 233, .34);
  --target: rgba(61, 155, 233, .13);

  --b-summary-bg: rgba(61, 155, 233, .18); --b-summary-fg: #9fd0f7;
  --b-improve-bg: rgba(34, 197, 94, .16);  --b-improve-fg: #5ad07f;
  --b-fix-bg:     rgba(245, 158, 11, .16); --b-fix-fg:     #fbbf24;
  --b-admin-bg:   rgba(148, 163, 184, .16);--b-admin-fg:   #cbd5e1;
  --b-migrate-bg: rgba(167, 139, 250, .20);--b-migrate-fg: #c9b8fd;
  --b-info-bg:    rgba(96, 165, 250, .16); --b-info-fg:    #93c5fd;
  --b-neutral-bg: rgba(148, 163, 184, .14);--b-neutral-fg: #cbd5e1;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--hairline);
  padding: 18px 0 15px;
}
.site-header h1 { font-size: 1.4rem; margin: 0 0 13px; letter-spacing: -.02em; font-weight: 700; }

.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

#search {
  flex: 1 1 320px;
  min-width: 200px;
  padding: 11px 15px;
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: box-shadow .18s ease, border-color .18s ease;
}
#search::placeholder { color: var(--muted); }
#search:focus { outline: none; border-color: transparent; box-shadow: 0 0 0 3px var(--focus), var(--shadow); }

.tech-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .9rem; color: var(--muted); user-select: none; cursor: pointer; white-space: nowrap;
}
.tech-toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: 0 0 auto;
  border: 1px solid var(--hairline); border-radius: 12px;
  background: var(--surface); color: var(--muted);
  box-shadow: var(--shadow); cursor: pointer;
  transition: color .15s ease, box-shadow .18s ease, transform .1s ease;
}
.icon-btn:hover { color: var(--accent); box-shadow: var(--shadow-hover); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.icon-btn svg { width: 19px; height: 19px; }

.result-count { margin-top: 10px; font-size: .8rem; color: var(--muted); }

main { padding: 26px 0 64px; }

.commit {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px 22px 9px;
  margin: 0 0 14px;
  scroll-margin-top: 132px;
  transition: box-shadow .2s ease, background-color .35s ease;
}
.commit:hover { box-shadow: var(--shadow-hover); }
.commit.target {
  background: var(--target);
  box-shadow: inset 3px 0 0 0 var(--accent), var(--shadow-hover);
}

.commit-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.commit-head .ver { font-weight: 700; font-size: 1.06rem; letter-spacing: -.01em; }
.commit-head .meta { color: var(--muted); font-size: .84rem; }
.commit-head .permalink {
  margin-left: auto; color: var(--muted); text-decoration: none;
  font-weight: 700; opacity: 0; transition: opacity .15s ease, color .15s ease; padding: 0 4px;
}
.commit:hover .permalink, .permalink:focus { opacity: 1; }
.permalink:hover { color: var(--accent); }

.commit-body { padding-bottom: 9px; }
.sec { margin: 11px 0; }

.badge {
  display: inline-block;
  font-size: .67rem; font-weight: 700; letter-spacing: .045em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px; margin: 0 0 7px;
  background: var(--b-neutral-bg); color: var(--b-neutral-fg);
}
.badge-sm { font-size: .62rem; padding: 2px 9px; }
.b-summary  { background: var(--b-summary-bg);  color: var(--b-summary-fg); }
.b-improve  { background: var(--b-improve-bg);  color: var(--b-improve-fg); }
.b-fix      { background: var(--b-fix-bg);      color: var(--b-fix-fg); }
.b-admin    { background: var(--b-admin-bg);    color: var(--b-admin-fg); }
.b-migrate  { background: var(--b-migrate-bg);  color: var(--b-migrate-fg); }
.b-info     { background: var(--b-info-bg);     color: var(--b-info-fg); }
.b-neutral  { background: var(--b-neutral-bg);  color: var(--b-neutral-fg); }

/* Indented sub-sections under a section (e.g. a Summary's own Improvements / Bug Fixes). */
.subsec { margin: 8px 0 10px 4px; padding-left: 14px; border-left: 2px solid var(--hairline); }
.subsec ul { margin-top: 2px; }

.commit-body ul { margin: 4px 0; padding-left: 22px; }
.commit-body li { margin: 3px 0; }
.commit-body ul ul { margin: 2px 0; }
.commit-body .para { margin: 7px 0; }

.placeholder { color: var(--muted); font-style: italic; margin: 8px 0 12px; }

/* Friendly text + the all-internal placeholder swap by mode. */
.tech-only { display: none; }
body.show-technical .tech-only { display: block; }
body.show-technical .friendly-only { display: none; }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 1.05rem; }

.site-footer { border-top: 1px solid var(--hairline); padding: 18px 0 40px; color: var(--muted); font-size: .8rem; }

@media (max-width: 560px) {
  .commit-head .permalink { opacity: 1; }
  .site-header h1 { font-size: 1.2rem; }
}
