/* ============================================================
   OPENDRIP — PERSONAL HYDRATION INTELLIGENCE TERMINAL
   Department of Hydration | Classification: SOGGY/CONFIDENTIAL

   Visual Language: Cold War-era CRT government monitoring terminal
   Color System: Phosphor green on black with amber warnings
   ============================================================ */

/* --- FONTS --- */
@import url('https://fonts.googleapis.com/css2?family=VT323&family=Share+Tech+Mono&display=swap');

/* --- CSS CUSTOM PROPERTIES --- */
:root {
  --phosphor: #00ff41;
  --phosphor-dim: #00cc33;
  --phosphor-bright: #33ff66;
  --phosphor-glow: rgba(0, 255, 65, 0.4);
  --amber: #ffbf00;
  --amber-dim: #cc9900;
  --amber-glow: rgba(255, 191, 0, 0.3);
  --red-alert: #ff3333;
  --red-glow: rgba(255, 51, 51, 0.3);
  --bg-dark: #0a0a0a;
  --bg-panel: #0d1a0d;
  --bg-panel-alt: #0a150a;
  --border-green: #004d1a;
  --border-bright: #006622;
  --text-dim: #338033;
  --scanline-opacity: 0.03;
  --flicker-intensity: 0.015;
  --font-terminal: 'VT323', 'Courier New', monospace;
  --font-mono: 'Share Tech Mono', 'Courier New', monospace;
}

/* --- RESET & BASE --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--phosphor);
  font-family: var(--font-terminal);
  font-size: 18px;
  line-height: 1.5;
  cursor: default;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
}

::selection {
  background: var(--phosphor);
  color: #000;
}

/* --- CRT SCREEN CONTAINER --- */
#crt-screen {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* Scanline overlay */
#crt-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, var(--scanline-opacity)) 2px,
    rgba(0, 0, 0, var(--scanline-opacity)) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* Vignette / screen curvature */
#crt-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      ellipse at center,
      transparent 55%,
      rgba(0, 0, 0, 0.25) 82%,
      rgba(0, 0, 0, 0.55) 100%
    ),
    /* grain */
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.05   0 0 0 0 0.25   0 0 0 0 0.1   0 0 0 0.35 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: auto, 140px 140px;
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: 9998;
  opacity: 0.85;
}

/* Screen flicker animation */
@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.985; }
}

#crt-screen {
  animation: flicker 4s ease-in-out infinite;
}

/* --- BOOT SEQUENCE --- */
#boot-screen {
  position: absolute;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-dark);
  transition: opacity 0.8s ease;
}

#boot-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

#boot-screen.hidden {
  display: none;
}

/* CRT warm-up dot */
#boot-warmup {
  width: 4px;
  height: 4px;
  background: var(--phosphor);
  border-radius: 50%;
  box-shadow: 0 0 20px var(--phosphor-glow), 0 0 60px var(--phosphor-glow);
  animation: warmup 1.5s ease-out forwards;
}

@keyframes warmup {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  70% {
    transform: scale(80, 2);
    opacity: 1;
  }
  100% {
    transform: scale(200, 200);
    opacity: 0;
  }
}

#boot-terminal {
  position: absolute;
  inset: 0;
  padding: 40px;
  font-size: 15px;
  font-family: var(--font-mono);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.3s ease;
  display: flex;
  flex-direction: column;
}

#boot-terminal.visible {
  opacity: 1;
}

#boot-output {
  white-space: pre-wrap;
  word-break: break-all;
  flex: 1;
  overflow-y: auto;
}

#boot-output .line-amber {
  color: var(--amber);
  text-shadow: 0 0 8px var(--amber-glow);
}

#boot-output .line-bright {
  color: var(--phosphor-bright);
  text-shadow: 0 0 10px var(--phosphor-glow);
}

#boot-output .line-dim {
  color: var(--text-dim);
}

#boot-output .line-red {
  color: var(--red-alert);
  text-shadow: 0 0 8px var(--red-glow);
}

#boot-output .stamp {
  color: var(--red-alert);
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 4px;
  text-shadow: 0 0 10px var(--red-glow);
  border: 2px solid var(--red-alert);
  display: inline-block;
  padding: 2px 12px;
  margin: 4px 0;
  transform: rotate(-2deg);
}

