/* src/alba/style.css */
:root {
  --app-height: 100dvh;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
}

body {
  font-family: monospace;
  background: #f4ecd8;
  color: #24292f;
  margin: 0;
  padding: 0;
  overflow: hidden;
  user-select: none;
  height: 100vh;
  height: var(--app-height);
  width: 100vw;
  width: 100dvw;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

#ambient-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: var(--app-height);
  z-index: 1;
  background: radial-gradient(circle at 50% 45%, #fffdf7 0%, #faecd5 55%, #dfceb1 100%);
  display: block;
}

/* Contenedor central de calibración / recalibración con spinner y texto descriptivo */
#recalib-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 5;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s ease;
}

#recalib-container.hidden {
  opacity: 0;
  visibility: hidden;
}

/* Spinner sutil de calibración */
#recalib-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(223, 206, 177, 0.4);
  border-top-color: rgba(140, 115, 85, 0.65);
  border-radius: 50%;
  animation: recalibSpin 0.9s linear infinite;
}

/* Texto bajo el spinner de calibración */
#recalib-text {
  font-family: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.5px;
  color: rgba(110, 90, 65, 0.85);
  font-weight: bold;
  user-select: none;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

@keyframes recalibSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Contenedor central de advertencia: rostro ausente */
#noface-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 6;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.25s ease;
}

#noface-container.hidden {
  opacity: 0;
  visibility: hidden;
}

/* Spinner rojo carmesí de rostro no detectado */
#noface-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(207, 34, 46, 0.25);
  border-top-color: #cf222e;
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(207, 34, 46, 0.2);
  animation: noFaceSpin 0.85s linear infinite;
}

/* Texto de advertencia bajo el spinner rojo */
#noface-text {
  font-family: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.5px;
  color: #cf222e;
  font-weight: bold;
  user-select: none;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
}

@keyframes noFaceSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Botón flotante para desactivar alarma enclavada */
#alarm-dismiss-container {
  position: absolute;
  top: calc(var(--safe-top) + 20px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 85;
  opacity: 1;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 90vw;
}

#alarm-dismiss-container.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-20px);
}

#btn-dismiss-alarm {
  background: #cf222e;
  color: #ffffff;
  border: 2px solid #b62324;
  border-radius: 8px;
  padding: 12px 20px;
  font-family: inherit;
  font-size: clamp(0.9rem, 2vw, 1.15rem);
  font-weight: bold;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 30px rgba(207, 34, 46, 0.45);
  animation: pulseAlarmBtn 1.1s infinite alternate ease-in-out;
  white-space: nowrap;
}

#btn-dismiss-alarm:hover {
  background: #b62324;
}

@keyframes pulseAlarmBtn {
  from {
    transform: scale(1);
    box-shadow: 0 4px 18px rgba(207, 34, 46, 0.35);
  }
  to {
    transform: scale(1.04);
    box-shadow: 0 10px 32px rgba(207, 34, 46, 0.65);
  }
}

/* Intro de Soberanía del Dato */
#privacy-card-intro {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 490px;
  max-width: 90vw;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(208, 215, 222, 0.95);
  border-radius: 12px;
  padding: clamp(22px, 4vw, 36px) clamp(18px, 3.5vw, 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  z-index: 45;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(12px);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.55s ease, transform 0.55s ease, visibility 0.55s;
  cursor: pointer;
}

#privacy-card-intro.hidden {
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -46%);
  pointer-events: none;
}

.intro-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.intro-title {
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  font-weight: bold;
  color: #1f2328;
}

.intro-text {
  font-size: clamp(0.85rem, 1.3vw, 1rem);
  color: #24292f;
  line-height: 1.5;
}

.intro-warning {
  font-size: clamp(0.72rem, 1vw, 0.8rem);
  color: #57606a;
  font-weight: bold;
}

/* Cinemática del Candado */
.padlock-box {
  position: relative;
  width: 44px;
  height: 54px;
  flex-shrink: 0;
  animation: padlockDropFromSky 0.85s cubic-bezier(0.22, 1, 0.36, 1) 0.10s both;
}

.padlock-shackle {
  position: absolute;
  top: 0;
  left: 6px;
  width: 32px;
  height: 26px;
  border: 5px solid #6e7781;
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  box-sizing: border-box;
  transform-origin: left bottom;
  transform: translateY(-15px) rotate(-24deg);
  animation: shackleSnapClose 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28) 0.95s forwards;
}

