:root {
  color-scheme: dark;
  --ink: #07141d;
  --navy: #0b2534;
  --blue: #1297ea;
  --blue-deep: #0b6bcb;
  --cream: #eef6f7;
  --muted: #9bb1bc;
  --line: rgba(255, 255, 255, .12);
  --green: #4ee1a0;
  --red: #ff706b;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }

body {
  background: var(--ink);
  color: white;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button { font: inherit; }

.app-shell {
  display: grid;
  grid-template-rows: 1fr 96px 1fr;
  min-height: 100dvh;
  background: var(--ink);
}

.language-panel {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.language-panel::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: radial-gradient(circle at 12% 50%, rgba(18, 151, 234, .18), transparent 38%);
}

.language-panel--english { background: linear-gradient(115deg, #08202d, #07141d 65%); }
.language-panel--spanish { background: linear-gradient(65deg, #07141d 35%, #0b2635); }

.panel-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(170px, .55fr) minmax(320px, 1.8fr) minmax(190px, .6fr);
  align-items: center;
  gap: clamp(16px, 3vw, 48px);
  width: 100%;
  height: 100%;
  padding: clamp(18px, 3.2vh, 34px) clamp(24px, 5vw, 72px);
}

.panel-content--flipped { transform: rotate(180deg); }

.panel-header h1 { margin: 2px 0 10px; font-size: clamp(28px, 4vw, 52px); letter-spacing: -.04em; }

.eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .18em;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #647985; box-shadow: 0 0 0 4px rgba(100, 121, 133, .12); }
.status-pill.is-live { color: var(--green); }
.status-pill.is-live .status-dot { background: var(--green); box-shadow: 0 0 0 5px rgba(78, 225, 160, .13); animation: pulse 1.35s infinite; }
.status-pill.is-error { color: var(--red); }
.status-pill.is-error .status-dot { background: var(--red); }

.subtitle-wrap { align-self: stretch; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.subtitle { margin: 0; max-height: 3.7em; overflow: hidden; color: var(--cream); font-size: clamp(27px, 4.3vw, 58px); line-height: 1.07; font-weight: 690; letter-spacing: -.035em; text-wrap: balance; }
.subtitle.is-placeholder { color: #64808d; font-weight: 520; }
.source-caption { min-height: 1.4em; margin: 13px 0 0; overflow: hidden; color: var(--muted); font-size: clamp(13px, 1.5vw, 18px); white-space: nowrap; text-overflow: ellipsis; }
.source-caption:not(:empty)::before { content: "Tú: "; color: var(--blue); font-weight: 750; }

.talk-button {
  justify-self: end;
  display: grid;
  grid-template-columns: 52px 1fr;
  grid-template-rows: auto auto;
  gap: 1px 12px;
  align-items: center;
  min-width: 188px;
  min-height: 82px;
  padding: 14px 18px;
  border: 1px solid rgba(18, 151, 234, .44);
  border-radius: 18px;
  background: rgba(10, 58, 82, .62);
  color: white;
  text-align: left;
  box-shadow: inset 0 1px rgba(255, 255, 255, .08), 0 12px 34px rgba(0, 0, 0, .18);
  cursor: pointer;
  transition: transform .15s ease, background .2s ease, border-color .2s ease;
}

.talk-button:active { transform: scale(.97); }
.talk-button:disabled { opacity: .42; cursor: not-allowed; }
.talk-button.is-listening { background: var(--blue-deep); border-color: #65bdff; box-shadow: 0 0 0 7px rgba(18, 151, 234, .13), 0 12px 34px rgba(0, 0, 0, .22); }
.talk-label { grid-column: 2; font-weight: 760; font-size: 15px; }
.talk-hint { grid-column: 2; color: #a8c3d0; font-size: 11px; }
.talk-button.is-listening .talk-hint { color: white; }

.mic-icon {
  grid-row: 1 / 3;
  width: 31px;
  height: 42px;
  margin: auto;
  border: 4px solid currentColor;
  border-radius: 18px;
  position: relative;
}
.mic-icon::before { position: absolute; left: 50%; bottom: -13px; width: 43px; height: 25px; content: ""; transform: translateX(-50%); border: 4px solid currentColor; border-top: 0; border-radius: 0 0 22px 22px; }
.mic-icon::after { position: absolute; left: 50%; bottom: -22px; width: 4px; height: 10px; content: ""; transform: translateX(-50%); background: currentColor; box-shadow: -10px 9px 0 -1px currentColor, 10px 9px 0 -1px currentColor; }

.control-deck {
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(145px, .7fr) auto minmax(180px, 1.2fr) auto;
  align-items: center;
  gap: clamp(12px, 2vw, 28px);
  padding: 12px clamp(18px, 4vw, 54px);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #0c1b24;
  box-shadow: 0 0 42px rgba(0, 0, 0, .36);
}

.brand-lockup { display: flex; align-items: center; gap: 10px; font-size: 12px; letter-spacing: .12em; }
.brand-lockup img { border-radius: 9px; }
.brand-lockup strong, .brand-lockup span { display: block; }
.brand-lockup span { color: var(--blue); font-size: 9px; font-weight: 750; }

.mode-switch { display: flex; padding: 4px; border-radius: 12px; background: rgba(255, 255, 255, .055); }
.mode-button { min-height: 40px; padding: 0 15px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 720; cursor: pointer; }
.mode-button.is-active { background: #173b4d; color: white; box-shadow: inset 0 0 0 1px rgba(103, 190, 240, .25); }
.mode-button span { color: var(--blue); font-size: 9px; text-transform: uppercase; vertical-align: super; }
.global-status { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }

.utility-actions { display: flex; gap: 8px; }
.icon-button { display: grid; place-items: center; gap: 1px; min-width: 58px; height: 57px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .04); color: #d8e5ea; font-size: 21px; cursor: pointer; }
.icon-button span:last-child { font-size: 9px; font-weight: 700; }
.icon-button:disabled { opacity: .34; cursor: not-allowed; }
.icon-button[aria-pressed="true"] { color: var(--red); border-color: rgba(255, 112, 107, .34); }
.icon-button--danger { color: #ffaca8; }

.speaker-icon { position: relative; width: 13px; height: 15px; border-radius: 2px 0 0 2px; background: currentColor; }
.speaker-icon::before { position: absolute; left: 7px; top: -5px; content: ""; border-width: 12px 12px 12px 0; border-style: solid; border-color: transparent currentColor transparent transparent; transform: rotate(180deg); }
.icon-button[aria-pressed="true"] .speaker-icon::after { position: absolute; z-index: 1; left: 5px; top: -7px; width: 3px; height: 29px; content: ""; transform: rotate(-45deg); background: var(--red); box-shadow: 0 0 0 2px #0c1b24; }

.start-screen { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 30%, #123e54 0, #07141d 60%); transition: opacity .35s ease, visibility .35s ease; }
.start-screen.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.start-card { width: min(470px, 100%); padding: 36px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 28px; background: rgba(6, 20, 29, .82); text-align: center; box-shadow: 0 34px 90px rgba(0, 0, 0, .4); backdrop-filter: blur(22px); }
.start-logo { display: inline-flex; align-items: center; gap: 14px; font-weight: 850; letter-spacing: .14em; }
.start-logo img { border-radius: 16px; }
.start-card h2 { margin: 27px 0 10px; font-size: 32px; letter-spacing: -.035em; }
.start-card > p { color: var(--muted); line-height: 1.55; }
.primary-button { width: 100%; min-height: 58px; margin-top: 18px; border: 0; border-radius: 15px; background: linear-gradient(135deg, #159fec, #0b66c8); color: white; font-weight: 800; font-size: 16px; box-shadow: 0 15px 35px rgba(11, 107, 203, .25); cursor: pointer; }
.primary-button:disabled { opacity: .62; cursor: wait; }
.privacy-note { font-size: 12px; }
.privacy-note span { color: var(--green); }
.start-error { min-height: 1.4em; margin: 12px 0 0 !important; color: #ffaaa6 !important; font-size: 13px; }

.toast { position: fixed; z-index: 30; left: 50%; bottom: 112px; max-width: min(520px, calc(100% - 32px)); padding: 12px 18px; border: 1px solid rgba(255, 255, 255, .15); border-radius: 12px; background: #18323f; color: white; font-size: 13px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .25s ease; }
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

audio { display: none; }

@keyframes pulse { 50% { box-shadow: 0 0 0 9px rgba(78, 225, 160, 0); } }

@media (max-width: 900px), (max-height: 650px) {
  .app-shell { grid-template-rows: 1fr 82px 1fr; }
  .panel-content { grid-template-columns: minmax(120px, .5fr) 1.7fr 165px; padding-block: 13px; }
  .talk-button { min-width: 160px; min-height: 68px; grid-template-columns: 42px 1fr; padding: 10px 12px; }
  .mic-icon { transform: scale(.78); }
  .control-deck { padding-block: 8px; }
  .brand-lockup span, .global-status { display: none; }
  .icon-button { height: 52px; }
}

@media (orientation: portrait) {
  .app-shell { min-width: 700px; }
  body::after { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 20vw; content: "Gira la tablet para usar Indasol Translate en horizontal"; background: #07141d; color: white; font-size: 24px; font-weight: 750; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
