/* =========================================================
   Gemini Workshop OS — Salary Theory Document
   Light / Google-inspired / Academic reading theme
   ========================================================= */

:root {
  /* Surfaces */
  --surface-0: #ffffff;
  --surface-1: #f8f9fa;
  --surface-2: #f1f3f4;
  --surface-3: #e8eaed;

  /* Ink */
  --ink-1: #202124;
  --ink-2: #3c4043;
  --ink-3: #5f6368;
  --ink-4: #80868b;
  --ink-5: #bdc1c6;

  /* Lines */
  --line-1: #e8eaed;
  --line-2: #dadce0;

  /* Brand + semantic */
  --brand: #1a73e8;
  --brand-hover: #1557b0;
  --brand-soft: #e8f0fe;
  --brand-soft-2: #d2e3fc;

  --green: #188038;
  --green-soft: #e6f4ea;
  --yellow: #b06000;
  --yellow-soft: #fef7e0;
  --red: #c5221f;
  --red-soft: #fce8e6;
  --purple: #673ab7;
  --purple-soft: #e9e1f7;

  /* Shadows */
  --shadow-1: 0 1px 2px rgba(60,64,67,.08), 0 1px 3px rgba(60,64,67,.06);
  --shadow-2: 0 1px 3px rgba(60,64,67,.12), 0 4px 8px rgba(60,64,67,.08);
  --shadow-3: 0 4px 12px rgba(60,64,67,.14), 0 10px 24px rgba(60,64,67,.10);

  /* Layout */
  --topbar-h: 56px;
  --tabbar-h: 48px;
  --sidebar-w: 280px;
  --content-max: 860px;

  /* Radii */
  --r-1: 4px;
  --r-2: 8px;
  --r-3: 12px;
  --r-pill: 999px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Roboto', 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-1);
  background: var(--surface-1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* =========================================================
   TOP BAR
   ========================================================= */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--surface-0);
  border-bottom: 1px solid var(--line-1);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
  gap: 20px;
}

.brand-mark { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink-1); }

.brand-logo {
  width: 32px; height: 32px; border-radius: var(--r-2);
  background: linear-gradient(135deg, var(--brand) 0%, #4285f4 100%);
  display: grid; place-items: center;
  color: white; font-family: 'Roboto Serif', serif;
  font-weight: 700; font-size: 16px;
  box-shadow: var(--shadow-1);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text .name { font-family: 'Roboto Serif', serif; font-weight: 500; font-size: 16px; color: var(--ink-1); }
.brand-text .sub { font-size: 11px; color: var(--ink-4); letter-spacing: .02em; }

.topbar-spacer { flex: 1; }
.topbar-meta { display: flex; align-items: center; gap: 18px; font-size: 13px; color: var(--ink-3); }
.topbar-meta .chip { padding: 4px 10px; border-radius: var(--r-pill); background: var(--surface-2); font-size: 12px; color: var(--ink-2); }
.topbar-meta .chip.version { background: var(--brand-soft); color: var(--brand); font-weight: 500; }

/* ---------- Search box ---------- */
.topbar-search {
  position: relative;
  width: 320px;
  max-width: 40vw;
}
.topbar-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--line-1);
  border-radius: var(--r-pill);
  background: var(--surface-1);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-1);
  transition: all .15s ease;
  outline: none;
}
.topbar-search input:focus {
  background: var(--surface-0);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.topbar-search .search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--ink-4);
  pointer-events: none;
}
.topbar-search input::placeholder { color: var(--ink-4); }

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-3);
  max-height: 60vh;
  overflow-y: auto;
  display: none;
  z-index: 200;
}
.search-results.show { display: block; }
.search-result {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-1);
  cursor: pointer;
  transition: background .12s ease;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover, .search-result.active { background: var(--brand-soft); }
