:root {
  color-scheme: light dark;
  --bg: #f6f7fb;
  --surface: rgba(255, 255, 255, .88);
  --surface-solid: #fff;
  --surface-muted: #eef1f7;
  --text: #172033;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #dfe3eb;
  --accent: #5277d4;
  --accent-soft: #e8eeff;
  --danger: #b42318;
  --code: #f1f3f8;
  --shadow: 0 14px 40px rgba(31, 42, 68, .08);
  --toolbar-height: 58px;
  --tree-width: 270px;
  --tree-collapsed-width: 48px;
  --toc-width: 25vw;
  --toc-collapsed-width: 66px;
  --scrollbar-thumb: #b8c0cf;
  --scrollbar-thumb-hover: #8f9aad;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

:root[data-theme="dark"] {
  --bg: #0c1017;
  --surface: rgba(18, 23, 33, .9);
  --surface-solid: #121721;
  --surface-muted: #1a2230;
  --text: #eef2ff;
  --muted: #a5afc1;
  --faint: #737f94;
  --line: #293344;
  --accent: #8aabff;
  --accent-soft: #202d49;
  --danger: #ff8d86;
  --code: #161d29;
  --shadow: 0 14px 40px rgba(0, 0, 0, .24);
  --scrollbar-thumb: #3b475a;
  --scrollbar-thumb-hover: #58677d;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0c1017;
    --surface: rgba(18, 23, 33, .9);
    --surface-solid: #121721;
    --surface-muted: #1a2230;
    --text: #eef2ff;
    --muted: #a5afc1;
    --faint: #737f94;
    --line: #293344;
    --accent: #8aabff;
    --accent-soft: #202d49;
    --danger: #ff8d86;
    --code: #161d29;
    --shadow: 0 14px 40px rgba(0, 0, 0, .24);
    --scrollbar-thumb: #3b475a;
    --scrollbar-thumb-hover: #58677d;
  }
}

* { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  min-height: 36px; background: var(--scrollbar-thumb); background-clip: padding-box;
  border: 3px solid transparent; border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--scrollbar-thumb-hover); }
*::-webkit-scrollbar-corner { background: transparent; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--toolbar-height) + 24px); }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; }
button, select, input, textarea { font: inherit; }
a { color: var(--accent); }

.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;
}

.toolbar {
  position: sticky; top: 0; z-index: 20; height: var(--toolbar-height);
  display: flex; align-items: center; gap: 10px; padding: 0 18px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}

