:root {
  --bg-deep: #050505;
  --bg-panel: #0d0d11;
  --bg-panel-inner: #14141b;
  --kitt-red: #ff1e27;
  --kitt-amber: #ff9900;
  --kitt-yellow: #ffbe0b;
  --kitt-green: #00e676;
  --crt-green: #38ff7a;
  --crt-amber: #ffb340;
  --text-main: #f5f5f7;
  --text-muted: #9e9ea8;
  --border-red: rgba(255, 30, 39, 0.45);
  --font-display: "Antonio", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background-color: var(--bg-deep); color: var(--text-main);
  font-family: var(--font-display); overflow: hidden; user-select: none;
}

.hidden { display: none !important; }

.view {
  width: 100%; height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top, 8px) 10px env(safe-area-inset-bottom, 10px);
  background: radial-gradient(circle at 50% 12%, rgba(255, 30, 39, 0.14), transparent 60%), #050505;
}

.login-box {
  width: 100%; max-width: 400px; background: var(--bg-panel);
  border: 1.5px solid var(--border-red); border-radius: 20px;
  padding: 24px 20px; display: flex; flex-direction: column; gap: 12px; text-align: center;
  box-shadow: 0 0 35px rgba(255, 30, 39, 0.2);
}

#login-form { display: flex; flex-direction: column; gap: 10px; }
.login-box input[type="password"] {
  width: 100%; padding: 13px; background: #070709; border: 1px solid var(--border-red);
  border-radius: 10px; color: var(--text-main); font-family: var(--font-mono);
  font-size: 15px; text-align: center; outline: none;
}
.login-box input[type="password"]:focus {
  border-color: var(--kitt-amber); box-shadow: 0 0 12px rgba(255, 153, 0, 0.35);
}
.error { min-height: 20px; color: var(--kitt-red); font-family: var(--font-mono); font-size: 12px; }

.kitt-device {
  width: 100%; max-width: 470px; height: 100%; max-height: 920px;
  background: linear-gradient(180deg, #13131a 0%, #08080b 100%);
  border: 1.5px solid var(--border-red); border-radius: 22px;
  padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 9px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.9), 0 0 24px rgba(255, 30, 39, 0.16);
}