.search-result-title { font-size: 14px; font-weight: 500; color: var(--ink-1); margin-bottom: 2px; }
.search-result-path { font-size: 12px; color: var(--ink-4); font-family: 'Roboto Mono', monospace; }
.search-result-empty { padding: 16px; text-align: center; color: var(--ink-4); font-size: 13px; }

/* =========================================================
   TAB BAR
   ========================================================= */
.tabbar {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0;
  height: var(--tabbar-h);
  background: var(--surface-0);
  border-bottom: 1px solid var(--line-1);
  display: flex;
  align-items: stretch;
  padding: 0 24px;
  z-index: 99;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }

.tab {
  display: flex; align-items: center; gap: 8px;
  padding: 0 18px;
  font-size: 14px; font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  border: none; background: transparent;
  position: relative;
  white-space: nowrap;
  transition: color .15s ease;
  font-family: inherit;
}

.tab:hover { color: var(--ink-1); background: var(--surface-1); }
.tab.active { color: var(--brand); }
.tab.active::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: 0;
  height: 3px;
  background: var(--brand);
  border-radius: 3px 3px 0 0;
}

.tab .tab-num {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-4);
  font-weight: 600;
  letter-spacing: .02em;
}

.tab.active .tab-num { background: var(--brand-soft); color: var(--brand); }

/* =========================================================
   LAYOUT
   ========================================================= */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  margin-top: calc(var(--topbar-h) + var(--tabbar-h));
  min-height: calc(100vh - var(--topbar-h) - var(--tabbar-h));
}

.sidebar {
  background: var(--surface-0);
  border-right: 1px solid var(--line-1);
  padding: 24px 0;
  position: sticky;
  top: calc(var(--topbar-h) + var(--tabbar-h));
  height: calc(100vh - var(--topbar-h) - var(--tabbar-h));
  overflow-y: auto;
}

.sidebar-section { padding: 0 12px; margin-bottom: 18px; }
.sidebar-section:last-child { margin-bottom: 0; }

.sidebar-heading {
  font-size: 11px; font-weight: 600;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 8px 12px;
  margin-bottom: 4px;
}

.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-1);
  font-size: 14px;
  color: var(--ink-2);
  text-decoration: none;
  cursor: pointer;
  border: none; background: transparent;
  width: 100%; text-align: left;
  font-family: inherit;
  transition: background .15s ease;
  line-height: 1.4;
}

.sidebar-link:hover { background: var(--surface-2); color: var(--ink-1); }
.sidebar-link.active { background: var(--brand-soft); color: var(--brand); font-weight: 500; }

.sidebar-link .dot-num {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
  color: var(--ink-3);
  font-family: 'Roboto Mono', monospace;
}

.sidebar-link.active .dot-num { background: var(--brand); color: white; }

.sidebar-link .link-body { flex: 1; min-width: 0; }
.sidebar-link .link-sub {
  font-size: 12px;
  color: var(--ink-4);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-link.active .link-sub { color: var(--brand); opacity: .75; }

/* =========================================================
   CONTENT
   ========================================================= */
.content { padding: 32px 48px 96px; max-width: 100%; }
.content-inner { max-width: var(--content-max); margin: 0 auto; }

.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  color: var(--ink-3);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.breadcrumb a {
  color: var(--ink-3);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: var(--r-1);
  transition: background .15s ease;
  cursor: pointer;
}
.breadcrumb a:hover { background: var(--surface-2); color: var(--brand); }
.breadcrumb .sep { color: var(--ink-5); font-size: 14px; line-height: 1; }
.breadcrumb .current { color: var(--ink-1); padding: 4px 8px; font-weight: 500; }

/* =========================================================
   ARTICLE
   ========================================================= */
.article { animation: fadeIn .3s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.article-eyebrow {
  font-size: 12px; font-weight: 600;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 10px;
  font-family: 'Roboto Mono', monospace;
}

.article h1 {
  font-family: 'Roboto Serif', serif;
  font-weight: 500;
  font-size: 40px;
  line-height: 1.15;
  color: var(--ink-1);
  letter-spacing: -.015em;
  margin-bottom: 12px;
}

.article h2 {
  font-family: 'Roboto Serif', serif;
  font-weight: 500;
  font-size: 26px;
  line-height: 1.3;
  color: var(--ink-1);
  margin-top: 40px;
  margin-bottom: 14px;
  letter-spacing: -.005em;
}

.article h3 {
  font-family: 'Roboto Serif', serif;
  font-weight: 500;
  font-size: 19px;
  line-height: 1.4;
  color: var(--ink-1);
  margin-top: 28px;
  margin-bottom: 10px;
}

.article h4 {
  font-family: 'Roboto', sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink-2);
  margin-top: 20px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.article .lede {
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink-2);
  margin-bottom: 24px;
  font-weight: 400;
}

.article p {
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink-2);
  margin-bottom: 14px;
}

