/* ═══════════════════════════════════════════════════════════════
   SIGNSPEAK AI — FUTURISTIC DARK UI  v2.1
   Aesthetic: Cyberpunk terminal meets holographic AR overlay
   ═══════════════════════════════════════════════════════════════ */

/* ─── CSS VARIABLES ─────────────────────────────────────────── */
:root {
  --bg-base:       #F8FAFC;
  --bg-panel:      #FFFFFF;
  --bg-panel-2:    #FFFFFF;
  --bg-border:     #E5E7EB;
  --cyan:          #10B981;
  --cyan-dim:      #ECFDF5;
  --cyan-glow:     transparent;
  --magenta:       #059669;
  --magenta-dim:   #ECFDF5;
  --green:         #10B981;
  --green-dim:     #ECFDF5;
  --amber:         #D97706;
  --red:           #DC2626;
  --red-dim:       #FEF2F2;
  --text-primary:  #111827;
  --text-secondary:#6B7280;
  --text-dim:      #9CA3AF;
  --font-display:  'Inter', sans-serif;
  --font-mono:     'Inter', sans-serif;
  --font-body:     'Inter', sans-serif;

  --panel-w:       230px;
  --border-radius: 10px;
  --transition:    0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  overflow: hidden;
  /* Prevent text selection on rapid clicking */
  -webkit-user-select: none;
  user-select: none;
}

/* Re-enable text selection for inputs */
input, textarea { -webkit-user-select: text; user-select: text; }

/* ─── ATMOSPHERIC EFFECTS ────────────────────────────────────── */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}

.noise-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* ─── STATUS BAR ──────────────────────────────────────────────── */
.status-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 44px;
  background: rgba(5, 8, 16, 0.95);
  border-bottom: 1px solid var(--bg-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.status-bar::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--magenta), transparent);
  opacity: 0.6;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--text-primary);
}

.logo-text .accent { color: var(--cyan); }

.version-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  border: 1px solid var(--bg-border);
  padding: 2px 6px;
  border-radius: 2px;
  letter-spacing: 1px;
}

.status-center {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 0 8px;
}

.status-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  padding: 4px 10px;
  border: 1px solid var(--bg-border);
  border-radius: 20px;
  background: var(--bg-panel);
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: var(--transition);
}

.status-pill.online {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-dim);
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.2);
}

.mode-pill.training {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(255, 183, 0, 0.1);
}

/* Status dots */
.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  animation: pulse-dot 2s infinite;
}
.dot.green  { background: var(--green);   animation: pulse-dot-green 2s infinite; }
.dot.cyan   { background: var(--cyan);    animation: pulse-dot-cyan  2s infinite; }
.dot.amber  { background: var(--amber);   animation: pulse-dot-amber 2s infinite; }
.dot.red    { background: var(--red); }

@keyframes pulse-dot        { 0%,100%{opacity:1}50%{opacity:0.3} }
@keyframes pulse-dot-green  { 0%,100%{opacity:1;box-shadow:0 0 4px var(--green)}50%{opacity:0.4;box-shadow:none} }
@keyframes pulse-dot-cyan   { 0%,100%{opacity:1;box-shadow:0 0 4px var(--cyan)}50%{opacity:0.4;box-shadow:none} }
@keyframes pulse-dot-amber  { 0%,100%{opacity:1;box-shadow:0 0 4px var(--amber)}50%{opacity:0.4;box-shadow:none} }

.status-right {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}

.device-select, .source-label { display:block; width:100%; }
.device-select { background:var(--bg-panel-2); color:var(--text-primary); border:1px solid var(--bg-border); padding:8px; margin:6px 0 10px; font-family:var(--font-mono); }
.source-label { color:var(--text-secondary); font-family:var(--font-mono); font-size:10px; letter-spacing:1px; margin-top:6px; }
.device-status { font-family:var(--font-mono); font-size:11px; color:var(--green); padding:5px 0; }
.device-help { color:var(--text-secondary); font-size:11px; line-height:1.35; margin:7px 0; }
.device-help code { color:var(--cyan); }

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--cyan);
  font-weight: bold;
  text-shadow: 0 0 8px var(--cyan-glow);
  min-width: 28px;
  text-align: center;
}

/* ─── MAIN LAYOUT ─────────────────────────────────────────────── */
.main-layout {
  display: flex;
  height: 100vh;
  padding-top: 44px;
  overflow: hidden;
}

/* ─── SIDE PANELS ─────────────────────────────────────────────── */
.side-panel {
  width: var(--panel-w);
  background: var(--bg-panel);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  /* Smooth scroll on iOS */
  -webkit-overflow-scrolling: touch;
  /* Reserve space for scrollbar to prevent layout shift */
  scrollbar-gutter: stable;
}

.left-panel  { border-right: 1px solid var(--bg-border); }
.right-panel { border-left: 1px solid var(--bg-border); }

/* Custom scrollbar */
.side-panel::-webkit-scrollbar { width: 3px; }
.side-panel::-webkit-scrollbar-track { background: var(--bg-base); }
.side-panel::-webkit-scrollbar-thumb { background: var(--bg-border); border-radius: 2px; }
.side-panel::-webkit-scrollbar-thumb:hover { background: var(--cyan); }

