/* ============================================================
   J.A.R.V.I.S. HUD — Stark Industries Directive Protocol
   ============================================================ */

:root {
  --bg: #080C14;
  --bg-2: #0A0F1D;
  --cyan: #00F0FF;
  --cyan-dim: rgba(0, 240, 255, 0.25);
  --cyan-faint: rgba(0, 240, 255, 0.08);
  --orange: #FF6B00;
  --gold: #FFB800;
  --glass: rgba(10, 25, 47, 0.75);
  --text: #CFEBFF;
  --text-dim: rgba(207, 235, 255, 0.55);
  --red: #FF3860;
  --font-display: 'Orbitron', 'Segoe UI', sans-serif;
  --font-body: 'Rajdhani', 'Segoe UI', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
  color-scheme: dark;
}

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

body {
  background: var(--bg);
  background: radial-gradient(ellipse at 50% -10%, #0e1a30 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- Background FX ---------- */
.grid-bg {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(0, 240, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 50% 20%, #000 30%, transparent 90%);
}
.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.018) 0 1px, transparent 1px 3px);
}
.sweep {
  position: fixed; left: 0; right: 0; height: 120px; pointer-events: none; z-index: 1;
  background: linear-gradient(to bottom, transparent, rgba(0,240,255,0.05), transparent);
  animation: sweep 9s linear infinite;
}
@keyframes sweep { 0% { top: -15%; } 100% { top: 110%; } }

/* ---------- Layout ---------- */
.app { position: relative; z-index: 2; max-width: 980px; margin: 0 auto; padding: 24px 16px 48px; }

.panel {
  background: var(--glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--cyan-dim);
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.06), inset 0 0 40px rgba(0, 240, 255, 0.03);
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
}

/* ---------- Header ---------- */
.hud-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 20px 28px;
}
.header-left { min-width: 0; }
.logo {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 28px;
  letter-spacing: 4px;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(0, 240, 255, 0.6);
}
.status-line {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--gold);
  margin-top: 8px;
  display: flex; align-items: center; gap: 8px;
}
.pulse-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
  animation: pulse 1.6s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: .35; transform: scale(.75);} }
.date-line {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  letter-spacing: 2px;
}

/* ---------- Arc Reactor ---------- */
.reactor-wrap { display: flex; flex-direction: column; align-items: center; }
.reactor { width: 190px; height: 190px; }
#reactorProgress { transition: stroke-dasharray .6s cubic-bezier(.22,1,.36,1), stroke .4s; }
.reactor-pct {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  fill: var(--cyan);
}
.reactor-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 3px;
  fill: var(--text-dim);
}
.spin-slow { animation: spin 24s linear infinite; transform-origin: 110px 110px; }
.spin-rev  { animation: spin 14s linear infinite reverse; transform-origin: 110px 110px; }
@keyframes spin { to { transform: rotate(360deg); } }
.reactor-sub {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 3px;
  color: var(--text-dim); margin-top: -8px;
}
.reactor.maxed #reactorProgress { stroke: var(--gold); }
.reactor.maxed .reactor-pct { fill: var(--gold); }
.reactor.maxed { animation: reactorFlare 2.2s ease-in-out infinite; }
@keyframes reactorFlare {
  0%,100% { filter: drop-shadow(0 0 6px rgba(255,184,0,.5)); }
  50% { filter: drop-shadow(0 0 22px rgba(255,184,0,.9)); }
}

/* ---------- Level / XP ---------- */
.header-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.level-line { font-family: var(--font-mono); font-size: 10px; letter-spacing: 2px; color: var(--text-dim); }
.level-num { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--orange); text-shadow: 0 0 14px rgba(255,107,0,.55); }
.xp-bar {
  width: 180px; height: 8px; margin-top: 4px;
  background: rgba(0,240,255,.08);
  border: 1px solid var(--cyan-dim);
  clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px);
}
.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--gold));
  box-shadow: 0 0 10px rgba(255,184,0,.7);
  width: 0%;
  transition: width .5s cubic-bezier(.22,1,.36,1);
}
.xp-text { font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); letter-spacing: 1px; }
.xp-total { font-family: var(--font-mono); font-size: 11px; color: var(--cyan); letter-spacing: 1px; }
.icon-btn {
  margin-top: 6px;
  background: none; border: 1px solid var(--cyan-dim); color: var(--cyan);
  width: 34px; height: 34px; cursor: pointer;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  transition: all .2s;
}
.icon-btn:hover { background: var(--cyan-faint); box-shadow: 0 0 12px rgba(0,240,255,.35); }