/* --- MAIN TERMINAL LAYOUT --- */
#terminal-main {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 300px;
  grid-template-rows: 72px minmax(min-content, auto) minmax(min-content, auto) 1fr 32px;
  gap: 1px;
  background: var(--border-green);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

#terminal-main.visible {
  opacity: 1;
  pointer-events: auto;
}

/* --- HEADER BAR --- */
#header-bar {
  grid-column: 1 / -1;
  grid-row: 1;
  background: var(--bg-panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-bright);
  position: relative;
}

#header-bar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--phosphor-dim), transparent);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-seal {
  width: 32px;
  height: 32px;
  border: 1px solid var(--phosphor-dim);
  border-radius: 2px;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--phosphor);
  position: relative;
}

.header-seal::before {
  content: '';
  position: absolute;
  inset: -3px;
  border: 1px solid var(--border-bright);
  border-radius: 3px;
}

.header-title {
  font-size: 26px;
  letter-spacing: 4px;
  text-transform: uppercase;
  text-shadow: 0 0 10px var(--phosphor-glow);
  line-height: 1;
  color: var(--phosphor-bright);
}

.header-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--text-dim);
  padding: 2px 6px;
  border: 1px solid rgba(0,255,65,0.25);
  border-left: none;
  border-right: none;
  text-transform: uppercase;
}

.hdr-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--phosphor-dim);
  padding: 3px 8px;
  border: 1px solid rgba(0,255,65,0.25);
  text-transform: uppercase;
}
.hdr-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--phosphor-bright);
  box-shadow: 0 0 5px var(--phosphor-glow);
  animation: codec-blink 1.6s ease-in-out infinite;
}

.hdr-sep {
  color: var(--border-bright);
  font-family: var(--font-mono);
}

.mode-readout {
  font-family: var(--font-mono);
  letter-spacing: 2px;
  padding: 1px 8px;
  border: 1px solid currentColor;
  font-size: 12px;
}
.mode-readout.mode-soggy         { color: var(--phosphor); text-shadow: 0 0 6px var(--phosphor-glow); }
.mode-readout.mode-manic         { color: var(--red-alert); text-shadow: 0 0 6px var(--red-glow); animation: mode-pulse 1.4s ease-in-out infinite; }
.mode-readout.mode-quarter-baked { color: var(--amber); text-shadow: 0 0 6px var(--amber-glow); }

@keyframes mode-pulse {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 1; }
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.system-clock {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--phosphor-dim);
  letter-spacing: 1px;
}

.settings-btn {
  background: none;
  border: 1px solid var(--border-bright);
  color: var(--phosphor-dim);
  font-family: var(--font-terminal);
  font-size: 16px;
  padding: 2px 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.settings-btn:hover {
  color: var(--phosphor);
  border-color: var(--phosphor);
  text-shadow: 0 0 8px var(--phosphor-glow);
}

/* --- LEFT SIDEBAR: MURRAY + INFO --- */
#panel-operator {
  grid-column: 2;
  grid-row: 2;
}

#panel-left {
  grid-column: 2;
  grid-row: 3;
}

/* Right column filler */
#terminal-main::after {
  content: '';
  grid-column: 2;
  grid-row: 4;
  background: var(--bg-dark);
}

/* Mode switcher — bottom of right column's 1fr filler row */
#panel-modes {
  grid-column: 2;
  grid-row: 4;
  align-self: end;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-bright);
  display: flex;
  align-items: stretch;
  padding: 0;
}

#panel-modes .pipeline-list-compact {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0;
  margin: 0;
  padding: 0;
  border: none;
  width: 100%;
}

#panel-modes .pipeline-item {
  padding: 0;
  border-radius: 0;
  border-right: 1px solid var(--border-green);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 2px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  background: transparent;
  transition: background 0.15s, color 0.15s;
}

#panel-modes .pipeline-item:last-child {
  border-right: none;
}

#panel-modes .pipeline-item:hover {
  background: rgba(0,255,65,0.08);
  color: var(--phosphor-bright);
}

#panel-modes .pipeline-item.active {
  background: rgba(0,255,65,0.12);
  color: var(--phosphor-bright);
  text-shadow: 0 0 6px var(--phosphor-glow);
}

