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

:root {
  --bg: #0a0a0a;
  --bg-sidebar: #111111;
  --bg-card: #1e1e1e;
  --bg-input: #282828;
  --bg-hover: #252525;
  --border: #2e2e2e;
  --text: #ffffff;
  --text-muted: #a3a3a3;
  --text-subtle: #6b6b6b;
  --accent: #ffffff;
  --tag-use: #166534;
  --tag-use-text: #bbf7d0;
  --tag-avoid: #7f1d1d;
  --tag-avoid-text: #fecaca;
  --tag-what: #1e3a5f;
  --tag-what-text: #bfdbfe;
  --sidebar-width: 260px;
  --header-height: 56px;
  --toc-height: 44px;
}

:root.light {
  --bg: #ffffff;
  --bg-sidebar: #fafafa;
  --bg-card: #f4f4f5;
  --bg-input: #f4f4f5;
  --bg-hover: #f0f0f0;
  --border: #e4e4e7;
  --text: #333333;
  --text-muted: #4b4b4b;
  --text-subtle: #888888;
  --accent: #18181b;
  --tag-use: #dcfce7;
  --tag-use-text: #166534;
  --tag-avoid: #fee2e2;
  --tag-avoid-text: #991b1b;
  --tag-what: #dbeafe;
  --tag-what-text: #1d4ed8;
}

/* Theme toggle */
.settings-wrap {
  position: relative;
  margin-left: auto;
  flex-shrink: 0;
}
.settings-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}
.settings-btn:hover { color: var(--text); background: var(--bg-hover); }
.settings-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 200;
}
.settings-dropdown.open { display: block; }
.settings-section { margin-bottom: 14px; }
.settings-section:last-child { margin-bottom: 0; }
.settings-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  margin-bottom: 8px;
}
.settings-theme-toggle {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.theme-opt {
  flex: 1;
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  border: none;
  background: transparent;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  text-align: center;
}
.theme-opt.active {
  background: #ffffff;
  color: #0a0a0a;
}
.settings-font-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.font-size-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  min-width: 32px;
}
.font-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}
.font-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

/* Panel toggle (sidebar open/close) */
.panel-toggle {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px;
  border-radius: 6px;
  transition: background 0.15s;
  color: var(--text-muted);
  flex-shrink: 0;
}
.panel-toggle:hover { background: var(--bg-hover); color: var(--text); }
.panel-toggle .icon-panel-close { display: block; }
.panel-toggle .icon-panel-open  { display: none; }
body.nav-collapsed .panel-toggle .icon-panel-close { display: none; }
body.nav-collapsed .panel-toggle .icon-panel-open  { display: block; }

body {
  font-family: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 4px 24px;
  gap: 16px;
  background: var(--bg);
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 101;
}
/* Sidebar view toggle */
.sidebar-view-toggle {
  padding: 12px 16px 10px;
  border-bottom: none;
  margin-bottom: 8px;
}
.sv-toggle-inner {
  display: flex;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px;
  gap: 2px;
}
.sv-opt {
  flex: 1;
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  border: none;
  background: transparent;
  transition: background 0.15s, color 0.15s;
  text-align: center;
}
.sv-opt.active {
  background: #ffffff;
  color: #0a0a0a;
}

.logo {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--accent);
  white-space: nowrap;
}
.logo span { color: var(--text-muted); font-weight: 400; }
.search-wrap {
  flex: 1;
  max-width: 480px;
  margin-left: 16px;
  position: relative;
}
.search-wrap > svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  z-index: 3;
}
#search {
  width: 100%;
  padding: 13px 36px 13px 38px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, border-radius 0.15s;
}
#search::placeholder { color: var(--text-muted); }
#search:focus { border-color: var(--border); }
/* Clear button — shared between landing and header search */
.search-clear {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s;
  flex-shrink: 0;
}
.search-clear:hover { color: var(--text); }
.search-clear.visible { display: flex; }
/* Position clear button inside search inputs */
.search-wrap .search-clear,
.landing-search .search-clear {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
}
/* inputs don't need stacking context — let clear button sit above */
.search-wrap.typeahead-open #search {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
}
.search-wrap .landing-typeahead {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0;
  z-index: 100;
}
.search-wrap .landing-typeahead.open {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top: none;
}
.search-wrap .landing-typeahead .ta-item-name { font-size: 15px; }
.search-wrap .landing-typeahead .ta-item-desc { font-size: 13px; }
.search-wrap .landing-typeahead .ta-item { padding: 10px 14px; }