/* ---------- Motto Banner & Ticker ---------- */
.motto-banner {
  margin-top: 14px;
  padding: 14px 20px 14px 22px;
  border-left: 3px solid var(--orange);
  box-shadow: 0 0 24px rgba(255, 107, 0, 0.08), inset 0 0 40px rgba(0, 240, 255, 0.03);
}
.motto-label {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 2.5px;
  color: var(--gold); opacity: .8; margin-bottom: 7px;
}
.motto-quote {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 700; letter-spacing: 1.5px; line-height: 1.45;
  color: var(--cyan);
  text-shadow: 0 0 14px rgba(0, 240, 255, 0.4);
  min-height: 24px;
}
.motto-quote::after {
  content: '▌';
  margin-left: 2px;
  color: var(--orange);
  animation: cursorBlink 1s step-end infinite;
}
@keyframes cursorBlink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }
.motto-sub {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.5px;
  color: var(--text-dim); margin-top: 6px;
}
.ticker-line {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.5px;
  color: var(--cyan); margin-top: 6px; opacity: .9;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.35);
}
.ticker-line.maxed { color: var(--gold); text-shadow: 0 0 10px rgba(255, 184, 0, 0.55); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 8px; margin: 20px 0 18px; }
.tab {
  flex: 1;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2.5px;
  padding: 14px;
  background: rgba(10, 25, 47, 0.5);
  color: var(--text-dim);
  border: 1px solid rgba(0, 240, 255, 0.12);
  cursor: pointer;
  clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
  transition: all .25s;
}
.tab:hover { color: var(--cyan); border-color: var(--cyan-dim); }
.tab.active {
  color: var(--bg);
  background: linear-gradient(90deg, var(--cyan), #66f7ff);
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.45);
}

/* ---------- Sections ---------- */
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none;} }

.section-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap; margin-bottom: 14px;
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 700; letter-spacing: 3px;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(0,240,255,.4);
}
.progress-wrap { display: flex; align-items: center; gap: 12px; }
.progress {
  width: 220px; height: 10px;
  background: rgba(0,240,255,.07);
  border: 1px solid var(--cyan-dim);
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #0090b0, var(--cyan));
  box-shadow: 0 0 10px rgba(0,240,255,.7);
  transition: width .5s cubic-bezier(.22,1,.36,1);
}
.progress-text { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); letter-spacing: 1px; white-space: nowrap; }

/* ---------- Sectors & Directive rows ---------- */
.directive-list { display: flex; flex-direction: column; }
.sector-block { margin-bottom: 18px; display: flex; flex-direction: column; gap: 10px; }
.sector-head {
  display: flex; align-items: baseline; gap: 12px;
  padding: 4px 2px;
  border-bottom: 1px solid rgba(0, 240, 255, 0.15);
}
.sector-name {
  font-family: var(--font-display); font-size: 11px; font-weight: 700;
  letter-spacing: 2.5px; color: var(--orange);
  text-shadow: 0 0 10px rgba(255, 107, 0, 0.4);
}
.sector-range { font-family: var(--font-mono); font-size: 9px; letter-spacing: 1.5px; color: var(--text-dim); }
.sector-count {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1px;
  color: var(--cyan); text-shadow: 0 0 8px rgba(0,240,255,.4);
}
.time-badge {
  flex-shrink: 0;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1px;
  color: var(--cyan);
  background: rgba(0, 240, 255, 0.05);
  border: 1px solid var(--cyan-dim);
  padding: 5px 8px;
  white-space: nowrap;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
}
.directive.done .time-badge {
  color: var(--gold); border-color: rgba(255, 184, 0, 0.4);
  text-shadow: 0 0 8px rgba(255, 184, 0, 0.5);
}

