:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #172033;
  --muted: #697386;
  --line: #dce2ea;
  --line-dark: #bdc7d5;
  --accent: #0067c0;
  --accent-dark: #00549e;
  --accent-soft: #e7f2ff;
  --sidebar: #151a22;
  --sidebar-ink: #f6f8fb;
  --sidebar-muted: #aeb7c4;
  --green: #107c10;
  --green-soft: #e8f5e8;
  --amber: #986f00;
  --amber-soft: #fff4ce;
  --red: #c42b1c;
  --red-soft: #fdecea;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.11);
  --small-shadow: 0 7px 24px rgba(23, 32, 51, 0.08);
  --radius: 8px;
}

body.dark {
  --bg: #101317;
  --panel: #1b1f25;
  --panel-soft: #161a20;
  --ink: #f4f6f8;
  --muted: #a9b2bf;
  --line: #313844;
  --line-dark: #46505d;
  --accent: #60aef2;
  --accent-dark: #7cc0fa;
  --accent-soft: #18334d;
  --sidebar: #090b0e;
  --sidebar-ink: #f5f7fa;
  --sidebar-muted: #959eab;
  --green: #6ccb6c;
  --green-soft: #19361e;
  --amber: #f3c94e;
  --amber-soft: #3d3217;
  --red: #ff8277;
  --red-soft: #3d2020;
  --shadow: 0 18px 50px rgba(0,0,0,.35);
  --small-shadow: 0 7px 24px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI Variable", "Segoe UI", Inter, Arial, sans-serif;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
[hidden] { display: none !important; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent), transparent 55%);
  outline-offset: 2px;
}

/* Activation screen */
.access-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 30px;
  background:
    radial-gradient(circle at 15% 18%, rgba(255,255,255,.16), transparent 28%),
    radial-gradient(circle at 84% 80%, rgba(255,255,255,.11), transparent 24%),
    linear-gradient(135deg, #0078d4 0%, #0067b8 52%, #004b86 100%);
}
.activation-window {
  width: min(820px, 100%);
  color: #172033;
  background: #fff;
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 10px;
  box-shadow: 0 34px 110px rgba(0, 38, 78, .42);
  overflow: hidden;
}
.activation-top {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 58px;
  padding: 0 24px;
  border-bottom: 1px solid #e2e7ed;
  font-size: 13px;
  font-weight: 600;
}
.windows-logo {
  display: grid;
  grid-template-columns: 11px 11px;
  grid-template-rows: 11px 11px;
  gap: 2px;
  transform: skewY(-4deg);
}
.windows-logo span { background: #0078d4; }
.activation-body { padding: 52px 58px 48px; }
.activation-kicker {
  margin: 0 0 13px;
  color: #0067c0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
}
.activation-body h1 {
  margin: 0;
  color: #14213a;
  font-size: clamp(38px, 6vw, 62px);
  font-weight: 600;
  letter-spacing: -.045em;
  line-height: 1.04;
}
.activation-copy {
  max-width: 680px;
  margin: 23px 0 0;
  color: #617086;
  font-size: 15px;
  line-height: 1.7;
}
.access-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 38px;
}
.access-option,
.admin-activation {
  min-height: 180px;
  padding: 24px;
  color: #172033;
  background: #f8fafc;
  border: 1px solid #dbe2eb;
  border-radius: 8px;
}
.access-option {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: start;
  gap: 13px;
  text-align: left;
}
.access-option:hover {
  background: #fff;
  border-color: #8bbce8;
  box-shadow: 0 8px 25px rgba(0, 103, 192, .09);
}
.access-option strong,
.admin-activation strong {
  display: block;
  font-size: 15px;
}
.access-option small,
.admin-activation small {
  display: block;
  margin-top: 7px;
  color: #697386;
  font-size: 12px;
  line-height: 1.5;
}
.access-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #0067c0;
  background: #e7f2ff;
  border-radius: 6px;
  font-size: 18px;
}
.access-arrow {
  color: #0067c0;
  font-size: 26px;
  line-height: 1;
}
.admin-activation-heading {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 13px;
  align-items: start;
}
.activation-code {
  display: grid;
  gap: 7px;
  margin-top: 19px;
}
.activation-code > span {
  color: #4f5e73;
  font-size: 11px;
  font-weight: 600;
}
.activation-code > div {
  display: flex;
  gap: 8px;
}
.activation-code input {
  min-width: 0;
  height: 42px;
  flex: 1;
  padding: 0 12px;
  color: #172033;
  background: #fff;
  border: 1px solid #bcc8d6;
  border-radius: 5px;
}
.activation-error {
  min-height: 17px;
  margin: 8px 0 0;
  color: #c42b1c;
  font-size: 11px;
}
.activation-footer {
  display: flex;
  justify-content: space-between;
  padding: 17px 24px;
  color: #7b8798;
  background: #f7f9fb;
  border-top: 1px solid #e2e7ed;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .12em;
}

