:root.theme-terminal,
.theme-terminal {
  /* ============================================
     Catppuccin Mocha Core Tokens
     ============================================ */
  
  /* Surfaces (dark to light) */
  --ctp-crust: #11111b;
  --ctp-mantle: #181825;
  --ctp-base: #1e1e2e;
  --ctp-surface0: #313244;
  --ctp-surface1: #45475a;
  --ctp-surface2: #585b70;
  
  /* Text (bright to dim) */
  --ctp-text: #cdd6f4;
  --ctp-subtext1: #bac2de;
  --ctp-subtext0: #a6adc8;
  
  /* Overlays (dim UI text) */
  --ctp-overlay2: #9399b2;
  --ctp-overlay1: #7f849c;
  --ctp-overlay0: #6c7086;
  
  /* Accents */
  --ctp-blue: #89b4fa;
  --ctp-green: #a6e3a1;
  --ctp-red: #f38ba8;
  --ctp-yellow: #f9e2af;
  
  /* ============================================
     Terminal Semantic Tokens (mapped to Catppuccin)
     ============================================ */
  
  /* Layout surfaces */
  --term-wallpaper: var(--ctp-crust);
  --term-chrome-bg: var(--ctp-mantle);
  --term-body-bg: var(--ctp-base);
  
  /* Borders & dividers */
  --term-border: rgba(205, 214, 244, 0.12);
  --term-border-subtle: rgba(205, 214, 244, 0.08);
  
  /* Text hierarchy */
  --term-text: var(--ctp-text);
  --term-text-dim: var(--ctp-subtext0);
  --term-text-faint: var(--ctp-overlay0);
  
  /* Selection (fzf highlight) */
  --term-selection-bg: var(--ctp-blue);
  --term-selection-fg: var(--ctp-crust);
  
  /* Legacy mappings for compatibility */
  --term-base: var(--ctp-base);
  --term-mantle: var(--ctp-mantle);
  --term-crust: var(--ctp-crust);
  --term-subtext0: var(--ctp-subtext0);
  --term-subtext1: var(--ctp-subtext1);
  --term-overlay0: var(--ctp-overlay0);
  --term-overlay1: var(--ctp-overlay1);
  --term-overlay2: var(--ctp-overlay2);
  --term-surface0: var(--ctp-surface0);
  --term-surface1: var(--ctp-surface1);
  --term-surface2: var(--ctp-surface2);
  --term-blue: var(--ctp-blue);
  --term-green: var(--ctp-green);
  --term-red: var(--ctp-red);
  --term-yellow: var(--ctp-yellow);
  
  /* Standard theme variables */
  --bg-dark: var(--ctp-crust);
  --bg-mid: var(--ctp-base);
  --text-primary: var(--ctp-text);
  --text-muted: var(--ctp-subtext0);
  --text-subtle: var(--ctp-overlay0);
  --card-bg: var(--ctp-base);
  --card-border: var(--ctp-surface0);
  --card-border-strong: var(--ctp-surface1);
  --button-bg: transparent;
  --button-border: var(--ctp-surface0);
  --button-hover-bg: var(--ctp-surface0);
  --button-active-bg: var(--ctp-surface1);
  --accent: var(--ctp-blue);
  --font-sans: ui-monospace, "SF Mono", "Cascadia Code", "Segoe UI Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Segoe UI Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  color-scheme: dark;
}

/* ============================================
   Page & Window Structure
   ============================================ */

/* Desktop wallpaper - darkest (crust) */
.theme-terminal body {
  background: var(--term-wallpaper);
  font-family: var(--font-mono);
}

/* Base anchor reset for terminal theme */
.theme-terminal a {
  text-decoration: none;
}

/* Terminal window container */
.theme-terminal .sb-card-shell {
  max-width: 520px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
}

/* Window body - lighter than wallpaper (base) */
.theme-terminal .sb-card {
  background: var(--term-body-bg);
  border: 1px solid var(--term-border);
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
}