.header { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid rgba(255, 30, 39, 0.25); padding-bottom: 4px; }
.header-titles { text-align: left; min-width: 0; }
.title-main { font-size: 1.32rem; font-weight: 700; letter-spacing: 0.1em; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-sub { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.12em; color: var(--kitt-amber); text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userline { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
#username { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; max-width: 80px; overflow: hidden; text-overflow: ellipsis; }

/* 8-Kammer K.I.T.T. Scanner */
.scanner-bar {
  position: relative; width: 100%; height: 24px; background: #160203; border: 2px solid #2b0608;
  border-radius: 6px; overflow: hidden; flex-shrink: 0; box-shadow: inset 0 0 12px #000, 0 0 16px rgba(255, 30, 39, 0.35);
}
.scanner-track { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; padding: 3px; z-index: 2; pointer-events: none; }
.scanner-cell { border-radius: 2px; background: rgba(60, 0, 5, 0.35); border: 1px solid rgba(255, 60, 60, 0.12); }
.scanner-light {
  position: absolute; top: 2px; bottom: 2px; width: 34%; left: 0; border-radius: 4px;
  background: radial-gradient(ellipse at center, #ffffff 0%, #ff6b6b 18%, #ff1e27 48%, rgba(190, 0, 10, 0.55) 75%, transparent 100%);
  filter: blur(1px); box-shadow: 0 0 18px 4px #ff1e27, 0 0 32px 8px rgba(255, 30, 39, 0.65);
  animation: kitt-sweep 1.95s ease-in-out infinite alternate; z-index: 1;
}
.scanner-bar.pursuit .scanner-light { animation-duration: 1.05s; }
@keyframes kitt-sweep { 0% { transform: translateX(-8%); } 100% { transform: translateX(202%); } }

.console-upper { display: grid; grid-template-columns: 122px 1fr; gap: 10px; flex-shrink: 0; }
.voice-box-frame { background: #060608; border: 1.5px solid #2b2b36; border-radius: 12px; padding: 8px 8px 5px; display: flex; flex-direction: column; justify-content: space-between; }
.voice-box-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; height: 112px; }
.voice-column { display: flex; flex-direction: column; justify-content: space-between; gap: 4px; }
.led-segment { flex: 1; background: #270407; border: 1px solid #45090e; border-radius: 3px; transition: background-color 0.04s, box-shadow 0.04s; }
.led-segment.active { background: #ff1e27; border-color: #ff9a9e; box-shadow: 0 0 8px #ff1e27, inset 0 0 4px #fff; }
.voice-label { margin-top: 5px; text-align: center; font-family: var(--font-mono); font-size: 0.56rem; letter-spacing: 0.08em; color: var(--text-muted); }

.dashboard-grid { display: grid; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(3, 1fr); gap: 7px; }
.dash-btn {
  appearance: none; border: 1.5px solid #2d2d38; border-radius: 8px !important;
  background: linear-gradient(180deg, #1b1b22 0%, #111116 100%); color: #7c7c88;
  font-family: var(--font-display); font-size: 0.82rem; font-weight: 700; letter-spacing: 0.08em;
  padding: 6px 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; text-align: center;
}
.dash-btn:active { transform: scale(0.96); }
.dash-btn.active-yellow { background: linear-gradient(180deg, #ffca28 0%, #ff9900 100%); color: #050505; border-color: #ffe082; box-shadow: 0 0 12px rgba(255, 190, 11, 0.55); }
.dash-btn.active-red { background: linear-gradient(180deg, #ff4b52 0%, #d80012 100%); color: #fff; border-color: #ff999e; box-shadow: 0 0 12px rgba(255, 30, 39, 0.65); }
.dash-btn.active-green { background: linear-gradient(180deg, #38ff90 0%, #00b85c 100%); color: #04140a; border-color: #9effc6; box-shadow: 0 0 12px rgba(0, 230, 118, 0.55); }

.crt-display {
  position: relative; flex: 1; min-height: 120px;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.22) 0px, rgba(0,0,0,0.22) 1px, transparent 1px, transparent 3px), radial-gradient(circle at 50% 50%, #0a1f12 0%, #040d07 100%);
  border: 1.5px solid rgba(0, 230, 118, 0.38); border-radius: 12px; padding: 10px 12px;
  font-family: var(--font-mono); font-size: 0.84rem; line-height: 1.45; color: var(--crt-green);
  overflow-y: auto; user-select: text;
}
.crt-display .sys { color: var(--crt-amber); margin-bottom: 6px; }
.crt-display .u { color: #9be7ff; margin: 6px 0 3px; padding-left: 8px; border-left: 2px solid #4fc3f7; }
.crt-display .u::before { content: "DANIEL > "; font-weight: 700; }
.crt-display .a { color: var(--crt-green); margin: 4px 0 8px; padding-left: 8px; border-left: 2px solid var(--crt-green); white-space: pre-wrap; }
.crt-display .a::before { content: "K.I.T.T. > "; font-weight: 700; color: var(--kitt-amber); }

.crt-display.statusline {
  flex: 0 0 auto; min-height: 0; padding: 6px 11px; display: flex; align-items: center; gap: 8px;
  font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--kitt-amber);
  border-color: rgba(255, 153, 0, 0.35);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--kitt-green); box-shadow: 0 0 8px var(--kitt-green); flex-shrink: 0; }
.status-dot.busy { background: var(--kitt-amber); box-shadow: 0 0 8px var(--kitt-amber); }
.status-dot.rec { background: var(--kitt-red); box-shadow: 0 0 10px var(--kitt-red); }

.text-input-row { display: flex; gap: 6px; flex-shrink: 0; }
.text-input-row input {
  flex: 1; background: #080a0d; border: 1px solid rgba(255, 30, 39, 0.38); border-radius: 999px;
  padding: 9px 14px; color: var(--text-main); font-family: var(--font-mono); font-size: 0.82rem; outline: none;
}
.text-input-row input:focus { border-color: var(--kitt-amber); }
.send-btn {
  background: #1d1d26; color: var(--kitt-amber); border: 1px solid rgba(255, 153, 0, 0.55);
  border-radius: 999px; padding: 0 16px; font-family: var(--font-display); font-weight: 700; font-size: 0.85rem; cursor: pointer;
}

.talk-btn {
  appearance: none; width: 100%; padding: 13px 16px; border-radius: 999px;
  border: 1.5px solid #ff7b80; background: linear-gradient(180deg, #ff2a32 0%, #b80009 100%);
  color: #fff; font-family: var(--font-display); font-size: 1.05rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer;
  box-shadow: 0 0 18px rgba(255, 30, 39, 0.55); flex-shrink: 0;
}
.talk-btn:active { transform: scale(0.98); }
.talk-btn.recording { background: linear-gradient(180deg, #ffbe0b 0%, #ff6d00 100%); color: #050505; border-color: #fff3b0; box-shadow: 0 0 24px rgba(255, 190, 11, 0.9); }
.talk-btn.speaking { background: linear-gradient(180deg, #00e676 0%, #008e46 100%); color: #03140a; border-color: #b9f6ca; box-shadow: 0 0 20px rgba(0, 230, 118, 0.75); }
.talk-btn.minimal { width: auto; padding: 5px 10px; font-size: 0.72rem; background: #17171f; color: var(--text-main); border: 1px solid var(--border-red); box-shadow: none; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.82); backdrop-filter: blur(5px);
  z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 14px;
}
.modal-panel { width: 100%; max-width: 450px; max-height: 90dvh; background: var(--bg-panel); border: 1.5px solid var(--kitt-red); border-radius: 18px; display: flex; flex-direction: column; overflow: hidden; }
.modal-header { padding: 14px 16px; border-bottom: 1px solid var(--border-red); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 14px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 12px 16px; border-top: 1px solid var(--border-red); background: #09090d; }
.cfg-section { background: var(--bg-panel-inner); border: 1px solid rgba(255, 30, 39, 0.25); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.cfg-heading { font-size: 0.9rem; font-weight: 700; color: var(--kitt-amber); border-bottom: 1px solid rgba(255, 153, 0, 0.2); padding-bottom: 4px; }
.cfg-label { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); }
.cfg-row-between { display: flex; align-items: center; justify-content: space-between; }
.mini-action-btn { background: transparent; border: 1px solid var(--kitt-amber); color: var(--kitt-amber); border-radius: 999px; padding: 2px 8px; font-family: var(--font-mono); font-size: 0.65rem; cursor: pointer; }
.cfg-select, .cfg-input { width: 100%; padding: 9px 10px; background: #07070a; border: 1px solid rgba(255, 30, 39, 0.4); border-radius: 8px; color: var(--text-main); font-family: var(--font-mono); font-size: 0.78rem; outline: none; }
.cfg-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-family: var(--font-mono); font-size: 0.74rem; }
.cfg-actions-inline { display: flex; justify-content: flex-end; margin-top: 4px; }
.cfg-feedback { min-height: 18px; font-family: var(--font-mono); font-size: 0.74rem; color: var(--kitt-green); text-align: center; }