/* Base shell: same structure as original */
.app-shell {
  display: grid;
  grid-template-columns: 258px minmax(0, 1fr);
  grid-template-rows: 78px minmax(calc(100vh - 78px), auto);
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
}
.topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 78px;
  padding: 0 26px 0 24px;
  background: color-mix(in srgb, var(--panel), transparent 3%);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 6px;
  border: 2px solid var(--accent);
  gap: 3px;
  border-radius: 4px;
}
.brand-mark span { display: block; background: var(--accent); }
.brand-copy { display: grid; gap: 5px; line-height: 1; }
.brand-copy strong { font-size: 13px; letter-spacing: .12em; }
.brand-copy small { color: var(--muted); font-size: 11px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.access-badge {
  padding: 7px 10px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.button, .icon-button, .view-button, .text-button, .nav-item, .dialog-close {
  border: 0;
}
.button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}
.button-primary { color: white; background: var(--accent); }
.button-primary:hover { background: var(--accent-dark); }
.button-secondary {
  color: var(--ink);
  background: transparent;
  border-color: var(--line-dark);
}
.button-secondary:hover,
.button-quiet:hover { background: var(--panel-soft); }
.button-quiet {
  min-height: 42px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
}
.icon-button, .view-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.icon-button:hover, .view-button:hover, .view-button.active {
  background: var(--panel-soft);
  border-color: var(--line-dark);
}
.icon-button svg, .search-box svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar {
  grid-area: sidebar;
  position: sticky;
  top: 78px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: calc(100vh - 78px);
  padding: 29px 17px 20px;
  color: var(--sidebar-ink);
  background: var(--sidebar);
  overflow-y: auto;
}
.nav-label {
  margin: 0 12px 10px;
  color: var(--sidebar-muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.nav-label-spaced { margin-top: 31px; }
.nav-item {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  width: 100%;
  min-height: 43px;
  padding: 0 12px;
  color: var(--sidebar-muted);
  background: transparent;
  border-radius: 6px;
  text-align: left;
  font-size: 13px;
}
.nav-item:hover, .nav-item.active {
  color: var(--sidebar-ink);
  background: rgba(255,255,255,.08);
}
.nav-item.active { box-shadow: inset 3px 0 0 var(--accent); }
.nav-icon { font-size: 15px; }
.nav-count {
  min-width: 22px;
  padding: 2px 6px;
  color: var(--sidebar-muted);
  background: rgba(255,255,255,.08);
  border-radius: 999px;
  font-size: 10px;
  text-align: center;
}
.sidebar-footer {
  margin-top: 30px;
  padding: 16px 12px 0;
  border-top: 1px solid rgba(255,255,255,.12);
}
.archive-status { display: flex; align-items: center; gap: 10px; }
.archive-status div { display: grid; gap: 4px; }
.archive-status strong { font-size: 10px; letter-spacing: .05em; text-transform: uppercase; }
.archive-status small { color: var(--sidebar-muted); font-size: 10px; }
.status-dot {
  width: 8px;
  height: 8px;
  background: #75c57f;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(117,197,127,.13);
}
.text-button {
  margin-top: 16px;
  padding: 0;
  color: var(--sidebar-muted);
  background: none;
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.text-button:hover { color: var(--sidebar-ink); }
.main-content {
  grid-area: main;
  min-width: 0;
  padding: 50px clamp(24px, 5vw, 76px) 90px;
}

/* Original-style guide library, lightly modernised */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .55fr);
  align-items: end;
  gap: 50px;
  padding-bottom: 52px;
  border-bottom: 1px solid var(--line);
}
.eyebrow {
  margin: 0 0 15px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.hero h1,
.work-hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(48px, 6vw, 84px);
  font-weight: 600;
  letter-spacing: -.055em;
  line-height: .94;
}
.hero-copy {
  max-width: 610px;
  margin: 27px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}
.library-summary {
  min-height: 236px;
  padding: 24px;
  color: white;
  background:
    radial-gradient(circle at 80% 25%, rgba(255,255,255,.16), transparent 30%),
    linear-gradient(140deg, #0078d4, #005a9e);
  border-radius: 10px;
  box-shadow: 12px 12px 0 color-mix(in srgb, var(--line), transparent 5%);
}
.summary-top, .summary-bottom {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
}
.summary-number {
  margin: 39px 0 35px;
  font-size: 72px;
  font-weight: 600;
  line-height: 1;
}
.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 25px 0;
  border-bottom: 1px solid var(--line);
}
.search-box {
  display: flex;
  align-items: center;
  width: min(100%, 660px);
  height: 46px;
  padding: 0 13px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.search-box:focus-within {
  color: var(--ink);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 84%);
}
.search-box input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 12px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: none;
}
.search-box input::placeholder { color: var(--muted); }
.search-box kbd {
  padding: 4px 7px;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 9px;
}
.toolbar-right { display: flex; gap: 8px; }
.select-control {
  min-width: 166px;
  height: 42px;
  padding: 0 34px 0 12px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.archive-heading, .work-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding: 42px 0 20px;
}
.archive-heading .eyebrow, .work-heading .eyebrow { margin-bottom: 8px; }
.archive-heading h2, .work-heading h2 {
  margin: 0;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -.035em;
}
.archive-heading > p, .work-heading > p {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 10px;
}
.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.guide-grid.list-view { grid-template-columns: 1fr; }
.guide-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 328px;
  padding: 22px;
  color: inherit;
  background: var(--panel);
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  overflow: hidden;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.guide-card:hover {
  z-index: 2;
  background: var(--panel-soft);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}
.guide-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.record-code, .guide-date {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .06em;
}
.record-code { color: var(--accent); font-weight: 700; }
.guide-card h3 {
  margin: 37px 0 13px;
  font-size: clamp(24px, 2.05vw, 31px);
  font-weight: 600;
  letter-spacing: -.04em;
  line-height: 1.08;
}
.guide-summary {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}
.guide-card-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-top: auto;
  padding-top: 28px;
}
.tag-list, .reader-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 4px 7px;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 9px;
  text-transform: uppercase;
}
.guide-read-time { flex: 0 0 auto; color: var(--muted); font-size: 10px; white-space: nowrap; }
.guide-status {
  position: absolute;
  top: 51px;
  right: 22px;
  padding: 4px 7px;
  color: var(--amber);
  background: var(--amber-soft);
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}
.guide-grid.list-view .guide-card {
  display: grid;
  grid-template-columns: 130px minmax(220px,.8fr) 1.2fr auto;
  align-items: center;
  min-height: 136px;
  gap: 20px;
}
.guide-grid.list-view .guide-card h3 { margin: 0; font-size: 23px; }
.guide-grid.list-view .guide-card-top { display: grid; justify-content: start; gap: 8px; }
.guide-grid.list-view .guide-card-footer { align-items: center; margin: 0; padding: 0; }
.guide-grid.list-view .guide-status { position: static; width: max-content; margin-top: 8px; }
.empty-state {
  padding: 80px 20px;
  text-align: center;
  border: 1px dashed var(--line-dark);
  border-radius: 8px;
}
.empty-symbol { color: var(--line-dark); font-size: 52px; }
.empty-state h3 { margin: 13px 0 8px; font-size: 29px; font-weight: 600; }
.empty-state p { margin: 0 auto 25px; color: var(--muted); }