.padlock-body {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 44px;
  height: 33px;
  background: #6e7781;
  border-radius: 6px;
  animation: bodyLockImpact 0.45s ease-out 0.95s forwards;
}

.padlock-body::after {
  content: '';
  position: absolute;
  top: 10px;
  left: 19px;
  width: 6px;
  height: 11px;
  background: #ffffff;
  border-radius: 3px;
}

@keyframes padlockDropFromSky {
  0% { transform: translateY(-100vh); opacity: 0; }
  40% { opacity: 1; }
  85% { transform: translateY(5px); }
  100% { transform: translateY(0); opacity: 1; }
}

@keyframes shackleSnapClose {
  0% { transform: translateY(-15px) rotate(-24deg); border-color: #6e7781; }
  65% { transform: translateY(0) rotate(0deg); border-color: #6e7781; }
  75% { transform: translateY(-2px) rotate(0deg); border-color: #2da44e; }
  100% { transform: translateY(0) rotate(0deg); border-color: #2da44e; }
}

@keyframes bodyLockImpact {
  0% { background: #6e7781; transform: scale(1); }
  65% { background: #6e7781; transform: scale(0.96, 1.04); }
  75% { background: #2da44e; transform: scale(1.06, 0.95); }
  100% { background: #2da44e; transform: scale(1); }
}

/* Selector de idioma */
.lang-switch {
  display: flex;
  align-items: center;
  gap: 4px;
}

.lang-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  padding: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  transition: opacity 0.15s, border-color 0.15s, transform 0.1s;
}

.lang-btn:hover {
  opacity: 0.95;
  transform: scale(1.08);
}

.lang-btn.active {
  opacity: 1;
  border-color: #2da44e;
  background: rgba(45, 164, 78, 0.12);
}

.lang-btn svg {
  display: block;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Modales generales */
.modal-window {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(208, 215, 222, 0.95);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  z-index: 35;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: text;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: #fbf6ec;
  border-bottom: 1px solid #e1d8c5;
  font-size: clamp(0.85rem, 1.1vw, 1rem);
  font-weight: bold;
  color: #57606a;
  user-select: none;
  flex-shrink: 0;
  gap: 12px;
}

.modal-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.modal-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25em;
  color: #6e7781;
  padding: 2px 8px;
  line-height: 1;
  border-radius: 4px;
}

.modal-close-btn:hover {
  color: #cf222e;
  background: rgba(207, 34, 46, 0.08);
}

/* Ventana Demo */
#demo-card {
  width: 640px;
  max-width: 92vw;
  height: auto;
  max-height: 85vh;
  max-height: 85dvh;
  background: #fbf6ec;
}

.demo-body {
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f4ecd8;
  overflow: hidden;
  line-height: 0;
}

#stage {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 640 / 349;
  object-fit: contain;
  margin: 0;
  padding: 0;
}

/* Ventana FAQ */
#faq-card {
  width: 820px;
  max-width: 92vw;
  max-height: 82vh;
  max-height: 82dvh;
}

.faq-body {
  padding: clamp(14px, 2.5vw, 24px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}

.faq-body::-webkit-scrollbar,
.settings-body::-webkit-scrollbar,
.feedback-body::-webkit-scrollbar {
  width: 6px;
}

.faq-body::-webkit-scrollbar-thumb,
.settings-body::-webkit-scrollbar-thumb,
.feedback-body::-webkit-scrollbar-thumb {
  background: #d0d7de;
  border-radius: 3px;
}

.faq-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px dashed #e1d8c5;
  padding-bottom: 16px;
}

.faq-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.faq-sec-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.faq-badge {
  font-size: 0.78rem;
  font-weight: bold;
  background: #2da44e;
  color: #ffffff;
  padding: 2px 7px;
  border-radius: 4px;
}

.faq-sec-header h3 {
  margin: 0;
  font-size: clamp(0.95rem, 1.25vw, 1.15rem);
  color: #24292f;
}

.faq-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: clamp(0.82rem, 1.05vw, 0.95rem);
  line-height: 1.55;
  color: #3b424b;
}

.faq-subsection {
  margin-top: 8px;
  background: #fbf8f1;
  border: 1px solid #ebdcc5;
  border-radius: 6px;
  padding: 10px 14px;
}

.faq-subsection h4 {
  margin: 0 0 6px 0;
  font-size: 0.88rem;
  color: #cf222e;
  text-transform: uppercase;
}

.faq-sublist {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: clamp(0.8rem, 1vw, 0.92rem);
  line-height: 1.5;
  color: #4f5761;
}

/* ==========================================================================
   Ventana de Feedback SARA
   ========================================================================== */
#feedback-card {
  width: 540px;
  max-width: 92vw;
  max-height: 84vh;
  max-height: 84dvh;
}

.feedback-body {
  padding: clamp(14px, 2.5vw, 22px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.feedback-desc {
  font-size: clamp(0.8rem, 1.05vw, 0.9rem);
  color: #4f5761;
  line-height: 1.5;
  margin: 0 0 6px 0;
}

.fb-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

.fb-field label {
  font-size: 0.82rem;
  font-weight: bold;
  color: #24292f;
}

.fb-field input,
.fb-field textarea {
  width: 100%;
  padding: 8px 10px;
  background: #fbf6ec;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.85rem;
  color: #24292f;
}

.fb-field textarea {
  resize: vertical;
  min-height: 85px;
}

.fb-field input:focus,
.fb-field textarea:focus {
  outline: none;
  border-color: #2da44e;
  box-shadow: 0 0 0 2px rgba(45, 164, 78, 0.2);
}

.fb-consent-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.74rem;
  color: #57606a;
  line-height: 1.4;
  margin-top: 4px;
}

.fb-consent-row input[type="checkbox"] {
  accent-color: #2da44e;
  margin-top: 2px;
}

.fb-status {
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: bold;
  text-align: center;
}

.fb-status.hidden {
  display: none;
}

.fb-status.success {
  background: #dafbe1;
  color: #1a7f37;
  border: 1px solid #4ac26b;
}

.fb-status.error {
  background: #ffebe9;
  color: #cf222e;
  border: 1px solid #ff8182;
}

.fb-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

button.feedback-header-btn {
  background: #eef6ff;
  border: 1px solid #a5d0ff;
  color: #0969da;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: bold;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1.3;
}
button.feedback-header-btn:hover {
  background: #ddf4ff;
  border-color: #54aeff;
}

/* Ventana de Configuración */
#settings-card {
  width: 720px;
  max-width: 92vw;
  max-height: 82vh;
  max-height: 82dvh;
}

.settings-body {
  padding: clamp(14px, 2.5vw, 24px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  -webkit-overflow-scrolling: touch;
}

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f0e6d2;
}

.setting-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.setting-info label {
  font-size: clamp(0.85rem, 1.1vw, 0.98rem);
  font-weight: bold;
  color: #24292f;
}

.setting-desc {
  font-size: clamp(0.72rem, 0.95vw, 0.82rem);
  color: #57606a;
  line-height: 1.4;
}

.setting-ctrl {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 170px;
  justify-content: flex-end;
}

.setting-ctrl-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.setting-select {
  background: #fbf6ec;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  padding: 5px 8px;
  font-family: inherit;
  font-size: 0.82rem;
  color: #24292f;
  font-weight: bold;
  cursor: pointer;
  max-width: 100%;
}

.setting-value {
  font-size: 0.85rem;
  font-weight: bold;
  color: #24292f;
  min-width: 50px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.setting-ctrl input[type="range"] {
  accent-color: #2da44e;
  cursor: pointer;
  width: 110px;
  height: 6px;
}

.setting-ctrl-row input[type="checkbox"] {
  accent-color: #2da44e;
  cursor: pointer;
  width: 18px;
  height: 18px;
}

.settings-footer {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #ebdcc5;
  padding-top: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-footer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.settings-cookie-hint {
  font-size: 0.76rem;
  color: #6e7781;
}

/* ==========================================================================
   Actuador biométrico: Barra de carga adaptativa
   ========================================================================== */
#ui-container {
  position: absolute;
  pointer-events: none;
  z-index: 10;
}

/* Disposición vertical en lateral derecho (Escritorio / Pantallas anchas) */
@media (min-width: 769px) and (orientation: landscape), (min-width: 900px) {
  #ui-container {
    top: 0;
    right: 0;
    width: auto;
    height: 100vh;
    height: var(--app-height);
    display: flex;
    justify-content: flex-end;
  }

  .trigger-strip {
    width: 52px;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(2px);
    border-left: 1px solid rgba(0, 0, 0, 0.08);
    padding-top: calc(var(--safe-top) + 16px);
  }

  .strip-header-icon {
    font-size: 1.7rem;
    z-index: 2;
    opacity: 0.35;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  .strip-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    transition: height 0.08s linear, background-color 0.15s ease;
    border-top: 2px solid rgba(255, 255, 255, 0.9);
  }
}

/* Disposición horizontal superior (Pantallas estrechas / Verticales) */
@media (max-width: 768px), (orientation: portrait) {
  #ui-container {
    top: 0;
    left: 0;
    width: 100vw;
    width: 100dvw;
    height: auto;
  }

  .trigger-strip {
    width: 100%;
    height: calc(var(--safe-top) + 38px);
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(3px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding-top: var(--safe-top);
    padding-left: calc(var(--safe-left) + 14px);
    padding-right: calc(var(--safe-right) + 14px);
  }

  .strip-header-icon {
    font-size: 1.35rem;
    z-index: 2;
    opacity: 0.4;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  .strip-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    transition: width 0.08s linear, background-color 0.15s ease;
    border-right: 2px solid rgba(255, 255, 255, 0.9);
  }
}

.strip-header-icon.alarm-prealert {
  opacity: 1;
  animation: bellPreAlert 0.35s infinite alternate ease-in-out;
}

@keyframes bellPreAlert {
  0% { transform: rotate(-16deg) scale(1.12); }
  100% { transform: rotate(16deg) scale(1.12); }
}

.strip-header-icon.alarm-ringing {
  opacity: 1;
  animation: bellRingingFast 0.10s infinite alternate ease-in-out;
}

@keyframes bellRingingFast {
  0% { transform: rotate(-24deg) scale(1.3); }
  100% { transform: rotate(24deg) scale(1.3); }
}

/* ==========================================================================
   Barra técnica de control inferior (#tech-drawer)
   ========================================================================== */
#tech-drawer {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(208, 215, 222, 0.85);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 6px 14px;
  padding-bottom: calc(var(--safe-bottom) + 6px);
  display: flex;
  align-items: center;
  z-index: 20;
  backdrop-filter: blur(8px);
  box-shadow: 0 -2px 14px rgba(0, 0, 0, 0.07);
}

/* En pantallas estándar: una sola fila horizontal con todos los elementos */
.drawer-controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.drawer-section {
  display: flex;
  align-items: center;
  gap: 6px;
}

.drawer-divider {
  width: 1px;
  height: 18px;
  background-color: rgba(208, 215, 222, 0.85);
  margin: 0 2px;
}

#sensor-status-box {
  display: flex;
  align-items: center;
  padding: 0 2px;
}

