/* ==========================================================================
   RELAX · ESTUDIO TIKTOKER 2.5D — Tema Oscuro Sereno (CERO BLANCOS AGRESIVOS)
   Luminancia máxima <= #b8c4ce (184/255)
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg-void: #05070b;
  --bg-dock: rgba(10, 14, 20, 0.94);
  --bg-card: rgba(16, 22, 31, 0.88);
  --bg-input: rgba(8, 11, 17, 0.94);
  --border-dim: rgba(88, 112, 134, 0.22);
  --border-active: rgba(104, 154, 180, 0.62);
  --text-main: #aebbc6;
  --text-muted: #738394;
  --text-accent: #88b0c6;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: #263445 #080c12;
}

*::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

*::-webkit-scrollbar-track {
  background: #080c12;
}

*::-webkit-scrollbar-thumb {
  background: #263445;
  border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
  background: #36495f;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg-void);
  color: var(--text-main);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  user-select: none;
}

#studio-layout {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  background: radial-gradient(circle at center, #0c121b 0%, #05070b 78%);
  overflow: hidden;
}

/* Modo Limpio OBS (?clean=1 o tecla L): solo el lienzo 9:16 a pantalla completa */
body.clean-mode #studio-layout {
  padding: 0;
  gap: 0;
}

body.clean-mode .studio-dock {
  display: none !important;
}

.exit-clean-btn {
  display: none;
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 30;
  background: rgba(11, 16, 24, 0.72);
  border: 1px solid var(--border-dim);
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 11.5px;
  cursor: pointer;
  opacity: 0.18;
  transition: opacity 0.25s ease;
}

.exit-clean-btn:hover {
  opacity: 0.95;
  color: var(--text-main);
  border-color: var(--border-active);
}

body.clean-mode:not(.obs-hard-clean) .exit-clean-btn {
  display: block;
}

/* Paneles laterales del Estudio */
.studio-dock {
  flex: 1 1 265px;
  min-width: 232px;
  max-width: 345px;
  height: 100%;
  background: var(--bg-dock);
  border: 1px solid var(--border-dim);
  border-radius: 13px;
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  overflow-x: hidden;
}

.dock-brand {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border-dim);
}

.dock-brand h1 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-main);
}

.subtitle {
  font-size: 10.5px;
  color: var(--text-muted);
}

.path-tag {
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(36, 56, 74, 0.35);
  border: 1px solid var(--border-dim);
  color: var(--text-accent);
}

/* Lienzo vertical 9:16 central */
#stage-9x16 {
  position: relative;
  width: min(calc((100vh - 20px) * 9 / 16), calc(100vw - 504px));
  aspect-ratio: 9 / 16;
  max-height: 100%;
  background: #070a0f;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.88);
  flex-shrink: 0;
}

body.clean-mode #stage-9x16 {
  width: min(calc(100vh * 9 / 16), 100vw);
  height: auto;
  max-height: 100vh;
  border-radius: 0;
}

#stage-9x16 canvas:first-child {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

#mist-canvas {
  position: absolute;
  top: 2%;
  left: 0;
  width: 100%;
  height: 50%;
  pointer-events: none;
  z-index: 4;
}

/* Capa cinematográfica 9:16 para videos de agradecimiento en donaciones/regalos */
.gift-video-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: #05080d;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gift-video-overlay.visible {
  opacity: 1;
}

#gift-video-player {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gift-donor-pill {
  position: absolute;
  top: 6.4%;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(7, 11, 18, 0.78);
  border: 1px solid rgba(154, 140, 188, 0.38);
  backdrop-filter: blur(6px);
  color: #b8c2cc;
  font-size: 11.5px;
  font-weight: 500;
  text-shadow:
    -1px -1px 0 #04070c,
     1px -1px 0 #04070c,
    -1px  1px 0 #04070c,
     1px  1px 0 #04070c;
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.35s ease;
}

.gift-donor-pill.hidden {
  opacity: 0;
}