/* ─── PANEL SECTIONS ──────────────────────────────────────────── */
.panel-section {
  background: var(--bg-panel-2);
  border: 1px solid var(--bg-border);
  border-radius: var(--border-radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--transition);
}

.panel-title {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--cyan);
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--bg-border);
  margin-bottom: 2px;
}

.title-icon { font-size: 12px; }

/* ─── BUTTONS ─────────────────────────────────────────────────── */
.btn {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 1.5px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  width: 100%;
  justify-content: center;
  position: relative;
  overflow: hidden;
  outline: none;
  /* Prevent double-tap zoom on mobile */
  touch-action: manipulation;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.05), transparent);
  opacity: 0;
  transition: var(--transition);
}

.btn:hover::before { opacity: 1; }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.btn-icon { font-size: 12px; }

.btn-primary {
  background: var(--cyan-dim);
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.1), inset 0 0 12px rgba(0, 245, 255, 0.05);
}
.btn-primary:hover {
  background: rgba(0, 245, 255, 0.2);
  box-shadow: 0 0 20px rgba(0, 245, 255, 0.25);
}

.btn-accent {
  background: var(--magenta-dim);
  border-color: var(--magenta);
  color: var(--magenta);
  box-shadow: 0 0 12px rgba(255, 0, 170, 0.1);
}
.btn-accent:hover {
  background: rgba(255, 0, 170, 0.2);
  box-shadow: 0 0 20px rgba(255, 0, 170, 0.25);
}

.btn-secondary {
  background: rgba(255,255,255,0.03);
  border-color: var(--bg-border);
  color: var(--text-secondary);
}
.btn-secondary:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}
.btn-danger:hover {
  background: rgba(255, 51, 85, 0.3);
  box-shadow: 0 0 16px rgba(255, 51, 85, 0.2);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.hidden { display: none !important; }

/* Arduino Web Serial controls */
.arduino-status {
  padding: 7px 8px;
  border: 1px solid var(--bg-border);
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  background: rgba(255,255,255,0.025);
  font-family: var(--font-mono);
  font-size: 10px;
}

.arduino-status.connected {
  color: var(--green);
  border-color: var(--green);
  background: var(--green-dim);
}

.arduino-status.connecting {
  color: var(--cyan);
  border-color: var(--cyan);
  background: var(--cyan-dim);
}

.arduino-status.unsupported {
  color: var(--red);
  border-color: var(--red);
  background: var(--red-dim);
}

.arduino-details {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
}

.arduino-details div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 9px;
}

.arduino-details dt {
  color: var(--text-muted);
}

.arduino-details dd {
  margin: 0;
  color: var(--text-primary);
  text-align: right;
  overflow-wrap: anywhere;
}

.arduino-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.arduino-actions .btn {
  padding-inline: 6px;
  letter-spacing: 1px;
}

.arduino-error {
  margin: 0;
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1.35;
}

/* ─── MODE TOGGLE ─────────────────────────────────────────────── */
.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--bg-border);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.mode-btn {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 1.5px;
  padding: 8px 4px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: var(--transition);
  touch-action: manipulation;
  outline: none;
}

.mode-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }

.mode-btn.active {
  background: var(--cyan-dim);
  color: var(--cyan);
}

.mode-btn:nth-child(2).active {
  background: var(--magenta-dim);
  color: var(--magenta);
}

/* ─── TOGGLE SWITCHES ─────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 0;
  touch-action: manipulation;
}

.toggle-row input[type="checkbox"] {
  /* Visually hidden but accessible */
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
  pointer-events: none;
}

.toggle-switch {
  width: 32px; height: 16px;
  border-radius: 8px;
  border: 1px solid var(--bg-border);
  background: var(--bg-base);
  position: relative;
  margin-left: auto;
  flex-shrink: 0;
  transition: var(--transition);
}

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

.toggle-row input:checked ~ .toggle-switch {
  background: var(--cyan-dim);
  border-color: var(--cyan);
}

.toggle-row input:checked ~ .toggle-switch::after {
  left: 18px;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
}

/* Focus ring on toggle */
.toggle-row:focus-within .toggle-switch {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.toggle-label {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.5px;
  pointer-events: none;
}

/* ─── SLIDERS ─────────────────────────────────────────────────── */
.slider-label {
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  letter-spacing: normal;
}

/* Keep a generous hit area; only the native track is painted. */
input.slider {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-width: 0;
  height: 44px;
  min-height: 44px;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
}

input.slider:focus-visible {
  outline: 2px solid #047857;
  outline-offset: 2px;
}

.slider::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--bg-border);
  border-radius: 999px;
}

.slider::-moz-range-track {
  height: 6px;
  background: var(--bg-border);
  border-radius: 999px;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border: 2px solid #047857;
  border-radius: 50%;
  background: var(--green);
  box-shadow: none;
  cursor: pointer;
}

.slider::-moz-range-thumb {
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  border: 2px solid #047857;
  border-radius: 50%;
  background: var(--green);
  box-shadow: none;
  cursor: pointer;
}

/* ─── VIEWPORT / CAMERA ───────────────────────────────────────── */
.viewport-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-width: 0;
}

