/* ============================================================================
   FORGE PROTOCOL - ASCERTAIN UI Design System v1.0
   "Trust is forged, not assumed."
   ============================================================================ */

:root {
  /* ===== FORGE DESIGN SYSTEM v2.0 ===== */

  /* Surfaces - High contrast obsidian tones */
  --bg-obsidian: #0A0A0B;      /* Main background */
  --bg-ingot: #161618;         /* Response Slab */
  --bg-vault: #1C1C1E;         /* Sidebar / Nav */

  /* Legacy aliases for compatibility */
  --obsidian: #0A0A0B;
  --obsidian-dark: #0A0A0B;
  --forge-grey: #1C1C1E;
  --forge-grey-dark: #161618;
  --forge-grey-light: #2A2A2C;

  /* Brand & Status - Stoplight convention per FORGE_STYLE_GUIDE v2.1 */
  --text-gold: #FFB347;        /* Headers / Titles */
  --text-white: #F2F2F2;       /* Body Text */
  --accent-ember: #FF4D00;     /* High Impact / Failure */
  --accent-glow: #2EA043;      /* Pass / Verification (stoplight green) */
  --accent-molten: #F0B000;    /* Warning / Hedging (stoplight amber) */

  /* Legacy aliases - updated to stoplight convention */
  --ember-orange: #FF4D00;
  --trust-green: #2EA043;      /* stoplight green */
  --caution-amber: #F0B000;    /* stoplight amber */
  --fail-red: #FF2D00;         /* stoplight red */
  /* --ice-cyan removed: no cyan/blue in Forge palette */

  /* Text Colors */
  --text-primary: #F2F2F2;
  --text-secondary: #A0A0A0;
  --ghost: rgba(255, 255, 255, 0.3);

  /* Glows - updated to stoplight colors */
  --glow-pass: 0 0 12px rgba(46, 160, 67, 0.5);
  --glow-fail: 0 0 12px rgba(255, 45, 0, 0.5);
  --glow-warn: 0 0 12px rgba(240, 176, 0, 0.5);
  --glow-green: 0 0 12px rgba(46, 160, 67, 0.5);
  --glow-amber: 0 0 12px rgba(240, 176, 0, 0.5);
  --glow-red: 0 0 12px rgba(255, 45, 0, 0.5);
  --glow-orange: 0 0 16px rgba(255, 77, 0, 0.6);

  /* Heat Gradients (for progress bars) - updated to stoplight */
  --heat-low: linear-gradient(90deg, #2EA043, #1C1C1E);
  --heat-medium: linear-gradient(90deg, #F0B000, #FF4D00);
  --heat-high: linear-gradient(90deg, #FF4D00, #FF2D00);
  --confidence-gradient: linear-gradient(90deg, #F0B000, #2EA043);

  /* Layout Dimensions */
  --hud-height: 64px;
  --vault-collapsed: 56px;
  --vault-expanded: 280px;
  --seal-width: 380px;
}

/* ============================================================================
   ZONE 1: THE HUD (Top Context Bar) - Mission-Focused
   ============================================================================ */

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--hud-height);
  background: var(--bg-obsidian);
  border-bottom: 1px solid var(--bg-vault);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 1000;
  gap: 16px;
}

.hud-divider {
  width: 1px;
  height: 32px;
  background: var(--forge-grey-dark);
  margin: 0 12px;
}

/* HUD Logo */
.hud-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 140px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.hud-logo:hover {
  background: var(--bg-vault);
}

.hud-logo-icon {
  color: #FFFFFF;
  font-size: 18px;
}

.hud-logo-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: contain;
}

.hud-logo-text {
  font-family: 'Inter Tight', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: #FFFFFF;
  letter-spacing: 0.12em;
}

/* HUD Project Selector - Gold emphasis */
.hud-project {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-secondary);
  background: var(--bg-vault);
}

.hud-project:hover {
  background: var(--forge-grey-light);
  color: var(--text-gold);
}

.hud-project.active {
  color: var(--text-gold);
  background: var(--bg-vault);
  border: 1px solid var(--text-gold);
}

.hud-project-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-right: 4px;
}

.hud-project-icon {
  font-size: 14px;
  color: var(--text-gold);
}

.hud-project-name {
  font-size: 14px;
  font-weight: 600;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-gold);
}

.hud-project-chevron {
  font-size: 10px;
  opacity: 0.6;
}

/* HUD Mission Progress - BRIGHTEST element per directive */
.hud-mission {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--bg-vault);
  border: 1px solid var(--text-gold);
  flex: 1;
  max-width: 400px;
}

.hud-mission:hover {
  background: var(--forge-grey-light);
  box-shadow: 0 0 12px rgba(255, 179, 71, 0.3);
}

.hud-mission-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-gold);
}

.hud-mission-icon {
  color: var(--text-gold);
  font-size: 16px;
}

.hud-mission-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-gold);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-mission-dots {
  display: flex;
  gap: 3px;
  align-items: center;
  margin-left: auto;
}

/* Segmented progress bar - glow green when complete */
.hud-mission-dot {
  width: 20px;
  height: 6px;
  border-radius: 2px;
  background: var(--forge-grey-light);
  transition: all 0.3s ease;
}

.hud-mission-dot.complete {
  background: var(--accent-glow);
  box-shadow: 0 0 8px rgba(0, 255, 157, 0.6);
}

.hud-mission-more {
  font-size: 11px;
  color: var(--text-gold);
  font-weight: 600;
}

/* HUD Anchor Count */
.hud-anchors {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
  color: var(--caution-amber);
}

.hud-anchors:hover {
  background: var(--forge-grey-dark);
}

.hud-anchors-icon {
  font-size: 14px;
}

.hud-anchors-count {
  font-size: 14px;
  font-weight: 600;
}

/* HUD Spacer */
.hud-spacer {
  flex: 1;
}

/* HUD Settings - forge-settings (anvil) per TASK-148 */
.hud-settings {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 150ms ease-out;
}