.video-trig-btn {
  border-color: rgba(118, 102, 168, 0.36);
  color: #a498c0;
}

.stream-whisper {
  position: absolute;
  top: 2.0%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(6, 10, 16, 0.72);
  border: 1px solid rgba(100, 128, 148, 0.24);
  backdrop-filter: blur(5px);
  color: #9fb0be;
  font-size: 11px;
  font-weight: 500;
  text-shadow:
    -1px -1px 0 #04070c,
     1px -1px 0 #04070c,
    -1px  1px 0 #04070c,
     1px  1px 0 #04070c,
     0 2px 6px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.stream-whisper.hidden {
  opacity: 0;
}

/* Meta colectiva serena ("Gotas de calma · X / 100") — cero blancos agresivos */
.calm-goal-pill {
  position: absolute;
  top: 5.5%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 12px 5px;
  min-width: 176px;
  max-width: 78%;
  border-radius: 999px;
  background: rgba(6, 10, 16, 0.66);
  border: 1px solid rgba(92, 128, 148, 0.22);
  backdrop-filter: blur(5px);
  color: #8ea4b4;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-shadow:
    -1px -1px 0 #04070c,
     1px -1px 0 #04070c,
    -1px  1px 0 #04070c,
     1px  1px 0 #04070c;
  pointer-events: none;
  transition: opacity 0.4s ease, border-color 0.45s ease;
}

.calm-goal-pill.hidden {
  opacity: 0;
}

.calm-goal-pill.event-active {
  border-color: rgba(88, 156, 134, 0.46);
  color: #96c0b0;
}

.calm-goal-track {
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: rgba(24, 36, 48, 0.85);
  overflow: hidden;
}

.calm-goal-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4b7892 0%, #5c9e88 100%);
  transition: width 0.45s ease;
}

.calm-goal-pill.event-active .calm-goal-fill {
  width: 100% !important;
  background: linear-gradient(90deg, #549682 0%, #8678b2 50%, #549682 100%);
}

.calm-trig-btn {
  border-color: rgba(84, 142, 124, 0.36);
  color: #8cb8a8;
}

.smart-rtk-row {
  justify-content: space-between;
  padding: 1px 2px;
}

.whisper-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6c94ab;
  flex-shrink: 0;
  animation: slowPulse 3.4s ease-in-out infinite;
}

@keyframes slowPulse {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 0.9; transform: scale(1.12); }
}

.audio-unlock-pill {
  position: absolute;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  background: rgba(13, 19, 28, 0.88);
  color: #9cb0c0;
  border: 1px solid rgba(108, 144, 168, 0.38);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.audio-unlock-pill.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Bloques de herramientas */
.panel-block {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 10px;
  padding: 7.5px 9px;
  display: flex;
  flex-direction: column;
  gap: 5.5px;
}

.highlight-block {
  border-color: rgba(98, 142, 168, 0.34);
}

.grow-block {
  flex: 1;
  min-height: 230px;
}

.panel-block h2 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-accent);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hint {
  font-weight: 400;
  text-transform: none;
  color: var(--text-muted);
  font-size: 10.5px;
}

