/* Intérprete PL ⇄ ES — estilos. Paleta cálida de papel con dos acentos:
   verde azulado = escuchar al otro · óxido = hablar yo.
   Base visual heredada de zhai66666-max/airpods-live-translate (MIT), rehecha. */

:root {
  --bg: #f4f3ef;
  --bg2: #eceae4;
  --card: #fff;
  --ink: #15181c;
  --ink2: #3d434b;
  --muted: #6f7680;
  --line: #e2e0d8;
  --line2: #efece5;
  --a1: #0d7a68;
  --a1soft: #e3f2ee;
  --a2: #a8501c;
  --a2soft: #f8ece2;
  --accent: var(--a1);
  --accentsoft: var(--a1soft);
  --danger: #c0392b;
  --sab: env(safe-area-inset-bottom, 0px);
  --sat: env(safe-area-inset-top, 0px);
  --dst-size: 21px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121416;
    --bg2: #1b1e21;
    --card: #1e2226;
    --ink: #eef0f2;
    --ink2: #c3c8ce;
    --muted: #8d949c;
    --line: #2c3237;
    --line2: #262b30;
    --a1: #3fc2a8;
    --a1soft: #17332d;
    --a2: #e08a52;
    --a2soft: #3a2a1e;
    --danger: #ff7b6b;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overscroll-behavior: none;
}
body.replying { --accent: var(--a2); --accentsoft: var(--a2soft); }
html.big { --dst-size: 27px; }

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 780px; margin: 0 auto; }

/* ---------- cabecera ---------- */
header { padding: calc(var(--sat) + 8px) 16px 8px; flex: 0 0 auto; border-bottom: 1px solid var(--line2); }
.hrow { display: flex; align-items: center; gap: 10px; }
.brand { font-size: 15px; font-weight: 650; letter-spacing: .02em; display: flex; align-items: center; gap: 7px; }
.pair { font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accentsoft); padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #b9b7b0; transition: .2s; }
.dot.live { background: var(--accent); animation: pulse 1.8s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(13, 122, 104, .45); }
  70% { box-shadow: 0 0 0 9px rgba(13, 122, 104, 0); }
  100% { box-shadow: 0 0 0 0 rgba(13, 122, 104, 0); }
}
.spacer { flex: 1; }
.iconbtn {
  width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--line); background: var(--card);
  display: grid; place-items: center; cursor: pointer; color: var(--ink2); font-size: 15px; padding: 0; font-family: inherit;
}
.iconbtn:active { transform: scale(.95); }
.chanbadge { font-size: 11px; padding: 3px 8px; border-radius: 20px; background: var(--a1soft); color: var(--a1); font-weight: 600; white-space: nowrap; }
.chanbadge.bad { background: #fdecea; color: var(--danger); }

.seg { display: flex; margin-top: 9px; background: var(--bg2); border-radius: 13px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border: 0; background: transparent; padding: 9px 4px; border-radius: 10px; font: inherit; font-size: 13.5px;
  font-weight: 600; color: var(--muted); cursor: pointer; transition: .18s; white-space: nowrap;
}
.seg button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .09); }