/* Codec-screen panel — shared */
.codec-panel {
  background:
    linear-gradient(180deg, rgba(0,30,10,0.95), rgba(0,10,5,0.95));
  padding: 10px 12px 12px;
  border: 1px solid var(--phosphor);
  box-shadow:
    0 0 18px -4px var(--phosphor-glow),
    inset 0 0 0 1px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  font-family: var(--font-mono);
  overflow: hidden;
}
.codec-panel::before {
  /* scanline sheen */
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent 0 2px,
    rgba(0, 255, 65, 0.04) 2px 3px
  );
  mix-blend-mode: screen;
}
.codec-panel::after {
  /* corner bracket decoration */
  content: '';
  position: absolute;
  inset: 3px;
  pointer-events: none;
  border: 1px dashed rgba(0, 255, 65, 0.18);
}

.codec-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--phosphor-bright);
  text-transform: uppercase;
  text-shadow: 0 0 6px var(--phosphor-glow);
  border-bottom: 1px dashed rgba(0,255,65,0.25);
  padding-bottom: 4px;
  position: relative;
  z-index: 1;
}
.codec-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--phosphor-bright);
  box-shadow: 0 0 6px var(--phosphor-glow), 0 0 2px #fff;
  animation: codec-blink 1.4s ease-in-out infinite;
}
@keyframes codec-blink {
  0%, 60%, 100% { opacity: 1; }
  70%, 80% { opacity: 0.15; }
}
.codec-label { flex: 0 0 auto; }
.codec-spacer { flex: 1; border-bottom: 1px dotted rgba(0,255,65,0.25); margin: 0 4px; height: 1px; align-self: center; }
.codec-freq {
  font-size: 10px;
  color: var(--amber);
  letter-spacing: 1px;
  text-shadow: 0 0 4px var(--amber-glow);
}

.operator-ascii {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.05;
  color: var(--phosphor-bright);
  white-space: pre;
  text-align: center;
  text-shadow: 0 0 5px var(--phosphor-glow);
  padding: 4px 0;
  position: relative;
  z-index: 1;
}

.codec-callsign {
  text-align: center;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-dim);
  border-top: 1px dashed rgba(0,255,65,0.2);
  padding-top: 5px;
  position: relative;
  z-index: 1;
}

.codec-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--phosphor-dim);
  border-top: 1px dashed rgba(0,255,65,0.2);
  padding-top: 5px;
  position: relative;
  z-index: 1;
}
.codec-sep { opacity: 0.35; }
.codec-status { color: var(--phosphor-bright); text-shadow: 0 0 4px var(--phosphor-glow); }

/* Signal bars */
.signal-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}
.signal-bars i {
  display: inline-block;
  width: 3px;
  background: var(--phosphor);
  box-shadow: 0 0 4px var(--phosphor-glow);
  animation: signal-pulse 1.6s ease-in-out infinite;
}
.signal-bars i:nth-child(1) { height: 3px;  animation-delay: 0.0s; }
.signal-bars i:nth-child(2) { height: 5px;  animation-delay: 0.1s; }
.signal-bars i:nth-child(3) { height: 7px;  animation-delay: 0.2s; }
.signal-bars i:nth-child(4) { height: 9px;  animation-delay: 0.3s; }
.signal-bars i:nth-child(5) { height: 11px; animation-delay: 0.4s; }
@keyframes signal-pulse {
  0%, 100% { opacity: 0.35; transform: scaleY(0.8); }
  50%      { opacity: 1;    transform: scaleY(1); }
}

/* When pipeline switcher is inside codec panel, keep visual cohesion */

.panel-title {
  font-size: 14px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--phosphor-dim);
  padding: 6px 0 6px 2px;
  text-shadow: 0 0 6px var(--phosphor-glow);
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.panel-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-bright), transparent);
  margin-left: 4px;
}
.panel-title .title-idx {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--amber-dim);
  opacity: 0.8;
}

