:root {
  --bg: #faf7f1;
  --bg-alt: #f3eee3;
  --surface: #fff;
  --ink: #1a1817;
  --ink-soft: #3d3934;
  --ink-muted: #6e6760;
  --rule: #e1d9c8;
  --rule-soft: #efe9dc;
  --accent: #fd6431;
  --accent-rgb: 253, 100, 49;
  --accent-soft: #fdeee8;
  --accent-deep: #d95228;
  --serif: "Charter", "Iowan Old Style", "Palatino Linotype", "Source Serif Pro", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gdoc-font: var(--serif);
  --measure: 64ch;
  --page-max: 1280px;
  --page-pad-x: 32px;
  --layout-gap: 64px;
  --layout-rail: 360px;
  --masthead-gap: 48px;
  --doc-pad-top: 64px;
  --site-nav-height: 52px;
  --sip-toc-bar-height: 92px;
}

* { box-sizing: border-box; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--accent); }
a.workshop-btn,
a.workshop-btn:hover,
a.workshop-btn:focus-visible {
  color: #fff;
  text-decoration: none;
}
a.workshop-btn:hover,
a.workshop-btn:focus-visible {
  background: var(--accent-deep);
}

/* MASTHEAD (matches live SIP site) */
.masthead { border-bottom: 1px solid var(--rule); background: var(--bg); padding: 72px 0 56px; }
.masthead-inner {
  max-width: var(--page-max); margin: 0 auto;
  padding: 0 var(--page-pad-x);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--masthead-gap);
  align-items: start;
}
.masthead-content { min-width: 0; }
.masthead-aside {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.masthead-summary {
  width: 100%;
  min-width: 0;
  margin-top: calc(11px * 1.6 + 18px);
  display: flex;
  flex-direction: column;
}
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 24px; align-items: center; }
.hero-chip {
  display: inline-flex; align-items: center; gap: 0.35em;
  padding: 6px 14px; border-radius: 999px;
  background: var(--accent); color: #fff;
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  letter-spacing: 0.02em; line-height: 1.3;
}
.hero-chip strong { color: #fff; font-weight: 700; }
.eyebrow {
  font-family: var(--sans); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-muted); margin: 0 0 18px; font-weight: 600;
}
.masthead h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(34px, 4.4vw, 56px); line-height: 1.08;
  letter-spacing: -0.01em; margin: 0 0 24px; max-width: 22ch;
}
.masthead h1 em { font-style: italic; font-weight: 500; color: var(--ink-soft); }
.masthead .lede {
  font-size: 18px; line-height: 1.6; color: var(--ink-soft);
  max-width: var(--measure); margin: 0 0 14px;
}
.masthead .lede:empty { display: none; margin: 0; }
.legend {
  display: flex; flex-wrap: wrap; gap: 14px 24px; margin-top: 28px;
  padding-top: 20px; border-top: 1px dashed var(--rule);
  font-family: var(--sans); font-size: 13px; color: var(--ink-muted);
}
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend-swatch { width: 28px; height: 12px; border-radius: 2px; border-left: 3px solid; }
.legend-swatch.annotation { border-left-color: var(--accent); background: var(--surface); }
.legend-swatch.summary { border-left-color: var(--ink-muted); background: var(--rule-soft); }
.legend-swatch.data { border-left-color: var(--ink-soft); background: var(--surface); }

/* Site nav */
.site-nav {
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 200;
}
.site-nav-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--page-pad-x);
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.site-nav-brand {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}
.site-nav-brand:hover { color: var(--accent); }
.site-nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}
.site-nav-link {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.site-nav-link:hover,
.site-nav-link:focus-visible { color: var(--accent); }
.site-nav-link--muted { color: var(--ink-muted); font-weight: 500; }
.site-nav-user {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-muted);
}

.doc-visibility {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--sans);
  font-size: 12px;
}
.doc-visibility[hidden] { display: none !important; }
.doc-visibility-state {
  color: var(--ink-muted);
  font-weight: 600;
}
.doc-visibility-state.is-live { color: #1a7f37; }
.doc-visibility-live-label {
  color: var(--ink-soft);
  font-weight: 600;
}
.doc-visibility-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.doc-visibility-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.doc-visibility-track {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--rule);
  transition: background 0.15s ease;
  position: relative;
}
.doc-visibility-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease;
}
.doc-visibility-switch input:checked + .doc-visibility-track {
  background: var(--accent);
}
.doc-visibility-switch input:checked + .doc-visibility-track::after {
  transform: translateX(16px);
}
.doc-visibility-switch input:focus-visible + .doc-visibility-track {
  outline: 2px solid rgba(var(--accent-rgb), 0.45);
  outline-offset: 2px;
}