.article p strong, .article p b { color: var(--ink-1); font-weight: 600; }
.article p em { color: var(--brand); font-style: italic; }

.article ul, .article ol { margin: 12px 0 18px 22px; color: var(--ink-2); }
.article li { margin-bottom: 8px; line-height: 1.7; }

.article a {
  color: var(--brand);
  text-decoration: none;
  border-bottom: 1px solid var(--brand-soft-2);
  transition: border-color .15s ease;
}
.article a:hover { border-bottom-color: var(--brand); }

.article hr { border: none; border-top: 1px solid var(--line-1); margin: 32px 0; }

.article-meta {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line-1);
}

.meta-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 500;
  background: var(--surface-2);
  color: var(--ink-3);
  font-family: 'Roboto Mono', monospace;
}

.meta-chip.part { background: var(--brand-soft); color: var(--brand); }
.meta-chip.status { background: var(--green-soft); color: var(--green); }
.meta-chip.read-time { background: var(--surface-2); color: var(--ink-3); }
.meta-chip.critical { background: var(--red-soft); color: var(--red); }
.meta-chip.planning { background: var(--purple-soft); color: var(--purple); }

/* =========================================================
   TERMINOLOGY LINKING
   ========================================================= */
.term {
  display: inline;
  color: var(--brand);
  cursor: help;
  border-bottom: 1px dashed var(--brand-soft-2);
  padding-bottom: 1px;
  transition: all .15s ease;
  position: relative;
  text-decoration: none;
}

.term:hover {
  background: var(--brand-soft);
  border-bottom-style: solid;
  border-bottom-color: var(--brand);
  border-radius: 2px;
  padding: 1px 3px;
  margin: 0 -3px;
}

.term:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  background: var(--brand-soft);
  border-bottom-style: solid;
  border-bottom-color: var(--brand);
  border-radius: 2px;
  padding: 1px 3px;
  margin: 0 -3px;
}

/* Tooltip on hover */
.term::after {
  content: attr(data-def);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--ink-1);
  color: var(--surface-0);
  padding: 8px 12px;
  border-radius: var(--r-2);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  white-space: normal;
  width: max-content;
  max-width: 280px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 50;
  box-shadow: var(--shadow-2);
  font-style: normal;
  text-align: left;
}
.term::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--ink-1);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  z-index: 50;
}

.term:hover::after,
.term:hover::before,
.term:focus-visible::after,
.term:focus-visible::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =========================================================
   CALLOUTS
   ========================================================= */
.callout {
  display: flex; gap: 14px;
  padding: 16px 18px;
  border-radius: var(--r-2);
  margin: 20px 0;
  background: var(--surface-2);
  border-left: 3px solid var(--ink-4);
  font-size: 14px;
  line-height: 1.6;
}

.callout.info { background: var(--brand-soft); border-left-color: var(--brand); }
.callout.warn { background: var(--yellow-soft); border-left-color: var(--yellow); }
.callout.success { background: var(--green-soft); border-left-color: var(--green); }
.callout.danger { background: var(--red-soft); border-left-color: var(--red); }
.callout.quote { background: var(--surface-2); border-left-color: var(--purple); font-style: italic; }