.status-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.status-label {
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.status-value {
  color: var(--phosphor);
  font-family: var(--font-mono);
  font-size: 14px;
}

/* Murray mascot */
.murray-container {
  text-align: center;
  padding: 4px 2px;
  position: relative;
  z-index: 1;
}

.murray-ascii {
  font-size: 11px;
  line-height: 1.2;
  color: var(--phosphor-dim);
  white-space: pre;
  animation: murray-bob 3s ease-in-out infinite;
}

@keyframes murray-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.murray-status {
  font-size: 11px;
  color: var(--amber);
  margin-top: 4px;
  font-style: italic;
}

/* Mobile Murray comms bar — hidden on desktop. Button reset applied so
   it inherits the terminal typography rather than native button chrome. */
#murray-mobile-bar {
  display: none;
  font-family: inherit;
  color: inherit;
  background: transparent;
  border: none;
  margin: 0;
  width: 100%;
  text-align: left;
}

/* --- CENTER PANEL: THE SPILLWAY --- */
#panel-center {
  grid-column: 1;
  grid-row: 2 / 5; /* spans rows 2-4; footer at row 5 */
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.spillway-header {
  padding: 8px 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-green);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.spillway-title {
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--phosphor-dim);
  text-transform: uppercase;
}

.spillway-status {
  font-size: 11px;
  color: var(--text-dim);
}

#chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 22px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
  align-items: stretch;
}

#chat-container > .chat-message {
  max-width: 820px;
  width: 100%;
}

/* Scrollbar styling */
#chat-container::-webkit-scrollbar {
  width: 6px;
}
#chat-container::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
#chat-container::-webkit-scrollbar-thumb {
  background: var(--border-bright);
  border-radius: 3px;
}

.chat-message {
  font-size: 17px;
  line-height: 1.65;
  padding: 10px 14px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  border-left: 2px solid transparent;
}

.chat-message.user {
  border-left-color: var(--amber);
  background: rgba(255, 176, 0, 0.04);
}

.chat-message.agent {
  border-left-color: var(--phosphor);
  background: rgba(0, 255, 65, 0.04);
}

.msg-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  margin-bottom: 4px;
  opacity: 0.75;
}
.msg-stamp {
  color: var(--phosphor-bright);
  text-shadow: 0 0 4px var(--phosphor-glow);
}
.msg-class {
  color: var(--text-dim);
  padding: 1px 5px;
  border: 1px solid rgba(0,255,65,0.25);
  text-transform: uppercase;
}
.chat-message.user .msg-class {
  color: var(--amber-dim);
  border-color: rgba(255,176,0,0.3);
}

.chat-message .msg-prefix {
  color: var(--amber);
  font-weight: bold;
  margin-right: 6px;
  letter-spacing: 1px;
}

.chat-message.agent .msg-prefix {
  color: var(--phosphor-bright);
  text-shadow: 0 0 6px var(--phosphor-glow);
}

.chat-message.system {
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
  border-left: 2px solid var(--border-green);
  padding: 4px 12px;
  background: transparent;
}

.chat-message .msg-text {
  color: var(--phosphor);
  white-space: pre-wrap;
}

.chat-message.agent .msg-text {
  color: var(--phosphor-bright);
}

/* Typing indicator */
.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--phosphor-dim);
  border-radius: 50%;
  animation: typing-dot 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-dot {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

/* Input area */
#input-area {
  padding: 12px 16px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-green);
  display: flex;
  align-items: center;
  gap: 8px;
}

#input-area .prompt-symbol {
  color: var(--amber);
  font-size: 16px;
  font-weight: bold;
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--phosphor);
  font-family: var(--font-terminal);
  font-size: 16px;
  caret-color: var(--phosphor);
}

#chat-input::placeholder {
  color: var(--text-dim);
}

#chat-input:focus {
  text-shadow: 0 0 4px var(--phosphor-glow);
}

/* Blinking cursor for input */
.cursor-blink {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--phosphor);
  animation: cursor-blink-anim 1s step-end infinite;
  flex-shrink: 0;
}

@keyframes cursor-blink-anim {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Command menu button */
#cmd-menu-btn {
  background: none;
  border: 1px solid var(--border-bright);
  color: var(--amber);
  font-family: var(--font-terminal);
  font-size: 18px;
  font-weight: bold;
  width: 32px;
  height: 32px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}