.brand {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px;
  color: white; background: linear-gradient(145deg, #6f8fe7, #405fb7);
  font-weight: 800; letter-spacing: -.04em; text-decoration: none; box-shadow: 0 6px 18px rgba(82,119,212,.28);
}
.context-picker { min-width: 130px; max-width: min(480px, 42vw); flex: 1 1 320px; }
.context-picker select, .theme-picker select {
  width: 100%; height: 38px; padding: 0 34px 0 12px; color: var(--text);
  background: var(--surface-solid); border: 1px solid var(--line); border-radius: 10px;
}
.theme-picker { flex: 0 0 92px; }
.toolbar-spacer { flex: 1; }
.button, .icon-button {
  height: 36px; border: 1px solid var(--line); border-radius: 10px; color: var(--text);
  background: var(--surface-solid); cursor: pointer; transition: border-color .15s, transform .15s, background .15s;
}
.button { padding: 0 14px; font-weight: 650; background: var(--accent); border-color: var(--accent); color: #fff; }
.icon-button { width: 36px; padding: 0; font-size: 18px; }
.button:hover, .icon-button:hover { transform: translateY(-1px); }
.icon-button.danger { color: var(--danger); }
.button:disabled { opacity: .55; cursor: wait; }
.button.secondary { color: var(--text); background: var(--surface-solid); border-color: var(--line); }
.button.danger-button { color: #fff; background: var(--danger); border-color: var(--danger); }
.button.wide { width: 100%; }
.toolbar-action { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 6px; white-space: nowrap; }
.toolbar-action > span:first-child { font-size: 16px; line-height: 1; }
.toolbar-form { display: contents; }
.user-pill {
  max-width: 150px; overflow: hidden; padding: 7px 10px; color: var(--muted); background: var(--surface-muted);
  border: 1px solid var(--line); border-radius: 9px; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap;
}
.toast {
  position: fixed; z-index: 50; top: calc(var(--toolbar-height) + 14px); left: 50%; padding: 10px 16px;
  color: #fff; background: #25324a; border-radius: 10px; box-shadow: var(--shadow); opacity: 0;
  pointer-events: none; transform: translate(-50%, -8px); transition: opacity .18s, transform .18s;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

.layout {
  --active-tree-width: var(--tree-width);
  --active-toc-width: var(--toc-width);
  display: grid; grid-template-columns: var(--active-tree-width) minmax(0, 1fr) var(--active-toc-width);
  max-width: 1600px; min-height: calc(100vh - var(--toolbar-height)); margin: 0 auto;
  transition: grid-template-columns .18s ease;
}
.layout.without-tree { grid-template-columns: minmax(0, 1fr) var(--active-toc-width); }
.layout.without-toc { grid-template-columns: var(--active-tree-width) minmax(0, 1fr); }
.layout.without-tree.without-toc { display: block; max-width: 980px; }
.file-tree, .toc-rail {
  position: sticky; top: var(--toolbar-height); align-self: start; height: calc(100vh - var(--toolbar-height));
}
.file-tree {
  position: sticky; display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  padding: 0; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 84%, var(--surface-solid));
}
.toc-rail {
  display: flex; min-width: 0; align-items: stretch; justify-content: flex-end; overflow: visible; padding: 0;
}
.toc-card {
  position: relative; display: flex; width: 100%; height: 100%; max-height: none; min-height: 0; flex-direction: column;
  overflow: hidden; background: color-mix(in srgb, var(--surface-solid) 90%, transparent);
  border: 0; border-left: 1px solid var(--line); border-radius: 0; box-shadow: none;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  transition: flex-basis .18s ease, width .18s ease, height .18s ease, border-radius .18s ease, box-shadow .18s ease, background-color .18s ease, border-color .18s ease;
}
.toc-header {
  display: flex; min-height: 52px; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 9px 9px 16px; border-bottom: 1px solid var(--line);
}
.toc-title { overflow: hidden; color: var(--faint); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.toc-toggle {
  display: grid; flex: 0 0 32px; width: 32px; height: 32px; place-items: center; padding: 0;
  color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 10px; cursor: pointer;
}
.toc-toggle:hover, .toc-toggle:focus-visible { color: var(--accent); background: var(--accent-soft); border-color: var(--line); outline: none; }
.toc-toggle span { font-size: 24px; line-height: 1; transform: translateY(-1px); }
.toc-scroll { min-height: 0; flex: 1 1 auto; overflow: auto; padding: 12px 10px 16px; overscroll-behavior: contain; }

.tree-pane-header {
  display: flex; flex: 0 0 54px; align-items: center; justify-content: space-between;
  min-width: 0; padding: 0 12px 0 18px; border-bottom: 1px solid var(--line);
}
.tree-pane-title { overflow: hidden; color: var(--faint); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-decoration: none; text-transform: uppercase; }
.tree-toggle {
  display: grid; flex: 0 0 30px; width: 30px; height: 30px; place-items: center; padding: 0;
  color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 8px; cursor: pointer;
}
.tree-toggle:hover, .tree-toggle:focus-visible { color: var(--accent); background: var(--accent-soft); border-color: var(--line); outline: none; }
.tree-toggle span { font-size: 24px; line-height: 1; transform: translateY(-1px); }
.tree-scroll { min-height: 0; flex: 1; overflow: auto; padding: 15px 14px 28px; overscroll-behavior: contain; }
.tree-empty { margin: 10px 6px; color: var(--faint); font-size: 13px; }
.tree-resizer {
  position: absolute; z-index: 3; top: 0; right: -4px; width: 9px; height: 100%; cursor: col-resize; touch-action: none;
}
.tree-resizer::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 4px; width: 1px; background: transparent; transition: background .15s, box-shadow .15s;
}
.tree-resizer:hover::after, .tree-resizer:focus-visible::after, body.tree-resizing .tree-resizer::after {
  background: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);
}
body.tree-resizing { cursor: col-resize; user-select: none; }

.tree-list { list-style: none; padding: 0; margin: 0; }
.tree-list .tree-list { padding-left: 13px; border-left: 1px solid var(--line); margin-left: 7px; }
.tree-list li { margin: 2px 0; }
.tree-list summary, .tree-list a {
  display: block; padding: 6px 8px; border-radius: 7px; color: var(--muted); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
}
.tree-list summary { font-weight: 700; color: var(--text); }
.tree-list a { text-decoration: none; }
.tree-list a:hover, .tree-list a.active { color: var(--accent); background: var(--accent-soft); }
.tree-list a.active { font-weight: 700; }
.tree-list details > summary { list-style: none; }
.tree-list details > summary::before { content: "›"; display: inline-block; margin-right: 6px; transition: transform .15s; }
.tree-list details[open] > summary::before { transform: rotate(90deg); }

.document-shell { width: 100%; max-width: 900px; min-width: 0; margin: 0 auto; padding: 38px 54px 90px; }
.document-path { margin-bottom: 24px; color: var(--faint); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.empty-state {
  display: grid; place-items: center; min-height: 45vh; padding: 36px; text-align: center;
  color: var(--muted); background: var(--surface-solid); border: 1px dashed var(--line); border-radius: 18px;
}

.markdown-body { font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif; font-size: 18px; line-height: 1.72; overflow-wrap: break-word; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 {
  font-family: Inter, ui-sans-serif, -apple-system, sans-serif; line-height: 1.22; letter-spacing: -.025em;
  scroll-margin-top: calc(var(--toolbar-height) + 22px);
}
.markdown-body h1 { margin: 0 0 28px; font-size: clamp(2.2rem, 5vw, 3.5rem); letter-spacing: -.045em; }
.markdown-body h2 { margin: 2.3em 0 .7em; padding-bottom: .35em; font-size: 1.75rem; border-bottom: 1px solid var(--line); }
.markdown-body h3 { margin: 1.8em 0 .6em; font-size: 1.35rem; }
.markdown-body h4, .markdown-body h5, .markdown-body h6 { margin: 1.5em 0 .5em; }
.markdown-body p, .markdown-body ul, .markdown-body ol, .markdown-body blockquote, .markdown-body table { margin: 1em 0; }
.markdown-body a { text-decoration-thickness: .08em; text-underline-offset: .18em; }
.markdown-body img { display: block; max-width: 100%; height: auto; margin: 26px auto; border-radius: 10px; box-shadow: var(--shadow); }
.markdown-body blockquote { margin-left: 0; padding: .25em 1.15em; color: var(--muted); border-left: 4px solid var(--accent); background: var(--surface-muted); border-radius: 0 10px 10px 0; }
.markdown-body code { padding: .15em .38em; border-radius: 5px; background: var(--code); font: .86em ui-monospace, SFMono-Regular, Menlo, monospace; }
.markdown-body pre { overflow: auto; padding: 18px 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--code); box-shadow: var(--shadow); }
.markdown-body pre code { padding: 0; background: transparent; font-size: 14px; }
.markdown-body table { display: block; width: max-content; max-width: 100%; overflow: auto; border-collapse: collapse; font-family: Inter, ui-sans-serif, sans-serif; font-size: 15px; }
.markdown-body th, .markdown-body td { padding: 9px 13px; border: 1px solid var(--line); }
.markdown-body th { background: var(--surface-muted); text-align: left; }
.markdown-body hr { height: 1px; margin: 2.5em 0; background: var(--line); border: 0; }
.markdown-body input[type="checkbox"] { margin-right: .45em; accent-color: var(--accent); }

.mermaid-diagram { margin: 32px 0; padding: 24px; overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-solid); box-shadow: var(--shadow); }
.mermaid-output { display: grid; place-items: center; min-width: max-content; }
.mermaid-output svg { max-width: 100%; height: auto; }
.mermaid-diagram.has-error .mermaid-source { display: block; white-space: pre-wrap; }
.mermaid-error { color: var(--danger); font: 14px/1.5 Inter, sans-serif; }

.management-shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 58px 0 90px; }
.management-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 28px; margin-bottom: 30px; }
.management-heading h1 { margin: 4px 0 8px; font-size: clamp(2.25rem, 6vw, 4.5rem); line-height: 1; letter-spacing: -.055em; }
.management-heading p:not(.eyebrow) { max-width: 650px; margin: 0; color: var(--muted); font-size: 17px; }
.eyebrow { margin: 0; color: var(--accent); font-size: 11px; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.panel { background: var(--surface-solid); border: 1px solid var(--line); border-radius: 17px; box-shadow: var(--shadow); }
.stack-form { display: flex; flex-direction: column; gap: 17px; }
.artifact-panel h2 { margin: 4px 0 0; font-size: 21px; letter-spacing: -.025em; }
.stack-form label, .upload-form label {
  display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 750;
}
.stack-form input, .upload-form input:not([type="checkbox"]) {
  width: 100%; height: 42px; padding: 0 12px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; outline: none;
}
.stack-form input:focus, .upload-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.context-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.context-grid-wide { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.context-card {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 82px;
  padding: 16px; color: var(--text); background: var(--surface-solid); border: 1px solid var(--line); border-radius: 15px;
  text-decoration: none; box-shadow: 0 6px 20px rgba(31,42,68,.04); transition: transform .15s, border-color .15s, box-shadow .15s;
}
.context-card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); }
.context-icon { display: grid; width: 40px; height: 40px; place-items: center; color: var(--accent); background: var(--accent-soft); border-radius: 11px; font-weight: 900; }
.context-card strong, .context-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.context-card small { margin-top: 4px; color: var(--faint); font-size: 12px; }
.context-arrow { color: var(--faint); font-size: 20px; }
.dashboard-empty {
  width: 100%; min-height: 180px; grid-column: 1 / -1; color: var(--muted); font: inherit; cursor: pointer;
  transition: color .15s, border-color .15s, background .15s, transform .15s;
}
.dashboard-empty:hover, .dashboard-empty:focus-visible { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); outline: none; transform: translateY(-2px); }
.dashboard-empty strong, .dashboard-empty small { display: block; }
.dashboard-empty strong { margin-bottom: 7px; color: var(--text); font-size: 17px; }
.dashboard-empty small { font-size: 13px; }
.endpoint-copy { display: flex; align-items: center; gap: 10px; min-width: 0; }
.endpoint-copy code { max-width: 390px; overflow: auto; padding: 10px 12px; background: var(--code); border-radius: 9px; white-space: nowrap; }
.token-form { display: grid; grid-template-columns: minmax(220px, 1fr) auto; align-items: end; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.token-form label { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 750; }
.token-form input { width: 100%; height: 42px; padding: 0 12px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; outline: none; }
.token-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.token-result { display: grid; grid-template-columns: minmax(150px, .65fr) minmax(240px, 1.5fr) auto; align-items: center; gap: 14px; padding: 18px 24px; background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.token-result strong, .token-result small { display: block; }
.token-result small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.token-result code { min-width: 0; overflow: auto; padding: 10px 12px; color: var(--text); background: var(--surface-solid); border: 1px solid var(--line); border-radius: 9px; white-space: nowrap; }
.token-list { padding: 0 12px; }
.token-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 14px 12px; border-bottom: 1px solid var(--line); }
.token-row:last-child { border-bottom: 0; }
.token-row strong, .token-row small { display: block; }
.token-row small { margin-top: 5px; color: var(--faint); font-size: 11px; }
.token-row code { color: var(--muted); }
.token-empty { margin: 0; padding: 20px 12px; color: var(--faint); font-size: 13px; }

.context-manager { max-width: 980px; }
.context-heading { align-items: center; }
.context-heading h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
.upload-form { display: grid; gap: 14px; }
.upload-form input[type="file"] { height: auto; padding: 9px; }
.upload-form .check-label { display: flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 600; }
.upload-form input[type="checkbox"] { accent-color: var(--accent); }
.empty-drop-zone {
  display: grid; width: 100%; min-height: 330px; place-content: center; justify-items: center; gap: 8px; padding: 42px;
  color: var(--muted); background: color-mix(in srgb, var(--surface-solid) 60%, transparent); border: 2px dashed var(--line);
  border-radius: 22px; cursor: pointer; transition: color .15s, border-color .15s, background .15s, transform .15s;
}
.empty-drop-zone:hover, .empty-drop-zone:focus-visible { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); outline: none; transform: translateY(-2px); }
.empty-drop-zone .drop-icon { display: grid; width: 54px; height: 54px; place-items: center; margin-bottom: 8px; color: var(--accent); background: var(--accent-soft); border-radius: 16px; font-size: 28px; }
.empty-drop-zone strong { color: var(--text); font-size: 21px; letter-spacing: -.02em; }
.empty-drop-zone small { max-width: 390px; font-size: 13px; line-height: 1.55; }
.artifact-panel { overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; }
.panel-heading span { padding: 4px 8px; color: var(--muted); background: var(--surface-muted); border-radius: 99px; font-size: 11px; font-weight: 800; }
.artifact-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 12px 8px 20px; border-bottom: 1px solid var(--line); }
.artifact-row:last-child { border-bottom: 0; }
.artifact-row > a { min-width: 0; padding: 8px 0; color: var(--text); text-decoration: none; }
.artifact-name, .artifact-meta { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artifact-name { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
.artifact-meta { margin-top: 5px; color: var(--faint); font-size: 11px; }
.document-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.document-actions .document-path { margin: 0; text-decoration: none; }

.modal-dialog {
  width: min(520px, calc(100% - 32px)); max-width: none; max-height: calc(100dvh - 40px); padding: 0;
  color: var(--text); background: transparent; border: 0; overflow: visible;
}
.modal-dialog-wide { width: min(720px, calc(100% - 32px)); }
.modal-dialog::backdrop { background: rgba(8, 12, 20, .58); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-card { overflow: hidden; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 28px 80px rgba(0, 0, 0, .28); }
.modal-card-wide { width: 100%; max-height: calc(100dvh - 40px); overflow: auto; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 22px 24px 18px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 4px 0 0; font-size: 23px; letter-spacing: -.03em; }
.modal-form { padding: 22px 24px 24px; }
.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; margin-top: 4px; }
.modal-drop-hint { padding: 11px 13px; color: var(--muted); background: var(--surface-muted); border-radius: 10px; font-size: 12px; line-height: 1.45; }
.modal-drop-hint span { margin-right: 5px; color: var(--accent); font-weight: 900; }
.mcp-modal-content { display: grid; gap: 14px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.mcp-modal-content > p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.mcp-modal-content #copy-skill { justify-self: start; }
.connector-guide { padding: 22px 24px; border-bottom: 1px solid var(--line); }
.connector-guide > header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.connector-guide h3 { margin: 4px 0 0; font-size: 18px; letter-spacing: -.02em; }
.connector-guide ol { margin: 0 0 16px; padding-left: 21px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.connector-guide li + li { margin-top: 7px; }
.connector-guide li code { padding: 2px 5px; color: var(--text); background: var(--code); border-radius: 5px; font-size: 11px; overflow-wrap: anywhere; }
.platform-paths { display: grid; gap: 8px; margin-bottom: 14px; }
.platform-path { display: grid; grid-template-columns: minmax(130px, .55fr) minmax(0, 1.45fr); align-items: center; gap: 12px; padding: 10px 12px; background: var(--surface-muted); border-radius: 10px; }
.platform-path-command { grid-template-columns: minmax(130px, .55fr) minmax(0, 1.45fr) auto; }
.platform-path strong, .platform-path small { display: block; }
.platform-path strong { font-size: 12px; }
.platform-path small { margin-top: 3px; color: var(--faint); font-size: 10px; line-height: 1.35; }
.platform-path code { min-width: 0; overflow: auto; color: var(--muted); font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.connector-guide pre { max-height: 280px; margin: 0; overflow: auto; padding: 15px 17px; color: var(--text); background: var(--code); border: 1px solid var(--line); border-radius: 12px; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.connector-guide pre code { white-space: pre; }
.connector-note { margin: 10px 0 0; color: var(--faint); font-size: 11px; line-height: 1.45; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.danger-zone strong { color: var(--danger); }
.danger-zone p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.global-drop-overlay {
  position: fixed; z-index: 100; inset: 14px; display: grid; place-items: center; opacity: 0; pointer-events: none;
  color: var(--text); background: color-mix(in srgb, var(--accent-soft) 92%, transparent); border: 3px dashed var(--accent);
  border-radius: 24px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transform: scale(.985);
  transition: opacity .12s, transform .12s;
}
.global-drop-overlay.visible, .global-drop-overlay.uploading { opacity: 1; transform: scale(1); }
.global-drop-overlay > div { display: grid; justify-items: center; gap: 8px; padding: 30px; text-align: center; }
.global-drop-overlay span { display: grid; width: 68px; height: 68px; place-items: center; margin-bottom: 8px; color: #fff; background: var(--accent); border-radius: 20px; font-size: 36px; box-shadow: var(--shadow); }
.global-drop-overlay strong { font-size: clamp(1.4rem, 4vw, 2.2rem); letter-spacing: -.035em; }
.global-drop-overlay small { color: var(--muted); font-size: 14px; }

.auth-body { display: grid; place-items: center; padding: 42px 20px; background: radial-gradient(circle at 50% 0, var(--accent-soft), var(--bg) 45%); }
.auth-shell { width: min(440px, 100%); }
.auth-brand { margin: 0 auto 18px; }
.auth-card { padding: 30px; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 7px 0 10px; font-size: 30px; letter-spacing: -.04em; }
.auth-lede { margin: 0 0 24px; color: var(--muted); line-height: 1.55; }
.auth-switch { margin: 20px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.form-error { padding: 11px 13px; color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); border-radius: 10px; font-size: 13px; }

.toc-scroll nav { display: flex; flex-direction: column; gap: 1px; }
.toc-scroll a {
  --toc-indent: 0ch;
  display: block;
  padding: 6px 8px 6px var(--toc-indent); color: var(--muted); border-left: 2px solid transparent; border-radius: 0 8px 8px 0;
  font-size: 12px; line-height: 1.4; text-align: left !important; text-decoration: none; transition: color .15s, border-color .15s, background .15s;
}
.toc-scroll a:hover, .toc-scroll a.active { color: var(--accent); border-left-color: var(--accent); background: var(--accent-soft); }
.toc-scroll nav > a:first-child { padding-left: 6px; }
.toc-dash { display: none; height: 2px; background: currentColor; border-radius: 999px; opacity: .46; transition: width .15s, opacity .15s, color .15s; }
.toc-link-title {
  display: -webkit-box; width: 100%; min-width: 0; max-height: 2.8em; overflow: hidden; overflow-wrap: anywhere;
  text-align: left !important; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}
.toc-depth-1 { --toc-indent: 4ch !important; }
.toc-depth-2 { --toc-indent: 8ch !important; }
.toc-depth-3 { --toc-indent: 12ch !important; }
.toc-depth-4 { --toc-indent: 16ch !important; }
.toc-depth-5 { --toc-indent: 20ch !important; }

body.tree-collapsed .layout { --active-tree-width: var(--tree-collapsed-width); }
body.tree-collapsed .tree-pane-header { justify-content: center; padding: 0; }
body.tree-collapsed .tree-pane-title, body.tree-collapsed .tree-scroll, body.tree-collapsed .tree-resizer { display: none; }
body.toc-collapsed .layout { --active-toc-width: var(--toc-collapsed-width); }
body.toc-collapsed .toc-rail { align-items: center; padding: 18px 9px; }
body.toc-collapsed .toc-card {
  flex: 0 0 30px; width: 30px; height: auto; max-height: min(72vh, 680px); overflow: hidden;
  background: transparent; border-color: transparent; border-radius: 0; box-shadow: none;
}
body.toc-collapsed .toc-header { display: none; }
body.toc-collapsed .toc-link-title { display: none; }
body.toc-collapsed .toc-scroll { padding: 4px 2px; scrollbar-width: none; }
body.toc-collapsed .toc-scroll::-webkit-scrollbar { display: none; }
body.toc-collapsed .toc-scroll a {
  display: grid; width: 26px; height: 14px; place-items: center; padding: 0 !important;
  color: var(--faint); background: transparent; border: 0; border-radius: 0;
}
body.toc-collapsed .toc-dash { display: block; width: 14px; }
body.toc-collapsed .toc-depth-0 .toc-dash { width: 18px; }
body.toc-collapsed .toc-depth-1 .toc-dash { width: 13px; transform: translateX(2px); }
body.toc-collapsed .toc-depth-2 .toc-dash { width: 9px; transform: translateX(4px); }
body.toc-collapsed .toc-depth-3 .toc-dash, body.toc-collapsed .toc-depth-4 .toc-dash, body.toc-collapsed .toc-depth-5 .toc-dash { width: 7px; transform: translateX(5px); }
body.toc-collapsed .toc-scroll a:hover .toc-dash { opacity: .78; }
body.toc-collapsed .toc-scroll a.active .toc-dash { width: 20px; color: var(--text); opacity: 1; transform: none; }
body.toc-collapsed .toc-rail:hover .toc-card, body.toc-collapsed .toc-card:focus-within {
  flex-basis: min(320px, 34vw); width: min(320px, 34vw); max-height: min(72vh, 680px);
  background: var(--surface-solid); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
body.toc-collapsed .toc-rail:hover .toc-header, body.toc-collapsed .toc-card:focus-within .toc-header {
  position: absolute; z-index: 2; top: 7px; right: 7px; display: flex; min-height: 30px; padding: 0; border: 0;
}
body.toc-collapsed .toc-rail:hover .toc-title, body.toc-collapsed .toc-card:focus-within .toc-title { display: none; }
body.toc-collapsed .toc-rail:hover .toc-toggle, body.toc-collapsed .toc-card:focus-within .toc-toggle { width: 28px; height: 28px; background: var(--surface-solid); border-color: var(--line); }
body.toc-collapsed .toc-rail:hover .toc-scroll, body.toc-collapsed .toc-card:focus-within .toc-scroll {
  padding: 12px 10px 14px; scrollbar-width: thin;
}
body.toc-collapsed .toc-rail:hover .toc-scroll::-webkit-scrollbar, body.toc-collapsed .toc-card:focus-within .toc-scroll::-webkit-scrollbar { display: block; }
body.toc-collapsed .toc-rail:hover .toc-scroll a, body.toc-collapsed .toc-card:focus-within .toc-scroll a {
  display: block; width: auto; height: auto; place-items: initial; padding: 6px 8px 6px var(--toc-indent) !important;
  color: var(--muted); background: transparent; border-left: 2px solid transparent; border-radius: 0 8px 8px 0;
}
body.toc-collapsed .toc-rail:hover .toc-scroll a:first-child, body.toc-collapsed .toc-card:focus-within .toc-scroll a:first-child { padding-right: 36px !important; padding-left: 6px !important; }
body.toc-collapsed .toc-rail:hover .toc-scroll a:hover, body.toc-collapsed .toc-rail:hover .toc-scroll a.active,
body.toc-collapsed .toc-card:focus-within .toc-scroll a:hover, body.toc-collapsed .toc-card:focus-within .toc-scroll a.active {
  color: var(--accent); background: var(--accent-soft); border-left-color: var(--accent);
}
body.toc-collapsed .toc-rail:hover .toc-dash, body.toc-collapsed .toc-card:focus-within .toc-dash { display: none; }
body.toc-collapsed .toc-rail:hover .toc-link-title, body.toc-collapsed .toc-card:focus-within .toc-link-title { display: -webkit-box; }

@media (max-width: 1050px) {
  .layout, .layout.without-tree { grid-template-columns: var(--active-tree-width) minmax(0, 1fr); }
  .layout.without-tree { grid-template-columns: minmax(0, 1fr); }
  .toc-rail { display: none; }
  .document-shell { padding-left: 42px; padding-right: 42px; }
  .toolbar-action > span:last-child { display: none; }
  .context-grid-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  :root { --toolbar-height: 54px; }
  .toolbar { padding: 0 8px; gap: 5px; }
  .brand { width: 34px; height: 34px; }
  .context-picker { min-width: 90px; max-width: none; flex: 1 1 auto; }
  .context-picker select { padding-right: 24px; padding-left: 9px; }
  .button { padding: 0 10px; font-size: 13px; }
  .toolbar-action { width: 32px; height: 34px; justify-content: center; padding: 0; }
  .toolbar .icon-button { width: 34px; height: 34px; flex: 0 0 34px; }
  .user-pill, .theme-picker { display: none; }
  .layout, .layout.without-tree, .layout.without-toc { display: block; }
  .file-tree, .toc-rail { display: none; }
  .document-shell { padding: 28px 22px 70px; }
  .toolbar #print-document { display: none; }
  .markdown-body { font-size: 16px; }
  .markdown-body h1 { font-size: 2.25rem; }
  .mermaid-diagram { padding: 12px; margin-left: -8px; margin-right: -8px; }
  .management-shell { width: min(100% - 28px, 720px); padding-top: 34px; }
  .management-heading { display: block; }
  .management-heading .danger-button { margin-top: 18px; }
  .context-heading { margin-bottom: 22px; }
  .context-grid { grid-template-columns: 1fr; }
  .artifact-panel { overflow: visible; background: transparent; border: 0; border-radius: 0; box-shadow: none; }
  .artifact-panel .panel-heading { padding: 0 0 12px; border: 0; }
  .artifact-list { display: grid; gap: 10px; }
  .artifact-row, .artifact-row:last-child {
    min-height: 76px; padding: 12px 10px 12px 16px; background: var(--surface-solid); border: 1px solid var(--line);
    border-radius: 14px; box-shadow: 0 6px 20px rgba(31,42,68,.05);
  }
  .artifact-row > a { padding: 5px 0; }
  .artifact-name { font-size: 13px; }
  .artifact-meta { white-space: normal; line-height: 1.4; }
  .endpoint-copy { align-items: flex-start; flex-direction: column; }
  .endpoint-copy, .endpoint-copy code { width: 100%; max-width: none; }
  .token-form, .token-result { grid-template-columns: 1fr; }
  .modal-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 20px); }
  .modal-dialog-wide { width: calc(100% - 20px); }
  .modal-card-wide { max-height: calc(100dvh - 20px); }
  .modal-header, .modal-form, .mcp-modal-content, .connector-guide { padding-right: 18px; padding-left: 18px; }
  .connector-guide > header { align-items: flex-start; flex-direction: column; }
  .platform-path, .platform-path-command { grid-template-columns: 1fr; gap: 7px; }
  .platform-path-command .button { justify-self: start; }
  .danger-zone { align-items: stretch; flex-direction: column; }
  .empty-drop-zone { min-height: 280px; padding: 28px 20px; }
  .auth-card { padding: 24px; }
}

@media (max-width: 360px) {
  .toolbar > .brand { display: none; }
}

@media print {
  :root, :root[data-theme="dark"] {
    color-scheme: light; --bg: #fff; --surface-solid: #fff; --surface-muted: #f3f4f6;
    --text: #111827; --muted: #4b5563; --line: #d1d5db; --code: #f3f4f6; --shadow: none;
  }
  @page { margin: 18mm 17mm; }
  body { background: #fff; color: #111827; }
  .toolbar, .file-tree, .toc-rail, .document-path, .empty-state, .global-drop-overlay, .modal-dialog { display: none !important; }
  .layout, .layout.without-tree, .layout.without-toc { display: block; max-width: none; min-height: 0; }
  .document-shell { max-width: none; padding: 0; }
  .markdown-body { font-size: 11pt; line-height: 1.55; }
  .markdown-body h1 { font-size: 25pt; }
  .markdown-body h2 { font-size: 18pt; break-after: avoid; }
  .markdown-body h3, .markdown-body h4 { break-after: avoid; }
  .markdown-body pre, .markdown-body blockquote, .markdown-body table, .mermaid-diagram { break-inside: avoid; box-shadow: none; }
  .markdown-body a { color: inherit; text-decoration: underline; }
  .mermaid-diagram { border-color: #d1d5db; }
}