/* Tarjetas de los 3 Escenarios */
.scene-cards {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.scene-card {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  background: var(--bg-input);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s ease;
}

.scene-card:hover {
  border-color: rgba(108, 150, 176, 0.44);
  color: var(--text-main);
}

.scene-card.active {
  background: rgba(42, 74, 96, 0.38);
  border-color: var(--border-active);
  color: var(--text-main);
}

.sc-badge {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(32, 48, 64, 0.65);
  color: var(--text-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.scene-card.active .sc-badge {
  background: rgba(72, 122, 152, 0.55);
  color: var(--text-main);
}

.sc-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.sc-info strong {
  font-size: 12px;
  font-weight: 600;
}

.sc-info span {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Simulador de Público y Feed en Vivo */
.viewer-pill {
  font-size: 10px;
  text-transform: none;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(20, 28, 38, 0.9);
  color: var(--text-muted);
  border: 1px solid var(--border-dim);
}

.viewer-pill.live {
  background: rgba(36, 84, 68, 0.45);
  border-color: rgba(78, 148, 122, 0.5);
  color: #8cc0ab;
}

.quick-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.mini-act {
  padding: 5px 4px !important;
  font-size: 10.5px !important;
}

.feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-accent);
  font-size: 10.5px;
  cursor: pointer;
}

.live-feed {
  flex: 1;
  min-height: 120px;
  max-height: 260px;
  background: var(--bg-input);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  padding: 6px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  contain: content;
}

.feed-empty {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  padding: 8px 4px;
  text-align: center;
}

.feed-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  line-height: 1.32;
  padding: 5px 6px;
  border-radius: 6px;
  background: rgba(18, 25, 36, 0.72);
  border: 1px solid rgba(78, 100, 122, 0.14);
  contain: content;
}

.feed-item.gift {
  background: rgba(44, 68, 58, 0.28);
  border-color: rgba(86, 146, 120, 0.30);
}

.feed-body {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.feed-user {
  font-weight: 600;
  color: var(--text-accent);
  margin-right: 4px;
}

.feed-reply-btn {
  background: rgba(44, 78, 100, 0.45);
  border: 1px solid rgba(98, 146, 174, 0.38);
  color: var(--text-main);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 10.5px;
  cursor: pointer;
  flex-shrink: 0;
}

.feed-reply-btn:hover {
  background: rgba(58, 100, 128, 0.7);
}

/* Estadísticas y Clima */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.stat-chip {
  background: var(--bg-input);
  border: 1px solid var(--border-dim);
  border-radius: 7px;
  padding: 5px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-chip span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.stat-chip small {
  font-size: 9.5px;
  color: var(--text-muted);
}

.weather-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.engine-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.engine-btn {
  font-size: 10.4px !important;
  padding: 6px 3px !important;
  white-space: nowrap;
}

.weather-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-dim);
  color: var(--text-muted);
  border-radius: 7px;
  padding: 6px 4px;
  font-size: 11px;
  cursor: pointer;
}

.weather-btn.active {
  background: rgba(44, 78, 102, 0.42);
  border-color: var(--border-active);
  color: var(--text-main);
}

/* Controles comunes */
.field-row {
  display: flex;
  gap: 5px;
  align-items: center;
}

.compact-top {
  margin-top: 2px;
}

.inline-lbl {
  font-size: 11px;
  color: var(--text-muted);
  flex: 1;
}

.mini-chk {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-dim);
  border-radius: 7px;
  color: var(--text-main);
  padding: 6px 8px;
  font-size: 11.5px;
  font-family: inherit;
  outline: none;
  user-select: text;
}

input[type="text"],
input[type="password"],
select {
  flex: 1;
  min-width: 0;
}

input[type="number"] {
  width: 60px;
}

textarea {
  width: 100%;
  resize: vertical;
  line-height: 1.35;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-active);
}

.btn-row {
  display: flex;
  gap: 5px;
}

.primary-btn,
.accent-btn,
.ghost-btn {
  border-radius: 7px;
  padding: 6.5px 9px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  outline: none;
  transition: background 0.18s, border-color 0.18s;
}

button:focus,
button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 1px rgba(104, 154, 180, 0.45);
}

.primary-btn {
  flex: 1;
  background: rgba(46, 86, 110, 0.56);
  border: 1px solid rgba(104, 154, 180, 0.48);
  color: var(--text-main);
}

.primary-btn:hover {
  background: rgba(56, 102, 130, 0.72);
}

.accent-btn {
  background: rgba(44, 92, 78, 0.50);
  border: 1px solid rgba(88, 150, 130, 0.46);
  color: var(--text-main);
  white-space: nowrap;
}

.accent-btn:hover,
.accent-btn.running {
  background: rgba(58, 118, 98, 0.68);
}