/* ---------- conversación ---------- */
main {
  flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 14px 4px; display: flex; flex-direction: column; gap: 10px;
}
.card { background: var(--card); border: 1px solid var(--line2); border-radius: 16px; padding: 12px 15px; animation: rise .22s ease-out; }
.card.mine { border-left: 4px solid var(--a2); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* Etiqueta de voz: «Voz 2» / «Tú». Seis colores que se repiten; el color nunca es el único dato (va el texto). */
.card .who { display: inline-block; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--a2); margin-bottom: 6px; padding: 1px 8px; border-radius: 10px; }
.card .who[class*="spk-"] { color: var(--spk); background: color-mix(in oklab, var(--spk) 15%, transparent); }
.who.spk-0 { --spk: #0d7a68; }
.who.spk-1 { --spk: #a8501c; }
.who.spk-2 { --spk: #4c5fd5; }
.who.spk-3 { --spk: #7a8a1f; }
.who.spk-4 { --spk: #b03a8a; }
.who.spk-5 { --spk: #5b6670; }
@media (prefers-color-scheme: dark) {
  .who.spk-0 { --spk: #3fc2a8; }
  .who.spk-1 { --spk: #e08a52; }
  .who.spk-2 { --spk: #8f9dff; }
  .who.spk-3 { --spk: #b9c85a; }
  .who.spk-4 { --spk: #e47fc0; }
  .who.spk-5 { --spk: #9aa6b0; }
}
.card .src { font-size: 13.5px; line-height: 1.5; color: var(--muted); padding-left: 10px; border-left: 2px solid var(--line); }
.card .dst { margin-top: 7px; font-size: var(--dst-size); line-height: 1.42; font-weight: 500; color: var(--ink); word-break: break-word; }
.card .dst.streaming::after {
  content: ''; display: inline-block; width: 2px; height: 1.05em; vertical-align: -.16em; margin-left: 2px;
  background: var(--accent); animation: blink .9s step-end infinite;
}
.card .dst.error { color: var(--danger); font-size: 15px; }
@keyframes blink { 50% { opacity: 0; } }
.dots { display: inline-flex; gap: 4px; align-items: center; height: 21px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); opacity: .35; animation: hop 1.1s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes hop { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

.livebar { font-size: 13.5px; color: var(--muted); padding: 2px 20px 6px; min-height: 22px; font-style: italic; flex: 0 0 auto; }
.empty { margin: auto; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.8; padding: 16px; max-width: 520px; }
.empty .big { font-size: 32px; display: block; margin-bottom: 8px; }
.setup { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; text-align: left; }
.setup h4 { margin: 0 0 8px; font-size: 15.5px; color: var(--ink); }
.setup p { margin: 0 0 10px; font-size: 13.5px; color: var(--ink2); line-height: 1.7; }
.setup ol { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--ink2); line-height: 1.8; }
.setup code, .field code { background: var(--bg2); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }
.warnbox { background: #fdf1ec; border: 1px solid #f3d8cb; border-radius: 13px; padding: 12px 14px; font-size: 13px; color: #8a3f1c; line-height: 1.65; margin-top: 12px; text-align: left; }
@media (prefers-color-scheme: dark) { .warnbox { background: #35241b; border-color: #50362a; color: #f0b79a; } }

/* ---------- pie ---------- */
footer { flex: 0 0 auto; padding: 8px 14px calc(10px + var(--sab)); background: linear-gradient(to top, var(--bg) 72%, transparent); }
.ctrls { display: flex; align-items: center; gap: 10px; }
#talk {
  flex: 1; height: 56px; border: 0; border-radius: 18px; background: var(--accent); color: #fff; font: inherit; font-size: 16.5px;
  font-weight: 650; letter-spacing: .03em; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 9px;
  box-shadow: 0 4px 14px rgba(13, 122, 104, .22); transition: .16s;
}
#talk:active { transform: scale(.985); }
#talk.stop { background: #2a2e35; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
#talk .sq { width: 11px; height: 11px; border-radius: 3px; background: #fff; }
.mini {
  width: 52px; height: 56px; border-radius: 18px; border: 1px solid var(--line); background: var(--card); display: grid;
  place-items: center; font-size: 19px; cursor: pointer; color: var(--ink2); padding: 0; font-family: inherit;
}
.mini.on { background: var(--accentsoft); border-color: transparent; color: var(--accent); }
.mini.off { opacity: .42; }
.meter { height: 4px; margin: 8px 6px 0; background: var(--line); border-radius: 3px; overflow: hidden; }
.meter i { display: block; width: 100%; height: 100%; background: var(--accent); transform-origin: left center; transform: scaleX(0); transition: transform .08s linear; }
.stat { text-align: center; font-size: 11px; color: var(--muted); margin-top: 7px; height: 14px; }

.reply-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 56px; margin-bottom: 10px; border: 0;
  border-radius: 18px; background: var(--a2); color: #fff; font: inherit; font-size: 17px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 14px rgba(168, 80, 28, .28); transition: .16s;
}
.reply-btn:active { transform: scale(.985); }
.reply-sub { font-size: 13px; font-weight: 600; opacity: .85; }

/* ---------- pantalla para el interlocutor ---------- */
.reply { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: var(--a2); color: #fff; }
.reply-them { flex: 1 1 58%; transform: rotate(180deg); display: flex; align-items: center; justify-content: center; padding: 28px 24px; text-align: center; overflow: hidden; }
.reply-them p { margin: 0; font-size: clamp(28px, 8vw, 54px); line-height: 1.2; font-weight: 650; word-break: break-word; }
.reply-me {
  flex: 1 1 42%; background: var(--bg); color: var(--ink); border-radius: 26px 26px 0 0;
  padding: 20px 20px calc(18px + var(--sab)); display: flex; flex-direction: column; gap: 8px;
}
.reply-status { margin: 0; font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--a2); }
.reply-src { margin: 0; font-size: 20px; line-height: 1.4; flex: 1; overflow-y: auto; }
.reply-done { height: 48px; border: 0; border-radius: 14px; background: var(--a2); color: #fff; font: inherit; font-size: 15px; font-weight: 650; cursor: pointer; }
.reply-close { height: 48px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }

/* ---------- ajustes ---------- */
#sheet { position: fixed; inset: 0; z-index: 50; }
#sheet .veil { position: absolute; inset: 0; background: rgba(20, 22, 26, .4); }
#sheet .panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow-y: auto; background: var(--bg);
  border-radius: 22px 22px 0 0; padding: 8px 18px calc(26px + var(--sab)); animation: up .25s cubic-bezier(.2, .8, .3, 1);
  max-width: 780px; margin: 0 auto;
}
@keyframes up { from { transform: translateY(18px); opacity: .6; } to { transform: none; opacity: 1; } }
.grab { width: 38px; height: 4px; border-radius: 3px; background: var(--line); margin: 6px auto 14px; }
.panel h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 8px; font-weight: 650; }
.panel h3:first-of-type { margin-top: 4px; }
.field { background: var(--card); border: 1px solid var(--line2); border-radius: 13px; padding: 11px 13px; margin-bottom: 9px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.field-text { font-size: 14.5px; line-height: 1.6; }
.field input, .field textarea { width: 100%; border: 0; background: transparent; font: inherit; font-size: 15px; color: var(--ink); padding: 2px 0; outline: none; -webkit-appearance: none; appearance: none; }
.field textarea { resize: vertical; min-height: 56px; line-height: 1.5; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.row { display: flex; align-items: center; gap: 12px; justify-content: space-between; background: var(--card); border: 1px solid var(--line2); border-radius: 13px; padding: 12px 13px; margin-bottom: 9px; }
.row .lab { font-size: 14.5px; }
.row .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.4; max-width: 230px; }
select { font: inherit; font-size: 15px; border: 0; background: transparent; text-align: right; color: var(--ink); -webkit-appearance: none; appearance: none; padding: 2px 0; outline: none; max-width: 48%; }
input[type=range] { width: 112px; accent-color: var(--accent); }
.sw { width: 46px; height: 28px; border-radius: 16px; background: #cfccc3; position: relative; transition: .18s; flex: 0 0 auto; cursor: pointer; border: 0; padding: 0; }
.sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .18s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.sw.on { background: var(--accent); }
.sw.on::after { left: 21px; }
.btnrow { display: flex; gap: 9px; margin-top: 10px; }
.btnrow button { flex: 1; padding: 13px; border-radius: 13px; border: 1px solid var(--line); background: var(--card); font: inherit; font-size: 14.5px; font-weight: 600; color: var(--ink); cursor: pointer; }
.btnrow button.warn { color: var(--danger); }
#connmsg { font-size: 12.5px; margin-top: 6px; min-height: 16px; line-height: 1.5; }
#connmsg.ok { color: var(--a1); }
#connmsg.err { color: var(--danger); }
.fine { font-size: 11.5px; color: var(--muted); margin-top: 14px; line-height: 1.6; }

.toast {
  position: fixed; left: 50%; bottom: calc(150px + var(--sab)); transform: translateX(-50%); background: rgba(28, 31, 36, .95); color: #fff;
  font-size: 13.5px; padding: 10px 16px; border-radius: 12px; z-index: 80; max-width: 86vw; text-align: center; line-height: 1.5; animation: tin .2s;
}
@keyframes tin { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (min-width: 700px) { :root { --dst-size: 23px; } main { padding: 18px 20px 4px; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- autodiagnóstico ---------- */
.st-main { max-width: 780px; margin: 0 auto; height: 100%; overflow-y: auto; padding: calc(var(--sat) + 16px) 16px calc(24px + var(--sab)); }
.st-main h1 { font-size: 22px; margin: 4px 0 6px; }
.st-lead { color: var(--ink2); font-size: 14px; margin: 0 0 14px; }
.st-back { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 14px; }
.st-list { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 10px; }
.st-item { background: var(--card); border: 1px solid var(--line2); border-radius: 14px; padding: 12px 14px; }
.st-head { display: flex; gap: 10px; align-items: baseline; font-size: 14.5px; }
.st-icon { width: 18px; text-align: center; font-weight: 700; color: var(--muted); }
.st-msg { margin: 4px 0 0 28px; font-size: 13px; color: var(--ink2); line-height: 1.55; word-break: break-word; }
.st-item[data-status="ok"] .st-icon { color: var(--a1); }
.st-item[data-status="warn"] .st-icon { color: #c98a00; }
.st-item[data-status="bad"] { border-color: var(--danger); }
.st-item[data-status="bad"] .st-icon { color: var(--danger); }
.st-item .btnrow { margin: 10px 0 0 28px; }