#cmd-menu-btn:hover {
  color: var(--phosphor);
  border-color: var(--phosphor);
  text-shadow: 0 0 8px var(--phosphor-glow);
}

/* Command popup */
#cmd-popup {
  position: absolute;
  bottom: 56px;
  left: 16px;
  right: 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  padding: 8px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6);
}

.cmd-popup-title {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--text-dim);
  padding: 4px 8px 6px;
  border-bottom: 1px solid var(--border-green);
  margin-bottom: 4px;
}

.cmd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--amber);
  font-family: var(--font-terminal);
  font-size: 15px;
  padding: 6px 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.cmd-item:hover {
  background: rgba(0, 255, 65, 0.08);
}

.cmd-item .cmd-desc {
  color: var(--text-dim);
  font-size: 13px;
  margin-left: auto;
}

/* --- PIPELINES / MODE SELECTOR (tactical switch panel) --- */
.pipeline-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pipeline-item {
  --accent: var(--phosphor);
  --accent-dim: var(--phosphor-dim);
  --accent-glow: var(--phosphor-glow);
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  column-gap: 10px;
  padding: 8px 10px 8px 8px;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.35), transparent 60%),
    var(--bg-panel-alt);
  border: 1px solid var(--border-green);
  border-left: 3px solid var(--border-green);
  cursor: pointer;
  position: relative;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.pipeline-item::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent 0 3px,
    rgba(255,255,255,0.015) 3px 4px
  );
}

.pipeline-item:hover {
  border-color: var(--accent-dim);
  border-left-color: var(--accent);
  background:
    linear-gradient(90deg, rgba(0,0,0,0.25), transparent 60%),
    var(--bg-panel);
  transform: translateX(1px);
}

.pipeline-item.active {
  border-color: var(--accent);
  border-left-color: var(--accent);
  background:
    linear-gradient(90deg, rgba(0,0,0,0.1), transparent 60%),
    var(--bg-panel);
  box-shadow: inset 2px 0 0 var(--accent), 0 0 18px -6px var(--accent-glow);
}

.pipeline-item.accent-phosphor {
  --accent: var(--phosphor);
  --accent-dim: var(--phosphor-dim);
  --accent-glow: var(--phosphor-glow);
}
.pipeline-item.accent-red {
  --accent: var(--red-alert);
  --accent-dim: #b82828;
  --accent-glow: var(--red-glow);
}
.pipeline-item.accent-amber {
  --accent: var(--amber);
  --accent-dim: var(--amber-dim);
  --accent-glow: var(--amber-glow);
}

/* physical toggle switch */
.mode-switch {
  position: relative;
  width: 32px;
  height: 16px;
  flex-shrink: 0;
}
.sw-track {
  position: absolute;
  inset: 3px 0;
  background: #000;
  border: 1px solid var(--border-bright);
  box-shadow: inset 0 0 4px rgba(0,0,0,0.8);
}
.sw-knob {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  background: linear-gradient(180deg, var(--text-dim), #1a2a1a);
  border: 1px solid var(--border-bright);
  transition: left 0.18s cubic-bezier(.6,0,.4,1.3), background 0.2s, box-shadow 0.2s;
}
.pipeline-item.active .sw-knob {
  left: 17px;
  background: linear-gradient(180deg, var(--accent), var(--accent-dim));
  box-shadow: 0 0 10px var(--accent-glow), inset 0 -2px 0 rgba(0,0,0,0.3);
}

.mode-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}
.mode-label {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--phosphor-dim);
  transition: color 0.2s, text-shadow 0.2s;
}
.pipeline-item.active .mode-label {
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent-glow);
}
.mode-tagline {
  font-family: var(--font-terminal);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-dim);
  margin-top: 2px;
}
.pipeline-item.active .mode-tagline {
  color: var(--accent);
  opacity: 0.85;
}

.mode-sigil {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
  opacity: 0.6;
}
.pipeline-item.active .mode-sigil {
  color: var(--accent-dim);
  opacity: 0.9;
}

/* manic mode: tick the active item */
.pipeline-item.accent-red.active {
  animation: manic-jitter 4s ease-in-out infinite;
}
@keyframes manic-jitter {
  0%, 92%, 100% { transform: translateX(0); }
  93%           { transform: translateX(-1px); }
  94%           { transform: translateX(1px); }
  95%           { transform: translateX(-1px); }
  96%           { transform: translateX(0); }
}