/* Layout */
.layout {
  display: flex;
  margin-top: var(--header-height);
  height: calc(100vh - var(--header-height));
}

/* Sidebar */
aside {
  width: var(--sidebar-width);
  border-right: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
  padding: 0;
  transition: width 0.25s ease;
  display: flex;
  flex-direction: column;
}
.sidebar-sections {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-sections::-webkit-scrollbar { width: 12px; }
.sidebar-sections::-webkit-scrollbar-track { background: transparent; }
.sidebar-sections::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; border: 3px solid var(--bg); }
body.nav-collapsed aside {
  width: 0;
  padding: 0;
  border-right: none;
}
body.nav-collapsed #toc {
  left: 0;
}

.sidebar-expand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 16px 8px;
  margin-bottom: 8px;
}
.sidebar-expand-btn {
  background: none;
  border: none;
  font-size: 11px;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}
.sidebar-expand-btn:hover { color: var(--text-muted); }
.sidebar-expand-sep {
  font-size: 11px;
  color: var(--text-subtle);
}

.sidebar-section { margin-bottom: 4px; }
.sidebar-label {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-subtle);
  padding: 10px 16px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.sidebar-label:hover { color: var(--text-muted); }
.sidebar-chevron {
  display: flex;
  align-items: center;
  color: var(--text-subtle);
  flex-shrink: 0;
}
.sidebar-chevron .chev-down { display: block; }
.sidebar-chevron .chev-up   { display: none; }
.sidebar-section.collapsed .sidebar-chevron .chev-down { display: none; }
.sidebar-section.collapsed .sidebar-chevron .chev-up   { display: block; }
.sidebar-section.collapsed .sidebar-items { display: none; }
.sidebar-items {}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 0;
  transition: all 0.1s;
  border-left: 2px solid transparent;
  text-decoration: none;
}
.sidebar-item:hover {
  color: var(--text);
  background: var(--bg-hover);
}
.sidebar-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--bg-hover);
}
.sidebar-item .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-subtle);
  flex-shrink: 0;
  transition: background 0.1s;
}
.sidebar-item.active .dot { background: var(--accent); }
.sidebar-item.hidden { display: none; }

/* TOC bar */
#toc {
  position: fixed;
  top: var(--header-height);
  left: var(--sidebar-width);
  right: 0;
  height: var(--toc-height);
  background: var(--bg);
  display: none;
  align-items: center;
  padding: 0 48px 0 48px;
  z-index: 99;
  overflow-x: auto;
  gap: 0;
  transition: left 0.25s ease;
}
#toc::-webkit-scrollbar { display: none; }
.toc-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-right: 16px;
  white-space: nowrap;
  flex-shrink: 0;
}
.toc-label .toc-cat { color: var(--text-subtle); }
.toc-label .toc-arrow { color: var(--text-subtle); display: flex; align-items: center; }
.toc-label .toc-name { color: var(--text-muted); }
.toc-link {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0 14px;
  height: var(--toc-height);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.1s, border-color 0.1s;
  cursor: pointer;
}
.toc-link:hover { color: var(--text); }
.toc-link.active {
  color: var(--text);
  border-bottom-color: var(--text);
}
.layout.toc-visible main {
  padding-top: var(--toc-height);
}

/* Main content */
main {
  flex: 1;
  overflow-y: auto;
  padding: 40px 48px;
  min-width: 0;
}
main::-webkit-scrollbar { width: 12px; }
main::-webkit-scrollbar-track { background: transparent; }
main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; border: 3px solid var(--bg); }