/* Ongoing work */
.work-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 40px;
  padding: 20px 0 45px;
  border-bottom: 1px solid var(--line);
}
.work-hero > div > p:last-child {
  max-width: 700px;
  margin: 25px 0 0;
  color: var(--muted);
  line-height: 1.7;
}
.work-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  margin-top: 25px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.work-stats > div {
  min-height: 110px;
  padding: 20px;
  border-right: 1px solid var(--line);
}
.work-stats > div:last-child { border-right: 0; }
.work-stats span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
}
.work-stats strong {
  display: block;
  margin-top: 15px;
  font-size: 35px;
}
.work-grid { display: grid; gap: 15px; }
.work-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 24px;
  padding: 24px;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  box-shadow: var(--small-shadow);
}
.work-card:hover { border-color: var(--line-dark); transform: translateY(-2px); }
.work-card-top {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 17px;
}
.work-card h3 { margin: 0 0 10px; font-size: 25px; letter-spacing: -.03em; }
.work-card p { margin: 0; color: var(--muted); line-height: 1.6; }
.work-card-side {
  display: grid;
  align-content: center;
  justify-items: end;
  gap: 12px;
  padding-left: 20px;
  border-left: 1px solid var(--line);
}
.issue-count {
  color: var(--muted);
  font-size: 11px;
}
.issue-count.no-open { color: var(--green); font-weight: 700; }
.project-state,
.issue-status {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}
.project-state.active { color: var(--accent); background: var(--accent-soft); }
.project-state.paused { color: var(--amber); background: var(--amber-soft); }
.project-state.complete { color: var(--green); background: var(--green-soft); }
.issue-status.identified { color: var(--red); background: var(--red-soft); }
.issue-status.hotfix { color: var(--amber); background: var(--amber-soft); }
.issue-status.resolved { color: var(--green); background: var(--green-soft); }

