:root {
  --bg: #f6f5f2; --surface: #fff; --ink: #1c2330; --muted: #667085; --line: #e3e1da;
  --accent: #1f3a5f; --accent-ink: #fff; --accent-soft: #e8eef6; --err: #a33a2c; --err-soft: #fbeceA;
  --code: #f0eee8; --side: #efede7; --side-hover: #e4e1d9; --shadow: 0 1px 2px rgba(28, 35, 48, .06), 0 8px 24px rgba(28, 35, 48, .06);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1420; --surface: #171e2d; --ink: #e8ecf4; --muted: #9aa5b8; --line: #263148;
    --accent: #6f9bd6; --accent-ink: #0b1220; --accent-soft: #1d2a42; --err: #f08a7b; --err-soft: #3a1f1c;
    --code: #1f2940; --shadow: none; --side: #121827; --side-hover: #1b2438;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55; display: flex; flex-direction: column; overflow: hidden; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
code { background: var(--code); padding: .1em .35em; border-radius: 4px; font-size: .9em; }
pre { background: var(--code); padding: 12px 14px; border-radius: 8px; overflow: auto; position: relative; margin: 10px 0; font-size: 13px; line-height: 1.5; }
pre code { background: none; padding: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.login { flex: 1; overflow: auto; display: grid; place-items: center; padding: 24px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 36px 32px; width: min(420px, 100%); display: grid; gap: 14px; justify-items: start; }
.card h1 { margin: 0; font-size: 22px; }
.card p { margin: 0; }
.notice.err { background: var(--err-soft); color: var(--err); padding: 8px 12px; border-radius: 8px; width: 100%; }
.card .btn { width: 100%; }

.doc { width: min(800px, 100%); margin: 0 auto; padding: 28px 20px 60px; }
body.page-skill, body.page-docs { overflow: auto; }
.page-skill .main, .page-docs .main { overflow: auto; }
.doc h1 { margin: 0 0 6px; font-size: 26px; }
.lead { color: var(--muted); font-size: 16px; margin-top: 0; }
.steps { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 22px; margin: 18px 0; }
.steps h2 { font-size: 17px; margin: 0 0 8px; display: flex; align-items: center; gap: 10px; }
.n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 13px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 10px 0 14px; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button[aria-selected=true] { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.copy { position: absolute; top: 8px; right: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 6px; font: inherit; font-size: 12px; padding: 2px 8px; cursor: pointer; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }


/* App shell: sidebar + main, like the chat products. */
.shell { display: grid; grid-template-columns: 272px 1fr; height: 100vh; height: 100dvh; width: 100%; }
.side { background: var(--side); display: flex; flex-direction: column; padding: 12px 10px; min-height: 0; border-right: 1px solid var(--line); }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; text-decoration: none; color: var(--ink); }
.brand img { border-radius: 8px; }
.side-actions { display: grid; gap: 2px; margin-bottom: 14px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 520; }
.side-link:hover, .side-link[aria-current] { background: var(--side-hover); }
.side-link svg { color: var(--muted); }
.side-label { padding: 0 10px 6px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding-right: 2px; }
.side-empty { color: var(--muted); font-size: 13px; padding: 6px 10px; margin: 0; }
.group { font-size: 11.5px; color: var(--muted); padding: 12px 10px 4px; }
.chat-row { position: relative; display: flex; align-items: center; border-radius: 10px; }
.chat-row a { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 8px 10px; text-decoration: none; color: var(--ink); font-size: 14px; border-radius: 10px; }
.chat-row .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row .tag { font-size: 10.5px; padding: 1px 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; flex: none; }
.chat-row:hover, .chat-row.active { background: var(--side-hover); }
.chat-row .del { position: absolute; right: 6px; border: 0; background: var(--side-hover); color: var(--muted); border-radius: 8px; width: 28px; height: 28px; display: none; place-items: center; cursor: pointer; }
.chat-row:hover .del, .chat-row .del:focus-visible { display: grid; }
.chat-row:hover .tag, .chat-row:focus-within .tag { visibility: hidden; }
.chat-row .del:hover { color: var(--err); }
.side-foot { display: flex; align-items: center; gap: 10px; padding: 10px 6px 2px; margin-top: 8px; border-top: 1px solid var(--line); min-width: 0; }
.avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 650; text-transform: uppercase; font-size: 13px; }
.side-foot .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); }
.icon-btn { border: 0; background: none; color: var(--muted); border-radius: 8px; width: 34px; height: 34px; display: inline-grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--side-hover); color: var(--ink); }
.only-mobile, .scrim { display: none; }
.main { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; min-height: 58px; }
.chat-head h1 { margin: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.switch { display: inline-flex; background: var(--accent-soft); border-radius: 999px; padding: 3px; gap: 2px; flex: none; }
.switch button { border: 0; background: transparent; color: var(--muted); border-radius: 999px; padding: 5px 16px; cursor: pointer; font: inherit; font-size: 13.5px; font-weight: 600; }
.switch button[aria-selected=true] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.switch button:disabled:not([aria-selected=true]) { opacity: .45; cursor: not-allowed; }
.log { flex: 1; min-height: 0; overflow-y: auto; }
.col { width: min(760px, 100%); margin: 0 auto; padding: 8px 20px 24px; display: flex; flex-direction: column; gap: 22px; min-height: 100%; }
.empty { margin: auto; text-align: center; display: grid; justify-items: center; gap: 4px; padding-bottom: 60px; }
.empty img { border-radius: 16px; box-shadow: var(--shadow); }
.empty h2 { margin: 14px 0 0; font-size: 28px; font-weight: 600; letter-spacing: -.01em; }
.empty p { margin: 0; color: var(--muted); }
.msg { overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; max-width: 80%; background: var(--accent-soft); padding: 9px 15px; border-radius: 18px; white-space: pre-wrap; }
.msg.agent { display: flex; gap: 12px; align-items: flex-start; }
.msg.agent .av { flex: none; border-radius: 8px; margin-top: 2px; }
.msg.agent .body { flex: 1; min-width: 0; }
.msg.agent.error .body { color: var(--err); white-space: pre-wrap; }
.msg p { margin: 0 0 10px; } .msg p:last-child { margin-bottom: 0; }
.msg h4 { margin: 12px 0 4px; } .msg ul, .msg ol { margin: 4px 0 10px; padding-left: 22px; }
.msg.wait { color: var(--muted); }
.dots i { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite both; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; } }
.composer-wrap { width: min(760px, 100%); margin: 0 auto; padding: 0 20px 14px; }
.composer { display: flex; align-items: flex-end; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 8px 8px 8px 20px; box-shadow: var(--shadow); }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { flex: 1; border: 0; resize: none; background: transparent; color: var(--ink); font: inherit; outline: none; padding: 8px 0; max-height: 220px; line-height: 1.5; }
.send { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; }
.send:disabled { opacity: .35; cursor: not-allowed; }
.hint { margin: 8px 0 0; text-align: center; color: var(--muted); font-size: 12px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 30; transform: translateX(-100%); transition: transform .2s ease; }
  .shell.open .side { transform: none; box-shadow: var(--shadow); }
  .shell.open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 20; }
  .only-mobile { display: inline-grid; }
  .menu-btn { position: absolute; top: 12px; left: 8px; z-index: 5; }
  .chat-head { padding-left: 52px; }
  .page-skill .doc, .page-docs .doc { padding-top: 56px; }
  .col, .composer-wrap { padding-left: 14px; padding-right: 14px; }
  .empty h2 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

