/* Receptor Explorer — Styles */
/* Design tokens inlined for standalone page (no shared tokens.css dependency) */

/* ===== Layer order ===== */
@layer reset, tokens, base, components, utilities;

/* ===== Design Tokens ===== */
@layer tokens {
  :root {
    --font-heading: 'Instrument Serif', Georgia, 'Times New Roman', serif;
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;

    --leading-tight: 1.2;
    --leading-normal: 1.6;

    /* Palette */
    --color-bg: #0a0c10;
    --color-surface: #12151c;
    --color-surface-2: #1a1e28;
    --color-border: #252a36;
    --color-border-bright: #3d4556;
    --color-foreground: #e8eaf0;
    --color-dim: #8891a5;
    --color-muted: #515a6b;

    /* Accent colors */
    --color-purple: #c084fc;
    --color-purple-dim: rgba(192, 132, 252, 0.15);
    --color-purple-glow: 0 0 16px rgba(192, 132, 252, 0.35), 0 0 40px rgba(192, 132, 252, 0.12);

    --color-gold: #ffd166;
    --color-gold-dim: rgba(255, 209, 102, 0.15);
    --color-gold-glow: 0 0 16px rgba(255, 209, 102, 0.4), 0 0 40px rgba(255, 209, 102, 0.12);

    --color-coral: #ff6b6b;
    --color-coral-dim: rgba(255, 107, 107, 0.15);
    --color-coral-glow: 0 0 16px rgba(255, 107, 107, 0.35), 0 0 40px rgba(255, 107, 107, 0.12);

    --color-teal: #4ecdc4;
    --color-teal-dim: rgba(78, 205, 196, 0.15);
    --color-teal-glow: 0 0 16px rgba(78, 205, 196, 0.35), 0 0 40px rgba(78, 205, 196, 0.12);

    --color-blue: #6c9bff;
    --color-blue-dim: rgba(108, 155, 255, 0.15);
    --color-blue-glow: 0 0 16px rgba(108, 155, 255, 0.35), 0 0 40px rgba(108, 155, 255, 0.12);

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;

    /* Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout */
    --panel-width: 300px;
    --header-height: 4rem;
  }
}

/* ===== Reset ===== */
@layer reset {
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

  html {
    -webkit-text-size-adjust: 100%;
    tab-size: 4;
  }

  body {
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }

  img, canvas, svg {
    display: block;
    max-width: 100%;
  }

  button {
    cursor: pointer;
    border: none;
    background: none;
    font: inherit;
  }

  input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
  }

  ul[role="list"],
  ul[role="listbox"] {
    list-style: none;
  }
}

/* ===== Base ===== */
@layer base {
  html, body {
    height: 100%;
  }

  body {
    background: var(--color-bg);
    color: var(--color-foreground);
    font-family: var(--font-body);
    font-size: var(--text-base);
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
  }
}