.camera-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #020408;
  min-height: 360px;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #0a1020 0%, #020408 70%);
  z-index: 1;
}

.placeholder-inner {
  text-align: center;
  color: var(--text-dim);
}

.hex-icon {
  font-size: 64px;
  color: var(--bg-border);
  animation: pulse-hex 3s ease-in-out infinite;
  display: block;
}

@keyframes pulse-hex {
  0%, 100% { color: var(--bg-border); text-shadow: none; }
  50% { color: var(--cyan); text-shadow: 0 0 30px var(--cyan-glow), 0 0 60px var(--cyan-dim); }
}

.placeholder-inner p {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 3px;
  margin-top: 10px;
}

.placeholder-sub {
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 1px;
  margin-top: 6px;
  color: var(--text-dim);
}

#inputVideo {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  opacity: 0;
  transition: opacity 0.3s ease;
  /* GPU compositing layer */
  will-change: opacity;
  backface-visibility: hidden;
}

#outputCanvas {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  transform: none;
  z-index: 5;
  /* GPU compositing for smooth drawing */
  will-change: transform;
}

/* ─── CORNER DECORATIONS ──────────────────────────────────────── */
.corner {
  position: absolute;
  width: 24px; height: 24px;
  z-index: 10;
  pointer-events: none;
  opacity: 0.8;
}

.corner.tl { top: 12px; left: 12px;   border-top: 2px solid var(--cyan); border-left: 2px solid var(--cyan); }
.corner.tr { top: 12px; right: 12px;  border-top: 2px solid var(--cyan); border-right: 2px solid var(--cyan); }
.corner.bl { bottom: 56px; left: 12px;  border-bottom: 2px solid var(--cyan); border-left: 2px solid var(--cyan); }
.corner.br { bottom: 56px; right: 12px; border-bottom: 2px solid var(--cyan); border-right: 2px solid var(--cyan); }

/* ─── HOLD INDICATOR ──────────────────────────────────────────── */
.hold-indicator {
  position: absolute;
  bottom: 70px;
  right: 24px;
  width: 64px; height: 64px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.hold-indicator.active { display: flex; }

.hold-ring {
  position: absolute;
  width: 64px; height: 64px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(255,255,255,0.08);
  stroke-width: 6;
}

.ring-fill {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 276.46;
  stroke-dashoffset: 276.46;
  transition: stroke-dashoffset 0.1s linear;
  filter: drop-shadow(0 0 4px var(--cyan));
}

.hold-label {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--cyan);
  letter-spacing: 1px;
  z-index: 1;
  text-shadow: 0 0 6px var(--cyan);
}

/* ─── PREDICTION OVERLAY ──────────────────────────────────────── */
.prediction-overlay {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 20;
  pointer-events: none;
  min-width: 200px;
  /* Frosted glass backing */
  background: rgba(2, 4, 8, 0.35);
  padding: 8px 20px;
  border-radius: 6px;
  border: 1px solid rgba(0,245,255,0.08);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.pred-sign {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 900;
  color: var(--text-primary);
  text-shadow: 0 0 20px var(--cyan-glow), 0 2px 4px rgba(0,0,0,0.8);
  letter-spacing: 4px;
  transition: color 0.2s ease, text-shadow 0.2s ease;
  line-height: 1.1;
}

.pred-sign.flash {
  color: var(--cyan);
  text-shadow: 0 0 40px var(--cyan), 0 0 80px var(--cyan-glow);
  animation: flash-text 0.6s ease forwards;
}

@keyframes flash-text {
  0%  { transform: scale(1.2); }
  100%{ transform: scale(1); }
}

.pred-conf {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 1px;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

/* ─── SENTENCE STRIP ──────────────────────────────────────────── */
.sentence-strip {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  background: rgba(5, 8, 16, 0.88);
  border-top: 1px solid var(--bg-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 20;
}

.sentence-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 1px;
  flex-shrink: 0;
}

#sentenceText {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--cyan);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 0 12px var(--cyan-glow);
}

.clear-sentence-btn,
.speak-sentence-btn {
  background: none;
  border: 1px solid var(--bg-border);
  color: var(--text-secondary);
  cursor: pointer;
  width: 24px; height: 24px;
  border-radius: 3px;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
  touch-action: manipulation;
}

.clear-sentence-btn:hover  { border-color: var(--red);   color: var(--red); }
.speak-sentence-btn:hover  { border-color: var(--green); color: var(--green); }

/* ─── HISTORY BAR ─────────────────────────────────────────────── */
.history-bar {
  height: 42px;
  background: var(--bg-panel);
  border-top: 1px solid var(--bg-border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  overflow: hidden;
  flex-shrink: 0;
}

.history-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 1.5px;
  flex-shrink: 0;
}

.history-chips {
  flex: 1;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  align-items: center;
  /* Scroll on mobile */
  -webkit-overflow-scrolling: touch;
}
.history-chips::-webkit-scrollbar { display: none; }

.history-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--bg-border);
  background: var(--bg-panel-2);
  color: var(--text-secondary);
  white-space: nowrap;
  animation: chip-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
}

.history-chip:first-child {
  border-color: var(--cyan);
  color: var(--cyan);
  background: var(--cyan-dim);
  box-shadow: 0 0 8px rgba(0, 245, 255, 0.15);
}