.callout-icon {
  flex-shrink: 0;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  color: inherit;
  opacity: .85;
}

.callout-body { flex: 1; color: var(--ink-2); }
.callout-body strong, .callout-body b { color: var(--ink-1); }
.callout.info .callout-body { color: var(--brand-hover); }
.callout.warn .callout-body { color: var(--yellow); }
.callout.success .callout-body { color: var(--green); }
.callout.danger .callout-body { color: var(--red); }

/* =========================================================
   RULE CARDS
   ========================================================= */
.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.rule-card {
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  border-radius: var(--r-2);
  padding: 16px;
  transition: box-shadow .2s ease, border-color .2s ease;
}
.rule-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-1); }

.rule-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; gap: 8px;
}

.rule-card-label {
  font-size: 11px; font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.rule-card-tag {
  font-size: 10px; font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-family: 'Roboto Mono', monospace;
}

.rule-card-tag.rule { background: var(--brand-soft); color: var(--brand); }
.rule-card-tag.reward { background: var(--green-soft); color: var(--green); }
.rule-card-tag.penalty { background: var(--red-soft); color: var(--red); }
.rule-card-tag.note, .rule-card-tag.policy { background: var(--yellow-soft); color: var(--yellow); }
.rule-card-tag.metric { background: var(--purple-soft); color: var(--purple); }

.rule-card-body { font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.rule-card-body .hl { color: var(--brand); font-weight: 500; }
.rule-card-body .hl-g { color: var(--green); font-weight: 500; }
.rule-card-body .hl-r { color: var(--red); font-weight: 500; }

/* =========================================================
   DEFINITION LIST
   ========================================================= */
.def-list {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2px;
  background: var(--line-1);
  border: 1px solid var(--line-1);
  border-radius: var(--r-2);
  overflow: hidden;
  margin: 20px 0;
}

.def-term, .def-desc { padding: 12px 16px; background: var(--surface-0); font-size: 14px; }
.def-term {
  font-family: 'Roboto Mono', monospace;
  font-size: 13px;
  color: var(--brand);
  font-weight: 500;
  background: var(--surface-1);
}
.def-desc { color: var(--ink-2); }
.def-desc strong { color: var(--ink-1); font-weight: 600; }

/* =========================================================
   FORMULA BLOCK
   ========================================================= */
.formula {
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  border-radius: var(--r-2);
  padding: 32px 28px;
  margin: 24px 0;
  text-align: center;
  position: relative;
}

.formula-label {
  position: absolute;
  top: -10px; left: 20px;
  background: var(--surface-1);
  padding: 0 10px;
  font-family: 'Roboto Mono', monospace;
  font-size: 11px; font-weight: 600;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.formula-eq {
  font-family: 'Roboto Serif', serif;
  font-size: 30px;
  font-weight: 400;
  color: var(--ink-1);
  line-height: 1.4;
  letter-spacing: -.01em;
}

.formula-eq .var { color: var(--brand); font-style: italic; font-weight: 500; }
.formula-eq .op { color: var(--ink-4); margin: 0 6px; }
.formula-eq .sub { font-size: .7em; vertical-align: sub; color: var(--brand); }
.formula-eq .paren { color: var(--ink-3); }

.formula-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 20px;
  text-align: left;
}

.formula-legend-item { display: flex; gap: 10px; font-size: 13px; line-height: 1.5; }
.formula-legend-item .var-name {
  flex-shrink: 0;
  font-family: 'Roboto Mono', monospace;
  color: var(--brand);
  font-weight: 600;
  width: 54px;
}
.formula-legend-item .var-desc { color: var(--ink-2); }
.formula-legend-item .var-desc strong { color: var(--ink-1); font-weight: 600; }

/* =========================================================
   RISK / CRITIQUE CARDS
   ========================================================= */
.risk-card {
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  border-left: 4px solid var(--red);
  border-radius: var(--r-2);
  padding: 20px 24px;
  margin: 20px 0;
}
.risk-card.severe { border-left-color: var(--red); }
.risk-card.medium { border-left-color: var(--yellow); }

.risk-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.risk-num {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Roboto Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.risk-num .r-icon {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--red-soft);
  color: var(--red);
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 700;
}

.risk-card.medium .risk-num { color: var(--yellow); }
.risk-card.medium .r-icon { background: var(--yellow-soft); color: var(--yellow); }

.risk-severity {
  font-family: 'Roboto Mono', monospace;
  font-size: 10px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--red-soft);
  color: var(--red);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.risk-card.medium .risk-severity { background: var(--yellow-soft); color: var(--yellow); }

.risk-title {
  font-family: 'Roboto Serif', serif;
  font-weight: 500;
  font-size: 20px;
  color: var(--ink-1);
  line-height: 1.35;
  margin-bottom: 12px;
}

.risk-body { font-size: 14.5px; line-height: 1.7; color: var(--ink-2); }
.risk-body p { margin-bottom: 10px; }
.risk-body p:last-child { margin-bottom: 0; }

.risk-solution {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--green-soft);
  border-radius: var(--r-2);
  border-left: 3px solid var(--green);
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-2);
}
.risk-solution strong { color: var(--green); }

