/* ==========================================================================
   THEME TOKENS, RESETS & PRIMITIVES (v5.5.0)
   Scoped to core variables, typography, buttons, checkboxes and badges.
   ========================================================================== */

@property --angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

:root {
  color-scheme: dark;
  --bg-base: #121212;
  --bg-canvas: #121212;
  --bg-surface: #121212;
  --bg-surface-hover: #151515;
  --bg-element: #0e0e0e;
  --bg-card: #121212;

  --border-color: #151515;
  --border-focus: #242424;
  --border-subtle: #151515;

  --text-main: #f5f5f5;
  --text-muted: #9e9e9e;
  --text-dim: #666666;

  --status-green-bg: rgba(52, 211, 153, 0.06);
  --status-green-text: #34d399;
  --status-yellow-bg: rgba(251, 191, 36, 0.06);
  --status-yellow-text: #fbbf24;
  --status-blue-bg: rgba(255, 255, 255, 0.04);
  --status-blue-text: #e5e5e5;
  --status-red-bg: rgba(248, 113, 113, 0.06);
  --status-red-text: #f87171;

  --diff-add-bg: rgba(52, 211, 153, 0.08);
  --diff-del-bg: rgba(255, 133, 133, 0.10);

  --chrome-steel-bg: linear-gradient(180deg, #ffffff 0%, #d8d8d8 40%, #a8a8a8 100%);
  --chrome-steel-hover: linear-gradient(180deg, #ffffff 0%, #f0f0f0 40%, #d0d0d0 100%);
  --chrome-steel-text: #000000;
  --dark-steel-bg: #121212;
  --dark-steel-hover: #151515;
  --dark-steel-border: #151515;

  --font-sans: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Geist Mono', 'JetBrains Mono', monospace;
  --font-pixel: 'Geist Pixel', var(--font-mono);
}

* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: #202020 transparent;
}

*::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: #202020;
  border-radius: 4px;
}
*::-webkit-scrollbar-thumb:hover {
  background: #2e2e2e;
}
*::-webkit-scrollbar-corner {
  background: transparent;
}

html, body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: clamp(12.5px, 0.26vw + 10.2px, 15.5px);
  line-height: 1.5;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: transparent;
  border: none;
  cursor: pointer;
}

/* ANTI-REFLEW DEFENSIVE ISOLATION BOUNDARIES */
.companion-card, .diff-file-details, .terminal-entry, .ghost-tree-node, .matrix-turn-card {
  contain: layout style;
}

.ghost-node-name, .diff-deck-dir, .diff-deck-filename, .diff-text, .terminal-entry, .diff-fold-text {
  direction: ltr !important;
  unicode-bidi: isolate !important;
  overflow-wrap: anywhere;
}

/* FORM CONTROLS & CHECKBOXES */
input[type="checkbox"].diff-select-checkbox,
.diff-select-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  background: #0e0e0e;
  border: 1.5px solid #282828;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  outline: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}

input[type="checkbox"].diff-select-checkbox:hover,
.diff-select-checkbox:hover {
  border-color: #444444;
}

input[type="checkbox"].diff-select-checkbox:checked,
.diff-select-checkbox:checked {
  background: #ffffff;
  border-color: #ffffff;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='black' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 0 1 0 1.414l-5 5a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L6.5 9.086l4.293-4.293a1 1 0 0 1 1.414 0z'/%3E%3C/svg%3E");
  background-size: 10px 10px;
  background-position: center;
  background-repeat: no-repeat;
}

.input-field {
  background: #0e0e0e;
  border: 2px solid #151515;
  border-radius: 10px;
  padding: 6px 10px;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
}

.input-field-sm {
  background: #0e0e0e;
  border: 2px solid #151515;
  border-radius: 10px;
  padding: 4px 8px;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 11px;
  outline: none;
}

.input-field:focus, .input-field-sm:focus {
  border-color: var(--border-focus);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.input-error {
  border-color: var(--status-red-text) !important;
  box-shadow: 0 0 8px rgba(255, 51, 51, 0.4) !important;
}

.hardware-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 11px;
  color: var(--text-main);
}