.hud-settings:hover {
  background: var(--forge-basalt, #1E1E1E);
}

.hud-settings svg {
  width: 20px;
  height: 20px;
}

/* Default state: forge-ash */
.hud-settings svg path,
.hud-settings svg circle,
.hud-settings svg line {
  stroke: var(--forge-ash, #8A8A92);
  transition: stroke 150ms ease-out;
}

/* Hover state: forge-molten */
.hud-settings:hover svg path,
.hud-settings:hover svg circle,
.hud-settings:hover svg line {
  stroke: var(--forge-molten, #FF7A00);
}

/* Empty States */
.hud-empty {
  color: var(--ghost);
  font-style: italic;
}

/* ============================================================================
   ZONE 4: THE VAULT DRAWER (Left Panel)
   ============================================================================ */

.vault-drawer {
  position: fixed;
  top: var(--hud-height);
  left: 0;
  bottom: 0;
  width: var(--vault-collapsed);
  background: var(--bg-vault);
  border-right: 1px solid #2A2A2C;
  border-left: none;
  display: flex;
  flex-direction: column;
  z-index: 900;
  transition: width 0.25s ease-out;
  overflow: hidden;
  box-shadow: none;
}

.vault-drawer.expanded {
  width: var(--vault-expanded);
}

/* Vault Icon Strip (Collapsed State) */
.vault-icons {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  gap: 8px;
  background: var(--obsidian-dark);
  border: none;
  width: 100%;
}

.vault-drawer.expanded .vault-icons {
  display: none;
}

.vault-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 2px solid var(--accent-ember);
  background: var(--bg-vault);
  outline: none;
  box-shadow: none;
}

/* Remove focus ring that could appear as blue strip */
.vault-icon-btn:focus {
  outline: none;
  box-shadow: none;
}

.vault-icon-btn:focus-visible {
  outline: 2px solid var(--forge-gold, #FFB800);
  outline-offset: 2px;
}

/* Tooltip for sidebar icons */
.vault-icon-btn {
  position: relative;
}

.vault-icon-btn::after {
  content: attr(title);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 8px;
  padding: 6px 10px;
  background: var(--forge-grey);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  pointer-events: none;
  z-index: 1000;
}

.vault-icon-btn:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Vault Expanded Content */
.vault-content {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.vault-drawer.expanded .vault-content {
  display: flex;
}

/* Vault Section */
.vault-section {
  padding: 16px;
  border-bottom: 1px solid var(--forge-grey-dark);
}

/* Sessions section: fill remaining space, scroll the list, pin button */
#vault-sessions-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#vault-sessions-section > .forge-empty-btn {
  flex-shrink: 0;
}

/* Quick Access: always visible at bottom, never shrink */
.vault-content > .vault-section:last-child {
  flex-shrink: 0;
}

.vault-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.vault-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

.vault-section-collapse {
  cursor: pointer;
  color: var(--ghost);
  font-size: 12px;
}

/* Session List in Vault */
.vault-sessions {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.vault-session-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.vault-session-item:hover {
  background: var(--forge-grey);
}

.vault-session-item.active {
  background: var(--forge-grey);
}

.vault-session-item.active::before {
  content: '●';
  color: var(--forge-gold, #FFB800);  /* Gold for active state, NOT green */
  font-size: 8px;
  margin-right: 4px;
}

.vault-session-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-primary);
}

.vault-session-meta {
  font-size: 11px;
  color: var(--text-secondary);
}

.vault-session-owner {
  font-size: 10px;
  color: var(--forge-ash, #8A8A92);
  background: var(--forge-obsidian, #141414);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
}

/* Vault Session Actions */
.vault-session-actions {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--forge-grey-dark);
  flex-wrap: wrap;
}

.vault-action-btn {
  background: var(--forge-grey);
  border: 1px solid var(--forge-grey-light);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.vault-action-btn:hover {
  background: var(--forge-grey-light);
  color: var(--text-primary);
}

.vault-action-btn.danger {
  color: var(--fail-red);
}

.vault-action-btn.danger:hover {
  background: rgba(255, 59, 59, 0.15);
  border-color: var(--fail-red);
}

.vault-action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Vault Session Item with Selection */
.vault-session-item {
  position: relative;
}

.vault-session-item.selected {
  background: rgba(255, 77, 0, 0.1);
  border-left: 2px solid var(--forge-ember, #FF4D00);
}

.vault-session-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--forge-ember, #FF4D00);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
}

.vault-session-info {
  flex: 1;
  min-width: 0;
}

/* Vault Context Menu Button */
.vault-session-menu-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  opacity: 0;
  transition: all 0.15s ease;
}

.vault-session-item:hover .vault-session-menu-btn {
  opacity: 1;
}

.vault-session-menu-btn:hover {
  background: var(--forge-grey-light);
  color: var(--text-primary);
}

/* Vault Context Menu - uses fixed positioning set by JS, appended to body */
.vault-session-context-menu {
  background: var(--obsidian-dark);
  border: 1px solid var(--forge-grey);
  border-radius: 6px;
  min-width: 120px;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.vault-menu-item {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.vault-menu-item:hover {
  background: var(--forge-grey);
  color: var(--text-primary);
}

.vault-menu-item.danger {
  color: var(--fail-red);
}

.vault-menu-item.danger:hover {
  background: rgba(255, 59, 59, 0.15);
}

.vault-menu-divider {
  height: 1px;
  background: var(--forge-grey-dark);
  margin: 4px 0;
}

/* Forge Empty State */
.forge-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border: 1px dashed var(--forge-grey);
  border-radius: 8px;
  text-align: center;
}

.forge-empty-icon {
  font-size: 32px;
  color: var(--ghost);
  margin-bottom: 12px;
}

.forge-empty-text {
  font-size: 13px;
  color: var(--ghost);
  margin-bottom: 16px;
}

.forge-empty-btn {
  padding: 8px 16px;
  border-radius: 6px;
  background: var(--forge-grey);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s ease;
}

.forge-empty-btn:hover {
  background: var(--forge-grey-light);
}

/* ============================================================================
   ZONE 2: THE ANVIL (Chat Stage)
   ============================================================================ */

.anvil {
  position: fixed;
  top: var(--hud-height);
  left: var(--vault-collapsed);
  right: 0;
  bottom: 0;
  background: var(--bg-obsidian);
  display: flex;
  flex-direction: column;
  transition: left 0.25s ease-out, right 0.25s ease-out;
  border: none;
  outline: none;
}

.vault-drawer.expanded ~ .anvil {
  left: var(--vault-expanded);
}

.anvil.seal-open {
  right: var(--seal-width);
}

/* Anvil Chat Container */
.anvil-chat {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.anvil-chat-inner {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

/* Message / Ingot Base - Rectangular slabs per directive */
.ingot {
  padding: 16px 20px;
  border-radius: 8px;
  /* position: relative removed - TASK-150 uses flex sibling layout */
}

/* User Message */
.ingot-user {
  align-self: flex-end;
  background: var(--forge-basalt, #1E1E1E);
  border: 1px solid var(--forge-ash, #8A8A92);
  border-radius: 8px;
  max-width: 75%;
  margin-left: auto;
  color: var(--text-white);
}

/* Assistant Message (The Ingot) - Rectangular slab */
.ingot-assistant {
  align-self: flex-start;
  background: var(--forge-obsidian, #141414);
  border-radius: 8px;
  border: 1px solid var(--forge-basalt, #1E1E1E);
  max-width: 90%;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  color: var(--text-white);
}

/* Ingot Processing State - Pulsing molten border (per ASCERTAIN-UI-DESIGN-SPEC) */
.ingot-assistant.processing {
  border-color: var(--forge-ember, #FF4D00);
  animation: molten-pulse 2s ease-in-out infinite;
}

@keyframes molten-pulse {
  0%, 100% {
    box-shadow: 0 2px 6px var(--forge-ember, #FF4D00),
                inset 0 0 4px rgba(255, 77, 0, 0.2);
    border-color: var(--forge-ember, #FF4D00);
  }
  50% {
    box-shadow: 0 2px 10px var(--forge-ember, #FF4D00),
                inset 0 0 8px rgba(255, 77, 0, 0.3);
    border-color: var(--forge-molten, #FF7A00);
  }
}

/* Ingot Pass State - Cools from ember to gold, maintains visible border */
.ingot-assistant.pass {
  border-color: var(--forge-gold, #FFB800);
  animation: cool-to-gold 1s ease-out forwards;
}

@keyframes cool-to-gold {
  0% {
    box-shadow: 0 2px 10px var(--forge-ember, #FF4D00);
    border-color: var(--forge-ember, #FF4D00);
  }
  50% {
    box-shadow: 0 2px 8px var(--forge-gold, #FFB800);
    border-color: var(--forge-gold, #FFB800);
  }
  100% {
    box-shadow: 0 1px 3px rgba(255, 184, 0, 0.2);
    border-color: var(--forge-gold, #FFB800);
  }
}

/* Ingot Flag State - Cools to amber with persistent pulse */
.ingot-assistant.flag {
  border-color: var(--status-flag, #F0B000);
  animation: cool-to-amber 1s ease-out forwards,
             amber-pulse 3s ease-in-out infinite 1s;
}

@keyframes cool-to-amber {
  0% {
    box-shadow: 0 2px 10px var(--forge-ember, #FF4D00);
    border-color: var(--forge-ember, #FF4D00);
  }
  100% {
    box-shadow: 0 2px 6px var(--status-flag, #F0B000);
    border-color: var(--status-flag, #F0B000);
  }
}

@keyframes amber-pulse {
  0%, 100% {
    box-shadow: 0 2px 6px rgba(240, 176, 0, 0.4);
  }
  50% {
    box-shadow: 0 2px 10px rgba(240, 176, 0, 0.6);
  }
}

/* Ingot Fail State - Shake then cracked border */
.ingot-assistant.fail {
  border-color: var(--status-block, #FF2D00);
  box-shadow: 0 2px 8px rgba(255, 45, 0, 0.5);
  background: linear-gradient(135deg, var(--bg-ingot) 0%, rgba(255, 45, 0, 0.08) 100%);
  animation: fail-shake 0.3s ease-out;
}

@keyframes fail-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

/* ============================================================================
   MESSAGE ROW LAYOUT (TASK-150)
   Badge is a sibling of the message bubble, NOT a child.
   ============================================================================ */

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.message-row.ai {
  justify-content: flex-start;
}

.message-row.user {
  justify-content: flex-end;
}

/* Message bubble (the ingot) - reserves space for badge column */
.message-row.ai .message-bubble {
  flex: 1;
  min-width: 0;
  max-width: calc(100% - 104px); /* 72px badge + 16px gap + 16px breathing room */
}

.message-row.user .message-bubble {
  max-width: 75%;
}

/* ============================================================================
   FORGEGATE VERIFICATION BADGE (TASK-150)
   Concentric ring design, positioned in right margin area
   ============================================================================ */

.forgegate-badge {
  flex-shrink: 0;
  width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.forgegate-badge:hover {
  transform: scale(1.05);
}

/* Badge SVG container */
.forgegate-badge .badge-ring {
  width: 64px;
  height: 64px;
  position: relative;
}

.forgegate-badge .badge-ring svg {
  width: 100%;
  height: 100%;
}

/* Badge label below */
.forgegate-badge .badge-label {
  font-family: 'Inter Tight', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Score text in center */
.forgegate-badge .badge-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  fill: #FFFFFF;
}

/* PASS state - green glow */
.forgegate-badge.verdict-pass .badge-ring {
  filter: drop-shadow(0 0 12px rgba(46, 160, 67, 0.6));
}

.forgegate-badge.verdict-pass .badge-label {
  color: var(--status-pass, #2EA043);
}

.forgegate-badge.verdict-pass .ring-outer {
  stroke: var(--status-pass, #2EA043);
}

.forgegate-badge.verdict-pass .hept-outer {
  stroke: var(--status-pass, #2EA043);
  opacity: 0.7;
}

.forgegate-badge.verdict-pass .hept-inner {
  stroke: var(--status-pass, #2EA043);
  opacity: 0.5;
}

.forgegate-badge.verdict-pass .mesh-line {
  stroke: var(--status-pass, #2EA043);
  stroke-width: 0.5;
  opacity: 0.4;
}

.forgegate-badge.verdict-pass .core-fill {
  fill: var(--forge-void, #0A0A0A);
  stroke: var(--status-pass, #2EA043);
}

/* FLAG state - amber glow */
.forgegate-badge.verdict-flag .badge-ring {
  filter: drop-shadow(0 0 12px rgba(240, 176, 0, 0.6));
}

.forgegate-badge.verdict-flag .badge-label {
  color: var(--status-flag, #F0B000);
}

.forgegate-badge.verdict-flag .ring-outer {
  stroke: var(--status-flag, #F0B000);
}

.forgegate-badge.verdict-flag .hept-outer {
  stroke: var(--status-flag, #F0B000);
  opacity: 0.7;
}

.forgegate-badge.verdict-flag .hept-inner {
  stroke: var(--status-flag, #F0B000);
  opacity: 0.5;
}

.forgegate-badge.verdict-flag .mesh-line {
  stroke: var(--status-flag, #F0B000);
  stroke-width: 0.5;
  opacity: 0.4;
}

.forgegate-badge.verdict-flag .core-fill {
  fill: var(--forge-void, #0A0A0A);
  stroke: var(--status-flag, #F0B000);
}

/* BLOCK/FAIL state - red glow */
.forgegate-badge.verdict-block .badge-ring,
.forgegate-badge.verdict-fail .badge-ring {
  filter: drop-shadow(0 0 12px rgba(255, 45, 0, 0.6));
}

.forgegate-badge.verdict-block .badge-label,
.forgegate-badge.verdict-fail .badge-label {
  color: var(--status-block, #FF2D00);
}

.forgegate-badge.verdict-block .ring-outer,
.forgegate-badge.verdict-fail .ring-outer {
  stroke: var(--status-block, #FF2D00);
}

.forgegate-badge.verdict-block .hept-outer,
.forgegate-badge.verdict-fail .hept-outer {
  stroke: var(--status-block, #FF2D00);
  opacity: 0.7;
}

.forgegate-badge.verdict-block .hept-inner,
.forgegate-badge.verdict-fail .hept-inner {
  stroke: var(--status-block, #FF2D00);
  opacity: 0.5;
}

.forgegate-badge.verdict-block .mesh-line,
.forgegate-badge.verdict-fail .mesh-line {
  stroke: var(--status-block, #FF2D00);
  stroke-width: 0.5;
  opacity: 0.4;
}

.forgegate-badge.verdict-block .core-fill,
.forgegate-badge.verdict-fail .core-fill {
  fill: var(--forge-void, #0A0A0A);
  stroke: var(--status-block, #FF2D00);
}

/* Badge placeholder (no verdict yet) */
.forgegate-badge-placeholder {
  flex-shrink: 0;
  width: 72px;
}

/* FORGEGATE Heptagon Component */
.gate-heptagon-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.gate-heptagon {
  width: 180px;
  height: 180px;
}

.gate-heptagon polygon {
  transition: all 0.3s ease;
}

/* Gate vertex colors - Stoplight convention */
.gate-heptagon .gate-vertex {
  fill: var(--status-pass, #2EA043);
  cursor: pointer;
  transition: all 0.2s ease;
}

.gate-heptagon .gate-vertex:hover {
  fill: #FFFFFF;
  filter: drop-shadow(0 0 6px var(--status-pass, #2EA043));
}

.gate-heptagon .gate-vertex.pass {
  fill: var(--status-pass, #2EA043);
  filter: drop-shadow(0 0 4px rgba(46, 160, 67, 0.5));
}

.gate-heptagon .gate-vertex.flag {
  fill: var(--status-flag, #F0B000);
  animation: vertex-pulse 2s ease-in-out infinite;
}

.gate-heptagon .gate-vertex.fail {
  fill: var(--status-block, #FF2D00);
}

@keyframes vertex-pulse {
  0%, 100% {
    filter: drop-shadow(0 0 4px rgba(240, 176, 0, 0.5));
    transform: scale(1);
  }
  50% {
    filter: drop-shadow(0 0 8px rgba(240, 176, 0, 0.8));
    transform: scale(1.1);
  }
}

/* Heptagon edge connection lines - style by gate status */
.gate-heptagon .hept-edge {
  stroke: var(--status-pass, #2EA043);
  stroke-width: 2;
  transition: all 0.3s ease;
}

/* Solid: Both connected gates PASS */
.gate-heptagon .hept-edge.solid {
  stroke: var(--status-pass, #2EA043);
  stroke-dasharray: none;
}

/* Dashed: One gate PASS, one FLAG */
.gate-heptagon .hept-edge.dashed {
  stroke: var(--status-flag, #F0B000);
  stroke-dasharray: 8, 4;
}

/* Broken/Dotted: One or both gates FAIL/BLOCK */
.gate-heptagon .hept-edge.broken {
  stroke: var(--status-block, #FF2D00);
  stroke-dasharray: 2, 4;
}

/* Mixed: One FLAG, one FAIL */
.gate-heptagon .hept-edge.mixed {
  stroke: var(--status-flag, #F0B000);
  stroke-dasharray: 6, 3, 2, 3;
}

.gate-heptagon .confidence-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px;
  font-weight: 600;
  fill: var(--text-white);
}

.gate-heptagon .confidence-label {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 500;
  fill: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Processing Text Animation */
.processing-text {
  color: var(--ember-orange);
  animation: text-pulse 1.5s ease-in-out infinite;
}

@keyframes text-pulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

/* Selected Ingot Highlight */
.ingot-assistant.selected {
  outline: 2px solid var(--forge-gold, #FFB800);
  outline-offset: 2px;
}

/* Ingot padding removed - TASK-150 uses flex sibling layout for badge */

/* ============================================================================
   ZONE 5: TEMPER CHIPS BAR
   ============================================================================ */

.temper-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--forge-grey-dark);
  border-top: 1px solid var(--forge-grey);
}

.temper-bar.active {
  display: flex;
}

.temper-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.temper-chip:hover {
  transform: scale(1.02);
}

.temper-chip.constraint {
  background: rgba(255, 176, 32, 0.2);
  color: var(--caution-amber);
}

.temper-chip.style {
  background: rgba(255, 184, 0, 0.2);
  color: var(--forge-gold, #FFB800);
}

.temper-chip.persona {
  background: rgba(0, 208, 132, 0.2);
  color: var(--trust-green);
}

.temper-chip.safety {
  background: rgba(255, 59, 59, 0.2);
  color: var(--fail-red);
}

.temper-chip-icon {
  font-size: 10px;
}

.temper-bar-clear {
  margin-left: auto;
  color: var(--ghost);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s ease;
}

.temper-bar-clear:hover {
  color: var(--text-primary);
}

/* ============================================================================
   INPUT BAR
   ============================================================================ */

.anvil-input {
  padding: 16px 24px;
  background: var(--bg-obsidian);
  border-top: 1px solid var(--bg-vault);
}

.anvil-input-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.anvil-textarea {
  flex: 1;
  min-height: 48px;
  max-height: 200px;
  padding: 14px 18px;
  background: var(--bg-ingot);
  border: 1px solid #2A2A2C;
  border-radius: 8px;
  color: var(--text-white);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color 0.15s ease;
}

.anvil-textarea:focus {
  border-color: var(--text-gold);
}

.anvil-textarea::placeholder {
  color: var(--text-secondary);
}

.anvil-send-btn {
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.anvil-send-btn .send-btn-img {
  height: 44px;
  width: auto;
  transition: all 0.15s ease;
  filter: brightness(1);
}

.anvil-send-btn:hover .send-btn-img {
  filter: brightness(1.15);
  transform: scale(1.02);
}

.anvil-send-btn:active .send-btn-img {
  transform: scale(0.96);
  filter: brightness(1.25);
}

.anvil-send-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.anvil-send-btn:disabled .send-btn-img {
  filter: grayscale(0.8) brightness(0.6);
}

/* ============================================================================
   ZONE 3: THE SEAL PANEL (Right Panel)
   ============================================================================ */

.seal-panel {
  position: fixed;
  top: var(--hud-height);
  right: 0;
  bottom: 0;
  width: var(--seal-width);
  background: var(--bg-obsidian);
  border-left: 1px solid var(--bg-vault);
  z-index: 800;
  transform: translateX(100%);
  transition: transform 0.25s ease-out;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.seal-panel.open {
  transform: translateX(0);
}

.seal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--bg-vault);
}

.seal-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-gold);
}

.seal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  background: transparent;
  border: none;
}

.seal-close:hover {
  background: var(--forge-grey);
  color: var(--text-primary);
}

.seal-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Heptagon Container */
.heptagon-container {
  display: flex;
  justify-content: center;
  padding: 20px 0;
  margin-bottom: 20px;
}

.heptagon-svg {
  width: 200px;
  height: 200px;
}

/* Confidence Bar */
.seal-metric {
  margin-bottom: 20px;
}

.seal-metric-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.seal-metric-label span {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.seal-metric-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.seal-progress-bar {
  height: 8px;
  background: var(--forge-grey);
  border-radius: 4px;
  overflow: hidden;
}

.seal-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.seal-progress-fill.low {
  background: var(--heat-low);
}

.seal-progress-fill.medium {
  background: var(--heat-medium);
}

.seal-progress-fill.high {
  background: var(--heat-high);
}

/* Impact Info Button */
.impact-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-vault);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  margin-left: 8px;
  transition: all 0.15s ease;
}

.impact-info:hover {
  background: var(--text-gold);
  color: var(--bg-obsidian);
}

/* Impact Tooltip */
.impact-tooltip {
  position: absolute;
  background: var(--bg-vault);
  border: 1px solid var(--forge-grey-light);
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 100;
  max-width: 320px;
}

.impact-tooltip-item {
  margin-bottom: 8px;
}

.impact-tooltip-item:last-child {
  margin-bottom: 0;
}

.impact-tooltip-item strong {
  color: var(--text-gold);
}

/* Confidence Bar Gradient */
.seal-progress-fill.confidence {
  background: var(--confidence-gradient);
}

/* Impact Display */
.seal-impact-display {
  margin-top: 8px;
}

.impact-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.impact-badge[data-level="LOW"] {
  background: rgba(138, 138, 146, 0.15);
  color: var(--forge-ash, #8A8A92);
  border: 1px solid var(--forge-ash, #8A8A92);
}

.impact-badge[data-level="MEDIUM"] {
  background: rgba(255, 214, 10, 0.15);
  color: var(--accent-molten);
  border: 1px solid var(--accent-molten);
}

.impact-badge[data-level="HIGH"] {
  background: rgba(255, 77, 0, 0.15);
  color: var(--accent-ember);
  border: 1px solid var(--accent-ember);
}

/* Gate Trace Section */
.gate-trace-section {
  border-top: 1px solid var(--bg-vault);
  padding-top: 20px;
  margin-top: 20px;
}

.gate-trace-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-gold);
  margin-bottom: 16px;
}

.gate-trace-item {
  margin-bottom: 6px;
  border-radius: 4px;
  background: var(--bg-ingot);
  border: 1px solid #2A2A2C;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s ease;
}

.gate-trace-item:hover {
  border-color: var(--text-gold);
}

.gate-trace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  transition: background 0.15s ease;
}

.gate-trace-header:hover {
  background: var(--bg-vault);
}

.gate-trace-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-white);
}

.gate-trace-status {
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  padding: 3px 8px;
  border-radius: 3px;
}

.gate-trace-status.pass {
  background: rgba(0, 255, 157, 0.15);
  color: var(--accent-glow);
}

.gate-trace-status.flag {
  background: rgba(255, 214, 10, 0.15);
  color: var(--accent-molten);
}

.gate-trace-status.fail {
  background: rgba(255, 77, 0, 0.15);
  color: var(--accent-ember);
}

.gate-trace-body {
  display: none;
  padding: 0 14px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  border-top: 1px solid #2A2A2C;
}

.gate-trace-item.expanded .gate-trace-body {
  display: block;
}

.gate-trace-item.expanded {
  border-color: var(--text-gold);
}

.gate-trace-metrics {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  margin: 10px 0;
}

.gate-trace-flags {
  margin: 10px 0;
}

.gate-trace-flags strong {
  color: var(--accent-molten);
}

.gate-trace-flags ul {
  margin: 4px 0 0 16px;
  padding: 0;
  list-style: disc;
}

.gate-trace-flags li {
  margin-bottom: 4px;
  color: var(--text-secondary);
}

.gate-trace-summary {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #2A2A2C;
  font-style: italic;
  color: var(--ghost);
}

.gate-icon {
  font-size: 14px;
  margin-right: 4px;
}

/* Gate vertex styles for pass state */
.gate-heptagon .gate-vertex.pass {
  fill: var(--accent-glow);
  filter: drop-shadow(0 0 4px var(--accent-glow));
}

/* ============================================================================
   GATE APPEAL BUTTONS (Shadow Appeal Process — UAT-LRN-001)
   ============================================================================ */

.gate-trace-appeal {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #2A2A2C;
}

.gate-appeal-btn {
  flex: 1;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid;
  font-family: var(--font-display, 'Inter Tight', sans-serif);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 150ms ease-out;
  background: transparent;
}

.gate-appeal-btn.disagree {
  color: var(--text-gold, #FFB800);
  border-color: rgba(255, 184, 0, 0.3);
}

.gate-appeal-btn.disagree:hover {
  background: rgba(255, 184, 0, 0.1);
  border-color: var(--text-gold, #FFB800);
}

.gate-appeal-btn.appeal {
  color: var(--accent-ember, #FF4D00);
  border-color: rgba(255, 77, 0, 0.3);
}

.gate-appeal-btn.appeal:hover {
  background: rgba(255, 77, 0, 0.1);
  border-color: var(--accent-ember, #FF4D00);
}

.appeal-submitted-badge {
  display: inline-block;
  font-family: var(--font-display, 'Inter Tight', sans-serif);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-glow, #2EA043);
  padding: 4px 12px;
  border: 1px solid rgba(46, 160, 67, 0.3);
  border-radius: 6px;
  background: rgba(46, 160, 67, 0.08);
}

/* ============================================================================
   APPEAL MODAL (Shadow Appeal Process — UAT-LRN-001)
   ============================================================================ */

.appeal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.appeal-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 440px;
  max-width: 90vw;
  max-height: 80vh;
  background: var(--bg-surface, #1A1A1D);
  border: 1px solid var(--border-subtle, #2A2A2C);
  border-radius: 16px;
  z-index: 2001;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}

.appeal-modal.open {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.appeal-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #2A2A2C;
}

.appeal-modal-title {
  font-family: var(--font-display, 'Inter Tight', sans-serif);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-gold, #FFB800);
}

.appeal-modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary, #8A8A92);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 150ms;
}

.appeal-modal-close:hover {
  color: white;
}

.appeal-modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(80vh - 60px);
}

.appeal-gate-context {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  margin-bottom: 16px;
}

.appeal-gate-label {
  font-size: 12px;
  color: var(--text-secondary, #8A8A92);
}

.appeal-gate-name {
  font-family: var(--font-display, 'Inter Tight', sans-serif);
  font-weight: 700;
  font-size: 14px;
  color: white;
}

.appeal-gate-verdict {
  font-family: var(--font-display, 'Inter Tight', sans-serif);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: auto;
}

.appeal-gate-verdict.pass { color: var(--accent-glow, #2EA043); background: rgba(46, 160, 67, 0.1); }
.appeal-gate-verdict.flag { color: var(--text-gold, #FFB800); background: rgba(255, 184, 0, 0.1); }
.appeal-gate-verdict.fail { color: var(--accent-ember, #FF4D00); background: rgba(255, 77, 0, 0.1); }
.appeal-gate-verdict.block { color: #FF2D00; background: rgba(255, 45, 0, 0.1); }

.appeal-type-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.appeal-type-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #2A2A2C;
  cursor: pointer;
  transition: all 150ms;
}

.appeal-type-option:hover {
  border-color: #3A3A3E;
  background: rgba(255, 255, 255, 0.02);
}

.appeal-type-option input[type="radio"] {
  accent-color: var(--text-gold, #FFB800);
  margin-top: 3px;
}

.appeal-type-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.appeal-type-label strong {
  font-size: 13px;
  color: white;
}

.appeal-type-label small {
  font-size: 11px;
  color: var(--text-secondary, #8A8A92);
}

.appeal-field {
  margin-bottom: 14px;
}

.appeal-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary, #8A8A92);
  margin-bottom: 6px;
}

.appeal-field select,
.appeal-field textarea {
  width: 100%;
  background: rgba(20, 20, 22, 0.6);
  border: 1px solid #2A2A2C;
  border-radius: 8px;
  padding: 10px 12px;
  color: white;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 13px;
  transition: border-color 200ms;
}

.appeal-field select:focus,
.appeal-field textarea:focus {
  outline: none;
  border-color: var(--text-gold, #FFB800);
  box-shadow: 0 0 0 3px rgba(255, 184, 0, 0.1);
}

.appeal-field textarea {
  resize: vertical;
  min-height: 80px;
}

.appeal-field select option {
  background: #1A1A1D;
  color: white;
}

.appeal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.appeal-cancel-btn {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #2A2A2C;
  background: transparent;
  color: var(--text-secondary, #8A8A92);
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms;
}

.appeal-cancel-btn:hover {
  border-color: #3A3A3E;
  color: white;
}

.appeal-submit-btn {
  flex: 2;
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(180deg, #FF8C00 0%, #FF6200 100%);
  color: #000;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 150ms;
}

.appeal-submit-btn:hover {
  background: linear-gradient(180deg, #FFA033 0%, #FF7A1A 100%);
  box-shadow: 0 4px 16px rgba(255, 122, 0, 0.3);
}

.appeal-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.appeal-submit-btn:active {
  transform: scale(0.98);
}

.appeal-status {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
}

.appeal-status.success {
  background: rgba(46, 160, 67, 0.1);
  color: var(--accent-glow, #2EA043);
  border: 1px solid rgba(46, 160, 67, 0.2);
}

.appeal-status.error {
  background: rgba(255, 77, 0, 0.1);
  color: var(--accent-ember, #FF4D00);
  border: 1px solid rgba(255, 77, 0, 0.2);
}

/* ============================================================================
   CONTEXT PANEL (Slide-Over Modal)
   ============================================================================ */

.context-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.context-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(800px, 60vw);
  min-width: 500px;
  background: var(--obsidian);
  z-index: 1101;
  transform: translateX(100%);
  transition: transform 0.3s ease-out;
  display: flex;
  flex-direction: column;
}

.context-panel.open {
  transform: translateX(0);
}

.context-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--forge-grey-dark);
}

.context-panel-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.context-panel-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  background: transparent;
  border: none;
  font-size: 20px;
}

.context-panel-close:hover {
  background: var(--forge-grey);
  color: var(--text-primary);
}

/* Context Panel Tabs */
.context-tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  border-bottom: 1px solid var(--forge-grey-dark);
}

.context-tab {
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
  background: transparent;
  border-left: none;
  border-right: none;
  border-top: none;
}

.context-tab:hover {
  color: var(--text-primary);
}

.context-tab.active {
  color: var(--ember-orange);
  border-bottom-color: var(--ember-orange);
}

.context-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* Context Panel Loading */
.context-loading {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px;
}

/* Context Section */
.context-section {
  margin-bottom: 24px;
}

.context-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-gold);
}

.context-add-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-ember);
  background: transparent;
  border: 1px solid var(--accent-ember);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.context-add-btn:hover {
  background: rgba(255, 77, 0, 0.1);
}

/* Context Add Form */
.context-add-form {
  background: var(--bg-vault);
  border: 1px solid var(--forge-grey-light);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.context-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-ingot);
  border: 1px solid var(--forge-grey-light);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}

.context-input:focus {
  outline: none;
  border-color: var(--text-gold);
}

.context-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.context-btn {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
}

.context-btn-save {
  background: linear-gradient(180deg, #FF8C00 0%, #FF6200 100%);
  color: #000000;
  font-weight: 700;
  border-radius: 12px;
}

.context-btn-save:hover {
  background: linear-gradient(180deg, #FFA033 0%, #FF7A1A 100%);
  box-shadow: 0 4px 16px rgba(255, 122, 0, 0.4);
}

.context-btn-cancel {
  background: var(--forge-grey);
  color: var(--text-secondary);
}

.context-btn-cancel:hover {
  background: var(--forge-grey-light);
  color: var(--text-primary);
}

.context-btn-small {
  padding: 4px 10px;
  font-size: 11px;
  background: var(--forge-grey);
  color: var(--text-primary);
}

.context-btn-small:hover {
  background: var(--forge-grey-light);
}

/* Context List */
.context-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Context Card */
.context-card {
  background: var(--bg-ingot);
  border: 1px solid var(--forge-grey-light);
  border-radius: 8px;
  padding: 16px;
}

.context-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.context-card-type {
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.context-card-actions {
  display: flex;
  gap: 8px;
}

.context-action {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  transition: color 0.15s ease;
}

.context-action:hover {
  color: var(--text-primary);
}

.context-card-content {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
}

.context-card-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.context-card-rationale {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--forge-grey-light);
}

/* Mission Card */
.context-mission-card {
  background: var(--bg-ingot);
  border: 1px solid var(--forge-grey-light);
  border-radius: 8px;
  padding: 16px;
}

.context-mission-card.tracked {
  border-color: var(--text-gold);
}

.context-mission-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-gold);
  margin-bottom: 12px;
}

.context-mission-objectives {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.context-objective {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-vault);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.context-objective:hover {
  background: var(--forge-grey-light);
}

.context-objective.completed {
  opacity: 0.6;
}

.context-objective.completed .objective-text {
  text-decoration: line-through;
}

.objective-check {
  font-size: 14px;
  color: var(--accent-glow);
}

.objective-text {
  font-size: 13px;
  color: var(--text-primary);
}

.context-mission-status {
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  padding: 2px 8px;
  border-radius: 3px;
}

.status-pending { background: rgba(255, 255, 255, 0.1); color: var(--text-secondary); }
.status-active { background: rgba(0, 255, 157, 0.15); color: var(--accent-glow); }
.status-completed { background: rgba(255, 179, 71, 0.15); color: var(--text-gold); }
.status-failed { background: rgba(255, 77, 0, 0.15); color: var(--accent-ember); }

/* Entity Grid */
.context-entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.context-entity-card {
  background: var(--bg-ingot);
  border: 1px solid var(--forge-grey-light);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.context-entity-card:hover {
  border-color: var(--text-gold);
  transform: translateY(-2px);
}

.context-entity-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.context-entity-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-entity-type {
  font-size: 10px;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

/* ============================================================================
   CONTEXT PANEL MODALS (Entity & Decision Edit)
   ============================================================================ */

.context-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.context-modal {
  background: var(--bg-vault);
  border: 1px solid var(--forge-grey-light);
  border-radius: 12px;
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.context-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--forge-grey-light);
}

.context-modal-header span {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-gold);
}

.context-modal-header button {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.context-modal-header button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.context-modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.context-modal-footer {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--forge-grey-light);
}

/* Context Button Styles */
.context-btn-danger {
  background: linear-gradient(180deg, #FF8C00 0%, #FF6200 100%) !important;
  color: #000000 !important;
  font-weight: 700;
  border-radius: 12px;
}

.context-btn-danger:hover {
  background: linear-gradient(180deg, #FFA033 0%, #FF7A1A 100%) !important;
  box-shadow: 0 4px 16px rgba(255, 122, 0, 0.4);
}

/* Edit form inline */
.context-edit-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.context-edit-form .context-input {
  width: 100%;
  box-sizing: border-box;
}

/* ============================================================================
   KEYBOARD SHORTCUTS HELP
   ============================================================================ */

.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--forge-grey-light);
}

.shortcut-row:last-child {
  border-bottom: none;
}

.shortcut-row kbd {
  background: var(--forge-grey);
  border: 1px solid var(--forge-grey-light);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-gold);
}

.shortcut-row span {
  color: var(--text-secondary);
  font-size: 13px;
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

/* Tablet: 768px - 1200px */
@media (max-width: 1200px) {
  .vault-drawer {
    transform: translateX(-100%);
    width: var(--vault-expanded);
  }

  .vault-drawer.expanded {
    transform: translateX(0);
  }

  .anvil {
    left: 0;
  }

  .seal-panel {
    width: 100%;
    max-width: 400px;
  }

  /* Context panel as overlay on tablet */
  .context-panel {
    width: 100%;
    max-width: 360px;
  }

  /* Slightly smaller badge on tablet */
  .forgegate-badge .badge-ring {
    width: 56px;
    height: 56px;
  }

  .forgegate-badge {
    width: 64px;
  }

  .message-row.ai .message-bubble {
    max-width: calc(100% - 88px);
  }
}

/* Mobile: < 768px */
@media (max-width: 768px) {
  .hud {
    padding: 0 12px;
    height: 48px;
  }

  .hud-project-name {
    max-width: 100px;
    font-size: 12px;
  }

  .hud-mission {
    display: none;
  }

  .hud-anchors {
    display: none;
  }

  .anvil-chat {
    padding: 12px;
  }

  .anvil-input {
    padding: 8px 12px;
  }

  .anvil-textarea {
    font-size: 14px;
    min-height: 36px;
  }

  /* Full-width panels on mobile */
  .seal-panel,
  .context-panel {
    width: 100%;
    max-width: none;
    border-radius: 0;
  }

  /* Smaller badge on mobile */
  .forgegate-badge {
    width: 56px;
  }

  .forgegate-badge .badge-ring {
    width: 48px;
    height: 48px;
  }

  .forgegate-badge .badge-label {
    font-size: 8px;
  }

  .forgegate-badge .badge-score {
    font-size: 11px;
  }

  .message-row.ai .message-bubble {
    max-width: calc(100% - 72px);
  }

  /* Ingot spacing adjustments */
  .ingot {
    padding: 12px;
    border-radius: 8px;
  }

  .message-row {
    gap: 10px;
    margin-bottom: 12px;
  }

  /* Temper bar compact */
  .temper-bar {
    padding: 6px 10px;
  }

  .temper-chip {
    font-size: 10px;
    padding: 3px 8px;
  }

  /* Context panel compact */
  .context-card {
    padding: 10px;
  }

  .context-entity-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
  }
}

/* Very small screens */
@media (max-width: 480px) {
  .hud-project-name {
    display: none;
  }

  .forgegate-badge {
    width: 48px;
  }

  .forgegate-badge .badge-ring {
    width: 40px;
    height: 40px;
  }

  .forgegate-badge .badge-label {
    font-size: 7px;
  }

  .message-row.ai .message-bubble {
    max-width: calc(100% - 60px);
  }
}

/* ============================================================================
   REDUCED MOTION (Accessibility)
   ============================================================================ */

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

  /* Disable specific animations */
  .ingot-assistant.processing {
    animation: none;
    border-color: var(--accent-ember);
  }

  .ingot-assistant.flag {
    animation: none;
    border-color: var(--status-flag);
  }

  .gate-vertex.flag {
    animation: none;
  }

  /* Static glow instead of animated */
  .forgegate-badge .badge-ring {
    filter: none;
  }

  .forgegate-badge.verdict-pass .badge-ring {
    box-shadow: 0 0 8px rgba(46, 160, 67, 0.4);
  }

  .forgegate-badge.verdict-flag .badge-ring {
    box-shadow: 0 0 8px rgba(240, 176, 0, 0.4);
  }

  .forgegate-badge.verdict-block .badge-ring {
    box-shadow: 0 0 8px rgba(255, 45, 0, 0.4);
  }
}

/* ============================================================================
   KEYBOARD NAVIGATION & FOCUS STATES
   ============================================================================ */

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--text-gold);
  outline-offset: 2px;
}

/* Remove default outline when using mouse */
:focus:not(:focus-visible) {
  outline: none;
}

/* Interactive elements focus states */
.anvil-action-btn:focus-visible,
.anvil-send-btn:focus-visible,
.vault-toggle:focus-visible,
.context-btn:focus-visible,
.context-tab:focus-visible {
  outline: 2px solid var(--text-gold);
  outline-offset: 2px;
}

/* Forgegate badge keyboard accessible */
.forgegate-badge:focus-visible {
  outline: 2px solid var(--text-gold);
  outline-offset: 4px;
  border-radius: 50%;
}

/* Gate vertex focus */
.gate-vertex:focus-visible {
  outline: 2px solid var(--text-gold);
  outline-offset: 2px;
}

/* Context card focus */
.context-card:focus-visible,
.context-entity-card:focus-visible {
  outline: 2px solid var(--text-gold);
  outline-offset: 2px;
}

/* Skip link for keyboard users */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: var(--text-gold);
  color: var(--forge-void);
  font-weight: 600;
  z-index: 9999;
  border-radius: 4px;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

/* ============================================================================
   LOADING STATES
   ============================================================================ */

.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--forge-grey-light);
  border-top-color: var(--text-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.context-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.context-loading::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--forge-grey-light);
  border-top-color: var(--text-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Skeleton loading for cards */
.skeleton {
  background: linear-gradient(90deg,
    var(--forge-grey) 25%,
    var(--forge-grey-light) 50%,
    var(--forge-grey) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-text:last-child {
  width: 60%;
}

/* ============================================================================
   ERROR STATES
   ============================================================================ */

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
}

.error-state-icon {
  font-size: 32px;
  color: var(--status-block);
}

.error-state-message {
  color: var(--text-secondary);
  font-size: 14px;
  max-width: 280px;
}

.error-state-retry {
  margin-top: 8px;
  padding: 8px 16px;
  background: var(--forge-grey);
  border: 1px solid var(--forge-grey-light);
  border-radius: 6px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.error-state-retry:hover {
  background: var(--forge-grey-light);
  border-color: var(--text-gold);
}

/* Connection error banner */
.connection-error-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 20px;
  background: var(--status-block);
  color: white;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  display: none;
}

.connection-error-banner.visible {
  display: block;
}

/* ============================================================================
   PERFORMANCE OPTIMIZATIONS
   ============================================================================ */

/* GPU acceleration for animations */
.ingot-assistant.processing,
.ingot-assistant.pass,
.ingot-assistant.flag,
.ingot-assistant.fail,
.forgegate-badge,
.gate-vertex,
.vault-drawer {
  will-change: transform, opacity;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Panels use transform for positioning - only apply will-change, not transform override */
.seal-panel,
.context-panel {
  will-change: transform, opacity;
  backface-visibility: hidden;
}

/* Contain paint for performance */
.anvil-chat-inner {
  contain: content;
}

.context-panel-body {
  contain: content;
}

/* Disable pointer events during animations for performance */
.ingot-assistant.processing {
  pointer-events: none;
}

.ingot-assistant.processing .ingot-content {
  pointer-events: auto;
}

/* ============================================================================
   VAULT QUICK ACCESS
   ============================================================================ */

.vault-quick-access {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vault-quick-link {
  display: block;
  padding: 8px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.vault-quick-link:hover {
  background: var(--forge-grey);
  color: var(--text-primary);
}

/* ============================================================================
   SETTINGS MODAL STYLES
   ============================================================================ */

.settings-section {
  margin-bottom: 24px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin: 0 0 12px 0;
}

.settings-links {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.settings-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--forge-grey-dark);
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s ease;
}

.settings-link:hover {
  background: var(--forge-grey);
  color: var(--text-primary);
}

.settings-link svg {
  flex-shrink: 0;
}

.settings-link-highlight {
  border-left: 2px solid var(--caution-amber);
  background: rgba(255, 176, 32, 0.08);
}

.settings-link-highlight:hover {
  background: rgba(255, 176, 32, 0.15);
}

.settings-link small {
  display: block;
  width: 100%;
  font-size: 10px;
  color: var(--text-tertiary, #666);
  margin-top: -2px;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--forge-grey-dark);
  font-size: 13px;
  color: var(--text-secondary);
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-item span:last-child {
  color: var(--text-primary);
}

/* ============================================================================
   INGOT MESSAGE STYLES
   ============================================================================ */

.ingot-system {
  background: transparent;
  border: 1px solid var(--forge-grey);
  color: var(--text-secondary);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
}

.ingot-content {
  line-height: 1.5;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ============================================================================
   ANVIL ACTION BUTTON
   ============================================================================ */

.anvil-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  min-width: 48px;
  background: var(--bg-ingot);
  border: 1px solid #2A2A2C;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

/* Button icons - img-based per TASK-149 fix */
.anvil-action-btn img.anvil-icon {
  width: 20px;
  height: 20px;
  display: block;
  pointer-events: none;
}

.anvil-action-btn:hover {
  background: var(--forge-basalt, #1E1E1E);
  border-color: var(--forge-molten, #FF7A00);
}

/* Tooltip for action buttons */
.anvil-action-btn::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  padding: 6px 12px;
  background: var(--bg-vault);
  color: var(--text-white);
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  pointer-events: none;
  z-index: 1000;
  border: 1px solid var(--text-gold);
}

.anvil-action-btn:hover::after {
  opacity: 1;
  visibility: visible;
}

/* ============================================================================
   BODY FORGE PROTOCOL MODE
   ============================================================================ */

/* ============================================================================
   GLOBAL STYLES - FORGE DESIGN SYSTEM
   ============================================================================ */

html,
body.forge-protocol {
  margin: 0;
  padding: 0;
  background: var(--bg-obsidian);
  border: none;
  outline: none;
}

body.forge-protocol {
  color: var(--text-white);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Focus states - gold accent */
body.forge-protocol *:focus {
  outline: none;
}

body.forge-protocol *:focus-visible {
  outline: 2px solid var(--text-gold);
  outline-offset: 2px;
}

body.forge-protocol * {
  box-sizing: border-box;
}

/* Hide old layout elements when in forge protocol mode */
body.forge-protocol .sidebar,
body.forge-protocol .app-container,
body.forge-protocol .main-content,
body.forge-protocol .accountability-panel {
  display: none !important;
}

/* Scrollbar styling */
body.forge-protocol ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

body.forge-protocol ::-webkit-scrollbar-track {
  background: var(--bg-obsidian);
}

body.forge-protocol ::-webkit-scrollbar-thumb {
  background: var(--bg-vault);
  border-radius: 4px;
}

body.forge-protocol ::-webkit-scrollbar-thumb:hover {
  background: var(--forge-grey-light);
}

/* Hedging highlight - per directive */
.hedging-highlight {
  text-decoration: underline;
  text-decoration-color: var(--accent-molten);
  text-decoration-thickness: 2px;
  cursor: pointer;
}

.hedging-highlight:hover {
  background: rgba(255, 214, 10, 0.2);
}

/* ============================================================================
   GHOST TEXT - Source Attribution (Phase 4: Ambient Accountability)
   Shows which NIMBUS context influenced the AI response
   ============================================================================ */

.ghost-text-container {
  margin-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.ghost-text-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s ease;
  user-select: none;
}

.ghost-text-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

.ghost-text-toggle {
  font-size: 10px;
  transition: transform 0.2s ease;
  color: var(--ghost);
}

.ghost-text-container.expanded .ghost-text-toggle {
  transform: rotate(90deg);
}

.ghost-text-title {
  font-weight: 500;
  color: var(--ghost);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ghost-text-count {
  background: rgba(255, 179, 71, 0.2);
  color: var(--text-gold);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}

.ghost-text-sources {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0 0 16px;
  max-height: 200px;
  overflow-y: auto;
}

.ghost-text-container.expanded .ghost-text-sources {
  display: flex;
}

.ghost-text-source {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.02);
  border-left: 2px solid transparent;
  transition: all 0.15s ease;
  cursor: default;
}

.ghost-text-source:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Source type-specific colors */
.ghost-text-source[data-source-type="anchor"] {
  border-left-color: var(--text-gold);
}

.ghost-text-source[data-source-type="mission"],
.ghost-text-source[data-source-type="objective"] {
  border-left-color: var(--accent-ember);
}

.ghost-text-source[data-source-type="entity"] {
  border-left-color: var(--accent-glow);
}

.ghost-text-source[data-source-type="decision"] {
  border-left-color: var(--accent-molten);
}

.ghost-source-icon {
  font-size: 12px;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.ghost-source-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ghost);
  flex-shrink: 0;
  min-width: 60px;
}

.ghost-source-content {
  flex: 1;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Responsive: Hide Ghost Text on very small screens */
@media (max-width: 480px) {
  .ghost-text-container {
    display: none;
  }
}

/* Reduced motion: Skip toggle animation */
@media (prefers-reduced-motion: reduce) {
  .ghost-text-toggle {
    transition: none;
  }
}

/* PENDING state — spinner while async gates evaluate.
   No filter here — filter on any ancestor breaks CSS transform animations
   by creating a new stacking context. Use stroke-dashoffset instead of
   transform so we're immune to stacking context issues entirely. */
.forgegate-badge.verdict-pending .badge-label {
  color: var(--text-secondary, #8892a4);
}

.badge-pending-spin .spinner-track {
  stroke: rgba(120, 130, 200, 0.2);
}

.badge-pending-spin .spinner-arc {
  stroke: rgba(120, 130, 200, 0.9);
  stroke-dasharray: 60 128;
  stroke-dashoffset: 0;
  animation: badge-spin-dash 1.4s linear infinite;
}

@keyframes badge-spin-dash {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: -188; }
}

@media (prefers-reduced-motion: reduce) {
  .badge-pending-spin .spinner-arc {
    animation: none;
  }
}