.doc-slug {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--sans);
  font-size: 12px;
}
.doc-slug[hidden] { display: none !important; }
.doc-slug-label {
  color: var(--ink-muted);
  font-weight: 600;
  white-space: nowrap;
}
.doc-slug-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.doc-slug-prefix {
  color: var(--ink-soft);
  font-weight: 600;
}
.doc-slug-input {
  width: 9rem;
  max-width: 28vw;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 4px 8px;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
}
.doc-slug-input:focus {
  outline: 2px solid rgba(var(--accent-rgb), 0.35);
  border-color: var(--accent);
}

.masthead-editable {
  outline: none;
  border-radius: 4px;
  transition: box-shadow 0.15s ease, background 0.15s ease;
}
.masthead-editable:hover {
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.2);
}
.masthead-editable:focus-visible {
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.35);
  background: rgba(var(--accent-rgb), 0.04);
}
.masthead-editable--rich:focus-visible { background: rgba(var(--accent-rgb), 0.03); }

.masthead-fmt-toolbar {
  position: fixed;
  z-index: 1200;
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(26, 24, 23, 0.12);
}
.masthead-fmt-toolbar[hidden] { display: none !important; }
.masthead-fmt-toolbar.anno-body-toolbar {
  border-bottom: 1px solid var(--rule);
  background: var(--bg-alt);
}

.workshop-bar {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--rule);
  font-family: var(--sans);
}
.workshop-sync { font-size: 12px; color: var(--ink-muted); margin: 0 0 10px; }
.workshop-controls { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; margin-bottom: 10px; }
.font-label { font-size: 13px; color: var(--ink-muted); display: flex; gap: 8px; align-items: center; }
.font-label select { font-size: 13px; padding: 4px 8px; }
.workshop-btn {
  display: inline-block;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}
.workshop-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}
.workshop-btn--secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
}
.workshop-btn--compact {
  padding: 6px 10px;
  font-size: 11px;
  letter-spacing: 0.02em;
}
a.workshop-btn--secondary:hover,
a.workshop-btn--secondary:focus-visible {
  color: var(--ink);
  background: var(--surface);
}
.workshop-user {
  font-size: 13px;
  color: var(--ink-muted);
}
.workshop-banner {
  font-size: 12px; color: var(--ink-muted); margin: 0;
  padding: 8px 10px; background: var(--accent-soft); border-left: 3px solid var(--accent);
}

/* AI SUMMARY PANEL */
.note--ai {
  border-left-color: var(--accent);
  background: var(--surface);
  padding: 18px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  border-left-width: 3px;
  box-shadow: 0 14px 44px rgba(26, 24, 23, 0.07);
}
.ai-panel-head { margin-bottom: 14px; flex-shrink: 0; }
.ai-panel-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.ai-panel-title-row .ai-panel-title { flex: 1 1 auto; min-width: 0; }
.ai-panel-title-row .workshop-btn--compact { margin-left: auto; flex-shrink: 0; }
.ai-panel-hint {
  margin: 10px 0 0;
  font-family: var(--sans);
  font-size: 11px;
  line-height: 1.45;
  color: var(--ink-muted);
}
.ai-panel-hint[hidden] { display: none; }
.ai-brand-mark {
  display: block; width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 50%; background: var(--bg-alt); padding: 5px; object-fit: contain;
}
.note--ai[data-ai-model="claude"] .ai-brand-mark {
  border-radius: 6px; background: var(--bg); padding: 0; object-fit: cover;
}
.note--ai[data-ai-model="gemini"] .ai-brand-mark {
  border-radius: 7px; background: transparent; padding: 0; object-fit: cover;
}
.ai-panel-title {
  margin: 0; font-family: var(--sans); font-size: 11px;
  letter-spacing: 0.14em; text-transform: uppercase; font-weight: 700; color: var(--ink);
}
.ai-panel-body { display: flex; flex-direction: column; }
.ai-tabs {
  display: flex; gap: 2px; margin-bottom: 16px; padding: 3px;
  background: var(--bg); border-radius: 6px; border: 1px solid var(--rule);
}
.ai-tab {
  flex: 1; background: transparent; border: none; padding: 7px 8px;
  font-family: var(--sans); font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--accent-deep); cursor: pointer; border-radius: 4px;
  transition: background 0.15s ease, color 0.15s ease;
}
.ai-tab:hover { color: var(--ink); background: rgba(255, 255, 255, 0.55); }
.ai-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ai-tab.active { background: var(--accent); color: #fff; }
.ai-summary-text { display: none; }
.ai-summary-text.active { display: block; animation: ai-fade 0.2s ease; }
.ai-summary-text p { margin: 0 0 10px; }
.ai-summary-text p:last-child { margin-bottom: 0; }
.ai-summary-text strong { color: var(--ink); font-weight: 600; }
.ai-summary-footnote { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--rule); font-size: 11.5px; color: var(--ink-muted); font-style: italic; }
.ai-summary-footnote:empty { display: none; }
@keyframes ai-fade { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: translateY(0); } }