/* Dialogs and reader page: kept close to the original */
dialog {
  padding: 0;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line-dark);
  border-radius: 10px;
  box-shadow: 0 30px 100px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(10,14,20,.76); backdrop-filter: blur(4px); }
.reader-dialog, .work-dialog { width: min(1120px, calc(100vw - 34px)); max-height: calc(100vh - 34px); }
.reader { min-height: 80vh; }
.reader-header, .editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}
.record-id {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
}
.dialog-close {
  width: 38px;
  height: 38px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 24px;
  line-height: 1;
}
.dialog-close:hover { background: var(--panel-soft); }
.reader-title-block, .work-detail-title {
  padding: 60px clamp(28px,7vw,86px) 50px;
  border-bottom: 1px solid var(--line);
}
.reader-title-block h1, .work-detail-title h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(42px,6vw,72px);
  font-weight: 600;
  letter-spacing: -.055em;
  line-height: .98;
}
.reader-summary, .work-detail-title > p:not(.eyebrow) {
  max-width: 740px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}
.reader-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 24px;
  margin-top: 27px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.reader-layout {
  display: grid;
  grid-template-columns: 210px minmax(0,1fr);
  gap: clamp(30px,5vw,80px);
  padding: 55px clamp(28px,7vw,86px) 80px;
}
.reader-index { position: sticky; top: 0; align-self: start; padding-top: 6px; }
.reader-index > p, .preview-heading {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .12em;
}
.reader-index nav { display: grid; margin-top: 16px; border-left: 1px solid var(--line); }
.reader-index a {
  padding: 7px 0 7px 14px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-decoration: none;
}
.reader-index a:hover { color: var(--accent); }
.guide-content {
  min-width: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.78;
}
.guide-content > :first-child { margin-top: 0; }
.guide-content h1, .guide-content h2, .guide-content h3 {
  scroll-margin-top: 25px;
  font-weight: 600;
  letter-spacing: -.035em;
  line-height: 1.15;
}
.guide-content h1 { margin: 0 0 26px; font-size: 40px; }
.guide-content h2 {
  margin: 51px 0 17px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 29px;
}
.guide-content h3 { margin: 32px 0 11px; font-size: 22px; }
.guide-content p { margin: 0 0 18px; }
.guide-content ul, .guide-content ol { margin: 0 0 22px; padding-left: 24px; }
.guide-content li { margin: 7px 0; }
.guide-content blockquote {
  margin: 26px 0;
  padding: 17px 20px;
  color: var(--muted);
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
}
.guide-content code {
  padding: 2px 5px;
  color: var(--ink);
  background: var(--panel-soft);
  border-radius: 3px;
  font-family: Consolas, "Courier New", monospace;
  font-size: .9em;
}
.guide-content pre {
  margin: 25px 0;
  padding: 20px;
  color: #efeee9;
  background: #1b1f24;
  border-radius: 7px;
  overflow-x: auto;
}
.guide-content pre code { padding: 0; color: inherit; background: none; }
.guide-content a { color: var(--accent); }
.guide-content hr { margin: 38px 0; border: 0; border-top: 1px solid var(--line); }
.guide-content figure.guide-image {
  width: min(var(--guide-image-width, 100%), 100%);
  margin: 28px auto;
}
.guide-content img {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: 720px;
  margin: 0 auto;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--small-shadow);
}
.image-caption {
  margin: 8px 0 0 !important;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}
