/* ============================================================
   Library / Document page — sidebar + content layout
   Extends theme.css. Uses editorial design tokens.
   ============================================================ */

/* ============ Scroll progress override ============ */
.scroll-progress {
  position: fixed; top: 0; left: 0; height: 2px;
  background: var(--accent); width: 0%;
  z-index: 200; transition: width 0.1s linear;
}

/* ============ Layout ============ */
.lib-layout {
  display: flex;
  min-height: calc(100vh - 102px);
}

/* ============ Sidebar ============ */
.lib-sidebar {
  position: sticky; top: 70px;
  width: 240px; flex-shrink: 0;
  max-height: calc(100vh - 70px);
  background: var(--bone);
  border-right: 1px solid var(--rule);
  overflow-y: auto;
  padding: 28px 0;
  transition: background 0.35s ease;
  align-self: flex-start;
}
.lib-sidebar-brand {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 20px;
}
.lib-sidebar-brand a {
  font-family: var(--serif); font-size: 16px; font-weight: 600;
  letter-spacing: -.01em; color: var(--ink); text-decoration: none;
}
.lib-sidebar-section { padding: 0 12px; margin-bottom: 20px; }
.lib-sidebar-title {
  font-family: var(--sans); font-size: 10px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--muted); padding: 0 8px; margin-bottom: 6px;
}
.lib-sidebar-links { list-style: none; display: flex; flex-direction: column; gap: 1px; }
.lib-sidebar-links a {
  display: block;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  color: var(--ink-2); text-decoration: none;
  padding: 7px 10px; border-radius: 6px;
  transition: all .15s ease;
}
.lib-sidebar-links a:hover {
  color: var(--ink); background: var(--bg-2);
}
.lib-sidebar-links a.active {
  color: var(--accent); background: var(--accent-soft); font-weight: 600;
}
.lib-sidebar-links a.h3 { padding-left: 22px; font-size: 12px; color: var(--muted); }

/* ============ Main Content ============ */
.lib-main {
  flex: 1; min-width: 0;
}
.lib-content-wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 48px 48px 100px;
}

/* ============ Document Header ============ */
.lib-doc-header {
  margin-bottom: 44px;
  padding-bottom: 36px;
  border-bottom: 1px solid var(--rule);
}
.lib-doc-label {
  font-family: var(--sans); font-size: 11px; font-weight: 600;
  letter-spacing: .22em; text-transform: uppercase;
  color: var(--accent);
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 18px;
}
.lib-doc-label::before {
  content: ""; width: 16px; height: 1px; background: var(--accent);
}
.lib-doc-title {
  font-family: var(--serif); font-size: clamp(28px, 3.2vw, 42px);
  font-weight: 400; letter-spacing: -.025em;
  color: var(--ink); line-height: 1.12;
  margin-bottom: 14px;
}
.lib-doc-title em { font-style: italic; color: var(--accent); font-variation-settings: 'opsz' 144; }
.lib-doc-subtitle {
  font-family: var(--serif-2); font-style: italic; font-size: 16px;
  color: var(--ink-2); line-height: 1.6; margin-bottom: 20px;
  font-variation-settings: 'opsz' 144;
}
.lib-doc-meta { font-size: 13px; color: var(--ink-2); line-height: 1.7; }
.lib-doc-meta time {
  font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .04em;
}
.lib-doc-meta .sep { margin: 0 8px; color: var(--rule-2); }

/* ============ Document Body Typography ============ */
.lib-body {
  font-size: 15px; color: var(--ink-2); line-height: 1.85;
}
.lib-body > :first-child { margin-top: 0; }
.lib-body p { margin-bottom: 20px; }
.lib-body strong { color: var(--ink); font-weight: 600; }

.lib-body h2 {
  font-family: var(--serif); font-size: clamp(22px, 2.4vw, 28px);
  font-weight: 500; letter-spacing: -.02em;
  color: var(--ink); line-height: 1.2;
  margin: 52px 0 18px; padding-top: 8px;
}
.lib-body h3 {
  font-family: var(--serif); font-size: 18px; font-weight: 600;
  letter-spacing: -.012em; color: var(--ink);
  margin: 34px 0 12px;
}
.lib-body h4 {
  font-family: var(--serif); font-size: 15px; font-weight: 600;
  color: var(--ink); margin: 26px 0 8px;
}

/* Lists */
.lib-body ul, .lib-body ol { padding-left: 22px; margin-bottom: 20px; }
.lib-body li { margin-bottom: 8px; line-height: 1.75; }
.lib-body ul li::marker { color: var(--accent); }
.lib-body ol li::marker { color: var(--accent); font-weight: 600; }

