*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #050508;
  --bg2: #0a0a10;
  --panel: #0d0d14;
  --border: #1a1a28;
  --border2: #252535;
  --neon: #a3ff47;
  --neon2: #c8ff7a;
  --violet: #8b5cf6;
  --violet2: #a78bfa;
  --red: #ff4757;
  --amber: #ffa502;
  --text: #e8e8f0;
  --muted: #4a4a6a;
  --muted2: #6b6b8a;
}

* { cursor: crosshair; }
input, select, button { cursor: crosshair; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  min-height: 100vh;
  padding: 0;
  overflow-x: hidden;
  position: relative;
}

/* Scanlines overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 100;
}

/* Grid background */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(163,255,71,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(163,255,71,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.wrapper {
  position: relative;
  z-index: 1;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* Top chrome */
.chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border2);
  margin-bottom: 0;
}

.chrome-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chrome-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}

.chrome-right {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: var(--muted2);
  letter-spacing: 0.1em;
}

.blink { animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Header */
header {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--border2);
  margin-bottom: 40px;
  position: relative;
}

.header-tag {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: var(--neon);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-tag::before { content: '>'; color: var(--neon); }

h1 {
  font-family: 'Space Mono', monospace;
  font-size: clamp(3rem, 8vw, 6.5rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--text);
  text-shadow: 0 0 40px rgba(163,255,71,0.15);
}

h1 .accent { color: var(--neon); text-shadow: 0 0 20px rgba(163,255,71,0.5); }

.header-meta {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 16px;
}

.header-desc {
  font-size: 13px;
  color: var(--muted2);
  max-width: 360px;
  line-height: 1.6;
  font-family: 'Space Mono', monospace;
}

.version-badge {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: var(--violet2);
  border: 1px solid var(--violet);
  padding: 4px 10px;
  letter-spacing: 0.1em;
  text-shadow: 0 0 8px rgba(139,92,246,0.4);
  box-shadow: 0 0 12px rgba(139,92,246,0.1), inset 0 0 12px rgba(139,92,246,0.05);
}

/* Main grid */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto auto;
  gap: 2px;
  background: var(--border);
}

/* ══════════════════════════════════════════
   RESPONSIVE — MOBILE & TABLET
   ══════════════════════════════════════════ */

/* ── Tablet (≤ 900px) ── */
@media (max-width: 900px) {
  .wrapper { padding: 0 16px 60px; }
  h1 { font-size: clamp(2.5rem, 10vw, 5rem); }
  .metrics-side { min-width: 140px; }
  .bar-name { width: 100px; }
  .bar-amount { width: 72px; }
}

/* ── Mobile (≤ 650px) ── */
@media (max-width: 650px) {
  .wrapper { padding: 0 12px 50px; }

  /* Chrome bar: compact */
  .chrome { padding: 10px 0; }
  .chrome-dot { width: 8px; height: 8px; }
  .chrome-right { font-size: 8px; letter-spacing: 0.06em; }

  /* Header: tighter */
  header {
    padding: 28px 0 22px;
    margin-bottom: 24px;
  }
  .header-tag { font-size: 8px; margin-bottom: 10px; }
  h1 { font-size: clamp(2.8rem, 14vw, 4.5rem); line-height: 0.92; }
  .header-meta { flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 12px; }
  .header-desc { font-size: 11px; max-width: 100%; }
  .version-badge { font-size: 9px; padding: 3px 8px; }

  /* Main grid: single column */
  .main-grid {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .panel-result { grid-column: 1; }
  .panel-tips   { grid-column: 1; }

  /* Panels: tighter padding */
  .panel { padding: 18px 16px; }

  /* Fields: font-size 1rem prevents iOS zoom */
  input[type="number"] {
    font-size: 1rem;
    padding: 11px 44px 11px 12px;
  }

  /* Chips: bigger touch targets */
  .chips { gap: 5px; }
  .chip { padding: 8px 14px; font-size: 10px; }

  /* Sliders: bigger thumb */
  input[type="range"] { height: 3px; }
  input[type="range"]::-webkit-slider-thumb {
    width: 20px; height: 20px;
  }
  .slider-val { font-size: 13px; }

  /* Result panel: stack vertically on mobile */
  .result-inner {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .result-num { font-size: clamp(3rem, 16vw, 5rem); }

  /* Metrics side: horizontal row on mobile */
  .metrics-side {
    flex-direction: row;
    min-width: 0;
    gap: 2px;
  }
  .metric-box { flex: 1; padding: 9px 10px; }
  .metric-label { font-size: 7px; }
  .metric-value { font-size: 13px; }

  /* Breakdown bars: compact names */
  .bar-row { gap: 7px; margin-bottom: 8px; }
  .bar-name { width: 88px; font-size: 8px; }
  .bar-amount { width: 62px; font-size: 10px; }

  /* Tips: more readable on small screens */
  .tip-row { font-size: 12px; padding: 10px 0; gap: 9px; }
  .tip-prefix { font-size: 9px; }

  /* Footer: stack */
  footer { flex-direction: column; gap: 8px; text-align: center; }
  .footer-note { font-size: 8px; }
}

/* ── Very small (≤ 380px) ── */
@media (max-width: 380px) {
  .wrapper { padding: 0 8px 40px; }
  h1 { font-size: 2.6rem; }
  .panel { padding: 14px 12px; }
  .chips { gap: 4px; }
  .chip { padding: 7px 10px; font-size: 9px; }
  .metrics-side { flex-direction: column; }
  .metric-box { padding: 8px; }
  .bar-name { width: 76px; }
  .bar-amount { width: 54px; font-size: 9px; }
  .result-num { font-size: 2.8rem; }
}

/* Panels */
.panel {
  background: var(--panel);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.panel-result {
  grid-column: 1 / -1;
  background: var(--bg2);
}

.panel-tips {
  grid-column: 1 / -1;
  background: var(--bg2);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border2);
}

.panel-title {
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  color: var(--muted2);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-title-dot {
  width: 6px; height: 6px;
  background: var(--neon);
  box-shadow: 0 0 8px var(--neon);
}

.panel-num {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: var(--border2);
  letter-spacing: 0.1em;
}

/* Fields */
.field { margin-bottom: 16px; }

label {
  display: block;
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  color: var(--muted2);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.input-wrap { position: relative; display: flex; align-items: center; }

input[type="number"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-left: 2px solid var(--neon);
  color: var(--neon2);
  font-family: 'Space Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  padding: 10px 44px 10px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -moz-appearance: textfield;
  border-radius: 0;
  text-shadow: 0 0 8px rgba(163,255,71,0.3);
}

input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

input:focus {
  border-color: var(--neon);
  box-shadow: 0 0 0 1px rgba(163,255,71,0.2), inset 0 0 20px rgba(163,255,71,0.03);
}

.unit {
  position: absolute;
  right: 12px;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  pointer-events: none;
}

/* Chips */
.chips { display: flex; gap: 4px; flex-wrap: wrap; }

.chip {
  padding: 6px 14px;
  border: 1px solid var(--border2);
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted2);
  background: var(--bg);
  transition: all 0.12s;
  border-radius: 0;
}

.chip:hover { border-color: var(--neon); color: var(--neon); }
.chip.active {
  background: var(--neon);
  border-color: var(--neon);
  color: #000;
  font-weight: 700;
  box-shadow: 0 0 16px rgba(163,255,71,0.35);
}

/* Sliders */
.slider-field { margin-bottom: 18px; }

.slider-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.slider-lbl {
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  color: var(--muted2);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.slider-val {
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--violet2);
  text-shadow: 0 0 8px rgba(139,92,246,0.4);
}

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  height: 2px;
  background: var(--border2);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--violet);
  border-radius: 0;
  transform: rotate(45deg);
  box-shadow: 0 0 12px rgba(139,92,246,0.6);
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--violet2);
  transform: rotate(45deg) scale(1.3);
  box-shadow: 0 0 20px rgba(139,92,246,0.8);
}

