/* ── Rubik Font ── */
@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@300;400;500;600;700;800;900&display=swap');

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

:root {
  /* ── Light Theme (Default) ── */
  --header-bg: #FFFFFF;
  --sidebar-bg: #FFFFFF;
  --page-bg: #FFFFFF;
  --card-bg: #F8F9FA;
  --brand: #6B7280;
  --brand-dk: #111827;
  --brand-lt: #FFFFFF;
  --brand-mid: #9CA3AF;

  --t1: #111827;
  --t2: #374151;
  --t3: #6B7280;
  --t4: #9CA3AF;

  --border: #E5E7EB;
  --border2: #D1D5DB;
  --bg: #F3F4F6;
  --bg-s: #F8F9FA;
  --bg-h: #F9FAFB;

  --sw: 260px;
  --hh: 52px;
  --radius: 7px;

  --font: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Consolas', monospace;
  --ease: 0.15s ease;

  --get: #059669;
  --post: #2563eb;
  --del: #dc2626;
  --put: #d97706;
  --patch: #7c3aed;
}

/* ── Dark Theme ── */
[data-theme="dark"] {
  --header-bg: #0f1117;
  --sidebar-bg: #0f1117;
  --page-bg: #0a0c10;
  --card-bg: #16181f;
  --brand: #9CA3AF;
  --brand-dk: #e5e7eb;
  --brand-lt: #0a0c10;
  --brand-mid: #6B7280;

  --t1: #f3f4f6;
  --t2: #d1d5db;
  --t3: #9ca3af;
  --t4: #6b7280;

  --border: #2a2d35;
  --border2: #3a3d47;
  --bg: #1a1d24;
  --bg-s: #16181f;
  --bg-h: #1f222c;

  --get: #34d399;
  --post: #60a5fa;
  --del: #f87171;
  --put: #fbbf24;
  --patch: #a78bfa;
}

html {
  font-family: var(--font);
  color: var(--t1);
  background: var(--page-bg);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  line-height: 1.6;
  font-weight: 400;
  background: var(--page-bg);
}

a {
  color: inherit;
  text-decoration: none
}

button {
  font-family: inherit;
  cursor: pointer
}

/* ── Theme Toggle ── */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--t2);
  flex-shrink: 0;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
  padding: 0;
  position: relative;
  overflow: hidden;
}

.theme-toggle:hover {
  background: var(--bg-h);
  border-color: var(--border2);
  color: var(--t1);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Moon icon: visible in light mode */
.theme-toggle .icon-moon {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Sun icon: hidden in light mode */
.theme-toggle .icon-sun {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5);
}

/* Dark mode: swap icons */
[data-theme="dark"] .theme-toggle .icon-moon {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5);
}

[data-theme="dark"] .theme-toggle .icon-sun {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ── Header ── */
.site-header {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  z-index: 100;
  height: var(--hh);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
  flex-shrink: 0;
}

.logo-icon {
  width: 30px;
  height: 30px;
  background: var(--brand-dk);
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}

.logo-icon svg {
  width: 15px;
  height: 15px;
  stroke: var(--brand-lt)
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15
}

.logo-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--t1)
}

.logo-sub {
  font-size: 10px;
  font-weight: 500;
  color: var(--t3);
  letter-spacing: 0.6px;
  text-transform: uppercase
}

.hdr-div {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0
}

.search-box {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 10px;
  height: 32px;
  background: var(--bg);
  color: var(--t1);
  font-size: 12.5px;
  transition: border-color var(--ease), box-shadow var(--ease);
  flex: 1;
  max-width: 320px;
  text-align: left;
}

.search-box:hover {
  border-color: var(--border2)
}

.search-box:focus-visible {
  border-color: var(--border2);
  box-shadow: 0 0 0 3px rgba(209, 213, 219, 0.3);
  outline: none
}

[data-theme="dark"] .search-box:focus-visible {
  box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.3);
}

.search-box svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: .7;
  stroke: var(--t3);
}

.search-box kbd {
  margin-left: auto;
  background: var(--bg-h);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10.5px;
  color: var(--t3);
  font-family: var(--mono)
}

.hdr-space {
  flex: 1
}

.hdr-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--t3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
}

.hdr-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
}

.hamburger {
  display: none;
  background: none;
  border: none;
  padding: 5px;
  border-radius: var(--radius);
  color: var(--t1);
  line-height: 0;
}