/* SECTION NAV (full-width sticky bar; matches live SIP site) */
.sip-toc-bar {
  position: sticky;
  top: var(--site-nav-height, 0px);
  z-index: 40;
  width: 100%;
  background: rgba(250, 247, 241, 0.96);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-family: var(--sans);
}
.sip-toc-bar[hidden] { display: none !important; }
.sip-toc-bar-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--page-pad-x);
}
.sip-toc-mobile-head {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 8px 0;
  min-height: 44px;
}
.sip-toc-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0 -8px 0 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease;
}
.sip-toc-toggle:hover,
.sip-toc-toggle:focus-visible {
  background: var(--bg-alt);
  outline: none;
}
.sip-toc-toggle:focus-visible {
  box-shadow: 0 0 0 2px var(--accent);
}
.sip-toc-toggle-icon {
  position: relative;
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: background 0.15s ease;
}
.sip-toc-toggle-icon::before,
.sip-toc-toggle-icon::after {
  content: "";
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.15s ease, top 0.15s ease;
}
.sip-toc-toggle-icon::before { top: -6px; }
.sip-toc-toggle-icon::after { top: 6px; }
.sip-toc-bar.is-open .sip-toc-toggle-icon {
  background: transparent;
}
.sip-toc-bar.is-open .sip-toc-toggle-icon::before {
  top: 0;
  transform: rotate(45deg);
}
.sip-toc-bar.is-open .sip-toc-toggle-icon::after {
  top: 0;
  transform: rotate(-45deg);
}
.sip-toc-panel {
  display: block;
}
.sip-toc-list {
  list-style: none;
  margin: 0;
  padding: 10px 0 12px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px 10px;
  overflow: visible;
}
.sip-toc-list > li { display: flex; min-width: 0; }
.sip-toc-intro {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  color: var(--ink-soft);
  cursor: default;
  user-select: none;
}
.sip-toc-intro .sip-toc-num {
  color: var(--ink-muted);
  letter-spacing: 0.12em;
  white-space: nowrap;
}
.sip-toc-intro .sip-toc-title {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  white-space: normal;
  line-height: 1.35;
}
.sip-toc-link {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 4px;
  color: var(--ink-soft);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.sip-toc-link:hover,
.sip-toc-link:focus-visible {
  background: var(--bg-alt);
  color: var(--ink);
}
.sip-toc-link.is-active {
  background: var(--accent-soft);
  border-color: rgba(var(--accent-rgb), 0.35);
  color: var(--ink);
}
.sip-toc-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.sip-toc-num {
  flex-shrink: 0;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--accent);
}
.sip-toc-title {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.sip-section-heading {
  scroll-margin-top: calc(var(--site-nav-height, 0px) + var(--sip-toc-bar-height) + 20px);
}
@media (max-width: 900px) {
  .sip-toc-bar-inner { padding: 0 var(--page-pad-x); }
  .sip-toc-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  :root { --sip-toc-bar-height: 48px; }
  .sip-toc-mobile-head {
    display: flex;
    padding: 6px 0;
    min-height: 40px;
  }
  .sip-toc-panel {
    display: none;
    border-top: 1px solid var(--rule);
    overflow: visible;
  }
  .sip-toc-bar.is-open .sip-toc-panel { display: block; }
  .sip-toc-list {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 4px 0 8px;
  }
  .sip-toc-intro-cell { display: none; }
  .sip-toc-link {
    flex-direction: row;
    align-items: baseline;
    gap: 8px 10px;
    min-height: 0;
    padding: 9px 10px;
  }
  .sip-toc-num {
    min-width: 4.25em;
    font-size: 8px;
    letter-spacing: 0.12em;
  }
  .sip-toc-title {
    font-size: 12.5px;
    line-height: 1.3;
    white-space: normal;
    flex: 1;
    min-width: 0;
  }
}

/* SPEC TABLES — block wrapper matches p/ul max-width; table fills that box */
.spec-measure {
  max-width: var(--measure);
  width: 100%;
  margin: 12px 0 24px;
}
.spec-measure table {
  border-collapse: collapse;
  width: 100%;
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  table-layout: fixed;
}
.sip-document table th,
.sip-document table td { word-wrap: break-word; overflow-wrap: break-word; }
.sip-document th,
.sip-document td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}
.sip-document th {
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--rule-soft);
}