/* Chrome bar - between wallpaper and body (mantle) */
.theme-terminal .term-bar {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  background: var(--term-chrome-bg);
  border-bottom: 1px solid var(--term-border-subtle);
  position: relative;
  font-family: var(--font-mono);
}

/* Traffic lights */
.theme-terminal .term-lights {
  display: flex;
  gap: 8px;
  align-items: center;
}

.theme-terminal .term-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: block;
}

.theme-terminal .term-light-close {
  background: var(--ctp-red);
}

.theme-terminal .term-light-min {
  background: var(--ctp-yellow);
}

.theme-terminal .term-light-max {
  background: var(--ctp-green);
}

/* Window title */
.theme-terminal .term-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--term-text-faint);
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50%;
}

/* Terminal body - buffer area */
.theme-terminal .term-body {
  padding: 0;
  background: var(--term-body-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

/* Buffer - consistent left gutter */
.theme-terminal .term-buffer {
  padding: 16px 20px 16px 20px;
}

/* ============================================
   Prompt Block
   ============================================ */

.theme-terminal .term-prompt-block {
  margin-bottom: 12px;
}

.theme-terminal .term-prompt-line {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--term-text);
}

.theme-terminal .term-prompt-line.term-dim {
  color: var(--ctp-overlay1);
}

.theme-terminal .term-path {
  color: var(--term-text-dim);
}

/* Subtle prompt glyph - doesn't compete with selection */
.theme-terminal .term-prompt-char {
  color: var(--ctp-overlay1);
  margin-right: 6px;
}

.theme-terminal .term-pipe {
  color: var(--term-text-faint);
  margin: 0 4px;
}

.theme-terminal .term-menu-header {
  margin-top: 14px;
  margin-bottom: 6px;
}

/* ============================================
   Output Block
   ============================================ */

.theme-terminal .term-output {
  padding: 10px 0 6px 0;
  border-left: 2px solid var(--ctp-surface0);
  margin-left: 2px;
  padding-left: 14px;
}

/* Avatar */
.theme-terminal .sb-avatar {
  width: 56px;
  height: 56px;
  border: 1px solid var(--ctp-surface1);
  box-shadow: none;
  margin: 0 0 10px 0;
  display: block;
}

/* Name - primary */
.theme-terminal .sb-name {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.4;
  color: var(--term-text);
  text-align: left;
}

/* Handle - dim */
.theme-terminal .sb-handle {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--ctp-overlay1);
  text-align: left;
  margin-bottom: 0;
}

/* Bio */
.theme-terminal .sb-bio {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--term-text-dim);
  text-align: left;
  margin: 8px 0 0 0;
}

.theme-terminal .sb-bio::before {
  content: none;
}

/* ============================================
   fzf List Container
   ============================================ */

.theme-terminal .fzf-container {
  margin-top: 4px;
}

/* Status line */
.theme-terminal .fzf-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--term-text-faint);
  margin-bottom: 6px;
  padding-left: 2px;
}

/* List container - surface0 (lifted above base) */
.theme-terminal .fzf-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--ctp-surface0);
  border: 1px solid var(--ctp-surface1);
  border-radius: 4px;
  padding: 2px;
  overflow: hidden;
}

/* Hide default sb-links in SESSION mode (fzf-list is used instead) */
.theme-terminal .term-buffer .sb-links {
  display: none;
}

/* Link rows - interactive at rest */
.theme-terminal .fzf-list .sb-button {
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(69, 71, 90, 0.5);
  border-radius: 0;
  padding: 9px 12px 9px 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  color: var(--ctp-text);
  position: relative;
  transition: none;
  display: flex;
  align-items: center;
  gap: 0;
}

.theme-terminal .fzf-list .sb-button:last-child {
  border-bottom: none;
}