.directive {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: var(--glass);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-left: 3px solid var(--accent, var(--cyan));
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
  transition: all .25s;
}
.directive:hover { border-color: rgba(0,240,255,.6); box-shadow: 0 0 16px rgba(0,240,255,.18); }
.directive.done {
  border-color: rgba(0,240,255,.35);
  background: rgba(0, 60, 80, 0.28);
}
.directive.done .d-name { color: var(--cyan); text-shadow: 0 0 10px rgba(0,240,255,.5); }
.directive.flash { animation: directiveFlash .55s ease; }
@keyframes directiveFlash {
  0% { box-shadow: 0 0 0 rgba(0,240,255,0); }
  30% { box-shadow: 0 0 30px rgba(0,240,255,.85); background: rgba(0,240,255,.18); }
  100% { box-shadow: 0 0 16px rgba(0,240,255,.12); }
}

.check {
  width: 34px; height: 34px; flex-shrink: 0;
  background: rgba(0,240,255,.05);
  border: 1px solid var(--cyan-dim);
  color: transparent;
  cursor: pointer;
  display: grid; place-items: center;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  transition: all .2s;
}
.check:hover { border-color: var(--cyan); box-shadow: 0 0 12px rgba(0,240,255,.4); }
.directive.done .check {
  color: var(--cyan);
  background: rgba(0,240,255,.15);
  animation: energyRing 2s ease-out infinite;
}
@keyframes energyRing {
  0% { box-shadow: 0 0 0 0 rgba(0,240,255,.55); }
  70% { box-shadow: 0 0 0 9px rgba(0,240,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,240,255,0); }
}

.d-info { flex: 1; min-width: 0; }
.d-name { font-size: 17px; font-weight: 600; letter-spacing: .5px; }
.d-meta { display: flex; gap: 8px; margin-top: 3px; flex-wrap: wrap; }
.tag {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 1.5px;
  color: var(--c, var(--cyan));
  border: 1px solid var(--c, var(--cyan));
  padding: 1px 7px;
  opacity: .85;
}
.freq-tag { font-family: var(--font-mono); font-size: 9px; letter-spacing: 1.5px; color: var(--text-dim); padding: 1px 0; }
.d-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.xp-val { font-family: var(--font-mono); font-size: 12px; color: var(--gold); letter-spacing: 1px; }
.streak {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 1px;
  color: var(--text-dim); display: flex; align-items: center; gap: 4px;
}
.streak.hot { color: var(--orange); text-shadow: 0 0 8px rgba(255,107,0,.7); }

.empty-state {
  text-align: center; padding: 60px 20px;
  font-family: var(--font-mono); font-size: 13px; letter-spacing: 2px;
  color: var(--text-dim);
}
.empty-state .big { font-family: var(--font-display); font-size: 16px; color: var(--cyan); display: block; margin-bottom: 10px; letter-spacing: 3px; }

/* ---------- Protocol Database ---------- */
.db-actions { display: flex; gap: 10px; }
.cat-block { margin-bottom: 22px; }
.cat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--cyan-dim);
  margin-bottom: 10px;
}
.cat-dot { width: 10px; height: 10px; background: var(--c, var(--cyan)); box-shadow: 0 0 10px var(--c, var(--cyan)); clip-path: polygon(50% 0,100% 50%,50% 100%,0 50%); }
.cat-name { font-family: var(--font-display); font-size: 13px; font-weight: 700; letter-spacing: 2.5px; color: var(--c, var(--cyan)); }
.cat-count { font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); }
.cat-head .row-actions { margin-left: auto; }