/* Inline code */
.lib-body code {
  font-family: var(--mono); font-size: .85em;
  background: var(--bg-2); color: var(--ink);
  padding: 2px 6px; border-radius: 4px; font-weight: 500;
}

/* Links */
.lib-body a {
  color: var(--accent); text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-position: 0 100%; background-repeat: no-repeat;
  background-size: 100% 1px;
  transition: background-size .2s;
}
.lib-body a:hover { background-size: 100% 2px; }

/* ============ Code Block ============ */
.lib-code {
  background: #1a1a1a; border: 1px solid #333;
  border-radius: var(--radius-lg); margin: 22px 0;
  overflow: hidden;
}
.lib-code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; border-bottom: 1px solid #333;
  background: #222;
}
.lib-code-label {
  font-family: var(--sans); font-size: 10px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: #888;
}
.lib-copy-btn {
  display: flex; align-items: center; gap: 4px;
  background: transparent; border: 1px solid #555;
  border-radius: 999px; padding: 3px 10px;
  font-family: var(--sans); font-size: 10px; font-weight: 600;
  letter-spacing: .08em; color: #aaa; cursor: pointer;
  transition: all .18s ease;
}
.lib-copy-btn:hover { border-color: #999; color: #eee; }
.lib-copy-btn.copied { border-color: var(--accent); color: var(--accent); }
.lib-code-body {
  padding: 14px 18px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.75;
  color: #e0e0e0; white-space: pre-wrap; word-break: break-word;
  overflow-x: auto;
}

/* ============ Callout ============ */
.lib-callout {
  border-left: 3px solid var(--accent);
  background: var(--bone);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  padding: 16px 20px; margin: 26px 0;
}
.lib-callout p { font-size: 14px; line-height: 1.75; color: var(--ink-2); margin-bottom: 8px; }
.lib-callout p:last-child { margin-bottom: 0; }
.lib-callout strong { color: var(--ink); }
.lib-callout-title {
  font-family: var(--sans); font-size: 10px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 10px;
}

.lib-callout.tip       { border-left-color: #e9b94a; }
.lib-callout.tip .lib-callout-title    { color: #e9b94a; }
.lib-callout.warning   { border-left-color: #ed6f5c; }
.lib-callout.warning .lib-callout-title { color: #ed6f5c; }
.lib-callout.success   { border-left-color: #16B57F; }
.lib-callout.success .lib-callout-title { color: #16B57F; }
.lib-callout.info      { border-left-color: #4F7CFF; }
.lib-callout.info .lib-callout-title   { color: #4F7CFF; }

/* ============ Table ============ */
.lib-table-wrap { overflow-x: auto; margin: 22px 0; }
.lib-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.lib-table th {
  font-family: var(--sans); font-size: 10px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); text-align: left;
  padding: 10px 14px; border-bottom: 1px solid var(--rule);
  white-space: nowrap; background: var(--bone);
}
.lib-table td {
  padding: 10px 14px; border-bottom: 1px solid var(--rule);
  color: var(--ink-2); vertical-align: top; line-height: 1.6;
}
.lib-table tr:last-child td { border-bottom: none; }
.lib-table tr:hover td { background: var(--bone); }
.lib-table td strong { color: var(--ink); }
.lib-table td code {
  font-family: var(--mono); font-size: 12px;
  background: var(--bg-2); color: var(--ink);
  padding: 2px 6px; border-radius: 4px; font-weight: 500;
}

/* ============ Blockquote ============ */
.lib-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 16px 24px; margin: 26px 0;
  background: var(--bone);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}
.lib-body blockquote p {
  font-family: var(--serif-2); font-style: italic; font-size: 17px;
  color: var(--ink-2); line-height: 1.7; margin-bottom: 8px;
  font-variation-settings: 'opsz' 144;
}
.lib-body blockquote p:last-child {
  font-family: var(--sans); font-style: normal; font-size: 13px; color: var(--muted);
}

/* ============ Divider ============ */
.lib-body hr {
  border: none; border-top: 1px solid var(--rule);
  margin: 52px 0;
}

/* ============ Footer ============ */
.lib-footer {
  margin-top: 72px; padding-top: 28px;
  border-top: 1px solid var(--rule); text-align: center;
  font-family: var(--sans); font-size: 12px; color: var(--muted);
}

/* ============ Scrollbar ============ */
.lib-sidebar::-webkit-scrollbar { width: 4px; }
.lib-sidebar::-webkit-scrollbar-track { background: transparent; }
.lib-sidebar::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 2px; }

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .lib-sidebar { display: none; }
  .lib-content-wrap { padding: 40px 24px 80px; }
  .lib-doc-title { font-size: 28px; }
}
@media (max-width: 560px) {
  .lib-content-wrap { padding: 32px 16px 60px; }
  .lib-doc-title { font-size: 24px; }
}