/* Glyph column - visible but dim at rest */
.theme-terminal .fzf-list .sb-button::before {
  content: "›";
  color: var(--ctp-overlay0);
  font-size: 13px;
  font-weight: 400;
  width: 18px;
  flex-shrink: 0;
  text-align: left;
}

/* Hover: Catppuccin blue selection */
.theme-terminal .fzf-list .sb-button:hover {
  background: var(--term-selection-bg);
  color: var(--term-selection-fg);
}

.theme-terminal .fzf-list .sb-button:hover::before {
  content: "❯";
  color: var(--term-selection-fg);
}

/* Active */
.theme-terminal .fzf-list .sb-button:active {
  background: var(--ctp-text);
  color: var(--ctp-crust);
  transform: none;
}

.theme-terminal .fzf-list .sb-button:active::before {
  content: "❯";
  color: var(--ctp-crust);
}

/* Focus visible */
.theme-terminal .fzf-list .sb-button:focus-visible {
  outline: none;
  background: var(--term-selection-bg);
  color: var(--term-selection-fg);
}

.theme-terminal .fzf-list .sb-button:focus-visible::before {
  content: "❯";
  color: var(--term-selection-fg);
}

/* Footer hidden in Terminal theme */
.theme-terminal .sb-footer {
  display: none;
}

/* ============================================
   Terminal CLEAN Mode: Compact Reference Match
   Hard layout constraints - DO NOT tweak without measuring.
   Session/LARP mode is NOT affected by these selectors.
   ============================================ */

/* 1) Window width: 460px max, responsive */
.theme-terminal:has(.term-clean) .sb-card-shell {
  max-width: 460px;
  width: min(460px, calc(100vw - 32px));
}

/* 2) Title bar: 32px height */
.theme-terminal:has(.term-clean) .term-bar {
  height: 32px;
}

.theme-terminal:has(.term-clean) .term-title {
  font-size: 12px;
  color: var(--ctp-subtext0);
  letter-spacing: 0.2px;
}

.theme-terminal:has(.term-clean) .term-light {
  width: 11px;
  height: 11px;
}

/* 3) Body padding: narrow sides for wider content rail */
.theme-terminal .term-clean {
  padding: 10px 6px 12px;
}

/* 4) Inner column: full width, no constraint */
.theme-terminal .term-clean .termCleanCol {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

/* 5) Avatar: 74px, centered between top bar and name */
.theme-terminal .term-clean .sb-avatar {
  display: block;
  width: 74px;
  height: 74px;
  margin: 0 auto 16px;
  border: 2px solid var(--ctp-surface1);
  box-shadow: none;
}

/* 6) Name: 24px, tight to handle */
.theme-terminal .term-clean .sb-name {
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.08;
  margin: 0;
  color: var(--ctp-text);
}

/* 7) Handle: very close to name, more space before bio */
.theme-terminal .term-clean .sb-handle {
  text-align: center;
  font-size: 13px;
  margin: -1px 0 8px;
  color: var(--ctp-subtext0);
}

/* 8) Bio: more vertical space, with # prefix, lighter text */
.theme-terminal .term-clean .sb-bio {
  text-align: left;
  margin: 16px 0 22px;
  padding-left: 24px;
  position: relative;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ctp-subtext1);
}

.theme-terminal .term-clean .sb-bio::before {
  content: "#";
  position: absolute;
  left: 0;
  color: var(--ctp-overlay0);
}

/* 9) Links: full width, space from bio */
.theme-terminal .term-clean .sb-links {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  border: 1px solid var(--ctp-surface0);
  border-radius: 8px;
  overflow: hidden;
}

/* 10) Link rows: full width, vertically centered text */
.theme-terminal .term-clean .sb-button {
  width: 100%;
  background: rgba(49, 50, 68, 0.08);
  border: none;
  border-bottom: 1px solid var(--ctp-surface0);
  border-radius: 0;
  padding: 0 14px 0 36px;
  min-height: 44px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  text-align: left;
  color: var(--ctp-text);
  position: relative;
  transition: background 0.1s ease, color 0.1s ease;
  box-sizing: border-box;
  display: flex;
  align-items: center;
}