.ghost-btn {
  flex: 1;
  background: rgba(14, 20, 29, 0.82);
  border: 1px solid var(--border-dim);
  color: var(--text-muted);
}

.ghost-btn:hover {
  color: var(--text-main);
  border-color: var(--border-active);
}

.ghost-btn.mini {
  flex: 0 0 auto;
  padding: 6px 8px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--text-muted);
}

.slider-row label {
  width: 52px;
}

.slider-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: #121b26;
  border: 1px solid rgba(88, 124, 150, 0.34);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #6797b4;
  border: 2px solid #0b1119;
  cursor: pointer;
}

.slider-row input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #6797b4;
  border: 2px solid #0b1119;
  cursor: pointer;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
}

.toggle-row input,
.mini-chk input {
  accent-color: #5a88a4;
}

.status-badge {
  font-size: 10.5px;
  color: var(--text-muted);
  background: rgba(8, 11, 17, 0.8);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 5px 7px;
  line-height: 1.3;
}

.status-badge.ok {
  border-color: rgba(74, 142, 116, 0.46);
  color: #8ab8a6;
}

.status-badge.warn {
  border-color: rgba(168, 134, 82, 0.48);
  color: #bfa478;
}

/* 7. Log Histórico en Vivo de Gemini Poético */
.gemini-log-panel {
  flex: 1 0 auto;
  min-height: 195px;
  transition: border-color 0.25s ease, opacity 0.25s ease;
}

.gemini-log-panel.active-gemini {
  border-color: rgba(124, 102, 176, 0.48);
}

.gemini-log-panel.standby-gemini {
  opacity: 0.86;
}

.glog-toolbar {
  margin-top: 0;
  gap: 6px;
}

.glog-test-btn {
  padding: 4px 8px !important;
  font-size: 10.5px !important;
  border-color: rgba(124, 102, 176, 0.44);
  color: #a898c4;
  background: rgba(34, 26, 54, 0.48);
}

.glog-test-btn:hover {
  background: rgba(48, 36, 76, 0.68);
  border-color: rgba(152, 128, 196, 0.65);
  color: var(--text-main);
}

.gemini-log-list {
  min-height: 126px;
  max-height: 235px;
  gap: 6px;
}

.glog-item {
  background: rgba(13, 19, 28, 0.92);
  border: 1px solid rgba(88, 112, 134, 0.24);
  border-left: 3px solid #6c8ea6;
  border-radius: 7px;
  padding: 5.5px 7px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10.5px;
  line-height: 1.35;
  user-select: text;
}

.glog-item.ok {
  border-left-color: #8f74c2;
  background: rgba(18, 19, 32, 0.92);
}

.glog-item.rotation {
  border-left-color: #529682;
  background: rgba(13, 23, 25, 0.92);
}

.glog-item.fallback {
  border-left-color: #bfa478;
}

.glog-item.system {
  border-left-color: #5b8fa8;
  padding: 4.5px 7px;
}

.glog-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 5px;
  font-size: 9.8px;
  color: var(--text-muted);
}

.glog-badge {
  font-weight: 600;
  color: #a898c4;
}

.glog-item.rotation .glog-badge {
  color: #84b8a6;
}

.glog-item.fallback .glog-badge {
  color: #bfa478;
}

.glog-item.system .glog-badge {
  color: #88b0c6;
}

.glog-q {
  color: #7f91a3;
  font-size: 10px;
}

.glog-q b {
  color: #9ab2c4;
  font-weight: 600;
}

.glog-ans {
  color: var(--text-main);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 13px;
  line-height: 1.28;
}

.glog-note {
  color: #8a9bad;
  font-size: 10px;
}

/* Pantallas muy angostas (<860px): permite desplazar con barra nocturna oscura */
@media (max-width: 860px) {
  #studio-layout {
    overflow-x: auto;
    justify-content: flex-start;
  }
  #stage-9x16 {
    width: calc((100vh - 20px) * 9 / 16);
  }
}
