:root {
  /* Backgrounds */
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-alt: #334155;
  --surface-hover: #27354f;

  /* Borders */
  --border: rgba(148, 163, 184, 0.12);
  --border-hover: rgba(245, 158, 11, 0.45);

  /* Text */
  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-tertiary: #64748b;

  /* Accent */
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-dim: rgba(245, 158, 11, 0.15);

  /* RGB variants for rgba() */
  --bg-rgb: 15, 23, 42;
  --surface-rgb: 30, 41, 59;
  --accent-rgb: 245, 158, 11;

  /* Semantic */
  --success: #34d399;
  --error: #f87171;
  --warning: #fbbf24;

  /* Fonts */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei',
               'Noto Sans SC', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Monaco,
               'Cascadia Code', 'Consolas', 'Noto Sans SC Mono', monospace;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-secondary);
  background: var(--bg);
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 28px 60px;
}

.page-header {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 28px;
}

.page-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-title {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.page-title::before {
  content: '$ ';
  font-family: var(--font-mono);
  color: var(--accent);
}

.page-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 640px) {
  .page-controls {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-shrink: 0;
}

.tab {
  position: relative;
  padding: 8px 16px 8px 12px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.tab::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 8px;
  opacity: 0.5;
  transition: background 0.2s ease, opacity 0.2s ease;
}

.tab:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.tab:hover::before {
  opacity: 0.8;
}

.tab.active {
  color: var(--bg);
  background: var(--accent);
}

.tab.active::before {
  background: var(--bg);
  opacity: 1;
}

.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Search */
.search-wrap {
  position: relative;
  width: 100%;
  max-width: 520px;
}

.search-input {
  width: 100%;
  padding: 13px 16px 13px 44px;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

.search-input:hover {
  border-color: var(--border-hover);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

.search-prompt {
  position: absolute;
  left: 16px;
  top: 13px;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text-tertiary);
  pointer-events: none;
  transition: color 0.2s ease;
}

.search-input:focus + .search-prompt,
.search-input:not(:placeholder-shown) + .search-prompt {
  color: var(--accent);
}

.search-hint {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 8px;
  margin-left: 4px;
}

.search-hint code {
  color: var(--accent);
  background: var(--accent-dim);
  padding: 1px 5px;
  border-radius: 4px;
}

/* Panel grid */
.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

@media (max-width: 860px) {
  .panel-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  opacity: 0;
  animation: fadeInUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.panel:hover {
  border-color: var(--border-hover);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  background: rgba(var(--surface-rgb), 0.6);
  border-bottom: 1px solid var(--border);
}

.panel-header::before {
  content: '/';
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  opacity: 0.7;
}

.panel-title {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}

.panel-body {
  padding: 6px 0;
}

/* List rows */
.row {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 16px 10px 20px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.row::before {
  content: '›';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.row::after {
  content: '';
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  opacity: 0;
  transform: scaleY(0.7);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.row:hover {
  background: var(--surface-hover);
}

.row:hover::before {
  color: var(--accent);
  opacity: 1;
}

.row:hover::after {
  opacity: 1;
  transform: scaleY(1);
}

.row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.row-title {
  flex-shrink: 0;
  max-width: 45%;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
}

.row-summary {
  flex: 1;
  min-width: 0;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .row-title {
    max-width: 100%;
  }

  .row-summary {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-tertiary);
}

.empty-state.hidden {
  display: none;
}

.empty-state code {
  color: var(--error);
  background: rgba(248, 113, 113, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.empty-icon {
  font-family: var(--font-mono);
  font-size: 42px;
  color: var(--accent);
  opacity: 0.4;
  animation: blink 1.2s step-end infinite;
}

.empty-hint {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* Drawer overlay */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(var(--bg-rgb), 0.78);
  backdrop-filter: blur(5px);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Drawer */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 560px;
  max-width: 100%;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 101;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.32);
}

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

.drawer[aria-hidden="true"] {
  pointer-events: none;
}

.drawer[aria-hidden="false"] {
  pointer-events: auto;
}

@media (max-width: 860px) {
  .drawer {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-height: 90vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }

  .drawer.open {
    transform: translateY(0);
  }
}

.drawer-header {
  padding: 22px 26px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.drawer-title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
}

.drawer-summary {
  margin: 6px 0 0;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.drawer-body {
  flex: 1;
  padding: 26px;
  overflow-y: auto;
}

.drawer-body h2,
.drawer-body h3,
.drawer-body h4 {
  font-family: var(--font-sans);
  color: var(--text);
  margin-top: 24px;
  margin-bottom: 12px;
}

.drawer-body h2 {
  font-size: 19px;
  font-weight: 700;
}

.drawer-body h3 {
  font-size: 17px;
  font-weight: 700;
}

.drawer-body h4 {
  font-size: 15px;
  font-weight: 600;
}

.drawer-body p {
  font-family: var(--font-sans);
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 14px;
}

.drawer-body ul,
.drawer-body ol {
  padding-left: 22px;
  margin-bottom: 14px;
  color: var(--text-secondary);
  line-height: 1.75;
}

.drawer-body li {
  margin-bottom: 6px;
}

.drawer-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 14px;
}

.drawer-body th,
.drawer-body td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.drawer-body th {
  background: var(--surface-alt);
  color: var(--text);
  font-weight: 600;
}

.drawer-body code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
}

.drawer-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  overflow-x: auto;
}

.drawer-body pre code {
  background: transparent;
  padding: 0;
  color: var(--text);
  line-height: 1.65;
}

.drawer-body a {
  color: var(--accent);
  text-decoration: none;
}

.drawer-body a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.drawer-close {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  color: var(--text-secondary);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.drawer-close:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

.drawer-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes blink {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Mobile container padding */
@media (max-width: 640px) {
  .container {
    padding: 24px 16px 40px;
  }

  .page-title {
    font-size: 22px;
  }

  .tabs {
    overflow-x: auto;
    max-width: 100%;
  }

  .tab {
    white-space: nowrap;
  }
}
