/* Xiao DSL for Ktor Server — dark theme with violet accent */

:root {
  --bg-base: #0d0d0d;
  --bg-surface: #141414;
  --bg-elevated: #1a1a1a;
  --bg-sidebar: #111111;
  --bg-hover: #222222;
  --bg-active: #261830;
  --border: #2a2a2a;
  --border-subtle: #1f1f1f;
  --text-primary: #e8e8e8;
  --text-secondary: #9a9a9a;
  --text-muted: #666666;
  --accent: #c4b5fd;
  --accent-hover: #ddd6fe;
  --accent-dim: rgba(196, 181, 253, 0.15);
  --accent-glow: rgba(196, 181, 253, 0.35);
  --info-bg: #2a1f30;
  --info-border: #5c4d7a;
  --info-text: #c4b5fd;
  --code-bg: #1e1e1e;
  --code-color: #c4b5fd;
  --kbd-bg: #2a2a2a;
  --table-stripe: #161616;
  --header-height: 52px;
  --sidebar-width: 260px;
  --toc-width: 220px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
  --radius: 6px;
  --radius-lg: 10px;
  --transition: 0.15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 24px);
  overflow-x: clip;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 100;
  gap: 16px;
  overflow: visible;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
  color: var(--text-primary);
}

.header-brand-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #c4b5fd, #8b5cf6);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.header-brand-sub {
  font-weight: 400;
  color: var(--text-secondary);
}

.header-brand-text { font-weight: 600; font-size: 14px; white-space: nowrap; }

.header-brand-version {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.header-spacer { flex: 1; min-width: 0; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header-search {
  position: relative;
  max-width: 320px;
  width: 100%;
}

.header-search input {
  width: 100%;
  padding: 7px 12px 7px 34px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}

.header-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.header-search input::placeholder { color: var(--text-muted); }

.header-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.header-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.header-btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.header-btn-accent {
  background: var(--accent);
  color: #fff;
}

.header-btn-accent:hover {
  background: var(--accent-hover);
  color: #fff;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
}

.layout {
  display: flex;
  padding-top: var(--header-height);
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 0 40px;
  z-index: 50;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-section-title {
  padding: 8px 20px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.nav-group { margin-bottom: 4px; }

.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 20px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: color var(--transition);
}

.nav-group-toggle:hover { color: var(--text-primary); }

.nav-group-toggle svg {
  width: 12px;
  height: 12px;
  transition: transform var(--transition);
  flex-shrink: 0;
}

.nav-group.open .nav-group-toggle svg { transform: rotate(90deg); }

.nav-group-items { display: none; padding-left: 8px; }
.nav-group.open .nav-group-items { display: block; }

.nav-link {
  display: block;
  padding: 5px 20px 5px 28px;
  font-size: 13px;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-link.active {
  color: var(--accent);
  background: var(--bg-active);
  border-left-color: var(--accent);
  font-weight: 500;
}

.main {
  flex: 1 1 auto;
  min-width: 0;
  width: calc(100vw - var(--sidebar-width) - var(--toc-width));
  max-width: 860px;
  margin-left: var(--sidebar-width);
  margin-right: var(--toc-width);
  padding: 32px 48px 80px;
  box-sizing: border-box;
  overflow-x: clip;
}

article {
  max-width: 100%;
  min-width: 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

article img,
article svg {
  max-width: 100%;
  height: auto;
}

article p,
article li,
article td,
article th {
  overflow-wrap: anywhere;
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--accent); }

article section {
  margin-bottom: 64px;
  scroll-margin-top: calc(var(--header-height) + 24px);
}

article h1 {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

article h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 40px 0 12px;
  padding-top: 8px;
  letter-spacing: -0.01em;
}

article h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 28px 0 8px;
}

article p {
  margin-bottom: 14px;
  color: var(--text-secondary);
}

article ul, article ol {
  margin: 0 0 16px 20px;
  color: var(--text-secondary);
}

article li { margin-bottom: 6px; }
article strong { color: var(--text-primary); font-weight: 600; }

.lead {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  margin: 20px 0;
  font-size: 14px;
  line-height: 1.55;
}

.callout-info {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--info-text);
}

.callout-info svg { flex-shrink: 0; margin-top: 2px; color: var(--accent); }

.callout-warning {
  background: rgba(196, 181, 253, 0.08);
  border: 1px solid rgba(196, 181, 253, 0.25);
  color: #ddd6fe;
}

.feature-badge {
  display: inline-block;
  padding: 4px 12px;
  background: var(--accent-dim);
  border: 1px solid rgba(196, 181, 253, 0.25);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.table-wrap {
  overflow-x: auto;
  margin: 16px 0 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead { background: var(--bg-elevated); }

th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 9px 14px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: var(--table-stripe); }

code, kbd { font-family: var(--font-mono); font-size: 0.88em; }

code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--code-color);
  border: 1px solid var(--border);
  overflow-wrap: anywhere;
  word-break: break-word;
}

kbd {
  display: inline-block;
  background: var(--kbd-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  color: var(--text-primary);
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  overflow-x: auto;
  margin: 16px 0 24px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: #ccc;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  box-sizing: border-box;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.steps { counter-reset: step; list-style: none; margin-left: 0; padding: 0; }

.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 36px;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 24px;
  height: 24px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.block-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
  min-width: 0;
}

.block-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.block-card h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
  font-family: var(--font-mono);
}

.block-card p {
  font-size: 13px;
  margin: 0;
  color: var(--text-secondary);
}

.recipe-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 20px 0;
  max-width: 100%;
  box-sizing: border-box;
}