.hamburger svg {
  width: 20px;
  height: 20px;
  stroke: var(--t1);
}

.hamburger:focus-visible {
  outline: 2px solid var(--t1)
}

/* ── Layout ── */
.layout {
  display: flex;
  margin-top: var(--hh);
  min-height: calc(100vh - var(--hh));
  background: var(--page-bg);
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sw);
  flex-shrink: 0;
  position: fixed;
  top: var(--hh);
  left: 0;
  height: calc(100vh - var(--hh));
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
  z-index: 50;
}

.sidebar-section {
  margin-bottom: 4px
}

.sidebar-group-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--t4);
  padding: 18px 16px 5px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6.5px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--t2);
  border-radius: 6px;
  margin: 0 6px;
  transition: background var(--ease), color var(--ease);
  line-height: 1.5;
  position: relative;
}

.sidebar-link:hover {
  background: var(--bg);
  color: var(--t1);
}

.sidebar-link.active {
  background: var(--bg);
  color: var(--t1);
  font-weight: 600;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 65%;
  border-radius: 0 2px 2px 0;
  background: var(--brand);
  margin-left: -6px;
}

.sidebar-link svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: .7;
  stroke: currentColor;
}

.sidebar-link.active>svg {
  opacity: 1
}

.sidebar-sub[hidden] {
  display: none
}

.sidebar-sub .sidebar-link {
  font-size: 12.5px;
  font-weight: 500;
  padding: 5.5px 14px 5.5px 38px;
  color: var(--t2);
  margin: 0 6px;
}

.sidebar-sub .sidebar-link::before {
  display: none
}

.sidebar-sub .sidebar-link.active {
  background: var(--bg);
  color: var(--t1);
  font-weight: 600;
}

.sidebar-sub .sidebar-link.active::after {
  content: '';
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand);
}

.sidebar-sub .sidebar-link:not(.active)::after {
  content: '';
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--t3);
}

.chevron {
  margin-left: auto;
  flex-shrink: 0;
  width: 13px;
  height: 13px;
  opacity: .5;
  transition: transform .2s ease, opacity .2s;
  stroke: currentColor;
}

.sidebar-link.open .chevron {
  transform: rotate(90deg);
  opacity: .9
}

/* ── Scrollable nav area ── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  scroll-behavior: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
}

.sidebar-nav::-webkit-scrollbar {
  width: 3px
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px
}

/* Prevent focus from scrolling sidebar */
.sidebar-nav button:focus,
.sidebar-nav a:focus {
  scroll-margin: 0;
  scroll-margin-block: 0;
}

/* ── Overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .3);
  z-index: 49;
  backdrop-filter: blur(2px);
}

[data-theme="dark"] .sidebar-overlay {
  background: rgba(0, 0, 0, .5);
}

.sidebar-overlay.open {
  display: block
}

/* ── Main ── */
.main {
  margin-left: var(--sw);
  flex: 1;
  min-width: 0;
  display: flex;
  background: var(--page-bg);
}

.content {
  flex: 1;
  min-width: 0;
  padding: 40px 52px;
  max-width: 880px;
  background: var(--page-bg);
}

/* ── Breadcrumb ── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 12px;
  font-weight: 500;
  color: var(--t3);
  margin-bottom: 20px;
}

.breadcrumb a {
  color: var(--t3);
  transition: color var(--ease)
}

.breadcrumb a:hover {
  color: var(--t1)
}

.breadcrumb .sep {
  opacity: .4;
  font-weight: 400
}

.breadcrumb [aria-current] {
  color: var(--t1);
  font-weight: 600
}

/* ── Typography ── */
.page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--t1);
  letter-spacing: -0.7px;
  margin-bottom: 10px;
  line-height: 1.2;
}

.page-desc {
  font-size: 14.5px;
  color: var(--t2);
  line-height: 1.75;
  margin-bottom: 28px;
  max-width: 580px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0
}

/* ── Empty state ── */
.empty-state {
  background: var(--bg-s);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 52px 32px;
  text-align: center;
  color: var(--t3);
}

.es-icon svg {
  width: 32px;
  height: 32px;
  display: block;
  margin: 0 auto 14px;
  opacity: .25;
  stroke: var(--t1);
}