/* Home view */
#home-view { max-width: 100%; }
.home-title {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.8px;
  line-height: 1.2;
  margin-bottom: 12px;
}
.home-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 24px;
}
.home-view-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 40px;
}
.home-view-toggle {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.csv-download-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 12px;
  text-decoration: none;
  transition: color 0.15s;
}
.csv-download-link:hover {
  color: var(--text);
}
.hv-opt {
  padding: 5px 14px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  border: none;
  background: transparent;
  transition: background 0.15s, color 0.15s;
}
.hv-opt.active {
  background: #ffffff;
  color: #0a0a0a;
}
.atomic-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  line-height: 1.5;
}
.home-section {
  margin-bottom: 48px;
}
.home-section-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
  margin-bottom: 16px;
}
.home-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.home-card {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-decoration: none;
  display: block;
}
.home-card:hover {
  border-color: var(--text-subtle);
  background: var(--bg-hover);
}
.home-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.home-card-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.home-card-cat {
  font-size: 11px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Component view */
#component-view { max-width: 100%; display: none; }
.comp-header { margin-bottom: 32px; }
.comp-category {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.comp-title {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-top: 24px;
  margin-bottom: 10px;
}
.comp-desc {
  font-size: 15px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 4px;
}
.overview-section > .section-tag { margin-top: 0; margin-bottom: 20px; }
.overview-section > div + div { margin-top: 12px; }

/* Preview tabs */
.preview-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  width: fit-content;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.preview-tab {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-right: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.preview-tab:last-child {
  border-right: none;
}
.preview-tab:hover:not(.active) {
  background: var(--hover);
  color: var(--text);
}
.preview-tab.active {
  background: #0a0a0a;
  color: #ffffff;
}

/* Preview box */
.preview-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 32px;
  margin: 0 0 28px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  min-height: 140px;
}

/* Section blocks */
.section {
  margin-bottom: 28px;
}
.section-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 28px !important;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  padding: 0;
  background: none !important;
  color: var(--text) !important;
  border-radius: 0;
  margin-top: 8px;
  margin-bottom: 14px;
  line-height: 1.2;
}
h2.section-tag { font-size: 28px; }
h3.section-tag { font-size: 28px; }
.sub-section-tag { font-size: 20px !important; color: #666666 !important; }
.section-tag::before {
  display: none;
}

/* Also known as */
.aka-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.aka-card {
  width: 150px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-radius: 10px;
  padding: 12px 14px;
}
.aka-system {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 5px;
}
.aka-term {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}
a.aka-card-link {
  text-decoration: none;
  display: block;
  transition: background 0.15s, box-shadow 0.15s;
}
a.aka-card-link:hover {
  background: var(--hover);
  box-shadow: 0 0 0 1px var(--border);
}
a.aka-card-link .aka-term {
  color: var(--accent);
}
.tag-what  { background: var(--tag-what);  color: var(--tag-what-text); }
.tag-use   { background: var(--tag-use);   color: var(--tag-use-text); }
.tag-avoid { background: var(--tag-avoid); color: var(--tag-avoid-text); }

/* AI Prompt section */
.tag-prompt::before { background: #22d3ee; }
.prompt-block {
  background: #0d0d0d;
  border: 1px solid #262626;
  border-radius: 10px;
  padding: 20px 52px 20px 22px;
  font-family: 'SF Mono', 'Fira Code', 'Menlo', monospace;
  font-size: 13px;
  line-height: 1.75;
  color: #d4d4d4;
  white-space: pre-wrap;
  margin-top: 4px;
}
.prompt-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 10px;
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  color: #888;
  cursor: pointer;
  font-family: 'Archivo', -apple-system, BlinkMacSystemFont, sans-serif;
  transition: color 0.15s, background 0.15s;
}
.prompt-copy:hover { color: #d4d4d4; background: #2a2a2a; }

/* Icons section */
.icons-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.icon-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 14px 12px;
  background: var(--bg-card);
  border-radius: 10px;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s;
}
.icon-chip:hover {
  background: var(--bg-hover);
}
.icon-chip svg { stroke-width: 1; }
.icon-chip-name {
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', 'Menlo', monospace;
  color: var(--text-subtle);
}

/* States section */
.states-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 4px;
}
.state-card {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 12px 14px;
}
.state-name {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  margin-bottom: 4px;
}
.state-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

.section-content {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-muted);
}
.section-content p { margin-bottom: 14px; }
.section-content p:last-child { margin-bottom: 0; }
.section-content ul {
  list-style: none;
  margin-top: 10px;
}
.section-content li {
  padding: 5px 0 5px 18px;
  position: relative;
  color: var(--text-muted);
}
.section-content li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 13px;
  width: 5px; height: 5px;
  border-radius: 50%;
}
.tag-use ~ .section-content li::before         { background: #4ade80; }
.tag-avoid ~ .section-content li::before       { background: #f87171; }
.tag-what ~ .section-content li::before        { background: #60a5fa; }
.usage-subhead-use ~ .section-content li::before   { background: #4ade80; }
.usage-subhead-avoid ~ .section-content li::before { background: #f87171; }

.usage-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.usage-subhead {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-top: 4px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.usage-subhead::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.usage-subhead-use::before   { background: #4ade80; }
.usage-subhead-avoid::before { background: #f87171; }

/* Related components */
.related-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.related-card {
  display: block;
  background: var(--bg-card);
  border-radius: 10px;
  padding: 14px 16px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.related-card:hover {
  border-color: var(--text-subtle);
  background: var(--bg-hover);
}
.related-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
.related-card-desc {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Anatomy section */
.anatomy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.anatomy-card {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 14px 16px;
}
.anatomy-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.anatomy-card-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* No results */
#no-results {
  display: none;
  padding: 60px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---- Component Previews ---- */
/* Button */
.prev-btn {
  padding: 8px 18px;
  background: #0a0a0a;
  color: #ffffff;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.prev-btn-outline {
  padding: 8px 18px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-left: 10px;
}
.prev-btn-ghost {
  padding: 8px 18px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
  margin-left: 6px;
}
/* Badge */
.prev-badge { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.badge {
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.badge-default { background: #ffffff; color: #0a0a0a; }
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.badge-success { background: #166534; color: #bbf7d0; }
.badge-warn    { background: #713f12; color: #fef3c7; }
.badge-danger  { background: #7f1d1d; color: #fecaca; }
/* Avatar */
.prev-avatar { display: flex; gap: 10px; align-items: center; }
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #262626;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
/* Alert */
.prev-alert { width: 100%; max-width: 460px; }
.alert {
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.alert-default { border-color: var(--border); background: var(--bg-card); }
.alert-success { border-color: #166534; background: #052e16; color: #bbf7d0; }
.alert-warning { border-color: #78350f; background: #1c0a00; color: #fef3c7; }
.alert-error   { border-color: #7f1d1d; background: #1c0404; color: #fecaca; }
.alert-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-body {}
.alert-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.alert-desc  { font-size: 12px; opacity: 0.8; line-height: 1.5; }
/* Card */
.prev-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 260px;
}
.card-header { padding: 16px 18px 0; }
.card-title { font-size: 14px; font-weight: 600; }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 12px 18px; font-size: 13px; color: var(--text-muted); line-height: 1.55; }
.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
/* Input */
.prev-input { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 320px; }
.input-label { font-size: 13px; font-weight: 500; }
.input-field {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  width: 100%;
}
.input-hint { font-size: 12px; color: var(--text-muted); }
/* Checkbox */
.prev-checks { display: flex; flex-direction: column; gap: 10px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check-box {
  width: 16px; height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.check-box.checked {
  background: #ffffff;
  border-color: #ffffff;
  color: #0a0a0a;
  font-size: 10px;
}
/* Toggle / Switch */
.switch-wrap { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.switch {
  width: 40px; height: 22px;
  background: #262626;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
}
.switch.on { background: #ffffff; }
.switch::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform 0.2s;
}
.switch.on::after { background: #0a0a0a; transform: translateX(18px); }
/* Select */
.prev-select select {
  padding: 8px 32px 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  appearance: none;
  cursor: pointer;
  outline: none;
}
/* Tabs */
.prev-tabs { width: 100%; max-width: 420px; }
.tabs-list {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}
.tab-content { font-size: 13px; color: var(--text-muted); line-height: 1.6; padding: 0 4px; }
/* Tooltip */
.prev-tooltip { position: relative; display: inline-block; }
.tooltip-trigger { cursor: default; border-bottom: 1px dashed var(--text-muted); font-size: 13px; }
.tooltip-box {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #e5e5e5;
  color: #0a0a0a;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
}
.tooltip-box::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #e5e5e5;
}
/* Progress */
.prev-progress { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 16px; }
.progress-wrap { display: flex; flex-direction: column; gap: 6px; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }
.progress-bar { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s; }
/* Skeleton */
.prev-skeleton { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 10px; }
.skel {
  background: var(--border);
  border-radius: 6px;
}
.skel-circle { width: 40px; height: 40px; border-radius: 50%; }
.skel-line { height: 12px; }
.skel-row { display: flex; gap: 10px; align-items: center; }
/* Accordion */
.prev-accordion { width: 100%; max-width: 420px; }
.acc-item { border-bottom: 1px solid var(--border); }
.acc-trigger {
  width: 100%;
  padding: 14px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
}
.acc-trigger span { font-size: 16px; color: var(--text-muted); transition: transform 0.2s; }
.acc-content { font-size: 13px; color: var(--text-muted); padding-bottom: 0; line-height: 1.6; max-height: 0; overflow: hidden; transition: max-height 0.3s ease, padding-bottom 0.3s ease; }
.acc-item.open .acc-content { max-height: 200px; padding-bottom: 14px; }
.acc-item.open .acc-trigger span { transform: rotate(45deg); }
/* Dialog */
.prev-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 380px;
  width: 100%;
}
.dialog-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.dialog-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; line-height: 1.55; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
/* Breadcrumb */
.prev-breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.bc-item { color: var(--text-muted); cursor: pointer; }
.bc-item:hover { color: var(--text); }
.bc-item.current { color: var(--text); }
.bc-sep { color: var(--text-subtle); font-size: 11px; }
/* Pagination */
.prev-pagination { display: flex; align-items: center; gap: 6px; }
.page-btn {
  min-width: 38px; height: 38px;
  padding: 0 10px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  color: #525252;
  background: #fff;
  transition: all 0.12s;
}
.page-btn.active { background: #0a0a0a; color: #fff; border-color: #0a0a0a; font-weight: 600; }
.page-btn:hover:not(.active):not(:disabled) { border-color: #a3a3a3; color: #0a0a0a; }
.page-btn:disabled { opacity: 0.35; cursor: default; }
.page-btn.ellipsis { border-color: transparent; background: none; cursor: default; color: #a3a3a3; }

/* Compare table */
.compare-wrap {
  overflow-x: auto;
  margin-top: 8px;
}
.compare-table {
  min-width: 1200px;
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 14px;
}
.compare-table th {
  padding: 10px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-subtle);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}
.compare-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--bg-hover);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  margin-left: 4px;
  letter-spacing: 0;
  text-transform: none;
  vertical-align: middle;
}
.compare-table td {
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.compare-comp-row:hover td { background: var(--hover); }
.compare-cat-row {
  cursor: pointer;
  user-select: none;
}
.compare-cat-row:hover td { background: var(--hover); }
.compare-cat-row td {
  background: var(--card);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: 0;
  border-bottom: 1px solid var(--border);
}
.compare-cat-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
}
.compare-cat-chevron {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--text-subtle);
}
.compare-cat-chevron svg {
  transition: transform 0.2s ease;
}
.compare-cat-row.collapsed .compare-cat-chevron svg {
  transform: rotate(-90deg);
}
.compare-comp-link {
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}
.compare-comp-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.compare-ext-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
}
.compare-ext-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.compare-none { color: var(--text-subtle); font-size: 13px; }
/* Toast */
.prev-toast { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 360px; }
.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
}
.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-body {}
.toast-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.toast-desc  { font-size: 12px; color: var(--text-muted); }
/* Table */
.prev-table { width: 100%; max-width: 520px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.data-table tr:last-child td { border-bottom: none; }
/* Separator */
.prev-sep { width: 100%; max-width: 360px; text-align: center; }
.separator { height: 1px; background: var(--border); margin: 12px 0; }
.sep-text {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-subtle);
}
.sep-text::before, .sep-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
/* Radio */
.prev-radio { display: flex; flex-direction: column; gap: 10px; }
.radio-row { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.radio-circle {
  width: 16px; height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.radio-circle.selected::after {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
/* Popover */
.prev-popover { position: relative; display: inline-block; }
.popover-box {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  width: 220px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.popover-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.popover-desc { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* Responsive */
@media (max-width: 900px) {
  aside {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    z-index: 100;
    border-right: none;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    display: flex;
  }
  aside.mobile-open {
    transform: translateX(0);
  }
  body.nav-collapsed aside { transform: translateX(-100%); }
  main { padding: 32px 24px; }
  #toc { left: 0 !important; padding: 0 16px; }
  body { height: auto; overflow: auto; }
  .layout { display: block; height: auto; padding-top: var(--header-height); }
  /* Header layout on mobile: logo stretches, search + settings right */
  header { position: fixed; }
  .logo { flex: 1; }
  .search-wrap {
    flex: 0 0 auto;
    max-width: none;
    margin-left: 0;
    order: 3;
  }
  .settings-wrap { order: 4; margin-left: 0; }
  header { gap: 4px; }
  header .chat-fab { width: 40px; height: 40px !important; padding: 0; margin: 0; background: transparent !important; color: var(--text-muted); justify-content: center; border-radius: 8px; }
  header .chat-fab:hover { background: transparent !important; color: var(--text-muted); }
  .search-wrap { flex: 0 0 40px; width: 40px; display: none; }
  .search-wrap #search { width: 40px; height: 40px; }
  .settings-btn { width: 40px; height: 40px; justify-content: center; }
  .settings-btn:hover { background: transparent; color: var(--text-muted); }
  .logo { margin-right: auto; }
  .toc-label { display: none; }
  .search-wrap #search {
    width: 40px;
    padding: 11px 12px 11px 34px;
    cursor: pointer;
    background: transparent;
    border-color: transparent;
  }
  .search-wrap #search::placeholder { color: transparent; }
  .search-wrap.search-open {
    position: absolute;
    left: 60px;
    right: 16px;
    flex: 1;
    z-index: 5;
  }
  .search-wrap.search-open #search {
    width: 100%;
    cursor: text;
    background: var(--bg);
    border-color: var(--border);
  }
  .search-wrap.search-open #search::placeholder { color: var(--text-muted); }
  .search-wrap.search-open ~ .logo { visibility: hidden; }
  .search-wrap.search-open ~ .chat-fab,
  .search-wrap.search-open ~ .settings-wrap { display: none; }
}
@media (max-width: 600px) {
  main { padding: 20px 16px; }
  .home-grid { grid-template-columns: 1fr; }
  .anatomy-grid { grid-template-columns: 1fr; }
  .home-title { font-size: 28px; }
  .comp-title { font-size: 28px; }
  .usage-columns { grid-template-columns: 1fr; }
  .csv-download-link { display: none !important; }
  .home-view-toggle { width: 100%; }
  .hv-opt { flex: 1; text-align: center; }
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 40px 16px 24px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-subtle);
}
.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
}
.site-footer a:hover {
  color: var(--text);
  text-decoration: underline;
}
.footer-social {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
}
.footer-social a {
  color: var(--text-subtle);
  text-decoration: none;
  transition: color 0.15s;
}
.footer-social a:hover {
  color: var(--text);
  text-decoration: none;
}

/* Landing Page — override body scroll lock */
body:has(.landing) {
  height: auto;
  overflow: auto;
}
.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  background: var(--bg);
}
.landing-hero {
  text-align: center;
  margin-bottom: 48px;
  max-width: 560px;
}
.landing-logo {
  color: #cccccc;
  margin-bottom: 16px;
}
.landing-title {
  font-family: 'Archivo', sans-serif;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text);
  margin-bottom: 12px;
}
.landing-title span {
  font-weight: 400;
  color: var(--text-muted);
}
.landing-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
}
/* Landing search + Ask AI row */
.landing-search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 780px;
  width: 100%;
  margin-bottom: 56px;
}
.landing-search-row .landing-search {
  margin-bottom: 0;
}
.landing-search {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 780px;
  width: 100%;
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 40px;
  color: var(--text-muted);
  transition: border-color 0.2s, border-radius 0.2s;
  position: relative;
}
.landing-search > svg {
  flex-shrink: 0;
}
.landing-search:focus-within {
  border-color: var(--border);
}
.landing-search.typeahead-open {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
}
.landing-search input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: 'Archivo', sans-serif;
  font-size: 17px;
  color: var(--text);
  padding-right: 28px;
}
.landing-search input::placeholder {
  color: var(--text-subtle);
}
.landing-typeahead {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0;
  padding: 4px 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 12px 12px;
  max-height: 360px;
  overflow-y: auto;
  z-index: 10;
  display: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.landing-typeahead.open {
  display: block;
}
.ta-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 16px 20px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.1s;
  cursor: pointer;
}
.ta-item:first-child {
  border-radius: 0;
}
.ta-item:last-child {
  border-radius: 0 0 12px 12px;
}
.ta-no-results {
  padding: 14px 20px;
  color: var(--text-muted);
  font-size: 16px;
}
.ta-item:hover, .ta-item.active {
  background: var(--bg-hover);
}
.ta-item-name {
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
}
.ta-item-desc {
  font-size: 14px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.landing-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  max-width: 780px;
  width: 100%;
}
.landing-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--bg-card);
  border: none;
  border-radius: 12px;
  padding: 28px 24px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.2s;
}
.landing-card:hover {
  background: var(--border);
}
.landing-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: #666666;
}
.landing-card:hover .landing-card-icon {
  color: var(--text);
}
.landing-card-title {
  font-family: 'Archivo', sans-serif;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 8px;
  line-height: 1.4;
}
.landing-card-desc {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.7;
  flex: 1;
}
.landing-card-arrow {
  display: inline-flex;
  align-items: center;
  margin-top: 16px;
  color: var(--text-subtle);
  transition: color 0.2s, transform 0.2s;
}
.landing-card:hover .landing-card-arrow {
  color: var(--text);
  transform: translateX(4px);
}
@media (max-width: 640px) {
  .landing-cards {
    grid-template-columns: 1fr;
  }
  .landing-title {
    font-size: 28px;
  }
  .landing-search {
    min-width: 0;
    max-width: none;
  }
  .landing-search-row {
    gap: 8px;
  }
}

/* ── Chat Widget ────────────────────────────────── */

.chat-fab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: 'Archivo', sans-serif;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.chat-fab:hover {
  opacity: 0.85;
}
/* Landing page: place next to search */
.landing-search-row .chat-fab {
  padding: 16px 20px;
  border-radius: 12px;
  font-size: 15px;
}
/* Components page: place after search-wrap in header */
header .chat-fab {
  margin-left: -8px;
  margin-right: 0;
  height: 45px;
}

/* Chat panel */
.chat-panel {
  position: fixed;
  top: 8px;
  right: 8px;
  bottom: 8px;
  width: 33vw;
  min-width: 360px;
  display: flex;
  flex-direction: row;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  z-index: 1001;
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(100% + 8px));
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  color: #1a1a1a;
}
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chat-panel.chat-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}
.chat-panel.chat-expanded {
  top: 8px;
  right: 8px;
  bottom: 8px;
  left: 8px;
  width: auto;
  border-radius: 12px;
}

/* History sidebar */
.chat-history-sidebar {
  width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-right: 1px solid #e4e4e7;
  transition: width 0.25s ease;
  flex-shrink: 0;
}
.chat-history-sidebar.open {
  width: 100%;
}
/* In collapsed mode, history takes over the full panel */
.chat-panel:not(.chat-expanded) .chat-history-sidebar.open ~ .chat-main {
  display: none;
}
.chat-expanded .chat-history-sidebar.open {
  width: 33.333%;
  max-width: 360px;
  min-width: 240px;
}
.chat-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e4e4e7;
  flex-shrink: 0;
}
.chat-history-title {
  font-weight: 600;
  font-size: 16px;
  color: #1a1a1a;
  white-space: nowrap;
}
.chat-history-close[data-tooltip]::after {
  top: calc(100% + 6px);
}
.chat-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.chat-history-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.1s;
  gap: 8px;
}
.chat-history-item:hover {
  background: #f0f0f0;
}
.chat-history-item.active {
  background: #e8e8e8;
}
.chat-history-item-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.chat-history-item-title {
  font-size: 16px;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.chat-history-item-date {
  font-size: 13px;
  color: #888;
  margin-top: 2px;
}
.chat-history-delete {
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: #aaa;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.chat-history-item:hover .chat-history-delete {
  display: flex;
}
.chat-history-delete:hover {
  color: #666;
  background: #e4e4e7;
}
.chat-history-accordion {}
.chat-history-date-group {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s;
}
.chat-history-date-group:hover { color: #666; }
.chat-history-chevron {
  flex-shrink: 0;
  transition: transform 0.2s;
  transform: rotate(-90deg);
  order: 2;
}
.chat-history-date-group.open .chat-history-chevron {
  transform: rotate(0deg);
}
.chat-history-count {
  order: 1;
  margin-left: auto;
  background: #e4e4e7;
  color: #555;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 10px;
  line-height: 1.4;
}
.chat-history-group-items {
  display: none;
}
.chat-history-date-group.open + .chat-history-group-items {
  display: block;
}
.chat-history-empty {
  padding: 20px 16px;
  font-size: 13px;
  color: #888;
  text-align: center;
}

/* Hide history toggle in expanded mode (sidebar always visible) */
.chat-expanded .chat-header > .chat-history-toggle {
  display: none;
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid #e4e4e7;
  flex-shrink: 0;
}
.chat-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  font-weight: 600;
  font-size: 16px;
  color: #1a1a1a;
}
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-header-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #888;
  cursor: pointer;
  transition: all 0.15s;
}
.chat-header-btn:hover {
  background: #f0f0f0;
  color: #333;
}
/* Custom tooltips */
.chat-header-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 10;
}
.chat-header-btn[data-tooltip]:hover::after {
  opacity: 1;
}
/* Show/hide expand vs collapse icons */
.chat-expand .icon-collapse { display: none; }
.chat-expand .icon-expand { display: block; }
.chat-expanded .chat-expand .icon-collapse { display: block; }
.chat-expanded .chat-expand .icon-expand { display: none; }

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.chat-msg {
  display: flex;
  max-width: 100%;
  padding: 12px 20px;
}
.chat-msg-user {
  align-self: stretch;
}
.chat-msg-ai {
  align-self: stretch;
}
.chat-msg-content {
  padding: 0;
  font-size: 16px;
  line-height: 1.6;
  color: #1a1a1a;
  word-break: break-word;
}
.chat-msg-user .chat-msg-content {
  background: #f4f4f5;
  color: #1a1a1a;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 500;
}
.chat-msg-ai .chat-msg-content {
  color: #1a1a1a;
}
.chat-msg-content a {
  color: #18181b;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: opacity 0.15s;
}
.chat-msg-content a:hover {
  opacity: 0.7;
}
.chat-msg-content a.chat-component-link {
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid #d4d4d8;
  padding-bottom: 1px;
}
.chat-msg-content a.chat-component-link:hover {
  border-bottom-color: #18181b;
  opacity: 1;
}
.chat-msg-content a.chat-external-link {
  font-size: 13px;
  color: #666;
}
.chat-msg-content a.chat-external-link::after {
  content: ' \2197';
  font-size: 11px;
}
.chat-msg-content a.chat-ds-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chat-msg-content a.chat-ds-link:hover {
  opacity: 0.7;
}
.chat-msg-content code {
  background: #f4f4f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  border: 1px solid #e4e4e7;
}
.chat-msg-content pre {
  background: #fafafa;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 8px 0 4px;
  overflow-x: auto;
  font-size: 12px;
}
.chat-msg-content strong {
  font-weight: 600;
}
.chat-msg-content ul,
.chat-msg-content ol {
  margin: 4px 0;
  padding-left: 18px;
}
.chat-msg-content li {
  margin-bottom: 2px;
}

/* Suggested follow-up prompts */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 20px 12px;
}
.chat-suggestion {
  background: #f4f4f5;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-family: 'Archivo', sans-serif;
  font-size: 16px;
  color: #555;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  line-height: 1.4;
}
.chat-suggestion:hover {
  background: #e8e8eb;
  color: #1a1a1a;
}

/* Input area */
.chat-input-wrap {
  position: relative;
  padding: 12px 20px 8px;
  flex-shrink: 0;
}
.chat-disclaimer {
  text-align: center;
  font-size: 11px;
  color: #aaa;
  padding: 4px 20px 12px;
  flex-shrink: 0;
}
.chat-input {
  width: 100%;
  background: #f4f4f5;
  border: none;
  border-radius: 10px;
  padding: 13px 48px 13px 38px;
  font-family: 'Archivo', sans-serif;
  font-size: 16px;
  color: #1a1a1a;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
  max-height: 120px;
  line-height: 1.4;
}
.chat-input:focus {
  outline: none;
}
.chat-input::placeholder {
  color: #888;
}
.chat-input-icon {
  position: absolute;
  left: 34px;
  top: 50%;
  transform: translateY(-50%);
  color: #888;
  pointer-events: none;
}
.chat-send {
  position: absolute;
  right: 28px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: #e4e4e7;
  color: #999;
  border: none;
  border-radius: 8px;
  cursor: default;
  transition: background 0.2s, color 0.2s;
}
.chat-send.chat-send-active {
  background: #18181b;
  color: #ffffff;
  cursor: pointer;
}
.chat-send.chat-send-active:hover {
  opacity: 0.85;
}
.chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Streaming cursor */
.chat-streaming::after {
  content: '\25CF';
  display: inline;
  margin-left: 2px;
  color: #999;
  animation: chatCursorBlink 600ms infinite;
}
@keyframes chatCursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Loading thinking animation */
.chat-thinking {
  color: #999;
  font-style: italic;
  animation: chatThinkIn 250ms ease-out;
}
.chat-thinking-in {
  animation: chatThinkIn 250ms ease-out;
}
@keyframes chatThinkIn {
  0% { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Mobile responsive */
@media (max-width: 480px) {
  .chat-fab span {
    display: none;
  }
  .chat-fab {
    padding: 10px;
  }
  .chat-expand {
    display: none !important;
  }
  .chat-panel {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    border-radius: 0;
    border: none;
  }
  .chat-panel.chat-expanded {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    border-radius: 0;
  }
}