/* ===== Components ===== */
@layer components {

  /* Grain texture */
  .grain {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.028;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  }

  /* ===== Tool Header ===== */

  .tool-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-inline: var(--space-5);
    background: rgba(10, 12, 16, 0.92);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
  }

  .tool-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
  }

  .back-link {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 400;
    color: var(--color-dim);
    text-decoration: none;
    letter-spacing: 0.04em;
    transition: color var(--transition-fast);
    white-space: nowrap;
  }

  .back-link:hover {
    color: var(--color-teal);
  }

  .header-divider {
    width: 1px;
    height: 1.5rem;
    background: var(--color-border);
    flex-shrink: 0;
  }

  .tool-title-group {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
  }

  .tool-title {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 400;
    line-height: var(--leading-tight);
    color: var(--color-foreground);
    letter-spacing: -0.01em;
  }

  .tool-subtitle {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 300;
    color: var(--color-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .tool-badge {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 400;
    color: var(--color-teal);
    letter-spacing: 0.06em;
    border: 1px solid var(--color-teal-dim);
    border-radius: var(--radius-full);
    padding: var(--space-1) var(--space-3);
    background: rgba(78, 205, 196, 0.05);
  }

  .tool-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-teal);
    box-shadow: 0 0 6px rgba(78, 205, 196, 0.8);
    animation: pulse-dot 2s ease-in-out infinite;
  }

  @keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
  }

  /* ===== Tool Main Layout ===== */

  .tool-main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr auto var(--panel-width);
    grid-template-rows: 1fr;
    min-height: 0;
    overflow: hidden;
  }

  /* ===== Canvas Section ===== */

  .canvas-section {
    position: relative;
    overflow: hidden;
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
  }

  .canvas-wrapper {
    position: relative;
    flex: 1;
    overflow: hidden;
  }

  #receptor-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
  }

  /* Canvas Tooltip */
  .canvas-tooltip {
    position: absolute;
    z-index: 20;
    background: var(--color-surface);
    border: 1px solid var(--color-border-bright);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--color-foreground);
    pointer-events: none;
    max-width: 200px;
    line-height: var(--leading-normal);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  }

  .canvas-tooltip[hidden] {
    display: none;
  }

  /* Step overlay */
  .step-overlay {
    position: absolute;
    top: var(--space-4);
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 10;
  }

  .step-label {
    display: block;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--color-purple);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: rgba(10, 12, 16, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(192, 132, 252, 0.2);
    border-radius: var(--radius-full);
    padding: var(--space-1) var(--space-4);
    min-width: 180px;
    text-align: center;
    transition: opacity var(--transition-normal);
  }

  .step-label:empty {
    opacity: 0;
  }

  /* Canvas legend */
  .canvas-legend {
    position: absolute;
    bottom: var(--space-4);
    left: var(--space-4);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    background: rgba(10, 12, 16, 0.8);
    backdrop-filter: blur(8px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-2) var(--space-3);
    pointer-events: none;
  }

  /* No-JS fallback */
  .noscript-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: var(--space-6);
    text-align: center;
    color: var(--color-muted);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    gap: var(--space-2);
  }

  .noscript-message {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--color-muted);
    letter-spacing: 0.04em;
  }

  /* ===== Resize Handle ===== */

  .resize-handle {
    width: 6px;
    cursor: col-resize;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: background var(--transition-fast);
    margin-left: -3px;
    margin-right: -3px;
  }

  .resize-handle:hover,
  .resize-handle.active {
    background: var(--color-border-bright);
  }

  .resize-handle-line {
    width: 2px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--color-muted);
    opacity: 0;
    transition: opacity var(--transition-fast);
  }

  .resize-handle:hover .resize-handle-line,
  .resize-handle.active .resize-handle-line {
    opacity: 1;
  }

  /* ===== Side Panel ===== */

  .panel {
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .panel::-webkit-scrollbar {
    width: 4px;
  }

  .panel::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius-full);
  }

  .panel-section {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border);
  }

  .panel-heading {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-muted);
    margin-bottom: var(--space-3);
  }

  .panel-hint {
    margin-top: var(--space-2);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--color-muted);
    letter-spacing: 0.04em;
    line-height: var(--leading-normal);
  }

  /* ===== Tab Navigation ===== */

  .tab-nav {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    padding: 0;
    flex-shrink: 0;
  }

  .tab-btn {
    flex: 1;
    padding: var(--space-3) var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 400;
    color: var(--color-dim);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition:
      color var(--transition-fast),
      border-color var(--transition-fast);
  }

  .tab-btn:hover {
    color: var(--color-foreground);
  }

  .tab-btn.active {
    color: var(--color-purple);
    border-bottom-color: var(--color-purple);
  }

  /* ===== Tab Panels ===== */

  .tab-panel {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
  }

  .tab-panel[hidden] {
    display: none;
  }

  /* ===== Toggle group ===== */

  .toggle-group {
    display: flex;
    gap: var(--space-2);
  }

  .toggle-btn {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.06em;
    color: var(--color-dim);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition:
      color var(--transition-fast),
      background var(--transition-fast),
      border-color var(--transition-fast),
      box-shadow var(--transition-fast);
    text-align: center;
    white-space: nowrap;
  }

  .toggle-btn:hover {
    color: var(--color-foreground);
    border-color: var(--color-border-bright);
  }

  .toggle-btn.active,
  .toggle-btn[aria-pressed="true"] {
    color: var(--color-purple);
    background: var(--color-purple-dim);
    border-color: rgba(192, 132, 252, 0.4);
    box-shadow: inset 0 0 0 1px rgba(192, 132, 252, 0.1);
  }

  /* ===== Category Pills ===== */

  .category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
  }

  .category-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--color-dim);
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: all var(--transition-fast);
    white-space: nowrap;
  }

  .category-pill:hover {
    border-color: var(--color-border-bright);
    color: var(--color-foreground);
  }

  .category-pill.active {
    border-color: currentColor;
    color: var(--color-foreground);
  }

  .category-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  /* ===== Receptor List ===== */

  .receptor-list-section {
    flex: 1 0 180px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .receptor-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
  }

  .receptor-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--color-dim);
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all var(--transition-fast);
  }

  .receptor-item:hover {
    color: var(--color-foreground);
    background: var(--color-surface-2);
  }

  .receptor-item.active {
    color: var(--color-foreground);
    background: var(--color-surface-2);
    border-left-color: var(--color-purple);
  }

  .receptor-item-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .receptor-item-name {
    flex: 1;
  }

  .receptor-item-abbr {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--color-muted);
  }

  /* ===== NT List (kept for shared utility) ===== */

  .nt-list-section {
    flex: 1 0 180px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .nt-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
  }

  .nt-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--color-dim);
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all var(--transition-fast);
  }

  .nt-item:hover {
    color: var(--color-foreground);
    background: var(--color-surface-2);
  }

  .nt-item.active {
    color: var(--color-foreground);
    background: var(--color-surface-2);
    border-left-color: var(--color-purple);
  }

  .nt-item-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .nt-item-name {
    flex: 1;
  }

  .nt-item-abbr {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--color-muted);
  }

  /* ===== Substance List ===== */

  .substance-list-section {
    flex: 1 0 180px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .substance-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
  }

  .substance-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--color-dim);
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all var(--transition-fast);
  }

  .substance-item:hover {
    color: var(--color-foreground);
    background: var(--color-surface-2);
  }

  .substance-item.active {
    color: var(--color-foreground);
    background: var(--color-surface-2);
    border-left-color: var(--color-gold);
  }

  .substance-category-header {
    padding: var(--space-2) var(--space-3);
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 1px solid var(--color-border);
    background: rgba(18, 21, 28, 0.5);
  }

  /* ===== Target Tags ===== */

  .target-tag {
    display: inline-flex;
    align-items: center;
    padding: 1px var(--space-2);
    font-family: var(--font-mono);
    font-size: 0.6rem;
    border-radius: var(--radius-full);
    letter-spacing: 0.04em;
  }

  .target-tag--agonist {
    color: #4ecdc4;
    background: rgba(78, 205, 196, 0.12);
    border: 1px solid rgba(78, 205, 196, 0.25);
  }

  .target-tag--antagonist {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.12);
    border: 1px solid rgba(255, 107, 107, 0.25);
  }

  .target-tag--modulator {
    color: #ffd166;
    background: rgba(255, 209, 102, 0.12);
    border: 1px solid rgba(255, 209, 102, 0.25);
  }

  /* ===== Cross-link ===== */

  .cross-link {
    color: var(--color-purple);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: rgba(192, 132, 252, 0.3);
    text-underline-offset: 2px;
    transition: color var(--transition-fast);
  }

  .cross-link:hover {
    color: var(--color-foreground);
  }

  /* ===== Info Card ===== */

  .info-card {
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    transition: border-color var(--transition-normal);
  }

  .info-card-empty {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--color-muted);
    text-align: center;
    padding: var(--space-4);
  }

  /* Detail card content */
  .detail-name {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    color: var(--color-foreground);
    line-height: var(--leading-tight);
  }

  .detail-formula {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--color-dim);
    margin-top: var(--space-1);
  }

  .detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin-top: var(--space-3);
  }

  .detail-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--space-2);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    border-radius: var(--radius-full);
    letter-spacing: 0.04em;
  }

  .detail-section {
    margin-top: var(--space-3);
  }

  .detail-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: var(--space-1);
  }

  .detail-text {
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    color: var(--color-dim);
  }

  .detail-receptors {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--color-dim);
    line-height: var(--leading-normal);
  }

  /* ===== Insight callouts (accessible content) ===== */

  .insight-callout {
    background: rgba(78, 205, 196, 0.06);
    border-left: 2px solid var(--color-teal);
    padding: 8px 10px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-top: var(--space-3);
  }

  .insight-label {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
    margin-bottom: 4px;
  }

  .insight-text {
    font-size: var(--text-sm);
    line-height: 1.6;
    color: var(--color-foreground);
  }

  /* ===== Collapsible technical sections ===== */

  .tech-details {
    margin-top: var(--space-3);
  }

  .tech-details summary {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .tech-details summary::before {
    content: '▸';
    font-size: 9px;
    transition: transform var(--transition-fast);
  }

  .tech-details[open] summary::before {
    transform: rotate(90deg);
  }

  .tech-details .detail-text {
    margin-top: var(--space-1);
  }

  /* Reuptake info card internals */
  .info-card-title {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    color: var(--color-foreground);
    line-height: var(--leading-tight);
    margin-bottom: var(--space-2);
  }

  .info-card-desc {
    font-size: var(--text-sm);
    color: var(--color-dim);
    line-height: var(--leading-normal);
    margin-bottom: var(--space-3);
  }

  .info-card-biology {
    font-size: var(--text-xs);
    font-style: italic;
    color: var(--color-muted);
    line-height: var(--leading-normal);
    border-top: 1px solid var(--color-border);
    padding-top: var(--space-2);
  }

  /* ===== Receptor Select ===== */

  .receptor-select {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--color-foreground);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238891a5' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    padding-right: var(--space-6);
  }

  .receptor-select:hover {
    border-color: var(--color-border-bright);
  }

  .receptor-select:focus {
    outline: 2px solid var(--color-teal);
    outline-offset: -2px;
  }

  .receptor-select option {
    background: var(--color-surface);
    color: var(--color-foreground);
  }

  .receptor-select optgroup {
    font-family: var(--font-mono);
    font-weight: 500;
    color: var(--color-dim);
  }

  /* ===== NT Select ===== */

  .nt-select {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--color-foreground);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238891a5' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    padding-right: var(--space-6);
  }

  .nt-select:hover {
    border-color: var(--color-border-bright);
  }

  .nt-select:focus {
    outline: 2px solid var(--color-teal);
    outline-offset: -2px;
  }

  .nt-select option {
    background: var(--color-surface);
    color: var(--color-foreground);
  }

  .nt-select optgroup {
    font-family: var(--font-mono);
    font-weight: 500;
    color: var(--color-dim);
  }

  /* ===== Playback controls ===== */

  .ctrl-row {
    display: flex;
    gap: var(--space-2);
  }

  .ctrl-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    color: var(--color-dim);
    transition:
      color var(--transition-fast),
      background var(--transition-fast),
      border-color var(--transition-fast),
      box-shadow var(--transition-fast);
    flex-shrink: 0;
  }

  .ctrl-btn:hover {
    color: var(--color-foreground);
    border-color: var(--color-border-bright);
    background: rgba(255, 255, 255, 0.04);
  }

  .ctrl-btn:focus-visible {
    outline: 2px solid var(--color-teal);
    outline-offset: 2px;
  }

  /* ===== Speed control ===== */

  .speed-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-top: var(--space-3);
  }

  .speed-label {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--color-dim);
    letter-spacing: 0.06em;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .speed-slider {
    flex: 1;
    height: 4px;
    border-radius: var(--radius-full);
    background: var(--color-surface-2);
    outline: none;
    cursor: pointer;
  }

  .speed-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-teal);
    box-shadow: 0 0 8px rgba(78, 205, 196, 0.4);
    cursor: pointer;
    transition: box-shadow var(--transition-fast);
  }

  .speed-slider::-webkit-slider-thumb:hover {
    box-shadow: 0 0 14px rgba(78, 205, 196, 0.7);
  }

  .speed-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-teal);
    border: none;
    box-shadow: 0 0 8px rgba(78, 205, 196, 0.4);
    cursor: pointer;
  }

  .speed-slider:focus-visible {
    outline: 2px solid var(--color-teal);
    outline-offset: 2px;
    border-radius: var(--radius-full);
  }

  .speed-display {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--color-foreground);
    min-width: 2.5rem;
    text-align: right;
    flex-shrink: 0;
  }

  /* ===== Progress ===== */

  .step-progress {
    height: 3px;
    background: var(--color-surface-2);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-3);
  }

  .step-progress-bar {
    height: 100%;
    background: linear-gradient(to right, var(--color-purple), var(--color-teal));
    border-radius: var(--radius-full);
    width: 0%;
    transition: width var(--transition-normal);
  }

  .step-dots {
    display: flex;
    gap: var(--space-1);
    flex-wrap: wrap;
  }

  .step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    transition:
      background var(--transition-fast),
      border-color var(--transition-fast),
      box-shadow var(--transition-fast);
    flex-shrink: 0;
  }

  .step-dot.completed {
    background: var(--color-purple);
    border-color: rgba(192, 132, 252, 0.4);
  }

  .step-dot.active {
    background: var(--color-teal);
    border-color: rgba(78, 205, 196, 0.6);
    box-shadow: 0 0 8px rgba(78, 205, 196, 0.5);
  }

  /* ===== Legend List ===== */

  .legend-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
  }

  .legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--color-dim);
    letter-spacing: 0.04em;
    white-space: nowrap;
  }

  .legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
  }

}