#sensor-led {
  display: inline-block;
  width: 18px;
  height: 11px;
  border-radius: 3px;
  transition: background-color 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

#sensor-led.led-inactive {
  background-color: #cf222e;
  border: 1px solid #9e1c23;
  box-shadow: 0 0 6px rgba(207, 34, 46, 0.8), inset 0 1px 1px rgba(255, 255, 255, 0.35);
}

#sensor-led.led-active {
  background-color: #2da44e;
  border: 1px solid #1f7f38;
  box-shadow: 0 0 5px #2da44e, 0 0 10px rgba(45, 164, 78, 0.9), inset 0 1px 1px rgba(255, 255, 255, 0.45);
}

button.action-btn {
  padding: 6px 11px;
  background: #f6f8fa;
  border: 1px solid #d0d7de;
  color: #24292f;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
  border-radius: 4px;
  font-size: clamp(0.72rem, 0.95vw, 0.82rem);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

button.action-btn:hover { background: #eaeef2; }
button.primary-btn { background: #2da44e; border-color: #2c974b; color: #fff; }
button.primary-btn:hover { background: #2c974b; }
button.danger-btn { background: #cf222e; border-color: #b62324; color: #fff; }
button.danger-btn:hover { background: #b62324; }

button.support-btn {
  background: #fff8e5;
  border-color: #d4a72c;
  color: #7a4f01;
}
button.support-btn:hover {
  background: #fceec5;
  border-color: #bf8d1b;
  color: #593900;
}

button.icon-only-btn {
  padding: 6px 8px;
  color: #57606a;
}
button.icon-only-btn:hover { color: #24292f; }
button.icon-only-btn.active {
  background: #eaeef2;
  border-color: #afb8c1;
  color: #24292f;
}

/* ==========================================================================
   Monitor PiP de Cámara
   ========================================================================== */
#monitor-card {
  position: absolute;
  top: calc(var(--safe-top) + 16px);
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  max-width: 40vw;
  aspect-ratio: 4 / 3;
  background: #000;
  border: 2px solid rgba(208, 215, 222, 0.9);
  border-radius: 8px;
  overflow: hidden;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

#monitor-canvas {
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
  object-fit: cover;
}

#feed-hidden { display: none; }

/* Modal de Apoyo */
#support-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.55);
  backdrop-filter: blur(4px);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

#support-modal-backdrop.active { display: flex; }

.support-modal {
  background: #fffdf8;
  border: 1px solid #d0d7de;
  border-radius: 10px;
  padding: clamp(18px, 3vw, 26px);
  width: 92%;
  max-width: 520px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.24);
  display: flex;
  flex-direction: column;
  gap: 14px;
  user-select: text;
}

.support-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e1d8c5;
  padding-bottom: 10px;
  user-select: none;
}

.support-header h3 {
  margin: 0;
  font-size: clamp(0.98rem, 1.25vw, 1.15rem);
  color: #24292f;
}

.support-close-btn {
  background: transparent;
  border: none;
  font-size: 1.35em;
  cursor: pointer;
  color: #6e7781;
  padding: 0 6px;
}
.support-close-btn:hover { color: #cf222e; }

.support-desc {
  font-size: clamp(0.85rem, 1.1vw, 0.96rem);
  color: #3f4752;
  line-height: 1.55;
  margin: 0;
}

.support-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.support-tier-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #fbf6ec;
  border: 1px solid #e2d7c0;
  border-radius: 6px;
  color: #24292f;
  text-decoration: none;
  font-size: clamp(0.82rem, 1.1vw, 0.94rem);
  font-weight: bold;
}
.support-tier-btn:hover {
  background: #f4ecd8;
  border-color: #bfa882;
}

/* ==========================================================================
   ADAPTACIONES RESPONSIVAS: FILAS APILADAS Y CENTRADAS EN PANTALLAS VERTICALES
   ========================================================================== */
@media (max-width: 680px), (orientation: portrait) {
  #tech-drawer {
    width: 100vw;
    width: 100dvw;
    left: 0;
    transform: none;
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: 6px 12px;
    padding-bottom: calc(var(--safe-bottom) + 6px);
    display: flex;
    justify-content: center;
  }

  /* Se activa flex-wrap y dirección en columna con centrado estricto */
  .drawer-controls {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }

  .main-ops {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }

  #btn-toggle {
    flex: 1;
    max-width: 280px;
    padding: 8px 12px;
  }

  .divider-secondary,
  .divider-lang {
    display: none;
  }

  .secondary-ops {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    flex-wrap: wrap;
  }

  .secondary-ops button {
    padding: 6px 10px;
  }

  .lang-ops {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 2px;
  }

  .lang-switch {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.04);
    padding: 3px 8px;
    border-radius: 6px;
  }

  .lang-btn {
    padding: 3px;
  }

  .lang-btn svg {
    width: 22px;
    height: 15px;
  }

  /* Monitor PiP en móvil */
  #monitor-card {
    top: calc(var(--safe-top) + 48px);
    left: auto;
    right: calc(var(--safe-right) + 12px);
    transform: none;
    width: 110px;
    max-width: 32vw;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  }

  /* Modales Bottom Sheets (FAQ, Feedback y Ajustes) */
  #faq-card,
  #feedback-card,
  #settings-card {
    top: auto;
    bottom: 0;
    left: 0;
    transform: none;
    width: 100vw;
    width: 100dvw;
    max-width: 100vw;
    max-width: 100dvw;
    height: 86vh;
    height: 86dvh;
    max-height: 86vh;
    max-height: 86dvh;
    border-radius: 16px 16px 0 0;
    border-bottom: none;
    padding-bottom: var(--safe-bottom);
    animation: slideUpSheet 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }

  /* Demo centrada y contenida */
  #demo-card {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 94vw;
    max-width: 94vw;
    height: auto;
    max-height: 85vh;
    max-height: 85dvh;
    border-radius: 10px;
    border: 1px solid rgba(208, 215, 222, 0.95);
    padding-bottom: 0;
    animation: none;
  }

  @keyframes slideUpSheet {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .modal-header {
    padding: 14px 18px;
  }

  .modal-close-btn {
    font-size: 1.4em;
    padding: 4px 10px;
  }

  .setting-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .setting-ctrl {
    width: 100%;
    justify-content: space-between;
  }

  .setting-ctrl input[type="range"] {
    flex: 1;
    max-width: 70%;
  }

  .settings-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .settings-footer-actions {
    flex-direction: column;
    width: 100%;
  }

  .settings-footer-actions button {
    width: 100%;
    padding: 10px;
  }
}