:root { color-scheme: light dark; --fg: #111; --bg: #fafafa; --panel: #fff; --muted: #666; --border: #e5e5e5; --accent: #111; --accent-fg: #fff; --risk: #b45309; --ok: #047857; --err: #b91c1c; --subtle: #f2f2f2; }
@media (prefers-color-scheme: dark) { :root { --fg: #eee; --bg: #0b0b0b; --panel: #141414; --muted: #888; --border: #222; --accent: #fafafa; --accent-fg: #0b0b0b; --subtle: #161616; } }
* { box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif; margin: 0; min-height: 100vh; background: var(--bg); color: var(--fg); font-size: 14px; line-height: 1.5; }
a { color: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }
pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; background: var(--subtle); padding: .5rem .75rem; border-radius: .25rem; overflow-x: auto; white-space: pre-wrap; }
button { font: inherit; padding: .5rem .9rem; border: 1px solid var(--accent); border-radius: .375rem; background: var(--accent); color: var(--accent-fg); cursor: pointer; }
button.secondary { background: transparent; color: var(--fg); }
button.danger { background: var(--err); border-color: var(--err); color: white; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: .375rem; background: var(--panel); color: var(--fg); width: 100%; }
textarea { min-height: 6rem; resize: vertical; }
label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .25rem; margin-top: .75rem; }
label:first-child { margin-top: 0; }
.hidden { display: none !important; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.error { color: var(--err); }
.ok { color: var(--ok); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: .5rem; padding: 1.25rem; margin-bottom: 1rem; }
.card h2 { margin: 0 0 1rem; font-size: 1rem; font-weight: 600; }
.pill { display: inline-block; padding: .125rem .5rem; border-radius: 999px; font-size: .7rem; font-weight: 600; }
.pill-ok { background: rgba(4,120,87,.15); color: var(--ok); }
.pill-err { background: rgba(185,28,28,.15); color: var(--err); }
.pill-warn { background: rgba(180,83,9,.15); color: var(--risk); }
.pill-muted { background: var(--subtle); color: var(--muted); }

/* === auth (full-screen) === */
#view-auth { max-width: 26rem; margin: 4rem auto; padding: 0 1rem; }
#view-auth h1 { text-align: center; letter-spacing: .2em; font-weight: 700; margin-bottom: 2rem; }

/* === app shell === */
#view-app { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: auto 1fr; grid-template-areas: 'header header' 'sidebar main'; min-height: 100vh; }
#app-header { grid-area: header; display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; border-bottom: 1px solid var(--border); background: var(--panel); }
#app-header h1 { margin: 0; font-size: 1rem; letter-spacing: .2em; font-weight: 700; }
#app-header .user { display: flex; gap: .75rem; align-items: center; color: var(--muted); font-size: .85rem; }

#sidebar { grid-area: sidebar; border-right: 1px solid var(--border); background: var(--panel); overflow-y: auto; padding: .75rem 0; }
#sidebar .nav-group { margin-bottom: .5rem; }
#sidebar .nav-group-label { font-size: .65rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: .75rem 1rem .25rem; font-weight: 600; }
#sidebar .nav-item { display: flex; align-items: center; gap: .5rem; padding: .4rem 1rem; cursor: pointer; font-size: .875rem; color: var(--fg); border-left: 2px solid transparent; }
#sidebar .nav-item:hover { background: var(--subtle); }
#sidebar .nav-item.active { background: var(--subtle); border-left-color: var(--accent); font-weight: 600; }
#sidebar .nav-item.disabled { color: var(--muted); cursor: not-allowed; }
#sidebar .nav-item.disabled:hover { background: transparent; }
#sidebar .nav-sub { padding-left: 1rem; }
#sidebar .nav-sub .nav-item { font-size: .825rem; padding-left: 1.75rem; }
#sidebar .badge { margin-left: auto; font-size: .7rem; background: var(--err); color: white; border-radius: 999px; padding: 0 .4rem; }

#main { grid-area: main; overflow-y: auto; padding: 1.5rem; max-width: 64rem; }
#main h2.section-title { margin: 0 0 1rem; font-size: 1.25rem; font-weight: 600; }
#main .breadcrumbs { color: var(--muted); font-size: .8rem; margin-bottom: .5rem; }

/* === orchestrator panel (floating, bottom-right) === */
#orchestrator { position: fixed; right: 1rem; bottom: 1rem; width: 26rem; max-width: calc(100vw - 2rem); max-height: 60vh; background: var(--panel); border: 1px solid var(--border); border-radius: .5rem; box-shadow: 0 8px 24px rgba(0,0,0,.15); display: flex; flex-direction: column; z-index: 50; }
#orchestrator.collapsed { height: auto; }
#orchestrator.collapsed #orch-body { display: none; }
#orch-header { display: flex; align-items: center; justify-content: space-between; padding: .5rem .75rem; border-bottom: 1px solid var(--border); cursor: pointer; }
#orch-header .title { font-size: .8rem; font-weight: 600; letter-spacing: .05em; }
#orch-body { padding: .75rem; overflow-y: auto; }
#orch-body textarea { min-height: 3rem; }
#orch-body .orch-ctx { font-size: .7rem; color: var(--muted); margin-bottom: .25rem; }

/* === mobile === */
@media (max-width: 900px) {
  #view-app { grid-template-columns: 1fr; grid-template-areas: 'header' 'main'; }
  #sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 240px; transform: translateX(-100%); transition: transform .15s; z-index: 100; padding-top: 3.5rem; }
  #sidebar.open { transform: translateX(0); }
  #sidebar-scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; }
  #sidebar-scrim.open { display: block; }
  #btn-menu { display: inline-block !important; }
  #orchestrator { right: 1rem; bottom: 1rem; width: auto; }
  #orchestrator.collapsed { padding: 0; }
  #orchestrator.collapsed #orch-header { border: none; background: var(--accent); color: var(--accent-fg); border-radius: 999px; padding: .6rem .9rem; box-shadow: 0 6px 16px rgba(0,0,0,.2); }
  #orchestrator:not(.collapsed) { left: 1rem; right: 1rem; width: auto; }
}
#btn-menu { display: none; background: transparent; color: var(--fg); border: 1px solid var(--border); padding: .35rem .6rem; margin-right: .5rem; border-radius: .25rem; }

/* Help section: 2-column shell with TOC + article */
.help-shell { display: grid; grid-template-columns: 200px 1fr; gap: 1rem; }
.help-toc { padding: .5rem; align-self: start; position: sticky; top: 1rem; }
.help-toc-item { display: block; padding: .35rem .6rem; border-radius: .25rem; text-decoration: none; color: var(--fg); font-size: .9rem; }
.help-toc-item:hover { background: color-mix(in srgb, var(--border) 50%, transparent); }
.help-toc-item.active { background: color-mix(in srgb, var(--accent) 15%, transparent); font-weight: 600; }
.help-article { padding: 1.5rem 2rem; max-width: 48rem; }
@media (max-width: 700px) { .help-shell { grid-template-columns: 1fr; } .help-toc { position: static; } }

/* Markdown prose styling for /docs rendered HTML */
.prose { line-height: 1.65; }
.prose h1 { margin: 0 0 1rem; font-size: 1.5rem; font-weight: 700; }
.prose h2 { margin: 1.75rem 0 .75rem; font-size: 1.2rem; font-weight: 600; padding-top: .5rem; border-top: 1px solid var(--border); }
.prose h3 { margin: 1.25rem 0 .5rem; font-size: 1rem; font-weight: 600; }
.prose p { margin: 0 0 .85rem; }
.prose ul, .prose ol { margin: 0 0 .85rem; padding-left: 1.25rem; }
.prose li { margin-bottom: .25rem; }
.prose code { background: color-mix(in srgb, var(--border) 70%, transparent); padding: 1px 5px; border-radius: 3px; font-size: .9em; }
.prose pre { background: color-mix(in srgb, var(--border) 50%, transparent); padding: .75rem 1rem; border-radius: .375rem; overflow-x: auto; font-size: .85em; }
.prose pre code { background: none; padding: 0; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.prose table { border-collapse: collapse; margin: 0 0 1rem; font-size: .9rem; }
.prose th, .prose td { border-bottom: 1px solid var(--border); padding: .35rem .75rem; text-align: left; }
.prose th { font-weight: 600; }
.prose blockquote { margin: 0 0 .85rem; padding: .25rem 1rem; border-left: 3px solid var(--border); color: var(--muted); }

/* "?" help icon, used in section titles to jump to relevant docs */
.help-icon { display: inline-block; margin-left: .5rem; padding: 0 .5rem; font-size: .75rem; font-weight: 600; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); text-decoration: none; cursor: pointer; }
.help-icon:hover { color: var(--fg); border-color: var(--fg); }