.empty-state h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--t1);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  line-height: 1.65;
  max-width: 300px;
  margin: 0 auto;
  color: var(--t2);
}

/* ── API doc styles ── */
.api-section {
  margin-bottom: 44px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.api-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none
}

.api-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--t1);
  margin: 0 0 14px 0;
  padding-top: 18px;
  line-height: 1.3;
  letter-spacing: -0.3px;
}

.api-section:first-child .api-title {
  padding-top: 0
}

.api-section .page-desc {
  font-size: 14px;
  color: var(--t2);
  line-height: 1.7;
  margin-bottom: 22px;
  max-width: 580px
}

.endpoint-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--header-bg);
  border-radius: var(--radius);
  padding: 11px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}

.method-badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 4px;
  flex-shrink: 0;
  text-transform: uppercase;
  background: var(--bg);
  color: var(--t1);
}

.badge-get {
  background: #065f46;
  color: #6ee7b7
}

.badge-post {
  background: #1e3a8a;
  color: #93c5fd
}

.badge-delete {
  background: #7f1d1d;
  color: #fca5a5
}

.badge-put,
.badge-patch {
  background: #78350f;
  color: #fcd34d
}

[data-theme="dark"] .badge-get {
  background: #064e3b;
  color: #34d399;
}

[data-theme="dark"] .badge-post {
  background: #1e3a5f;
  color: #60a5fa;
}

[data-theme="dark"] .badge-delete {
  background: #7f1d1d;
  color: #f87171;
}

[data-theme="dark"] .badge-put,
[data-theme="dark"] .badge-patch {
  background: #78350f;
  color: #fbbf24;
}

.endpoint-path {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--t1);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn {
  background: none;
  border: none;
  padding: 4px;
  border-radius: 4px;
  color: var(--t4);
  display: flex;
  align-items: center;
  transition: color var(--ease);
  flex-shrink: 0;
}

.copy-btn:hover {
  color: var(--t1)
}

.copy-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
}

.copy-btn.copied svg {
  display: none
}

.copy-btn.copied::after {
  content: '✓';
  font-size: 13px;
  color: #059669
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  margin-bottom: 7px;
  line-height: 1.5;
}

.meta-row:last-of-type {
  margin-bottom: 12px
}

.meta-label {
  color: var(--t3);
  font-weight: 600;
  min-width: 110px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.meta-val {
  color: var(--t1);
  background: var(--bg-s);
  padding: 2px 9px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
}

/* ── Parameter tables ── */
.param-block {
  margin: 22px 0
}

.param-heading {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--t3);
  margin-bottom: 12px;
  margin-top: 18px;
}

.param-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--page-bg);
  box-shadow: 0 1px 3px rgba(17, 24, 39, .04);
}

[data-theme="dark"] .param-table {
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}

.param-table th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--t3);
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  background: var(--bg-s);
}

.param-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
  color: var(--t1);
  background: var(--page-bg);
}

.param-table tr:last-child td {
  border-bottom: none
}

.param-table tr:hover td {
  background: var(--bg-h)
}

.param-table code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--bg-s);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--t1);
  font-weight: 500;
  border: 1px solid var(--border);
}

.type-tag {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--t3);
  background: var(--bg-h);
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 500;
  border: 1px solid var(--border);
}

.text-muted {
  color: var(--t2);
  font-size: 13px;
  line-height: 1.6
}

/* ── JSON blocks ── */
.json-block {
  border-radius: var(--radius);
  overflow: hidden;
  margin: 14px 0 18px;
  border: 1px solid var(--border);
}

.json-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: var(--bg-s);
  border-bottom: 1px solid var(--border);
}

.json-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--t1);
  display: flex;
  align-items: center;
  gap: 6px;
}

.json-success .json-label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block
}

.json-failure .json-label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ef4444;
  display: inline-block
}

.json-block .copy-btn {
  color: var(--t3)
}

.json-block .copy-btn:hover {
  color: var(--t1)
}

.json-pre {
  background: #1e293b;
  padding: 16px 18px;
  overflow-x: auto;
  margin: 0;
  border-top: 1px solid var(--border);
}

.json-pre code {
  font-family: var(--mono);
  font-size: 12.5px;
  color: #e2e8f0;
  line-height: 1.7;
  white-space: pre;
  font-weight: 400
}