/* Compact horizontal variant — sits at bottom of Murray's box */
.pipeline-list-compact {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-green);
}
.pipeline-list-compact .pipeline-item {
  grid-template-columns: 1fr;
  padding: 5px 4px;
  column-gap: 0;
  text-align: center;
  justify-items: center;
}
.pipeline-list-compact .mode-switch,
.pipeline-list-compact .mode-sigil,
.pipeline-list-compact .mode-tagline {
  display: none;
}
.pipeline-list-compact .mode-text {
  align-items: center;
}
.pipeline-list-compact .mode-label {
  font-size: 11px;
  letter-spacing: 1px;
}

/* Reservoir stats */
.reservoir-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reservoir-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Protocol reference log */
.protocol-log {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
}

.protocol-entry {
  color: var(--text-dim);
  padding: 2px 4px;
  border-bottom: 1px solid rgba(0, 77, 26, 0.3);
}

.protocol-entry .proto-id {
  color: var(--amber-dim);
  font-family: var(--font-mono);
}

/* --- FOOTER STATUS BAR --- */
#footer-bar {
  grid-column: 1 / -1;
  grid-row: 5;
  background: var(--bg-panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 12px;
  border-top: 1px solid var(--border-bright);
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-dim);
}

.footer-center {
  color: var(--text-dim);
  letter-spacing: 1px;
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stay-moist {
  color: var(--phosphor);
  letter-spacing: 3px;
  text-transform: uppercase;
  font-size: 13px;
  text-shadow: 0 0 8px var(--phosphor-glow);
  animation: moist-pulse 4s ease-in-out infinite;
}

@keyframes moist-pulse {
  0%, 100% { text-shadow: 0 0 8px var(--phosphor-glow); }
  50% { text-shadow: 0 0 16px var(--phosphor-glow), 0 0 32px rgba(0, 255, 65, 0.2); }
}

.footer-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--phosphor);
  box-shadow: 0 0 6px var(--phosphor-glow);
  animation: heartbeat 2s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); opacity: 1; }
  25% { transform: scale(1.3); opacity: 1; }
  35% { transform: scale(1); opacity: 0.8; }
  45% { transform: scale(1.2); opacity: 1; }
  55% { transform: scale(1); }
}

/* --- SETTINGS MODAL --- */
#settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
}

#settings-overlay.visible {
  display: flex;
}

#settings-panel {
  background: var(--bg-panel);
  border: 2px solid var(--border-bright);
  padding: 24px;
  width: 480px;
  max-width: 90vw;
  box-shadow: 0 0 40px rgba(0, 255, 65, 0.1);
}

.settings-title {
  font-size: 16px;
  letter-spacing: 3px;
  color: var(--phosphor);
  text-transform: uppercase;
  margin-bottom: 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-green);
  text-shadow: 0 0 8px var(--phosphor-glow);
}

.settings-group {
  margin-bottom: 16px;
}

.settings-label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.settings-input {
  width: 100%;
  background: var(--bg-dark);
  border: 1px solid var(--border-green);
  color: var(--phosphor);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.2s;
}

.settings-input:focus {
  border-color: var(--phosphor-dim);
  box-shadow: 0 0 8px rgba(0, 255, 65, 0.1);
}

.settings-input::placeholder {
  color: var(--text-dim);
}

.settings-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

.settings-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  justify-content: flex-end;
}

.btn-terminal {
  background: transparent;
  border: 1px solid var(--border-bright);
  color: var(--phosphor-dim);
  font-family: var(--font-terminal);
  font-size: 14px;
  padding: 6px 16px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.2s;
}

.btn-terminal:hover {
  border-color: var(--phosphor);
  color: var(--phosphor);
  text-shadow: 0 0 6px var(--phosphor-glow);
  background: rgba(0, 255, 65, 0.05);
}

.btn-terminal.primary {
  border-color: var(--phosphor-dim);
  color: var(--phosphor);
}