.habit-row {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 18px; margin-bottom: 8px;
  background: var(--glass);
  border: 1px solid rgba(0, 240, 255, 0.10);
  border-left: 3px solid var(--accent, var(--cyan));
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  transition: border-color .2s;
}
.habit-row:hover { border-color: var(--cyan-dim); }
.habit-row .h-name { flex: 1; font-size: 16px; font-weight: 600; min-width: 0; }
.habit-row .h-freq { font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); letter-spacing: 1px; width: 170px; }
.habit-row .h-xp { font-family: var(--font-mono); font-size: 11px; color: var(--gold); width: 60px; text-align: right; }
.habit-row .h-streak { font-family: var(--font-mono); font-size: 11px; color: var(--orange); width: 52px; text-align: right; }
.habit-row .h-today { font-family: var(--font-mono); font-size: 9px; letter-spacing: 1px; width: 74px; text-align: center; color: var(--cyan); border: 1px solid var(--cyan-dim); padding: 2px 0; }
.habit-row .h-today.done { background: rgba(0,240,255,.15); }

.row-actions { display: flex; gap: 6px; }
.mini-btn {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 1px;
  background: none; border: 1px solid rgba(0,240,255,.18); color: var(--text-dim);
  padding: 4px 8px; cursor: pointer; transition: all .2s;
}
.mini-btn:hover { color: var(--cyan); border-color: var(--cyan); }
.mini-btn.danger:hover { color: var(--red); border-color: var(--red); box-shadow: 0 0 10px rgba(255,56,96,.35); }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-display); font-size: 12px; font-weight: 700; letter-spacing: 2px;
  padding: 11px 20px;
  background: linear-gradient(90deg, #0090b0, var(--cyan));
  color: var(--bg); border: none; cursor: pointer;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  transition: all .2s;
}
.btn:hover { box-shadow: 0 0 20px rgba(0,240,255,.6); }
.btn.ghost {
  background: none; color: var(--cyan);
  border: 1px solid var(--cyan-dim);
}
.btn.ghost:hover { background: var(--cyan-faint); }
.btn.danger { background: linear-gradient(90deg, #8f1d3a, var(--red)); color: #fff; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 8, 16, 0.8);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  animation: fadeIn .2s ease;
}
.modal-overlay.hidden { display: none; }
.modal {
  width: min(460px, calc(100vw - 32px));
  max-height: 88vh; overflow-y: auto;
  padding: 24px 26px;
}
.modal-title {
  font-family: var(--font-display); font-size: 14px; font-weight: 700;
  letter-spacing: 3px; color: var(--cyan);
  border-bottom: 1px solid var(--cyan-dim);
  padding-bottom: 12px; margin-bottom: 18px;
}
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 2px;
  color: var(--text-dim); margin-bottom: 6px;
}
.field input[type="text"], .field input[type="number"], .field input[type="time"], .field select {
  width: 100%;
  background: rgba(0, 240, 255, 0.05);
  border: 1px solid var(--cyan-dim);
  color: var(--text);
  font-family: var(--font-body); font-size: 15px; font-weight: 600;
  padding: 9px 12px;
  outline: none;
  transition: all .2s;
}
.field input:focus, .field select:focus { border-color: var(--cyan); box-shadow: 0 0 12px rgba(0,240,255,.25); }
.field select option { background: var(--bg-2); }

.freq-options { display: flex; gap: 8px; }
.freq-opt {
  flex: 1; text-align: center;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 1px;
  padding: 8px 4px; cursor: pointer;
  border: 1px solid rgba(0,240,255,.15); color: var(--text-dim);
  transition: all .2s;
}
.freq-opt:hover { border-color: var(--cyan); }
.freq-opt.sel { background: rgba(0,240,255,.14); color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 10px rgba(0,240,255,.3); }

.day-picker { display: flex; gap: 5px; margin-top: 8px; }
.day-btn {
  flex: 1; padding: 7px 0;
  font-family: var(--font-mono); font-size: 10px;
  background: none; border: 1px solid rgba(0,240,255,.15); color: var(--text-dim);
  cursor: pointer; transition: all .15s;
}
.day-btn.sel { background: rgba(0,240,255,.16); color: var(--cyan); border-color: var(--cyan); }