.recipe-card h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 32px;
}

.meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
}

.meta-badge svg { width: 14px; height: 14px; color: var(--accent); }

.toc {
  position: fixed;
  top: var(--header-height);
  right: 0;
  width: var(--toc-width);
  height: calc(100vh - var(--header-height));
  padding: 24px 16px 40px;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--bg-sidebar);
  scrollbar-width: thin;
}

.toc-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.toc-list { list-style: none; }

.toc-list a {
  display: block;
  padding: 4px 0 4px 12px;
  font-size: 12px;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  line-height: 1.4;
}

.toc-list a:hover { color: var(--text-secondary); }

.toc-list a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.toc-list .toc-h3 { padding-left: 24px; font-size: 11px; }

.search-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 360px;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  z-index: 200;
  scrollbar-width: thin;
  scrollbar-color: rgba(196, 181, 253, 0.45) transparent;
}

.search-results::-webkit-scrollbar { width: 5px; }
.search-results::-webkit-scrollbar-track { background: transparent; margin: 6px 0; }
.search-results::-webkit-scrollbar-thumb { background: rgba(196, 181, 253, 0.35); border-radius: 4px; }
.search-results::-webkit-scrollbar-thumb:hover { background: var(--accent); }

.search-results.visible { display: block; }

.search-result-item {
  display: block;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition);
}

.search-result-item:hover { background: var(--bg-hover); }

.search-result-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.search-result-snippet {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.search-no-results {
  padding: 20px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.search-result-snippet mark {
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 2px;
}

body.sidebar-open { overflow: hidden; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 40;
}

@media (max-width: 1200px) {
  .toc { display: none; }
  .main {
    margin-right: 0;
    width: calc(100vw - var(--sidebar-width));
    max-width: min(860px, calc(100vw - var(--sidebar-width)));
  }
  .block-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
  .layout { display: block; }

  .menu-toggle { display: block; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 60;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay.open { display: block; }

  .main {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
    max-width: 100%;
    padding: 28px 32px 64px;
  }
}

@media (max-width: 900px) {
  th {
    white-space: normal;
    word-break: break-word;
  }
}

@media (max-width: 768px) {
  :root {
    --sidebar-width: min(300px, 88vw);
    --header-offset: 96px;
  }

  .site-header {
    flex-wrap: wrap;
    align-items: center;
    height: auto;
    min-height: var(--header-height);
    padding: 10px 12px;
    gap: 8px;
  }

  .menu-toggle { order: 0; }

  .header-brand {
    order: 1;
    min-width: 0;
    flex: 1;
  }

  .header-brand-text {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }

  .header-brand-sub { display: none; }

  .header-spacer { display: none; }

  .header-actions {
    order: 2;
    gap: 6px;
  }

  .header-btn {
    padding: 5px 10px;
    font-size: 11px;
  }

  .header-search {
    order: 10;
    display: block !important;
    flex: 1 1 100%;
    max-width: none;
  }

  .layout {
    padding-top: var(--header-offset);
  }

  html {
    scroll-padding-top: calc(var(--header-offset) + 16px);
  }

  .sidebar {
    top: var(--header-offset);
    height: calc(100vh - var(--header-offset));
  }

  .main {
    padding: 20px 16px 56px;
  }

  .breadcrumb {
    font-size: 12px;
    line-height: 1.4;
    word-break: break-word;
  }

  article h1 {
    font-size: 24px;
    word-break: break-word;
  }

  article h2 { font-size: 19px; margin-top: 32px; word-break: break-word; }
  article h3 { font-size: 16px; word-break: break-word; }

  .lead { font-size: 15px; }

  pre,
  pre code {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  pre {
    font-size: 11px;
    padding: 12px 14px;
    border-radius: var(--radius);
    overflow-x: auto;
  }

  code { word-break: break-word; }

  .table-wrap {
    margin-left: 0;
    margin-right: 0;
    border-radius: var(--radius);
    width: 100%;
  }

  table {
    font-size: 12px;
    min-width: 0;
    table-layout: fixed;
  }

  th, td {
    padding: 8px 10px;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .callout {
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    font-size: 13px;
  }

  .steps li { padding-left: 32px; }

  .block-grid { grid-template-columns: 1fr; }

  .recipe-card { padding: 16px; }

  .meta-badges { gap: 6px; }

  .meta-badge { font-size: 11px; padding: 4px 10px; }
}

@media (max-width: 480px) {
  :root { --header-offset: 92px; }

  .header-actions .header-btn-ghost:not(.header-btn-compact) { display: none; }

  article h1 { font-size: 22px; }
  article section { margin-bottom: 48px; }

  .search-results { max-height: 50vh; }
}