@keyframes chip-in {
  from { transform: translateY(-10px) scale(0.8); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.clear-btn {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
  background: none;
  border: 1px solid var(--bg-border);
  color: var(--text-dim);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 3px;
  transition: var(--transition);
  flex-shrink: 0;
  touch-action: manipulation;
}
.clear-btn:hover { border-color: var(--red); color: var(--red); }

/* ─── TRAINING SECTION ────────────────────────────────────────── */
/* FIX: was missing proper display:flex in .visible */
.train-section { display: none; }
.train-section.visible { display: flex; }

.label-input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--bg-border);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px 10px;
  letter-spacing: 1px;
  outline: none;
  transition: var(--transition);
}

.label-input:focus {
  border-color: var(--magenta);
  box-shadow: 0 0 12px rgba(255, 0, 170, 0.15);
}

.label-input::placeholder { color: var(--text-dim); }

/* High-visibility capture flash */
.label-input.capture-flash {
  border-color: var(--green);
  box-shadow: 0 0 16px rgba(0, 255, 136, 0.3);
  animation: input-flash 0.4s ease forwards;
}

@keyframes input-flash {
  0%   { background: rgba(0,255,136,0.15); }
  100% { background: var(--bg-base); }
}

.sample-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  text-align: center;
  padding: 2px 0;
}

/* ─── CATEGORY SELECT (Day 1 — scalable context engine) ─────────── */
.category-select {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--bg-border);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 7px 10px;
  letter-spacing: 0.5px;
  outline: none;
  transition: var(--transition);
  cursor: pointer;
}

.category-select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.15);
}

/* ─── GESTURE LIBRARY ─────────────────────────────────────────── */
.gesture-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.gesture-list::-webkit-scrollbar { width: 3px; }
.gesture-list::-webkit-scrollbar-track { background: transparent; }
.gesture-list::-webkit-scrollbar-thumb { background: var(--bg-border); }

.empty-lib {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  padding: 20px 0;
}

.gesture-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border: 1px solid var(--bg-border);
  border-radius: 3px;
  background: var(--bg-base);
  gap: 6px;
  animation: item-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: var(--transition);
}

.gesture-item:hover {
  border-color: var(--cyan);
  background: var(--cyan-dim);
}