/* DOCUMENT + annotation rail (live SIP site behavior) */
.document {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--doc-pad-top) var(--page-pad-x) 96px;
}
.document-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--layout-rail);
  gap: var(--layout-gap);
  align-items: start;
}
.spec-column { min-width: 0; }
.spec-toolbar {
  margin-bottom: 20px;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  font-family: var(--sans);
}
.spec-toolbar .workshop-sync { margin: 0 0 10px; }
.spec-toolbar .workshop-controls { margin-bottom: 10px; }
.spec-toolbar .workshop-banner { margin: 0; }
.sip-document.gdoc-root {
  font-family: var(--gdoc-font);
  min-width: 0;
  user-select: text;
  cursor: text;
}
.gdoc-root h1, .gdoc-root h2, .gdoc-root h3 { font-family: var(--gdoc-font); line-height: 1.2; }
.gdoc-root p { margin: 0 0 1em; }
.gdoc-root img { max-width: 100%; height: auto; }

/* NOTES (aligned with live SIP site) */
.note {
  border: 1px solid var(--rule);
  border-left-width: 3px;
  padding: 18px 20px;
  background: var(--surface);
  border-radius: 0 4px 4px 0;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-soft);
}
.commentary-rail { position: relative; align-self: start; min-width: 0; }
.commentary-rail .note:not([data-anno]) { display: none; }
.commentary-rail .note {
  position: absolute;
  left: 0;
  right: 0;
  margin: 0;
  z-index: 1;
  padding-right: 28px;
  padding-bottom: 40px;
}
.commentary-rail .note.active { z-index: 3; }
.commentary-rail .note.is-pinned { z-index: 25; box-shadow: 0 8px 32px rgba(26, 24, 23, 0.14); }
.anno-share {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  order: 2;
  width: 26px;
  height: 26px;
  margin: -4px 0 -4px 4px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  transition: color 0.12s ease, background 0.12s ease;
}
.commentary-rail .note-label { padding-right: 20px; }
.commentary-rail .note-label::after { order: 1; }
.anno-share:hover,
.anno-share:focus-visible {
  color: var(--accent-deep);
  background: var(--bg-alt);
  outline: none;
}
.anno-share[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  padding: 5px 9px;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(3px);
  transition: opacity 0.07s ease, transform 0.07s ease, visibility 0.07s ease;
}
.anno-share:hover::before,
.anno-share:focus-visible::before {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition-delay: 0s;
}
.commentary-rail .note.is-pinned .anno-share::before { z-index: 30; }
.note-card-actions {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
}
.anno-edit {
  position: relative;
  width: 26px;
  height: 26px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  transition: color 0.12s ease, background 0.12s ease;
}
.anno-edit:hover,
.anno-edit:focus-visible {
  color: var(--accent-deep);
  background: var(--bg-alt);
  outline: none;
}
.anno-edit[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  padding: 5px 9px;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(3px);
  transition: opacity 0.07s ease, transform 0.07s ease, visibility 0.07s ease;
}
.anno-edit:hover::before,
.anno-edit:focus-visible::before {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition-delay: 0s;
}
.anno-field input[type="text"] {
  display: block;
  width: 100%;
  margin-top: 6px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 8px 10px;
}
.anno-share-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 120;
  padding: 10px 16px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.anno-share-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.commentary-rail .note-index {
  position: absolute;
  top: 10px;
  right: 10px;
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  opacity: 0.5;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}
.commentary-rail .note-index--unnumbered:empty { display: none; }
.note p { margin: 0 0 12px; }
.note p:last-child { margin-bottom: 0; }
.note ul, .note ol {
  margin: 0 0 12px;
  padding: 0;
  padding-inline-start: 0.85em;
  list-style-position: inside;
}
.note ul:last-child, .note ol:last-child { margin-bottom: 0; }
.note li { margin: 0 0 0.4em; padding: 0; }
.note li:last-child { margin-bottom: 0; }
.note > li {
  margin: 0 0 0.4em;
  padding-inline-start: 0.85em;
  list-style-position: inside;
}
.note p strong { color: var(--ink); font-weight: 600; }
.note-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--ink-muted);
}
.note-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}
.note--annotation { border-left-color: var(--accent); background: var(--surface); }
.note--annotation .note-label { color: var(--accent-deep); }
.note--annotation .note-label::after { background: var(--accent); opacity: 0.25; }
.note--summary { border-left-color: var(--ink-muted); }
.note--summary .note-label::before {
  content: "∑";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink-soft);
  color: white;
  font-size: 13px;
  font-weight: 400;
  line-height: 1;
}
.note--data { border-left-color: var(--ink-soft); background: var(--surface); }
.note--data .note-label::before {
  content: "▦";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--ink-soft);
  font-size: 14px;
}