/* Result */
.result-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: center;
}

.result-label {
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  color: var(--muted2);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.result-num {
  font-family: 'Space Mono', monospace;
  font-size: clamp(3.5rem, 9vw, 6rem);
  font-weight: 700;
  color: var(--neon);
  line-height: 0.9;
  letter-spacing: -0.03em;
  text-shadow: 0 0 30px rgba(163,255,71,0.4), 0 0 60px rgba(163,255,71,0.15);
  transition: text-shadow 0.3s;
}

.result-unit {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--muted2);
  margin-top: 10px;
  letter-spacing: 0.15em;
}

.result-hint {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: var(--violet2);
  margin-top: 6px;
}

/* Metrics side */
.metrics-side {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 180px;
}

.metric-box {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-left: 2px solid var(--violet);
  padding: 12px 16px;
}

.metric-label {
  font-family: 'Space Mono', monospace;
  font-size: 8px;
  color: var(--muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.metric-value {
  font-family: 'Space Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.metric-value.good { color: var(--neon); text-shadow: 0 0 8px rgba(163,255,71,0.4); }
.metric-value.warn { color: var(--amber); text-shadow: 0 0 8px rgba(255,165,2,0.3); }
.metric-value.bad  { color: var(--red);   text-shadow: 0 0 8px rgba(255,71,87,0.3); }

/* Breakdown bars */
.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.bar-name {
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  color: var(--muted2);
  letter-spacing: 0.08em;
  width: 120px;
  flex-shrink: 0;
}

.bar-track {
  flex: 1;
  height: 4px;
  background: var(--border);
  position: relative;
}

.bar-fill { height: 100%; transition: width 0.5s cubic-bezier(0.34,1.56,0.64,1); }

.bar-amount {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  width: 90px;
  text-align: right;
  flex-shrink: 0;
}

/* Tips */
.tip-row {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted2);
  line-height: 1.5;
  transition: color 0.2s;
}

.tip-row:last-child { border-bottom: none; }
.tip-row:hover { color: var(--text); }

.tip-prefix {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: var(--neon);
  flex-shrink: 0;
  margin-top: 2px;
}

/* Footer */
footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-note {
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.footer-right {
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  color: var(--neon);
  letter-spacing: 0.15em;
  text-shadow: 0 0 8px rgba(163,255,71,0.3);
}

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel { animation: fadeUp 0.4s ease both; }
.panel:nth-child(1) { animation-delay: 0.05s; }
.panel:nth-child(2) { animation-delay: 0.1s; }
.panel:nth-child(3) { animation-delay: 0.15s; }
.panel:nth-child(4) { animation-delay: 0.2s; }

.glitch { animation: glitch 0.15s ease; }

@keyframes glitch {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-2px); filter: hue-rotate(90deg); }
  40%  { transform: translateX(2px); }
  60%  { transform: translateX(-1px); filter: hue-rotate(0deg); }
  100% { transform: translateX(0); }
}

/* Live indicator */
.live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  color: var(--neon);
  letter-spacing: 0.1em;
}

.live-dot {
  width: 5px; height: 5px;
  background: var(--neon);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--neon);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.8); }
}