/* =========================================================
   STEPS / TIMELINE
   ========================================================= */
.steps { display: grid; gap: 16px; margin: 20px 0; }

.step {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  border-radius: var(--r-2);
}

.step-num {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid; place-items: center;
  font-family: 'Roboto Mono', monospace;
  font-size: 14px;
  font-weight: 700;
}

.step.final .step-num { background: var(--purple-soft); color: var(--purple); }

.step-body h4 {
  font-family: 'Roboto', sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink-1);
  margin: 0 0 4px;
  text-transform: none;
  letter-spacing: 0;
}

.step-body p { margin: 0; font-size: 14px; color: var(--ink-2); line-height: 1.6; }

/* ---------- Phase timeline for implementation ---------- */
.phase-timeline { margin: 24px 0; position: relative; }
.phase {
  position: relative;
  padding: 20px 24px 20px 52px;
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  border-radius: var(--r-2);
  margin-bottom: 14px;
  transition: box-shadow .2s ease;
}
.phase:hover { box-shadow: var(--shadow-1); }

.phase::before {
  content: "";
  position: absolute;
  left: 24px; top: 28px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.phase.beta::before { background: var(--yellow); box-shadow: 0 0 0 4px var(--yellow-soft); }
.phase.scaling::before { background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.phase.optim::before { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }

.phase-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.phase-title {
  font-family: 'Roboto Serif', serif;
  font-weight: 500;
  font-size: 22px;
  color: var(--ink-1);
  line-height: 1.3;
}

.phase-duration {
  font-family: 'Roboto Mono', monospace;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-3);
  font-weight: 500;
}

.phase.beta .phase-duration { background: var(--yellow-soft); color: var(--yellow); }
.phase.scaling .phase-duration { background: var(--brand-soft); color: var(--brand); }
.phase.optim .phase-duration { background: var(--green-soft); color: var(--green); }

.phase-goal {
  font-size: 14.5px;
  color: var(--ink-2);
  line-height: 1.6;
  margin-bottom: 14px;
  padding-left: 12px;
  border-left: 2px solid var(--line-2);
}
.phase-goal strong { color: var(--ink-1); }

.phase-body h5 {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 14px 0 6px;
}

.phase-body ul {
  margin: 6px 0 10px 18px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-2);
}
.phase-body ul li strong { color: var(--ink-1); }
.phase-body ul li::marker { color: var(--ink-4); }

.phase-body .month-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  background: var(--surface-1);
  border-radius: var(--r-2);
  margin-bottom: 6px;
  font-size: 14px;
}
.phase-body .month-row .m-label {
  flex-shrink: 0;
  font-family: 'Roboto Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  min-width: 90px;
}
.phase.beta .month-row .m-label { color: var(--yellow); }
.phase.optim .month-row .m-label { color: var(--green); }

