:root {
  color-scheme: dark;
  --ink: #eaf7ff;
  --ink-dim: #9fd8f5;
  --ink-faint: #6d8798;
  --accent: #7fd4ff;
  --panel: rgba(0, 0, 0, 0.7);
  --line: rgba(255, 255, 255, 0.1);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #000;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; }
button { cursor: pointer; }

/* Iris: el núcleo visual original, a pantalla completa */
#irisFrame {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ---------- Distribución vertical: avisos arriba, panel abajo,
   sin encimarse nunca; el centro queda libre para Iris ---------- */
.layout {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.5rem;
  padding: max(0.75rem, env(safe-area-inset-top)) 0.75rem max(0.75rem, env(safe-area-inset-bottom));
  pointer-events: none;
}
.layout .card, .layout .panel, .layout .gear { pointer-events: auto; }

/* ---------- Zona superior: indicador del micrófono + avisos ---------- */
.top-stack {
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.mic-banner {
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.7);
  padding: 0.75rem 3.5rem 0.75rem 1rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-align: left;
}
.mic-banner.mic-on { border-color: rgba(110, 231, 183, 0.4); background: rgba(2, 44, 34, 0.75); }
.mic-banner.mic-blocked { border-color: rgba(252, 165, 165, 0.5); background: rgba(69, 10, 10, 0.8); }
.mic-dot {
  flex: none;
  width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  background: #a1a1aa;
}
.mic-on .mic-dot { background: #34d399; animation: pulse 1.6s ease-in-out infinite; }
.mic-blocked .mic-dot { background: #f87171; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  .mic-on .mic-dot { animation: none; }
}
.mic-title { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: 0.02em; line-height: 1.2; color: #e4e4e7; }
.mic-on .mic-title { color: #a7f3d0; }
.mic-blocked .mic-title { color: #fecaca; }
.mic-sub { margin: 0.15rem 0 0; font-size: 12px; line-height: 1.35; color: rgba(207, 238, 255, 0.75); }

.notices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 30dvh;
  overflow-y: auto;
  pointer-events: auto;
}
.card {
  border-radius: 1rem;
  border: 1px solid rgba(127, 212, 255, 0.35);
  background: rgba(6, 20, 31, 0.9);
  padding: 0.75rem 1rem;
  text-align: left;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--ink);
  width: 100%;
}
.card h2 { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.35; }
.card p { margin: 0.4rem 0 0; font-size: 13px; line-height: 1.55; color: #b9d6e6; }
.card ol { margin: 0.5rem 0 0; padding-left: 1.25rem; font-size: 13px; line-height: 1.55; color: #d7edf9; }
.card ol li + li { margin-top: 0.25rem; }
.card .row-btns { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.btn-ghost {
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: #dff4ff;
  padding: 0.55rem 1rem;
  font-size: 13px;
  font-weight: 500;
  min-height: 2.25rem;
}
.btn-install {
  border-radius: 9999px;
  border: 1px solid rgba(127, 212, 255, 0.55);
  background: #0a2233;
  color: #dff4ff;
  padding: 0.55rem 1rem;
  font-size: 13px;
  font-weight: 600;
  min-height: 2.25rem;
}
.card.nokey {
  border-color: rgba(245, 177, 76, 0.4);
  background: rgba(42, 29, 5, 0.88);
  color: #ffd9a0;
  font-size: 13px;
  line-height: 1.45;
}

/* ---------- Botón de ajustes ---------- */
.gear {
  position: fixed;
  right: 0.75rem;
  top: max(0.75rem, env(safe-area-inset-top));
  z-index: 21;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  border: 0;
  background: rgba(255, 255, 255, 0.05);
  color: #cfeeff;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ---------- Panel de conversación ---------- */
.panel {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 40dvh;
  overflow-y: auto;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 0.75rem 1rem;
  text-align: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.panel p { margin: 0.3rem 0; }
.state-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.3em;
  color: rgba(159, 216, 245, 0.8);
}
.diag { font-size: 11px; line-height: 1.4; color: rgba(159, 216, 245, 0.6); }
.hint { font-size: 12px; line-height: 1.45; color: rgba(159, 216, 245, 0.5); }
.notice { font-size: 13px; line-height: 1.45; color: #ffd9a0; }
.error { font-size: 13px; line-height: 1.45; color: #ffb4a2; }
.heard { font-size: 13px; line-height: 1.45; color: rgba(159, 216, 245, 0.9); }
.interim { font-size: 14px; font-style: italic; line-height: 1.45; color: rgba(159, 216, 245, 0.75); }
.reply { font-size: 15px; line-height: 1.5; color: var(--ink); }
.tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.25em;
  color: rgba(159, 216, 245, 0.6);
}
.btn-primary {
  border-radius: 9999px;
  border: 1px solid rgba(127, 212, 255, 0.5);
  background: rgba(10, 34, 51, 0.9);
  color: #dff4ff;
  padding: 0.7rem 1.6rem;
  font-size: 15px;
  font-weight: 500;
  min-height: 2.75rem;
}
.btn-small {
  border-radius: 9999px;
  border: 1px solid rgba(127, 212, 255, 0.4);
  background: rgba(10, 34, 51, 0.9);
  color: #dff4ff;
  padding: 0.6rem 1.2rem;
  font-size: 13px;
  font-weight: 500;
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.center-row { display: flex; justify-content: center; padding-top: 0.35rem; }
.blocked-help {
  border-radius: 0.75rem;
  border: 1px solid rgba(252, 165, 165, 0.3);
  background: rgba(69, 10, 10, 0.5);
  padding: 0.65rem 0.85rem;
  text-align: left;
  font-size: 12.5px;
  line-height: 1.55;
  color: #ffd2cc;
  margin-top: 0.5rem;
}
.blocked-help p { margin: 0.25rem 0; }
.type-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.6rem;
}
.type-form input {
  min-width: 0;
  flex: 1;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.6);
  padding: 0.65rem 1rem;
  font-size: 14px;
  text-align: left;
  color: var(--ink);
  -webkit-user-select: text;
  user-select: text;
}
.type-form input::placeholder { color: #5b7484; }
.type-form button {
  flex: none;
  border-radius: 9999px;
  border: 1px solid rgba(127, 212, 255, 0.4);
  background: rgba(10, 34, 51, 0.9);
  color: #dff4ff;
  padding: 0.65rem 1.2rem;
  font-size: 13px;
  font-weight: 500;
  min-height: 2.5rem;
}

/* ---------- Hoja de ajustes ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.sheet {
  width: 100%;
  max-height: 92dvh;
  overflow-y: auto;
  border-radius: 1.5rem 1.5rem 0 0;
  background: #0a1118;
  padding: 1.5rem;
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  text-align: left;
}
@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; justify-content: center; }
  .sheet { max-width: 28rem; border-radius: 1.5rem; }
}
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 0.25rem; }
.sheet h2 { margin: 0; font-size: 18px; font-weight: 600; }
.sheet .sub { margin: 0.25rem 0 0; font-size: 13px; line-height: 1.55; color: #9fb9c9; }
.close-btn {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  border: 0;
  background: rgba(255, 255, 255, 0.05);
  color: #cfeeff;
  font-size: 15px;
}
.sheet-box {
  margin-top: 1.25rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 1rem;
}
.sheet-box h3 { margin: 0; font-size: 14px; font-weight: 500; }
.sheet-box p { font-size: 13px; line-height: 1.6; color: #9fb9c9; }
.sheet-box a { color: var(--accent); }
.warn-box {
  margin-top: 1rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(245, 177, 76, 0.4);
  background: rgba(42, 29, 5, 0.6);
  padding: 0.75rem 0.9rem;
  font-size: 13px;
  line-height: 1.55;
  color: #ffd9a0;
}
.key-ok { font-size: 14px; color: #b8e6c8; margin: 0.75rem 0 0; }
.sheet label { display: block; margin-top: 1rem; font-size: 13px; color: #9fb9c9; }
.sheet input[type="password"] {
  margin-top: 0.5rem;
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.5);
  padding: 0.75rem 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  color: var(--ink);
  -webkit-user-select: text;
  user-select: text;
}
.sheet input[type="password"]::placeholder { color: #5b7484; }
.btn-save {
  margin-top: 1rem;
  width: 100%;
  border-radius: 9999px;
  border: 0;
  background: #1d6fa8;
  color: #fff;
  padding: 0.8rem;
  font-size: 15px;
  font-weight: 500;
  min-height: 3rem;
}
.btn-save:disabled { opacity: 0.4; }
.btn-danger {
  border-radius: 9999px;
  border: 0;
  background: rgba(255, 255, 255, 0.05);
  color: #ffb4a2;
  padding: 0.6rem 1.2rem;
  font-size: 14px;
  min-height: 2.5rem;
}
.sheet .foot { margin-top: 1.25rem; font-size: 12px; line-height: 1.6; color: var(--ink-faint); }
.form-error { margin-top: 0.5rem; font-size: 13px; color: #ffb4a2; }
.type-form .toggle-btn { padding: 0; width: 2.5rem; display: inline-flex; align-items: center; justify-content: center; }
.type-form .toggle-btn[aria-expanded="true"] { background: rgba(127, 212, 255, 0.2); }
.panel:has(#transcript[hidden]) { padding-top: 0.15rem; }
.cam-overlay {
  position: fixed; z-index: 25; left: 0.75rem; right: 0.75rem;
  top: max(0.75rem, env(safe-area-inset-top));
  aspect-ratio: 3 / 4; max-height: 60dvh; margin: 0 auto;
  border-radius: 1.25rem; overflow: hidden;
  border: 1px solid rgba(127, 212, 255, 0.45);
  box-shadow: 0 0 40px rgba(127, 212, 255, 0.25);
  background: #000;
}
.cam-overlay video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-overlay.rec { border-color: rgba(248, 113, 113, 0.8); box-shadow: 0 0 40px rgba(248, 113, 113, 0.35); }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity 0.35s ease-out; }
.cam-flash.on { opacity: 0.85; transition: none; }
.cam-label {
  position: absolute; left: 50%; bottom: 0.75rem; transform: translateX(-50%); margin: 0;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; letter-spacing: 0.2em;
  color: #fff; background: rgba(0,0,0,0.55); padding: 0.35rem 0.8rem; border-radius: 9999px; white-space: nowrap;
}
.gallery-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; margin-top: 1rem; }
.g-item { border-radius: 0.75rem; overflow: hidden; background: rgba(255,255,255,0.04); }
.g-item img, .g-item video { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; background: #000; }
.g-actions { display: flex; justify-content: space-around; padding: 0.35rem 0; }
.g-actions button { border: 0; background: none; color: var(--accent); font-size: 12px; padding: 0.4rem; min-height: 2.25rem; }
.g-actions button.del { color: #ffb4a2; }
[hidden] { display: none !important; }