.hardware-toggle-label input {
  display: none;
}

.toggle-slider {
  width: 28px;
  height: 16px;
  background: #181818;
  border: 1px solid var(--border-focus);
  border-radius: 8px;
  position: relative;
  transition: all 0.15s ease;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: all 0.15s ease;
}

.hardware-toggle-label input:checked + .toggle-slider {
  background: var(--status-green-bg);
  border-color: var(--status-green-text);
}

.hardware-toggle-label input:checked + .toggle-slider::after {
  transform: translateX(12px);
  background: var(--status-green-text);
}

/* BUTTONS & ACTIONS */
.btn {
  background: #121212;
  border: 2px solid #151515;
  color: var(--text-main);
  padding: 7px 12px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: none;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.btn:hover {
  background: #151515;
  border-color: #1a1a1a;
  color: #ffffff;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 8px;
}

.btn-chrome {
  background: var(--chrome-steel-bg);
  border: 1px solid #ffffff;
  border-radius: 16px;
  color: #000000;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 2px 8px rgba(0, 0, 0, 0.5);
}

.btn-chrome:hover {
  background: var(--chrome-steel-hover);
  border-color: #ffffff;
  color: #000000;
}

.btn-chrome:active {
  background: linear-gradient(180deg, #e0e0e0 0%, #a0a0a0 100%);
  border-color: #d0d0d0;
  color: #000000;
  transform: translateY(1px);
}

.btn-chrome-lg {
  background: var(--chrome-steel-bg);
  color: var(--chrome-steel-text);
  border: 1px solid #ffffff;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 2px 10px rgba(255, 255, 255, 0.15);
}

.btn-chrome-lg:hover {
  background: var(--chrome-steel-hover);
  color: #000000;
}

.btn-dark-steel {
  background: #121212;
  border: 2px solid #151515;
  color: var(--text-muted);
}

.btn-dark-steel:hover {
  background: #151515;
  border-color: #1a1a1a;
  color: #ffffff;
}

/* MINIMALIST CRISP GHOST BUTTON (BORDERLESS & TRANSPARENT, GREEN ICON ONLY) */
.titanium-lens-btn {
  position: relative;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: transparent !important;
  border: none !important;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  overflow: hidden;
  box-shadow: none !important;
  transition: transform 0.12s ease;
  user-select: none;
  flex-shrink: 0;
}

.titanium-lens-btn:hover {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.titanium-lens-btn:active {
  transform: scale(0.92);
  box-shadow: none !important;
}

.lens-specular-ring {
  display: none;
}

.lens-aperture-core {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  z-index: 1;
}

.lens-star-icon {
  color: var(--status-green-text, #34d399);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.15s ease;
}

.titanium-lens-btn:hover .lens-star-icon {
  color: #34d399;
  transform: rotate(45deg) scale(1.08);
}

.titanium-lens-btn:active .lens-star-icon,
.titanium-lens-btn.is-fixing .lens-star-icon {
  transform: rotate(180deg) scale(0.92);
  color: var(--status-green-text, #34d399);
}

.btn-primary {
  background: #202020;
  border: 1px solid #333333;
  color: #ffffff;
  font-weight: 600;
}

.btn-primary:hover {
  background: #2a2a2a;
  border-color: #444444;
  color: #ffffff;
}

.btn-danger {
  background: var(--status-red-bg);
  border: 1px solid rgba(238, 0, 0, 0.3);
  color: var(--status-red-text);
}

.btn-danger:hover {
  background: rgba(238, 0, 0, 0.18);
  border-color: var(--status-red-text);
}

.btn-armed-cta {
  background: var(--chrome-steel-bg) !important;
  color: #000000 !important;
  border: 1px solid #ffffff !important;
  border-radius: 16px !important;
  font-weight: 700 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 2px 8px rgba(0, 0, 0, 0.6) !important;
  animation: none !important;
}

.btn-armed-cta:hover {
  background: var(--chrome-steel-hover) !important;
  border-color: #ffffff !important;
  color: #000000 !important;
}

/* LIQUID SILVER HERO CTA BUTTON (.silver-btn) */
.silver-btn {
  position: relative;
  height: 36px;
  width: auto;
  min-width: 140px;
  border: none;
  background: transparent;
  cursor: pointer;
  outline: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  transform: scale(1);
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  user-select: none;
}

.silver-btn:active {
  transform: scale(0.96);
}

.silver-btn .silver-ring {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  padding: 1.5px;
  background: conic-gradient(
    from var(--angle),
    #ffffff 0%,
    #a3a3a3 14%,
    #ffffff 28%,
    #262626 48%,
    #ffffff 62%,
    #d4d4d4 75%,
    #171717 88%,
    #ffffff 100%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  filter: none;
  transition: none;
  animation: liquidSpin 2.2s linear infinite;
}

.silver-btn:hover .silver-ring {
  filter: none;
  animation-duration: 1.4s;
}

.silver-btn .btn-plate {
  position: absolute;
  inset: 1.5px;
  border-radius: 16.5px;
  background: linear-gradient(180deg, #ffffff 0%, #ebebeb 45%, #c8c8c8 100%);
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -1.5px 3px rgba(0, 0, 0, 0.35),
    0 3px 12px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  overflow: hidden;
  z-index: 1;
}

.silver-btn:hover .btn-plate {
  background: linear-gradient(180deg, #ffffff 0%, #f4f4f4 45%, #d4d4d4 100%);
}

.silver-btn .btn-icon {
  width: 14px;
  height: 14px;
  color: #000000;
  z-index: 3;
  flex-shrink: 0;
  transition: color 0.2s ease, transform 0.2s ease;
}

.silver-btn .btn-parse-text {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  color: #000000;
  letter-spacing: -0.01em;
  white-space: nowrap;
  z-index: 3;
}

.silver-btn.is-active .silver-ring {
  animation: liquidSpin 1.2s linear infinite;
}

.silver-btn.is-active .btn-icon {
  transform: scale(1.15);
}

.silver-btn.is-armed .silver-ring {
  background: conic-gradient(
    from var(--angle),
    #ffffff 0%,
    #e5e5e5 20%,
    #525252 45%,
    #ffffff 65%,
    #262626 82%,
    #ffffff 100%
  );
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.35));
}

.silver-tally-pip {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #000000;
  color: #ffffff;
  border: 1px solid #333333;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
  z-index: 10;
  user-select: none;
}

.click-flash {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, rgba(163, 163, 163, 0.3) 40%, transparent 70%);
  transform: translate(-50%, -50%) scale(0);
  animation: flashExpand 0.5s cubic-bezier(0.15, 0.8, 0.25, 1) forwards;
  pointer-events: none;
  z-index: 2;
}

@keyframes flashExpand {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(4); opacity: 0; }
}

@keyframes liquidSpin {
  to { --angle: 360deg; }
}

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0;
  font-size: 10px;
  font-weight: 500;
  font-family: var(--font-mono);
  background: transparent !important;
  border: none !important;
}

.badge-exact { color: var(--status-green-text); }
.badge-suggested { color: var(--status-yellow-text); }
.badge-new { color: var(--status-blue-text); }
.badge-conflict { color: var(--status-red-text); }
.badge-blue { color: var(--status-blue-text); }
.badge-clean { color: var(--text-dim); }
.badge-warning { color: var(--status-yellow-text); }
.badge-tier1 { color: var(--status-blue-text); }

/* SPINNERS */
.spinner {
  animation: spin 0.8s linear infinite;
  transform-origin: 50% 50%;
  flex: 0 0 auto;
  display: block;
}

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

/* HARDWARE SKELETON PRIMITIVES */
.skeleton-bone {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0%, rgba(255, 255, 255, 0.06) 50%, rgba(255, 255, 255, 0.02) 100%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  border-radius: 4px;
  display: inline-block;
  pointer-events: none;
}

.skeleton-pill {
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

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