/* ── Request note ── */
.req-note {
  font-size: 13.5px;
  color: var(--t1);
  margin: 14px 0 22px;
  line-height: 1.7;
  background: var(--bg-s);
  border-left: 3px solid var(--brand);
  padding: 11px 15px;
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ── Overview cards ── */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 6px;
}

.ov-card {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  background: var(--card-bg);
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease), background var(--ease);
  display: block;
  color: inherit;
  cursor: pointer;
  position: relative;
}

/* Subtle inner shadow for depth */
.ov-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 10px;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.8);
  pointer-events: none;
}

[data-theme="dark"] .ov-card::after {
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.03);
}

.ov-card:hover {
  border-color: var(--border2);
  background: var(--page-bg);
  box-shadow: 0 2px 8px rgba(17, 24, 39, .06);
  transform: translateY(-2px);
}

[data-theme="dark"] .ov-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}

.ov-card:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(17, 24, 39, .04);
  background: var(--card-bg);
  border-color: var(--border);
}

[data-theme="dark"] .ov-card:active {
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}

.ov-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--page-bg);
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  transition: background var(--ease), transform var(--ease);
  border: 2px solid var(--border);
}

.ov-card:hover .ov-card-icon {
  background: var(--card-bg);
  transform: scale(1.05);
  border-color: var(--border2);
}

.ov-card-icon svg {
  width: 17px;
  height: 17px;
  stroke: var(--t1);
}

.ov-card h3 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--t1);
  margin-bottom: 5px;
  letter-spacing: -0.2px;
}

.ov-card p {
  font-size: 12.5px;
  color: var(--t2);
  line-height: 1.6;
}

/* ── Sidebar footer ── */
.sidebar-footer {
  flex-shrink: 0;
  padding: 11px 16px;
  border-top: 1px solid var(--border);
  background: var(--sidebar-bg);
  font-size: 11px;
  color: var(--t4);
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 2;
}

.sidebar-footer-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0
}

/* ── Responsive ── */
@media(max-width:900px) {
  .content {
    padding: 28px 28px
  }
}

@media(max-width:768px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 50;
    width: min(var(--sw), 84vw);
    position: fixed;
    padding: 0
  }

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

  .main {
    margin-left: 0
  }

  .content {
    padding: 24px 20px
  }

  .hamburger {
    display: grid
  }

  .page-title {
    font-size: 23px
  }

  .search-box {
    max-width: 200px
  }

  .overview-grid {
    grid-template-columns: 1fr 1fr
  }

  .hdr-badge {
    display: none
  }

  .sidebar-nav {
    padding: 12px 0 8px;
  }
}

@media(max-width:480px) {
  .search-box {
    display: none
  }

  .overview-grid {
    grid-template-columns: 1fr
  }
}

@media(prefers-reduced-motion:reduce) {

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important
  }
}

/* ── Sidebar button reset (for accordion triggers) ── */
button.sidebar-link {
  width: calc(100% - 12px);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font);
  color: var(--t2);
}

button.sidebar-link span {
  flex: 1;
  text-align: left;
}

/* ══════════════════════════════════════════════
   Search — Header trigger button (mobile icon)
══════════════════════════════════════════════ */

/* Show icon-only search button on small screens */
.search-icon-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--t2);
  flex-shrink: 0;
  transition: background var(--ease), border-color var(--ease);
}

.search-icon-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.search-icon-btn:hover {
  background: var(--bg-h);
  border-color: var(--border2);
}

/* ══════════════════════════════════════════════
   Search Modal — Base (all platforms)
══════════════════════════════════════════════ */

.search-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(17, 24, 39, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  animation: sm-backdrop 0.18s ease;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

[data-theme="dark"] .search-modal {
  background: rgba(0, 0, 0, 0.5);
}

.search-modal[hidden] {
  display: none;
}

@keyframes sm-backdrop {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.search-modal-box {
  background: var(--header-bg);
  border: 1px solid var(--border2);
  border-radius: 14px;
  width: 100%;
  max-width: 600px;
  margin: 0 20px;
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 14vh - 20px);
  animation: sm-slide 0.2s cubic-bezier(.22, 1, .36, 1);
}

[data-theme="dark"] .search-modal-box {
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

@keyframes sm-slide {
  from {
    transform: translateY(-14px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ── Header row ── */
.search-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border2);
  flex-shrink: 0;
}

.search-modal-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.55;
  stroke: var(--t3);
  fill: none;
}

.search-modal-input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  font-size: 15px;
  font-family: var(--font);
  color: var(--t1);
  caret-color: var(--t1);
  font-size: max(16px, 15px);
}

.search-modal-input::placeholder {
  color: var(--t4);
  opacity: 0.7;
}

.search-modal-input::-webkit-search-cancel-button,
.search-modal-input::-webkit-search-decoration {
  display: none;
}

.search-modal-close {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--t4);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--ease), color var(--ease), background var(--ease);
  min-height: 32px;
}