.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 30px; height: 30px; cursor: pointer;
  border: 2px solid transparent;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  transition: all .15s;
}
.color-swatch.sel { border-color: #fff; box-shadow: 0 0 14px currentColor; transform: scale(1.1); }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-body-text { font-size: 15px; line-height: 1.5; color: var(--text); }
.field-error { font-family: var(--font-mono); font-size: 10px; color: var(--red); letter-spacing: 1px; margin-top: 6px; display: none; }
.field-error.show { display: block; }

/* ---------- Toasts / floaters ---------- */
.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 1px;
  color: var(--cyan);
  background: var(--glass);
  border: 1px solid var(--cyan-dim);
  border-left: 3px solid var(--cyan);
  padding: 10px 16px;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  animation: toastIn .25s ease;
  box-shadow: 0 0 16px rgba(0,240,255,.2);
}
.toast.gold { color: var(--gold); border-left-color: var(--gold); box-shadow: 0 0 16px rgba(255,184,0,.3); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px);} to { opacity: 1; transform: none;} }

.xp-float {
  position: fixed; z-index: 150;
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
  color: var(--gold); text-shadow: 0 0 12px rgba(255,184,0,.8);
  pointer-events: none;
  animation: xpFloat 1s ease-out forwards;
}
@keyframes xpFloat {
  0% { opacity: 0; transform: translateY(6px) scale(.8); }
  20% { opacity: 1; transform: translateY(0) scale(1.05); }
  100% { opacity: 0; transform: translateY(-36px) scale(1); }
}

.hud-footer {
  margin-top: 40px; text-align: center;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 3px;
  color: rgba(207,235,255,.25);
}

/* ---------- System Log Matrix ---------- */
.matrix-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mx-mode.sel { color: var(--cyan); border-color: var(--cyan); background: rgba(0,240,255,.12); box-shadow: 0 0 10px rgba(0,240,255,.25); }
.mx-range {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 2px;
  color: var(--cyan); min-width: 150px; text-align: center;
}
.telemetry { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.mx-sector-name {
  font-family: var(--font-display); font-size: 11px; font-weight: 700;
  letter-spacing: 2.5px; color: var(--orange);
  text-shadow: 0 0 10px rgba(255, 107, 0, 0.4);
  padding: 4px 2px; border-bottom: 1px solid rgba(0,240,255,.15);
  margin-bottom: 10px; margin-top: 18px;
}
.mx-grid { display: grid; gap: 3px; align-items: center; }
.mx-dh {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 1px;
  color: var(--text-dim); text-align: center; padding-bottom: 4px;
}
.mx-dh.today { color: var(--cyan); text-shadow: 0 0 8px rgba(0,240,255,.6); }
.mx-name {
  font-size: 13px; font-weight: 600; letter-spacing: .3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-right: 10px;
}
.mx-cell {
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.02);
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 10px;
  color: rgba(255, 255, 255, 0.18);
  transition: border-color .15s, box-shadow .15s;
}
.mx-cell.clickable { cursor: pointer; }
.mx-cell.clickable:hover { border-color: var(--cyan); box-shadow: 0 0 8px rgba(0,240,255,.35); }
.mx-cell.done {
  background: var(--cyan); border-color: var(--cyan);
  animation: cellPulse 2.4s ease-in-out infinite;
}
@keyframes cellPulse {
  0%,100% { box-shadow: 0 0 5px rgba(0,240,255,.7); }
  50% { box-shadow: 0 0 13px rgba(0,240,255,1); }
}
.mx-cell.off { border-color: transparent; background: transparent; }
.mx-cell.future { opacity: .3; }
.mx-cell.today {
  outline: 1px solid rgba(0, 240, 255, 0.55);
  outline-offset: 1px;
}
.mx-tip {
  position: fixed; z-index: 400;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1px;
  color: var(--cyan);
  background: rgba(10, 25, 47, 0.95);
  border: 1px solid var(--cyan-dim);
  padding: 7px 12px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 0 16px rgba(0,240,255,.25);
  transform: translateX(-50%);
}

/* ---------- KV Status & Data Terminal ---------- */
.kv-status {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 1.5px;
  color: var(--text-dim); margin-top: 5px;
}
.kv-status.online { color: var(--cyan); text-shadow: 0 0 8px rgba(0,240,255,.6); }
.kv-status.offline { color: var(--orange); text-shadow: 0 0 8px rgba(255,107,0,.55); }

