:root {
  --primary: #ff7a18;
  --deep-navy: #071233;
  --light-grey: #e6eef8;
  --cream: #fff8ef;
  --cream-black: #0b0b0b;

  --bg: var(--light-grey);
  --surface: var(--cream);
  --text: var(--deep-navy);
  --muted: #64748b;
  --accent: var(--primary);
}

/* Dark theme */
.theme-dark {
  --bg: var(--deep-navy);
  --surface: #0f172a;
  --text: var(--cream);
  --muted: #94a3b8;
  --accent: var(--primary);
}

html, body { height: 100%; }
body {
  background: var(--bg) !important;
  color: var(--text) !important;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

/* Dark mode overrides */
.theme-dark .bg-white       { background-color: var(--surface) !important; }
.theme-dark .bg-slate-50    { background-color: #0c1628 !important; }
.theme-dark .bg-slate-900   { background-color: #07101a !important; }
.theme-dark .text-slate-800 { color: var(--text) !important; }
.theme-dark .text-slate-700 { color: var(--text) !important; }
.theme-dark .text-slate-600 { color: var(--muted) !important; }
.theme-dark .text-slate-500 { color: var(--muted) !important; }
.theme-dark .border-r       { border-color: rgba(255,255,255,0.08) !important; }
.theme-dark .border-b       { border-color: rgba(255,255,255,0.08) !important; }

/* Search input */
.search-input {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(15,23,42,0.1);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  width: 100%;
  box-sizing: border-box;
}
.search-input::placeholder        { color: rgba(0,0,0,0.4); }
.theme-dark .search-input::placeholder { color: rgba(255,255,255,0.5); }
.search-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255,122,24,0.18);
  border-color: var(--primary);
}

/* Desktop search sizing */
#header-controls .search-input { min-width: 220px; width: auto; }

/* Search results dropdown */
.search-results {
  position: absolute;
  z-index: 60;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  min-width: 260px;
  background: var(--surface);
  border: 1px solid rgba(2,6,23,0.08);
  border-radius: 8px;
  max-height: 320px;
  overflow: auto;
  box-shadow: 0 8px 24px rgba(2,6,23,0.1);
}
.search-result          { padding: 0.5rem 0.75rem; cursor: pointer; font-size: 0.875rem; }
.search-result:hover    { background: rgba(0,0,0,0.04); }
.theme-dark .search-result:hover { background: rgba(255,255,255,0.05); }

/* Mobile nav search results position */
#search-results-mobile { left: 0; right: 0; min-width: unset; width: 100%; }

/* Search highlight */
.search-hit { background: var(--accent); color: white; padding: 0 .15rem; border-radius: 3px; }

/* Animations */
.fade-in { opacity: 0; transform: translateY(8px); transition: opacity .45s ease, transform .45s ease; }
.fade-in.in-view { opacity: 1; transform: none; }

/* Sidebar TOC links */
.toc-link {
  transition: color .2s ease, background .2s ease;
  padding: .25rem .5rem;
  border-radius: 6px;
  display: block;
  font-size: 0.8125rem;
}
.toc-link.active {
  background: linear-gradient(90deg, rgba(255,122,24,0.12), transparent);
  color: var(--accent);
  font-weight: 600;
}
.toc-link:hover { color: var(--accent); }

/* Mobile nav links */
.mobile-nav-link {
  display: block;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.875rem;
  color: #374151;
  transition: background .15s ease, color .15s ease;
  text-decoration: none;
}
.mobile-nav-link:hover { background: rgba(255,122,24,0.08); color: var(--primary); }
.theme-dark .mobile-nav-link { color: var(--muted); }
.theme-dark .mobile-nav-link:hover { background: rgba(255,122,24,0.12); color: var(--primary); }
.theme-dark #mobile-nav { background: #0f172a; border-color: rgba(255,255,255,0.08); }

/* Theme toggle */
.theme-toggle {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .18s ease, transform .08s ease;
  border-radius: 6px;
}
.theme-toggle:hover { background: rgba(255,255,255,0.25); transform: translateY(-1px); }
.theme-toggle #theme-icon { font-size: 1rem; line-height: 1; }

/* Hamburger icon */
.hamburger { display: inline-block; width: 18px; height: 14px; position: relative; }
.hamburger span {
  display: block; position: absolute; left: 0; right: 0;
  height: 2px; background: currentColor; border-radius: 2px;
  transition: transform .18s ease, opacity .12s ease;
}
.hamburger span:nth-child(1) { top: 0; }
.hamburger span:nth-child(2) { top: 6px; }
.hamburger span:nth-child(3) { bottom: 0; }

#mobile-nav-toggle.open .hamburger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
#mobile-nav-toggle.open .hamburger span:nth-child(2) { opacity: 0; transform: scaleX(0); }
#mobile-nav-toggle.open .hamburger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Last-updated */
#last-updated { color: var(--muted); }

/* Print */
@media print {
  body { color: #000 !important; background: #fff !important; }
  a[href]:after { content: " (" attr(href) ")"; font-size: 90%; }
}

/* Fix: pre blocks inside flex step rows cause horizontal overflow.
   Flex children need min-width:0 to allow shrinking below content size. */
.step-num + div { min-width: 0; }

/* Fix: checklist items with long inline code overflow on mobile.
   word-break on the li lets text wrap, break-all on code handles
   long unbreakable strings like SSH_PRIVATE_KEY. */
.checklist li { word-break: break-word; overflow-wrap: break-word; }
code:not(pre code) { word-break: break-all; }

/* Mobile-specific tweaks */
@media (max-width: 640px) {
  header h1 { font-size: 1rem; }
  main { padding-left: 1rem !important; padding-right: 1rem !important; }
}