.theme-terminal .term-clean .sb-button:last-child {
  border-bottom: none;
}

/* 11) Glyph chevron - inline with text */
.theme-terminal .term-clean .sb-button::before {
  content: "❯";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ctp-blue);
  font-size: 14px;
  line-height: 1;
}

/* 12) Hover: inverse video selection */
.theme-terminal .term-clean .sb-button:hover {
  background: var(--ctp-blue);
  color: var(--ctp-base);
}

.theme-terminal .term-clean .sb-button:hover::before {
  color: var(--ctp-base);
}

/* 13) Active: stronger selection */
.theme-terminal .term-clean .sb-button:active {
  background: var(--ctp-subtext1);
  color: var(--ctp-base);
  transform: none;
}

.theme-terminal .term-clean .sb-button:active::before {
  color: var(--ctp-base);
}

/* 14) Focus visible */
.theme-terminal .term-clean .sb-button:focus-visible {
  outline: 2px solid var(--ctp-blue);
  outline-offset: -2px;
  background: rgba(137, 180, 250, 0.15);
}

/* 15) Footer - hidden in Terminal theme */
.theme-terminal .term-clean .sb-footer {
  display: none;
}

/* ============================================
   Mobile adjustments
   ============================================ */

@media (max-width: 428px) {
  .theme-terminal .sb-card-shell {
    max-width: 100%;
  }
  
  .theme-terminal .term-bar {
    height: 32px;
    padding: 0 12px;
  }
  
  .theme-terminal .term-light {
    width: 10px;
    height: 10px;
  }
  
  .theme-terminal .term-lights {
    gap: 6px;
  }
  
  .theme-terminal .term-title {
    font-size: 11px;
    max-width: 45%;
  }
  
  .theme-terminal .term-buffer {
    padding: 14px 16px 14px 16px;
  }
  
  .theme-terminal .term-prompt-line {
    font-size: 12px;
  }
  
  .theme-terminal .term-output {
    padding-left: 12px;
  }
  
  .theme-terminal .sb-avatar {
    width: 48px;
    height: 48px;
  }
  
  .theme-terminal .sb-name {
    font-size: 15px;
  }
  
  .theme-terminal .sb-handle {
    font-size: 11px;
  }
  
  .theme-terminal .sb-bio {
    font-size: 11px;
  }
  
  .theme-terminal .fzf-status {
    font-size: 10px;
  }
  
  .theme-terminal .fzf-list {
    padding: 2px;
  }

  .theme-terminal .fzf-list .sb-button {
    padding: 8px 10px 8px 8px;
    font-size: 12px;
  }

  .theme-terminal .fzf-list .sb-button::before {
    width: 16px;
    font-size: 12px;
  }
  
  .theme-terminal .sb-footer {
    display: none;
  }

  /* Clean mode responsive */
  .theme-terminal .term-clean {
    padding: 8px 4px 10px;
  }

  .theme-terminal .term-clean .sb-avatar {
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
  }

  .theme-terminal .term-clean .sb-name {
    font-size: 20px;
  }

  .theme-terminal .term-clean .sb-handle {
    font-size: 12px;
    margin: -1px 0 6px;
  }

  .theme-terminal .term-clean .sb-bio {
    padding-left: 12px;
    font-size: 13px;
    margin: 12px 0 16px;
  }

  .theme-terminal .term-clean .sb-button {
    padding: 0 12px 0 30px;
    min-height: 42px;
    font-size: 13px;
  }

  .theme-terminal .term-clean .sb-button::before {
    left: 10px;
    font-size: 13px;
  }

  .theme-terminal .term-clean .sb-footer {
    display: none;
  }
}