@keyframes item-in {
  from { transform: translateX(12px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.gesture-name {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gesture-category {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--cyan);
  background: var(--cyan-dim);
  padding: 2px 5px;
  border-radius: 2px;
  flex-shrink: 0;
}

.gesture-samples {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  background: var(--bg-border);
  padding: 2px 5px;
  border-radius: 2px;
  flex-shrink: 0;
}

.gesture-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 2px;
  transition: var(--transition);
  flex-shrink: 0;
  touch-action: manipulation;
}
.gesture-delete:hover { color: var(--red); }

/* ─── STATS GRID ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.stat-box {
  background: var(--bg-base);
  border: 1px solid var(--bg-border);
  border-radius: 3px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: var(--transition);
}

.stat-box-label {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.stat-box-val {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--red);
  font-weight: bold;
  transition: color var(--transition);
}

.stat-box-val.on {
  color: var(--green);
  text-shadow: 0 0 8px rgba(0, 255, 136, 0.4);
}

/* ─── DAY 2 — FACIAL GRAMMAR BADGES ───────────────────────────── */
.grammar-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.grammar-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  background: var(--bg-base);
  border: 1px solid var(--bg-border);
  padding: 4px 7px;
  border-radius: 3px;
  transition: var(--transition);
  opacity: 0.5;
}

.grammar-badge.active {
  color: var(--cyan);
  border-color: var(--cyan);
  background: var(--cyan-dim);
  opacity: 1;
  box-shadow: 0 0 10px rgba(0, 245, 255, 0.25);
}

/* ─── TOAST ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-panel-2);
  border: 1px solid var(--bg-border);
  border-radius: 4px;
  padding: 10px 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-primary);
  z-index: 5000;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success { border-color: var(--green);   color: var(--green);   background: var(--green-dim); }
.toast.error   { border-color: var(--red);     color: var(--red);     background: var(--red-dim); }
.toast.info    { border-color: var(--cyan);    color: var(--cyan);    background: var(--cyan-dim); }
.toast.warning { border-color: var(--amber);   color: var(--amber);   background: rgba(255,183,0,0.1); }

/* ─── MODAL ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: overlay-in 0.2s ease;
}

.modal-overlay.hidden { display: none !important; }

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--bg-border);
  border-radius: 6px;
  padding: 24px;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 0 60px rgba(0,0,0,0.6), 0 0 20px rgba(0,245,255,0.05);
  animation: modal-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-in {
  from { transform: scale(0.9) translateY(10px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal h3 {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--cyan);
  margin-bottom: 12px;
}

.modal p {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.modal-btns { display: flex; gap: 8px; }
.modal-btns .btn { flex: 1; }

/* ─── LOADING INDICATOR ───────────────────────────────────────── */
.loading-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--bg-border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

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

/* ─── RESPONSIVE — 900px ──────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --panel-w: 190px; }

  .status-bar {
    height: auto;
    padding: 6px 12px;
    gap: 4px;
    flex-wrap: wrap;
  }

  .status-right { display: none; }

  .status-center {
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .status-pill { font-size: 9px; padding: 3px 8px; }
  .logo-text   { font-size: 13px; }
}

/* ─── RESPONSIVE — 640px ──────────────────────────────────────── */
@media (max-width: 640px) {
  html, body { overflow: auto; }

  .main-layout {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .viewport-wrapper { order: 1; }
  .left-panel        { order: 0; }
  .right-panel       { order: 2; }

  .camera-container { min-height: 280px; max-height: 50vw; }

  .side-panel {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    padding: 8px;
    gap: 8px;
    max-height: 140px;
    scrollbar-gutter: auto;
  }

  .side-panel::-webkit-scrollbar { height: 3px; width: auto; }

  .panel-section {
    min-width: 150px;
    flex-shrink: 0;
    max-height: 120px;
    overflow: hidden;
  }

  .arduino-panel {
    min-width: 220px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .left-panel  { border-right: none; border-bottom: 1px solid var(--bg-border); }
  .right-panel { border-left: none;  border-top: 1px solid var(--bg-border); }

  .pred-sign { font-size: 22px; }
  .prediction-overlay { top: 8px; padding: 6px 12px; }

  .corner.bl, .corner.br { bottom: 46px; }

  /* Toast above bottom bar on mobile */
  .toast { bottom: 48px; }
}

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

/* Professional accessibility theme: one surface system, one accent, no HUD effects. */
html, body { background: var(--bg-base); color: var(--text-primary); font-family: var(--font-body); }
.scanlines, .noise-overlay { display: none; }
*, *::before, *::after { text-shadow: none !important; }
*, *::before, *::after { animation: none !important; filter: none !important; }
button, input, select, textarea { font-family: var(--font-body); }
button { text-transform: none !important; letter-spacing: normal !important; }
.status-bar { background: var(--bg-panel); border-bottom: 1px solid var(--bg-border); box-shadow: 0 1px 3px rgba(17,24,39,.06); backdrop-filter: none; }
.status-bar::after { display: none; }
.logo-text { font-size: 15px; letter-spacing: normal; font-weight: 700; }
.logo-text .accent, .version-tag, .stat-value { color: var(--green); }
.version-tag { border-color: var(--bg-border); }
.status-pill { background: var(--bg-panel); border-color: var(--bg-border); color: var(--text-secondary); font-family: var(--font-body); letter-spacing: normal; }
.status-pill.online { background: var(--green-dim); border-color: var(--green); color: #047857; box-shadow: none; }
.dot, .dot.green, .dot.cyan, .dot.amber { animation: none; box-shadow: none !important; }
.main-layout { background: var(--bg-base); gap: 16px; padding: 60px 16px 16px; }
.side-panel { background: transparent; }
.left-panel, .right-panel { border: 0; }
.panel-section { background: var(--bg-panel); border: 1px solid var(--bg-border); border-radius: 10px; box-shadow: 0 1px 3px rgba(17,24,39,.04); padding: 16px; }
.panel-title { font-family: var(--font-body); font-size: 13px; font-weight: 700; letter-spacing: normal; text-transform: none; color: var(--text-primary); border-bottom: 1px solid var(--bg-border); padding-bottom: 10px; }
.title-icon { color: var(--green); }
.btn { border-radius: 8px; min-height: 38px; font-family: var(--font-body); font-weight: 600; transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
.btn:focus-visible, .mode-btn:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid rgba(16,185,129,.35); outline-offset: 2px; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; box-shadow: none; }
.btn-primary:hover { background: #059669; border-color: #059669; box-shadow: none; }
.btn-secondary { background: #fff; border-color: var(--bg-border); color: var(--text-primary); box-shadow: none; }
.btn-secondary:hover { background: #F9FAFB; border-color: #D1D5DB; color: var(--text-primary); }
.btn-accent { background: var(--green); border-color: var(--green); color: #fff; box-shadow: none; }
.btn-danger { background: var(--red-dim); border-color: #FCA5A5; color: #B91C1C; box-shadow: none; }
.mode-toggle, .toggle-row, .device-select, .source-label, .device-status { font-family: var(--font-body); }
.mode-btn { background: #fff; border-color: var(--bg-border); color: var(--text-secondary); border-radius: 8px; text-transform: none; letter-spacing: normal; }
.mode-btn.active { background: var(--green-dim); border-color: var(--green); color: #047857; box-shadow: none; }
.toggle-switch { background: #D1D5DB; box-shadow: none; }
input:checked + .toggle-label + .toggle-switch, input:checked ~ .toggle-switch { background: var(--green); box-shadow: none; }
.camera-container { background: #1F2937; border: 1px solid #D1D5DB; border-radius: 12px; box-shadow: 0 2px 8px rgba(17,24,39,.08); }
.camera-placeholder { background: #1F2937; color: #F9FAFB; }
.camera-placeholder .hex-icon { color: #D1D5DB; animation: none; }
.camera-placeholder p { font-family: var(--font-body); letter-spacing: normal; }
.corner { display: none; }
.prediction-overlay, .sentence-strip, .history-bar { background: rgba(31,41,55,.9); border-color: rgba(255,255,255,.15); }
.pred-sign { color: #fff; font-family: var(--font-body); }
.pred-conf, .sentence-label, .history-label { color: #D1D5DB; font-family: var(--font-body); letter-spacing: normal; }
.clear-sentence-btn, .speak-sentence-btn { color: #fff; border-color: rgba(255,255,255,.35); }
.device-select { background: #fff; color: var(--text-primary); border-color: var(--bg-border); border-radius: 8px; }
.device-status { color: #047857; }
.toast { border-radius: 8px; box-shadow: 0 4px 12px rgba(17,24,39,.12); }


/* Compact tracking and detection controls share the existing card theme. */
.tracking-settings { gap: 10px; }
.tracking-settings .toggle-row { min-height: 32px; padding: 4px 0; }
.btn.calibration-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 50px;
  min-height: 50px;
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
  white-space: normal;
}
.calibration-btn .btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  font-size: 16px;
  line-height: 1;
}
.calibration-label { min-width: 0; }
.detection-settings { gap: 0; }
.detection-settings .panel-title { margin-bottom: 12px; }
.detection-settings .slider-label { margin-bottom: 2px; }
.detection-settings .slider + .slider-label { margin-top: 8px; }

/* ─── UTILITY ─────────────────────────────────────────────────── */
.text-cyan    { color: var(--cyan); }
.text-magenta { color: var(--magenta); }
.text-green   { color: var(--green); }
.text-amber   { color: var(--amber); }
.text-red     { color: var(--red); }

/* ═══════════════════════════════════════════════════════════════
   SIGNSPEAK AI — STT inline panel  v2.0
   Speech-to-Text section embedded in main page
   ═══════════════════════════════════════════════════════════════ */


/* ─── STT INLINE PANEL ──────────────────────────────────────── */
.stt-inline-panel {
  width: 100%;
  background: var(--bg-panel);
  border-top: 1px solid rgba(255, 0, 170, 0.3);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.stt-inline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-panel-2);
  border-bottom: 1px solid var(--bg-border);
  flex-shrink: 0;
}

.stt-inline-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.stt-inline-icon { font-size: 16px; line-height: 1; }

.stt-inline-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--magenta);
  text-shadow: 0 0 8px rgba(255,0,170,0.4);
}

.stt-badge {
  padding: 2px 8px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  border: 1px solid var(--text-dim);
  color: var(--text-dim);
  background: transparent;
  transition: all 0.2s;
}
.stt-badge.active {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-dim);
  animation: sttPulse 1.2s ease-in-out infinite;
}
.stt-badge.error {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-dim);
}
@keyframes sttPulse {
  0%, 100% { box-shadow: 0 0 0px rgba(0,255,136,0.3); }
  50%       { box-shadow: 0 0 8px rgba(0,255,136,0.6); }
}

.stt-inline-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  justify-content: flex-end;
}

/* ─── STT BUTTONS ───────────────────────────────────────────── */
.stt-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--border-radius);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  -webkit-user-select: none;
  user-select: none;
  white-space: nowrap;
}
.stt-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.stt-btn.hidden   { display: none !important; }

.stt-btn-start {
  background: linear-gradient(135deg, rgba(0,255,136,0.12), rgba(0,255,136,0.04));
  border-color: var(--green);
  color: var(--green);
}
.stt-btn-start:hover:not(:disabled) {
  background: var(--green-dim);
  box-shadow: 0 0 10px rgba(0,255,136,0.35);
}

.stt-btn-stop {
  background: linear-gradient(135deg, rgba(255,51,85,0.12), rgba(255,51,85,0.04));
  border-color: var(--red);
  color: var(--red);
  animation: sttPulseRed 1.5s ease-in-out infinite;
}
.stt-btn-stop:hover { background: var(--red-dim); }
@keyframes sttPulseRed {
  0%, 100% { box-shadow: 0 0 0px rgba(255,51,85,0.2); }
  50%       { box-shadow: 0 0 10px rgba(255,51,85,0.5); }
}

.stt-btn-clear {
  background: transparent;
  border-color: var(--text-dim);
  color: var(--text-secondary);
}
.stt-btn-clear:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(255,183,0,0.07);
}

/* ─── LANG BUTTONS ──────────────────────────────────────────── */
.stt-lang-group {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 4px;
}
.stt-lang-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}
.stt-lang-btn {
  padding: 4px 9px;
  border-radius: 20px;
  background: transparent;
  border: 1px solid var(--bg-border);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
  transition: all var(--transition);
}
.stt-lang-btn:hover {
  border-color: var(--magenta);
  color: var(--magenta);
  background: var(--magenta-dim);
}
.stt-lang-btn.active {
  border-color: var(--magenta);
  color: var(--magenta);
  background: var(--magenta-dim);
  box-shadow: 0 0 6px rgba(255,0,170,0.2);
}

/* ─── UNSUPPORTED ───────────────────────────────────────────── */
.stt-unsupported {
  padding: 8px 14px;
  background: rgba(255,51,85,0.07);
  border-bottom: 1px solid rgba(255,51,85,0.3);
  color: #ffaaaa;
  font-family: var(--font-body);
  font-size: 12px;
}
.stt-unsupported.hidden { display: none; }

/* ─── OUTPUT AREA ───────────────────────────────────────────── */
.stt-output-area {
  display: flex;
  flex-direction: column;
  max-height: 160px;
  overflow: hidden;
}

.stt-interim-wrap {
  flex-shrink: 0;
  min-height: 36px;
  padding: 6px 14px;
  background: rgba(255, 0, 170, 0.03);
  border-bottom: 1px solid var(--bg-border);
  display: flex;
  align-items: center;
}

.stt-interim {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  color: var(--magenta);
  font-style: italic;
  opacity: 0.9;
  text-shadow: 0 0 8px rgba(255,0,170,0.25);
  word-break: break-word;
  -webkit-user-select: text;
  user-select: text;
  line-height: 1.4;
  width: 100%;
}

.stt-history {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  scroll-behavior: smooth;
  max-height: 110px;
  -webkit-user-select: text;
  user-select: text;
}
.stt-history::-webkit-scrollbar { width: 3px; }
.stt-history::-webkit-scrollbar-thumb { background: rgba(255,0,170,0.3); border-radius: 2px; }

.stt-history-item {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 5px 10px;
  background: var(--bg-panel-2);
  border: 1px solid var(--bg-border);
  border-left: 3px solid var(--magenta);
  border-radius: var(--border-radius);
  animation: sttFadeIn 0.2s ease;
  flex-wrap: wrap;
}
@keyframes sttFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stt-item-lang {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--magenta-dim);
  border: 1px solid rgba(255,0,170,0.25);
  color: var(--magenta);
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.stt-item-time {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.stt-item-text {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
  flex: 1;
}

/* ─── MOBILE ────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .stt-inline-header { padding: 7px 10px; }
  .stt-inline-title  { font-size: 10px; }
  .stt-btn           { padding: 4px 10px; font-size: 9px; }
  .stt-lang-btn      { padding: 3px 7px; font-size: 9px; }
  .stt-interim       { font-size: 13px; }
  .stt-item-text     { font-size: 13px; }
  .stt-output-area   { max-height: 130px; }
}

/* ─── REDUCED MOTION ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .stt-btn-stop    { animation: none; }
  .stt-badge.active { animation: none; }
  .stt-history-item { animation: none; }
}
/* SignSpeak AI by RBHR — authentication, privacy, and creator UI */
/* Landing styles are scoped to account access; the app keeps its own theme. */
#authShell {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  padding: 48px 20px 28px;
  color: #A0AEC0;
  font-family: 'Inter', sans-serif;
  background: #090d16;
  isolation: isolate;
}
#authShell::before {
  content: '';
  position: fixed;
  inset: -15%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse at 25% 35%, rgba(0,200,150,.13), transparent 45%), radial-gradient(ellipse at 78% 70%, rgba(123,47,247,.14), transparent 45%);
  animation: auth-mesh 14s ease-in-out infinite alternate !important;
}
#authShell .auth-card {
  flex: 0 0 auto;
  width: 100%;
  max-width: 420px;
  min-height: 0;
  max-height: none;
  overflow: visible;
  margin-top: auto;
  padding: 48px 32px;
  border: 1px solid transparent;
  border-radius: 24px;
  background: linear-gradient(#111621, #111621) padding-box, linear-gradient(135deg, #00C896, #7B2FF7) border-box;
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
}
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-brand img { display: block; width: 72px; height: 72px; margin: 0 auto 18px; border-radius: 18px; }
#authShell h1, #authShell h2 { color: #fff; font-family: inherit; }
#authShell h1 { margin: 12px 0 10px; font-size: clamp(28px, 7vw, 36px); font-weight: 700; line-height: 1.2; letter-spacing: -.04em; }
#authShell h2 { font-size: 18px; line-height: 1.4; font-weight: 600; margin-bottom: 8px; }
.auth-kicker { font-size: 10px; letter-spacing: .2em; color: #A0AEC0; opacity: .5; }
.auth-brand > p:last-child { font-size: 12px; line-height: 1.6; }
#authShell [data-auth-panel='welcome'] { text-align: center; }
#authShell [data-auth-panel] > p { font-size: 13px; line-height: 1.7; }
/* Keep lifecycle updates accessible without duplicating the inline notice. */
.boot-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.provider-banner { display: flex; align-items: center; gap: 8px; margin: 0 0 24px; padding: 4px 6px 4px 10px; border: 1px solid rgba(251,191,36,.18); border-radius: 10px; background: rgba(251,191,36,.06); color: #E5BD73; }
.provider-info { flex-shrink: 0; font-size: 16px; }
.provider-status { flex: 1; font-size: 11px; white-space: nowrap; }
#dismissProviderNotice { flex: 0 0 32px; min-width: 32px; min-height: 36px; border: 0; border-radius: 6px; background: transparent; color: inherit; font-size: 20px; cursor: pointer; }
#dismissProviderNotice:hover { background: rgba(251,191,36,.1); }
.auth-actions, .auth-form { display: grid; gap: 12px; }
.auth-actions { margin-top: 24px; }
#authShell .btn { min-height: 50px; padding: 12px 18px; border-radius: 999px; font-size: 11px; letter-spacing: .18em !important; text-transform: uppercase !important; }
#authShell .btn::before { display: none; }
#authShell .btn-primary { background: #00C896; border-color: #00C896; color: #05251D; box-shadow: none; }
#authShell .btn-primary:hover { filter: brightness(1.1) !important; }
#authShell .btn-secondary { border-color: rgba(255,255,255,.3); background: transparent; color: #fff; }
#authShell .btn-secondary:hover { background: rgba(255,255,255,.1); }
#authShell .auth-demo { justify-self: center; width: auto; min-height: 44px; padding: 6px 0; border: 0; background: transparent; color: #7EC8B4; font: inherit; font-size: 12px; text-decoration: underline; text-underline-offset: 5px; cursor: pointer; }
#authShell .auth-demo:hover { color: #B1E8D9; }
#authShell .auth-actions > button { animation: auth-enter .55s ease both !important; }
#authShell .auth-actions > button:nth-child(2) { animation-delay: .08s !important; }
#authShell .auth-actions > button:nth-child(3) { animation-delay: .16s !important; }
.auth-form label { font: inherit; font-size: 12px; font-weight: 500; }
.auth-form input:not([type='checkbox']) { width: 100%; min-width: 0; min-height: 46px; padding: 10px 12px; border: 1px solid rgba(255,255,255,.18); border-radius: 10px; color: #fff; background: #0B101A; font: inherit; }
.password-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
#authShell .password-row button, #authShell .auth-link { min-height: 44px; padding: 8px; border: 0; border-radius: 8px; background: transparent; color: #7EC8B4; cursor: pointer; font: inherit; font-size: 11px; }
.terms-check { display: grid; grid-template-columns: 22px 1fr; align-items: center; gap: 10px; }
#authShell .terms-check input { width: 18px; height: 18px; min-height: 18px; accent-color: #00C896; }
.auth-message { font-size: 12px; line-height: 1.6; margin-top: 16px; color: #A0AEC0; }
.auth-message:empty { display: none; }
.auth-message.error { color: #E5BD73; }
.auth-message.success { color: #7EC8B4; }
#authShell .auth-privacy { flex: 0 0 auto; max-width: 390px; margin: 22px 0 auto; padding: 0 8px; text-align: center; color: #A0AEC0; font: 11px/1.8 'Inter', sans-serif; }
#authShell button:focus-visible, #authShell input:focus-visible { outline: 2px solid #7EC8B4; outline-offset: 4px; }
@keyframes auth-enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes auth-mesh { from { transform: translate(-2%, -1%) scale(1); } to { transform: translate(2%, 2%) scale(1.07); } }
@media (max-width: 380px) { #authShell { padding: 24px 16px; } #authShell .auth-card { padding: 48px 20px; } }
@media (prefers-reduced-motion: reduce) { #authShell::before, #authShell .auth-actions > button { animation: none !important; } }

.logo-text small {
  color: var(--magenta);
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.65em;
  letter-spacing: 0.08em;
}

.profile-wrap {
  position: relative;
}

.profile-button,
.profile-menu button {
  min-height: 44px;
  border: 1px solid rgba(255, 0, 170, 0.45);
  color: var(--magenta);
  background: rgba(255, 0, 170, 0.08);
  font-family: 'Orbitron', sans-serif;
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.profile-button {
  padding: 0 14px;
}

.profile-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--cyan);
  background: #070c17;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
}

.profile-menu strong,
.profile-menu span {
  overflow-wrap: anywhere;
}

.profile-menu span {
  color: var(--cyan);
  font: 0.72rem 'Share Tech Mono', monospace;
}

.secure-context-warning {
  grid-column: 1 / -1;
  padding: 12px 16px;
  border: 1px solid #ff6b88;
  color: #ffd3db;
  background: rgba(255, 40, 80, 0.12);
  text-align: center;
}

.creator-footer {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 20px;
  padding: 14px 18px 20px;
  color: rgba(220, 250, 255, 0.64);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.74rem;
}

.creator-footer a,
.about-links a {
  color: var(--cyan);
}

.about-modal,
.privacy-modal {
  max-width: 620px;
}

.about-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 18px 0;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid #ffe15a;
  outline-offset: 3px;
}

button,
select,
input[type='range'] {
  min-height: 44px;
}

button {
  min-width: 44px;
}

.creator-footer a,
.about-links a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.stt-btn,
.stt-lang-btn {
  min-height: 44px;
  min-width: 44px;
}

@media (max-width: 900px) {
  .status-right {
    display: flex;
    flex-wrap: wrap;
    margin-left: auto;
  }

  .status-right .stat-item {
    display: none;
  }

  .profile-menu {
    position: fixed;
    top: 72px;
    right: 12px;
  }

  .creator-footer {
    padding-bottom: 30px;
  }
}

@media (max-width: 560px) {
  .auth-shell {
    padding: 0;
  }

  .auth-card {
    min-height: 100vh;
    max-height: none;
    padding: 24px 18px;
    border-left: 0;
    border-right: 0;
  }

  .password-row {
    grid-template-columns: minmax(0, 1fr) 70px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-card,
  .profile-menu {
    animation: none !important;
    transition: none !important;
  }
}