.anno-link {
  display: inline;
  color: inherit;
  text-decoration: none;
  background-image: linear-gradient(transparent 58%, rgba(var(--accent-rgb), 0.12) 58%, rgba(var(--accent-rgb), 0.12) 94%, transparent 94%);
  border-bottom: 1px dotted rgba(var(--accent-rgb), 0.35);
  padding: 0 1px;
  cursor: pointer;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.anno-link:hover, .anno-link.active {
  background-image: linear-gradient(transparent 58%, rgba(var(--accent-rgb), 0.22) 58%);
  border-bottom: 1px solid var(--accent);
}
.sip-document .anno-link[data-note-index]::after {
  content: attr(data-note-index);
  display: inline-block;
  margin-left: 2px;
  font-family: var(--sans);
  font-size: 0.62em;
  font-weight: 700;
  vertical-align: super;
  color: var(--accent);
  pointer-events: none;
}
.note--annotation.active {
  box-shadow: 0 0 0 2px var(--accent), 0 8px 22px rgba(var(--accent-rgb), 0.18);
}

.connector-svg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 50;
}
.connector-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.connector-path.visible { opacity: 0.65; }

/* Selection → annotate */
.selection-toolbar {
  position: fixed;
  z-index: 1000;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: none;
  background: var(--ink);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(26, 24, 23, 0.25);
}
.selection-toolbar[hidden] { display: none !important; }
.selection-toolbar-btn {
  border: none;
  background: transparent;
  color: #fff;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.selection-toolbar-btn:hover { background: rgba(255, 255, 255, 0.12); }

.anno-dialog {
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 0;
  max-width: 420px;
  width: calc(100vw - 32px);
  box-shadow: 0 20px 50px rgba(26, 24, 23, 0.15);
}
.anno-dialog::backdrop { background: rgba(26, 24, 23, 0.35); }
.anno-dialog form { padding: 22px 24px; margin: 0; }
.anno-dialog-title {
  margin: 0 0 12px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 700;
}
.anno-dialog-quote {
  margin: 0 0 8px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  font-size: 14px;
  font-style: italic;
  color: var(--ink-soft);
}
.anno-dialog-hint {
  margin: 0 0 16px;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink-muted);
  line-height: 1.4;
}
.anno-dialog-hint code {
  font-size: 10px;
  background: var(--rule-soft);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
.anno-field {
  display: block;
  margin-bottom: 14px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
}
.anno-field-label {
  display: block;
  margin-bottom: 6px;
}
.anno-field select,
.anno-field textarea,
.anno-body-textarea {
  display: block;
  width: 100%;
  margin-top: 0;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 8px 10px;
}
.anno-field textarea,
.anno-body-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
  cursor: text;
  caret-color: var(--ink);
}
.anno-field--editor .anno-body-editor {
  position: relative;
  margin-top: 6px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  overflow: hidden;
  font-weight: 400;
}
.anno-body-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--rule-soft);
  background: var(--bg-alt);
  user-select: none;
}
.anno-fmt-btn {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.anno-fmt-btn:hover,
.anno-fmt-btn:focus-visible {
  background: var(--surface);
  color: var(--accent-deep);
  outline: none;
}
.anno-fmt-btn--italic {
  font-style: italic;
}
.anno-body-surface {
  position: relative;
  min-height: 120px;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px 12px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink);
  outline: none;
  cursor: text;
  caret-color: var(--ink);
}
.anno-body-surface.is-empty:not(:focus)::before {
  content: attr(data-placeholder);
  position: absolute;
  color: var(--ink-muted);
  pointer-events: none;
}
.anno-body-surface strong,
.anno-body-surface b {
  font-weight: 600;
}
.anno-body-surface em,
.anno-body-surface i {
  font-style: italic;
}
.anno-body-surface p { margin: 0 0 0.65em; }
.anno-body-surface p:last-child { margin-bottom: 0; }
.anno-body-surface ul,
.anno-body-surface ol {
  margin: 0 0 0.65em;
  padding-inline-start: 1.25em;
}
.anno-body-surface code {
  font-size: 0.92em;
  background: var(--rule-soft);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
.anno-body-surface a {
  color: var(--accent-deep);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.anno-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}
.anno-dialog-actions-main {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
}
.anno-btn-delete {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: #b42318;
}
.anno-btn-delete:hover {
  background: #fef3f2;
  border-color: #fecdca;
}
.anno-btn-delete:focus-visible {
  outline: 2px solid #fecdca;
  outline-offset: 2px;
}
.anno-btn-delete[hidden] { display: none !important; }
.anno-btn-primary,
.anno-btn-secondary {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--rule);
}
.anno-btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.anno-btn-secondary { background: var(--surface); color: var(--ink-soft); }