/* Administration page */
.side-actions.admin { margin: -6px 0 12px; }
.doc.wide { width: min(1040px, 100%); }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-weight: 650; font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; }
.toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 6px; }
.toc a { padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; font-size: 13px; background: var(--surface); }
.toc a:hover { border-color: var(--accent); }
.steps h3 { font-size: 14.5px; margin: 18px 0 6px; }
.steps ul, .steps ol { padding-left: 22px; margin: 8px 0; }
.steps li { margin: 4px 0; }
figure { margin: 14px 0; }
figcaption { color: var(--muted); font-size: 13px; margin-top: 6px; }
.dg { width: 100%; height: auto; display: block; font-family: inherit; }
.dg text { fill: var(--ink); font-size: 14px; text-anchor: middle; font-weight: 600; }
.dg .dg-sub { font-size: 11.5px; font-weight: 400; fill: var(--muted); }
.dg .dg-cap { font-size: 12px; fill: var(--muted); font-weight: 600; letter-spacing: .04em; }
.dg .dg-note { font-size: 12px; font-weight: 500; fill: var(--muted); }
.dg .dg-step { font-size: 12.5px; font-weight: 500; text-anchor: start; }
.dg .dg-bar { fill: #fff; font-size: 14px; }
.dg-zone rect { fill: none; stroke: var(--line); stroke-dasharray: 5 5; }
.dg-box rect { fill: var(--surface); stroke: var(--line); stroke-width: 1.4; }
.dg-box.hot rect { fill: var(--accent-soft); stroke: var(--accent); }
.dg-line { fill: none; stroke: var(--muted); stroke-width: 1.6; }
.dg-line.dash { stroke-dasharray: 6 4; }
.dg-line.mcp { stroke: #2f9e6e; }
.dg-line.hidden-line { display: none; }
.dg-head { fill: var(--muted); }
.dg-life { stroke: var(--line); stroke-width: 1.4; stroke-dasharray: 3 5; }
.dg-ok { fill: #2f9e6e; } .dg-warn { fill: #d08a1e; } .dg-bad { fill: #c0463a; }
.doc table td:first-child { white-space: nowrap; font-weight: 550; }
.doc table td code { word-break: break-word; }
@media (max-width: 760px) { .doc table td:first-child { white-space: normal; } }