.reader-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-top: 1px solid var(--line);
}
.reader-footer > p { margin: 0; color: var(--muted); font-size: 10px; }
.reader-footer > div, .editor-footer > div { display: flex; gap: 9px; }

/* Guide editor */
.editor-dialog { width: min(1380px, calc(100vw - 28px)); max-height: calc(100vh - 28px); }
.editor { min-height: 88vh; }
.editor-header h2 { margin: 0; font-size: 33px; font-weight: 600; }
.editor-header .eyebrow { margin-bottom: 5px; }
.editor-grid {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(380px,.8fr);
  min-height: calc(88vh - 150px);
}
.editor-fields {
  display: grid;
  align-content: start;
  gap: 20px;
  padding: 30px;
  border-right: 1px solid var(--line);
}
.field { display: grid; gap: 8px; }
.field > span { font-size: 12px; font-weight: 700; }
.field small, .issue-editor-heading small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}
.field input, .field textarea, .field select {
  width: 100%;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}
.field input, .field select { height: 44px; padding: 0 12px; }
.field textarea { padding: 12px; line-height: 1.55; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 84%);
}
.field-row { display: grid; grid-template-columns: 1fr 180px; gap: 15px; }
.body-editor { min-height: 480px; font-family: Consolas, "Courier New", monospace; font-size: 13px; tab-size: 2; }
.formatting-tools {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.formatting-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.formatting-group + .formatting-group {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.formatting-label {
  min-width: 48px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.format-button {
  min-height: 36px;
  padding: 0 11px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
}
.format-button:hover {
  background: var(--panel-soft);
  border-color: var(--line-dark);
}
.image-width-control {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.image-width-control select {
  height: 36px;
  padding: 0 28px 0 9px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
}
.image-formatting-group .button {
  min-height: 36px;
}
.editor-preview {
  padding: 30px;
  background: var(--panel-soft);
  overflow: auto;
}
.preview-heading { display: flex; justify-content: space-between; margin-bottom: 25px; }
.editor-preview .guide-content {
  min-height: 500px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--small-shadow);
}
.editor-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.featured-toggle { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; }
.featured-toggle input { accent-color: var(--accent); }

/* Work details/editor */
.work-detail { min-height: 70vh; }
.issue-section { padding: 45px clamp(28px,7vw,86px) 70px; }
.issue-section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 20px;
}
.issue-section-heading h2 { margin: 0; font-size: 30px; }
.issue-section-heading .eyebrow { margin-bottom: 7px; }
.issue-section-heading > span { color: var(--muted); font-size: 11px; }
.issue-list { display: grid; gap: 12px; }
.issue-row {
  padding: 18px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.issue-row-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
}
.issue-row h3 { margin: 0; font-size: 16px; }
.issue-row p { margin: 10px 0 0; color: var(--muted); line-height: 1.6; }
.issue-row time { display: block; margin-top: 12px; color: var(--muted); font-size: 9px; }
.no-issues-panel {
  padding: 35px;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid color-mix(in srgb, var(--green), transparent 65%);
  border-radius: 8px;
  text-align: center;
  font-weight: 700;
}
.work-editor-dialog { width: min(860px, calc(100vw - 28px)); max-height: calc(100vh - 28px); }
.work-editor-body { display: grid; gap: 20px; padding: 28px; }
.issue-editor-section {
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.issue-editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 15px;
}
.issue-editor-heading > div { display: grid; gap: 4px; }
.issue-editor-card {
  position: relative;
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 16px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.issue-editor-card .field-row { grid-template-columns: 1fr 220px; }
.remove-issue {
  position: absolute;
  top: 11px;
  right: 11px;
  width: 30px;
  height: 30px;
  color: var(--red);
  background: transparent;
  border: 0;
  border-radius: 5px;
}
.remove-issue:hover { background: var(--red-soft); }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  max-width: min(360px, calc(100vw - 48px));
  padding: 13px 16px;
  color: white;
  background: #20252b;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  box-shadow: var(--shadow);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(15px);
  transition: .2s ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1100px) {
  .guide-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .guide-grid.list-view .guide-card { grid-template-columns: 110px minmax(200px,.8fr) 1fr; }
  .guide-grid.list-view .guide-card-footer { display: none; }
  .editor-grid { grid-template-columns: 1fr; }
  .editor-fields { border-right: 0; }
  .editor-preview { border-top: 1px solid var(--line); }
}
@media (max-width: 820px) {
  .access-options { grid-template-columns: 1fr; }
  .activation-body { padding: 42px 30px; }
  .app-shell { display: block; }
  .topbar { position: sticky; height: 68px; padding: 0 15px; }
  .brand-copy small, .desktop-only, .access-badge { display: none; }
  .sidebar { position: static; display: block; height: auto; padding: 10px; overflow-x: auto; }
  .sidebar nav { display: flex; gap: 7px; }
  .nav-label, .sidebar-footer, .nav-label-spaced { display: none; }
  #categoryNav { display: flex; gap: 7px; }
  .nav-item { display: flex; width: auto; min-width: max-content; gap: 8px; padding: 0 12px; }
  .nav-item.active { box-shadow: inset 0 -3px 0 var(--accent); }
  .main-content { padding: 35px 18px 70px; }
  .hero { grid-template-columns: 1fr; gap: 35px; }
  .library-summary { min-height: 180px; }
  .summary-number { margin: 25px 0; font-size: 60px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-right { justify-content: flex-end; }
  .select-control { margin-right: auto; }
  .reader-layout { grid-template-columns: 1fr; }
  .reader-index { position: static; }
  .reader-index nav { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .work-stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .work-stats > div:nth-child(2) { border-right: 0; }
  .work-stats > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 620px) {
  .access-screen { padding: 0; background: #fff; }
  .activation-window { min-height: 100vh; border: 0; border-radius: 0; box-shadow: none; }
  .activation-body { padding: 36px 22px; }
  .activation-body h1 { font-size: 40px; }
  .activation-code > div { flex-direction: column; }
  .topbar-actions { gap: 5px; }
  .topbar .icon-button, .topbar .button-quiet { display: none; }
  .button { padding: 0 12px; }
  .hero h1, .work-hero h1 { font-size: 50px; }
  .hero-copy { font-size: 14px; }
  .guide-grid { grid-template-columns: 1fr; }
  .guide-card { min-height: 290px; }
  .guide-grid.list-view .guide-card { display: flex; min-height: 260px; gap: 0; }
  .guide-grid.list-view .guide-card h3 { margin: 28px 0 12px; }
  .guide-grid.list-view .guide-card-footer { display: flex; margin-top: auto; }
  .archive-heading, .work-heading, .work-hero { align-items: flex-start; flex-direction: column; gap: 12px; }
  .search-box kbd, #gridViewButton, #listViewButton { display: none; }
  .select-control { width: 100%; margin: 0; }
  .field-row, .issue-editor-card .field-row { grid-template-columns: 1fr; }
  .editor-fields, .editor-preview { padding: 20px; }
  .formatting-group { align-items: stretch; }
  .formatting-label { width: 100%; }
  .image-width-control { justify-content: space-between; }
  .reader-title-block, .work-detail-title { padding-top: 40px; }
  .reader-layout { padding-top: 35px; }
  .reader-footer, .editor-footer { align-items: stretch; flex-direction: column; }
  .reader-footer > div, .editor-footer > div { width: 100%; }
  .reader-footer .button, .editor-footer .button { flex: 1; }
  .work-card { grid-template-columns: 1fr; }
  .work-card-side { justify-items: start; padding: 17px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .work-stats { grid-template-columns: 1fr 1fr; }
}


/* Server-backed V6 additions */
.secured-access-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.access-code-card {
  height: 100%;
}

.access-code-card .activation-code {
  margin-top: auto;
}

@media (max-width: 760px) {
  .secured-access-options {
    grid-template-columns: 1fr;
  }
}