/* =========================================================
   CHECKLIST
   ========================================================= */
.checklist { display: grid; gap: 10px; margin: 20px 0; }

.checklist-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  border-radius: var(--r-2);
  transition: border-color .2s ease;
}
.checklist-item:hover { border-color: var(--line-2); }

.checklist-item .check {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  margin-top: 1px;
}

.checklist-item .ck-body { flex: 1; font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.checklist-item .ck-title { font-weight: 600; color: var(--ink-1); margin-bottom: 2px; }

/* =========================================================
   DIAGRAM
   ========================================================= */
.diagram {
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  border-radius: var(--r-2);
  padding: 24px;
  margin: 20px 0;
  display: grid;
  place-items: center;
}
.diagram svg { width: 100%; max-width: 500px; height: auto; }

/* =========================================================
   GLOSSARY PAGE
   ========================================================= */
.glossary-intro {
  background: var(--brand-soft);
  padding: 16px 20px;
  border-radius: var(--r-2);
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--brand-hover);
  line-height: 1.65;
}
.glossary-intro strong { color: var(--brand-hover); font-weight: 600; }

.glossary-list {
  display: grid;
  gap: 14px;
}

.glossary-entry {
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  border-radius: var(--r-2);
  padding: 18px 22px;
  scroll-margin-top: calc(var(--topbar-h) + var(--tabbar-h) + 16px);
}

.glossary-entry:target {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
  animation: pulse 1.5s ease 1;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 var(--brand-soft); }
  50% { box-shadow: 0 0 0 8px var(--brand-soft); }
  100% { box-shadow: 0 0 0 3px var(--brand-soft); }
}

.glossary-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.glossary-term {
  font-family: 'Roboto Serif', serif;
  font-weight: 500;
  font-size: 22px;
  color: var(--ink-1);
}

.glossary-key {
  font-family: 'Roboto Mono', monospace;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 500;
}

.glossary-category {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-family: 'Roboto Mono', monospace;
}

.glossary-category.core { background: var(--brand-soft); color: var(--brand); }
.glossary-category.formula { background: var(--purple-soft); color: var(--purple); }
.glossary-category.rule { background: var(--green-soft); color: var(--green); }
.glossary-category.risk { background: var(--red-soft); color: var(--red); }
.glossary-category.meta { background: var(--yellow-soft); color: var(--yellow); }

.glossary-def {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--ink-2);
  margin-bottom: 10px;
}
.glossary-def strong { color: var(--ink-1); font-weight: 600; }

.glossary-seealso {
  font-size: 13px;
  color: var(--ink-3);
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px dashed var(--line-1);
}
.glossary-seealso strong { color: var(--ink-2); }
.glossary-seealso a {
  color: var(--brand);
  text-decoration: none;
  border-bottom: 1px dashed var(--brand-soft-2);
}
.glossary-seealso a:hover { border-bottom-style: solid; }

/* Glossary alphabetical index */
.glossary-index {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 16px;
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  border-radius: var(--r-2);
  margin-bottom: 20px;
  position: sticky;
  top: calc(var(--topbar-h) + var(--tabbar-h) + 8px);
  z-index: 10;
}

.glossary-index a {
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--brand);
  border: 1px solid var(--line-1);
  border-radius: var(--r-1);
  text-decoration: none;
  font-family: 'Roboto Mono', monospace;
  transition: all .15s ease;
}
.glossary-index a:hover {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

/* =========================================================
   PAGE NAV
   ========================================================= */
.page-nav {
  display: flex;
  gap: 12px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line-1);
}