/* --- DRIP ANIMATION (ambient background) --- */
.drip-particle {
  position: fixed;
  width: 2px;
  height: 8px;
  background: var(--phosphor-dim);
  opacity: 0.15;
  pointer-events: none;
  z-index: 1;
  animation: drip-fall linear forwards;
  border-radius: 0 0 2px 2px;
}

@keyframes drip-fall {
  0% { transform: translateY(-10px); opacity: 0.15; }
  90% { opacity: 0.15; }
  100% { transform: translateY(100vh); opacity: 0; }
}

/* --- RESPONSIVE ---
   Floating codec panels don't fit a phone. Below 820px the layout
   collapses into a "handheld field codec": header / mode-strip /
   spillway / input / slim footer. Operator + Murray ASCII are 21ch
   wide and are dropped; modes stay accessible via the compact strip.
*/
@media (max-width: 820px) {
  /* Reclaim the layout: 4-row stack, no floating panels */
  #terminal-main,
  #terminal-main.visible {
    grid-template-columns: 1fr;
    grid-template-rows: 56px auto 1fr 28px;
  }

  #header-bar   { grid-row: 1; padding: 0 10px; }
  #panel-left   { display: none; }
  #panel-modes  {
    grid-column: 1;
    grid-row: 2;
    flex-direction: column;
    border-top: none;
    border-bottom: 1px solid var(--border-bright);
  }
  #panel-modes .pipeline-list-compact {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 0;
    width: 100%;
  }
  #panel-modes .pipeline-item {
    padding: 10px 4px;
    min-height: 44px;
    font-size: 12px;
    letter-spacing: 2px;
  }

  /* Mini Murray comms bar */
  #murray-mobile-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    min-height: 44px;
    border-top: 1px solid var(--border-bright);
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  #murray-mobile-bar:active {
    background: rgba(0, 255, 65, 0.18);
  }
  .murray-mobile-face {
    font-size: 13px;
    color: var(--phosphor-dim);
    flex-shrink: 0;
  }
  .murray-mobile-label {
    font-size: 10px;
    letter-spacing: 1.5px;
    color: var(--phosphor-dim);
    flex: 1;
  }
  .murray-mobile-status {
    font-size: 9px;
    letter-spacing: 1px;
    color: var(--text-dim);
    flex-shrink: 0;
  }
  #panel-center { grid-row: 3; }
  #footer-bar   { grid-row: 5; padding: 0 10px; font-size: 11px; }

  /* Operator codec drops — too wide for narrow screens */
  #panel-operator { display: none; }

  /* Header compaction */
  .header-left     { gap: 8px; min-width: 0; flex: 1 1 auto; }
  .header-seal     { width: 26px; height: 26px; flex: 0 0 auto; }
  .header-title    { font-size: 18px; letter-spacing: 2px; }
  .header-tag      { display: none; }
  .header-center   { gap: 6px; flex: 0 0 auto; }
  .header-right    { gap: 8px; flex: 0 0 auto; }
  .system-clock    { display: none; }
  /* Keep the live agent-status pill; drop channel readout to save space */
  .header-center .hdr-pill:first-child { display: none; }

  /* Footer compaction */
  .footer-center { display: none; }
  .footer-left { gap: 8px; }

  /* Spillway tightens up */
  #chat-container { padding: 10px 10px 8px; font-size: 15px; }
  .spillway-header { padding: 6px 10px; font-size: 11px; }
  #input-area { padding: 6px 8px; gap: 6px; }
  #input-area .prompt-symbol { font-size: 16px; }
  #chat-input { font-size: 15px; }
}

/* Very narrow phones — tighten further */
@media (max-width: 420px) {
  .header-title    { font-size: 16px; letter-spacing: 1.5px; }
  .header-center   { display: none; }
  #panel-modes .pipeline-item { font-size: 11px; letter-spacing: 1px; }
  .stay-moist { font-size: 11px; letter-spacing: 2px; }
  #footer-uptime { font-size: 10px; }
}

/* --- UTILITY CLASSES --- */
.text-phosphor { color: var(--phosphor); }
.text-amber { color: var(--amber); }
.text-dim { color: var(--text-dim); }
.text-red { color: var(--red-alert); }
.glow { text-shadow: 0 0 8px var(--phosphor-glow); }
.hidden { display: none !important; }