.data-terminal {
  margin-top: 30px;
  padding: 18px 22px;
  border-left: 3px solid var(--cyan);
}
.dt-title {
  font-family: var(--font-display); font-size: 12px; font-weight: 700;
  letter-spacing: 3px; color: var(--cyan);
  text-shadow: 0 0 10px rgba(0,240,255,.4);
}
.dt-sub {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 1.5px;
  color: var(--text-dim); margin-top: 5px;
}
.dt-actions { display: flex; gap: 12px; align-items: stretch; margin-top: 14px; flex-wrap: wrap; }
.dt-drop {
  flex: 1; min-width: 220px;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.5px;
  color: var(--text-dim);
  border: 1px dashed rgba(0,240,255,.3);
  padding: 12px;
  cursor: pointer;
  transition: all .2s;
}
.dt-drop:hover, .dt-drop.over {
  color: var(--cyan); border-color: var(--cyan);
  background: rgba(0,240,255,.06); box-shadow: 0 0 14px rgba(0,240,255,.25);
}

/* ---------- Security Gate ---------- */
.header-btns { display: flex; gap: 8px; margin-top: 6px; }
.header-btns .icon-btn { margin-top: 0; }

.gate {
  position: fixed; inset: 0; z-index: 500;
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(0, 240, 255, 0.07) 0%, transparent 55%),
    var(--bg);
}
.gate.hidden { display: none; }
.gate-panel {
  width: min(400px, calc(100vw - 40px));
  padding: 42px 34px 34px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.gate-ring {
  position: absolute; top: -70px; left: 50%;
  width: 140px; height: 140px; margin-left: -70px;
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 50%;
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.15), inset 0 0 30px rgba(0, 240, 255, 0.08);
}
.gate-title {
  font-family: var(--font-display); font-size: 16px; font-weight: 900;
  letter-spacing: 4px; color: var(--cyan);
  text-shadow: 0 0 16px rgba(0, 240, 255, 0.6);
  margin-top: 30px;
}
.gate-sub {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 2px;
  color: var(--gold); margin-top: 8px; opacity: .85;
}
.gate-input {
  width: 180px; margin: 26px auto 14px; display: block;
  background: rgba(0, 240, 255, 0.06);
  border: 1px solid var(--cyan-dim);
  color: var(--cyan);
  font-family: var(--font-mono); font-size: 24px; letter-spacing: 10px;
  text-align: center; padding: 12px 8px 12px 14px;
  outline: none;
  animation: gatePulse 2.2s ease-in-out infinite;
  caret-color: var(--gold);
}
@keyframes gatePulse {
  0%,100% { box-shadow: 0 0 8px rgba(0,240,255,.15), inset 0 0 8px rgba(0,240,255,.05); }
  50% { box-shadow: 0 0 22px rgba(0,240,255,.45), inset 0 0 14px rgba(0,240,255,.12); }
}
.gate-input::placeholder { color: rgba(0,240,255,.25); }
.gate-input:disabled { opacity: .35; animation: none; }
.gate-btn { display: block; margin: 0 auto; padding: 11px 34px; }
.gate-btn:disabled { opacity: .35; cursor: not-allowed; }
.gate-status {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 2px;
  color: var(--text-dim); margin-top: 20px; min-height: 14px;
}
.gate-status.error { color: var(--orange); text-shadow: 0 0 10px rgba(255, 107, 0, 0.6); }
.gate-status.locked { color: var(--red); text-shadow: 0 0 10px rgba(255, 56, 96, 0.6); }
.gate-panel.shake { animation: gateShake .4s ease; }
@keyframes gateShake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .hud-header { grid-template-columns: 1fr; text-align: center; padding: 20px; }
  .header-right { align-items: center; text-align: center; }
  .status-line { justify-content: center; }
  .tabs { flex-direction: column; }
  .habit-row { flex-wrap: wrap; }
  .habit-row .h-freq, .habit-row .h-xp, .habit-row .h-streak { width: auto; }
  .directive { flex-wrap: wrap; }
  .progress { width: 140px; }
}