.page-nav-btn {
  flex: 1;
  padding: 14px 18px;
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  border-radius: var(--r-2);
  text-decoration: none;
  color: var(--ink-2);
  transition: all .15s ease;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

.page-nav-btn:hover { border-color: var(--brand); box-shadow: var(--shadow-1); }
.page-nav-btn.next { text-align: right; }
.page-nav-btn:disabled { opacity: .4; cursor: not-allowed; }

.page-nav-label {
  font-size: 11px;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  margin-bottom: 4px;
}

.page-nav-title { font-size: 14px; font-weight: 500; color: var(--ink-1); }
.page-nav-btn.next .page-nav-title::after { content: " →"; color: var(--brand); }
.page-nav-btn.prev .page-nav-title::before { content: "← "; color: var(--brand); }

/* =========================================================
   VERDICT TABLE (for review)
   ========================================================= */
.verdict-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  border-radius: var(--r-2);
  overflow: hidden;
  font-size: 14px;
}

.verdict-table th {
  background: var(--surface-2);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--line-1);
}

.verdict-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-1);
  color: var(--ink-2);
  vertical-align: top;
}

.verdict-table tr:last-child td { border-bottom: none; }
.verdict-table tr:hover { background: var(--surface-1); }

.verdict-table td:first-child { font-weight: 600; color: var(--ink-1); }

.stars { font-family: 'Roboto Mono', monospace; letter-spacing: .08em; }
.stars.s1 { color: var(--red); }
.stars.s2 { color: var(--yellow); }
.stars.s3 { color: var(--yellow); }
.stars.s4 { color: var(--green); }
.stars.s5 { color: var(--green); }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 240px 1fr; }
  :root { --sidebar-w: 240px; }
  .content { padding: 28px 32px 80px; }
  .topbar-search { width: 220px; }
}

@media (max-width: 768px) {
  .risk-matrix-layout { flex-direction: column; }
  .risk-detail-panel { flex: 1 1 auto; width: 100%; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: calc(var(--topbar-h) + var(--tabbar-h));
    left: -100%;
    width: 80%;
    max-width: 320px;
    transition: left .25s ease;
    z-index: 95;
    box-shadow: var(--shadow-3);
  }
  .sidebar.open { left: 0; }
  .content { padding: 24px 20px 80px; }
  .article h1 { font-size: 30px; }
  .article h2 { font-size: 22px; }
  .formula-eq { font-size: 22px; }
  .topbar-meta { display: none; }
  .topbar-search { width: 160px; }
  .menu-toggle { display: grid !important; }
  .def-list { grid-template-columns: 1fr; }
  .def-term { border-bottom: 1px solid var(--line-1); }
  .term::after { max-width: 220px; }
}

/* Mobile menu button */
.menu-toggle {
  display: none;
  width: 36px; height: 36px;
  border: 1px solid var(--line-1);
  border-radius: var(--r-1);
  background: var(--surface-0);
  place-items: center;
  cursor: pointer;
  color: var(--ink-2);
}
.menu-toggle:hover { background: var(--surface-2); }

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: calc(var(--topbar-h) + var(--tabbar-h)) 0 0 0;
  background: rgba(0,0,0,.3);
  z-index: 94;
}
.sidebar-overlay.show { display: block; }

/* Scrollbar */
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--ink-5); }

/* =========================================================
   Enhancement: calculator, risk matrix, checklists, tooltips
   ========================================================= */
.breadcrumb-progress {
  margin-left: 8px;
  font-size: 13px;
  color: var(--brand);
  font-weight: 600;
  white-space: nowrap;
}

.term-tooltip-pop {
  position: fixed;
  z-index: 2000;
  max-width: min(360px, 92vw);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-1);
  background: var(--surface-0);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-2);
  pointer-events: none;
}

.formula-calc-note { font-size: 13px; color: var(--ink-3); margin: 12px 0; }

.formula-calc {
  margin: 20px 0 28px;
  padding: 20px;
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-1);
}