.workshop-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 1200;
  padding: 10px 16px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.workshop-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Login page (login.html) */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.login-shell {
  width: 100%;
  max-width: 440px;
}
.login-card {
  padding: 36px 32px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
}
.login-eyebrow {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.login-title {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
}
.login-lede {
  margin: 0 0 24px;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.login-status {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 6px;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.4;
}
.login-status--err {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
.login-status--ok {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}
.login-actions {
  margin-bottom: 20px;
}
.login-google {
  display: block;
  width: 100%;
  text-align: center;
  box-sizing: border-box;
}
.login-google.is-disabled {
  opacity: 0.55;
  pointer-events: none;
  cursor: not-allowed;
}
.login-foot {
  margin: 0;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-soft);
}

/* Home dashboard (index.html) */
.home-page {
  min-height: 100vh;
  background: var(--bg);
}
.home-header {
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}
.home-header-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 24px 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
}
.home-eyebrow {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.home-title {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1.15;
  font-weight: 600;
}
.home-lede {
  margin: 0;
  max-width: 52ch;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.home-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.home-sign-out {
  color: var(--ink) !important;
  border-color: var(--rule);
}
.home-sign-out:hover,
.home-sign-out:focus-visible {
  color: var(--ink) !important;
  background: var(--bg);
}
.home-user {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-muted);
}
.home-main {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}
.home-section + .home-section {
  margin-top: 40px;
}
.home-section--create { margin-top: 0; }
.home-create-card {
  padding: 24px;
  border: 2px dashed rgba(var(--accent-rgb), 0.45);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.06) 0%, var(--surface) 100%);
}
.home-create-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.home-create-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--sans);
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
}
.home-create-title {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.2;
  font-weight: 600;
}
.home-create-lede {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 52ch;
}
.home-add-form {
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}
.home-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.home-add-submit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.home-add-submit-icon {
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.home-section-title {
  margin: 0 0 16px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.home-add-form {
  padding: 20px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
}
.home-create-card .home-add-form {
  padding: 16px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
}
.home-add-label {
  display: block;
  margin-bottom: 8px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
}
.home-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.home-add-input {
  flex: 1 1 280px;
  min-width: 0;
  font: inherit;
  font-family: var(--sans);
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
}
.home-add-hint,
.home-add-status {
  margin: 12px 0 0;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-muted);
}
.home-add-status--ok { color: #1a7f37; }
.home-add-status--err { color: #b42318; }
.home-doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.home-doc-item {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
}
.home-doc-item-main {
  min-width: 0;
  flex: 1 1 240px;
}
.home-doc-link {
  display: block;
  color: inherit;
  text-decoration: none;
}
.home-doc-link:hover .home-doc-title {
  color: var(--accent);
}
.home-doc-title {
  display: block;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
}
.home-doc-meta {
  display: block;
  margin-top: 4px;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-muted);
}
.home-doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.home-empty {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink-muted);
}
.workshop-load-error {
  padding: 24px;
  border: 1px solid #f5c2c0;
  border-radius: 8px;
  background: #fff5f5;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: #7a271a;
}

@media (max-width: 900px) {
  .masthead { padding: 48px 0 40px; }
  .masthead-inner { grid-template-columns: 1fr; gap: 32px; }
  .masthead-aside { align-items: stretch; }
  .masthead-summary { margin-top: 0; margin-bottom: 32px; }
  .document-split { grid-template-columns: 1fr; }
  .masthead h1 { font-size: 30px; }
}