/* ===== Utilities ===== */
@layer utilities {

  :focus-visible {
    outline: 2px solid var(--color-teal);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
  }

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
  }

  [hidden] {
    display: none !important;
  }
}

/* ===== Responsive ===== */

@media (max-width: 768px) {
  :root {
    --panel-width: 100%;
    --header-height: 3.5rem;
  }

  .resize-handle {
    display: none;
  }

  .tool-main {
    grid-template-columns: 1fr !important;
    grid-template-rows: 60dvh auto;
    overflow: auto;
  }

  .canvas-section {
    min-height: 60dvh;
    max-height: 60dvh;
  }

  .panel {
    border-left: none;
    border-top: 1px solid var(--color-border);
    overflow-y: visible;
    max-height: none;
  }

  .tab-panel {
    overflow-y: visible;
  }

  .tool-title {
    font-size: var(--text-lg);
  }

  .tool-subtitle {
    display: none;
  }

  .back-link span {
    display: none;
  }

  .canvas-legend {
    display: none;
  }
}

@media (max-width: 480px) {
  .tool-header {
    padding-inline: var(--space-3);
  }

  .panel-section {
    padding: var(--space-3) var(--space-4);
  }

  .tool-badge {
    display: none;
  }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .tool-badge-dot {
    animation: none;
  }

  .step-progress-bar,
  .step-dot,
  .ctrl-btn,
  .toggle-btn,
  .tab-btn,
  .info-card,
  .category-pill,
  .nt-item,
  .receptor-item,
  .substance-item,
  .cross-link,
  .target-tag,
  .receptor-select,
  .nt-select {
    transition: none;
  }
}