.formula-calc__presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--r-2);
  border: 1px solid var(--line-2);
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}
.btn:hover { background: var(--brand-hover); }
.btn-secondary { background: var(--surface-0); color: var(--brand); border-color: var(--brand-soft-2); }
.btn-secondary:hover { background: var(--brand-soft); }

.formula-calc__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px 16px;
  margin-bottom: 16px;
}
.fc-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-3); }
.fc-field input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-1);
  border-radius: var(--r-1);
  font-size: 14px;
}

.formula-calc__results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.fc-result {
  padding: 12px;
  background: var(--surface-1);
  border-radius: var(--r-2);
  border: 1px solid var(--line-1);
  font-size: 13px;
}
.fc-result--total { background: var(--brand-soft); border-color: var(--brand-soft-2); }
.fc-result__label { display: block; color: var(--ink-3); font-size: 12px; margin-bottom: 4px; }
.fc-result strong { font-size: 18px; color: var(--ink-1); }
.formula-calc__footnote { font-size: 12px; color: var(--ink-3); margin-top: 12px; }

.risk-matrix-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
  margin: 20px 0 28px;
}
.risk-matrix-svgwrap { flex: 1 1 320px; min-width: 0; }
.risk-matrix-svg { width: 100%; height: auto; display: block; }
.risk-bubble { cursor: pointer; transition: transform .15s ease, filter .15s ease; }
.risk-bubble:hover, .risk-bubble:focus { transform: scale(1.06); outline: none; filter: drop-shadow(0 2px 4px rgba(0,0,0,.12)); }

.risk-detail-panel {
  flex: 0 1 280px;
  padding: 14px 16px;
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-1);
}
.risk-detail-panel__head { font-weight: 600; margin-bottom: 8px; color: var(--ink-1); }
.risk-detail-panel__body { font-size: 13px; color: var(--ink-2); line-height: 1.55; }

.collapse-modes { display: grid; gap: 14px; margin: 24px 0; }
@media (min-width: 768px) { .collapse-modes { grid-template-columns: 1fr 1fr; } }
.collapse-card {
  padding: 16px;
  background: var(--surface-0);
  border-radius: var(--r-3);
  border: 1px solid var(--line-1);
}
.collapse-card h3 { font-size: 15px; margin-bottom: 8px; color: var(--ink-1); }

.impl-timeline-svgwrap {
  margin: 16px 0 24px;
  padding: 12px;
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  border-radius: var(--r-3);
  overflow-x: auto;
}
.impl-timeline-svg { min-width: 640px; height: auto; display: block; }
.impl-milestone.is-hot circle { stroke-width: 3; filter: drop-shadow(0 0 4px rgba(26,115,232,.45)); }

.case-study-block {
  margin-top: 12px;
  padding: 16px;
  background: var(--surface-0);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-3);
  font-size: 14px;
  color: var(--ink-2);
}
.case-study-block p { margin-bottom: 10px; }
.case-study-block ul { margin-left: 1.2em; }

.interactive-checklist {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0 24px;
  padding: 16px;
  background: var(--surface-0);
  border: 1px solid var(--line-1);
  border-radius: var(--r-3);
}
.interactive-checklist__row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 14px;
}
.interactive-checklist__row label { color: var(--ink-2); }
.interactive-checklist__status {
  min-width: 120px;
  height: 32px;
  border: 1px solid var(--line-1);
  border-radius: var(--r-1);
  padding: 0 8px;
  font-size: 13px;
  background: var(--surface-0);
}
.interactive-checklist--dense .interactive-checklist__row { font-size: 13px; }

/* =========================================================
   PRINT
   ========================================================= */
@media print {
  .topbar, .tabbar, .sidebar, .sidebar-overlay, .menu-toggle, .page-nav { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .layout { display: block; }
  .content { padding: 0; max-width: none; }
  .content-inner { max-width: none; }
  .article { box-shadow: none; border: none; }
  .breadcrumb { padding: 0 0 8px; }
  .interactive-checklist__status { border: 1px solid #999; }
  a { color: #000; text-decoration: underline; }
}