.search-modal-close:hover,
.search-modal-close:focus-visible {
  border-color: var(--border2);
  color: var(--t1);
  background: var(--bg-h);
  outline: none;
}

.search-modal-close kbd {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}

/* ── Results list ── */
.search-modal-results {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  max-height: 360px;
}

.search-modal-results:empty {
  display: none;
}

/* Scrollbar — hidden on touch, subtle on desktop */
.search-modal-results::-webkit-scrollbar {
  width: 4px;
}

.search-modal-results::-webkit-scrollbar-track {
  background: transparent;
}

.search-modal-results::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 4px;
}

.search-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--t4);
  padding: 12px 10px 4px;
  user-select: none;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--t2);
  transition: background 0.12s;
  cursor: pointer;
  min-height: 48px;
  overflow: hidden;
}

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

/* Remove tap highlight on mobile */
.search-result-item {
  -webkit-tap-highlight-color: transparent;
}

.sri-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 8px;
  color: var(--t2);
}

.sri-icon svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.sri-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sri-label {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--t1);
}

.sri-bread {
  font-size: 11px;
  color: var(--t4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sri-arrow {
  font-size: 13px;
  color: var(--t4);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s;
}

.search-result-item.active .sri-arrow,
.search-result-item:hover .sri-arrow {
  opacity: 1;
}

/* Highlight matched chars */
.search-result-item mark {
  background: none;
  color: var(--t1);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: rgba(17, 24, 39, 0.2);
  text-underline-offset: 2px;
}

[data-theme="dark"] .search-result-item mark {
  text-decoration-color: rgba(255, 255, 255, 0.2);
}

/* Empty state */
.search-empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--t4);
  font-size: 14px;
}

.search-empty strong {
  color: var(--t1);
}

/* ── Footer hint bar ── */
.search-modal-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 16px;
  border-top: 1px solid var(--border2);
  font-size: 11px;
  color: var(--t4);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.search-modal-footer kbd {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--t1);
}

/* ══════════════════════════════════════════════
   Search — Tablet  (601px – 768px)
══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .search-box {
    max-width: 180px;
  }

  .search-box span {
    display: none;
  }

  /* hide label text, keep icon + kbd */
  .search-box kbd {
    margin-left: auto;
  }
}

/* ══════════════════════════════════════════════
   Search — Mobile  (≤ 600px)
   Replace text search-box with icon button
══════════════════════════════════════════════ */
@media (max-width: 600px) {

  .search-box {
    display: none !important;
  }

  .search-icon-btn {
    display: flex;
  }

  .search-modal {
    align-items: flex-end;
    padding-top: 0;
  }

  .search-modal-box {
    margin: 0;
    border-radius: 18px 18px 0 0;
    max-width: 100%;
    max-height: 88vh;
    animation: sm-sheet 0.22s cubic-bezier(.22, 1, .36, 1);
  }

  @keyframes sm-sheet {
    from {
      transform: translateY(100%);
    }

    to {
      transform: translateY(0);
    }
  }

  /* Drag handle */
  .search-modal-box::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }

  /* Larger input text (prevents iOS auto-zoom) */
  .search-modal-input {
    font-size: 16px;
  }

  /* Bigger results area on mobile */
  .search-modal-results {
    max-height: 55vh;
  }

  /* Bigger touch targets */
  .search-result-item {
    min-height: 52px;
    padding: 12px 12px;
  }

  /* Hide keyboard hint footer — not relevant on touch */
  .search-modal-footer {
    display: none;
  }

  /* Hide ESC close button; user swipes/taps backdrop */
  .search-modal-close {
    display: none;
  }
}

/* ══════════════════════════════════════════════
   Search — Reduced motion
══════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {

  .search-modal,
  .search-modal-box {
    animation: none !important;
  }
}