:root {
  --bg: #eef8ff;
  --card: #ffffff;
  --ink: #11263b;
  --muted: #6f8193;
  --line: #d8e8f4;
  --blue: #1379d1;
  --blue-dark: #085ca6;
  --green: #13a56f;
  --red: #e8505b;
  --shadow: 0 14px 38px rgba(39, 82, 115, .13);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { min-height: 100dvh; }
button, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(100%, 620px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(92px + env(safe-area-inset-bottom));
}

.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 8px 2px 18px; }
.eyebrow { font-size: 12px; letter-spacing: .14em; color: var(--blue); font-weight: 800; }
h1 { margin: 4px 0 0; font-size: clamp(26px, 7vw, 38px); line-height: 1.05; }
h1 span { color: var(--blue); }
.version { background: rgba(255,255,255,.8); border: 1px solid var(--line); padding: 7px 10px; border-radius: 999px; font-size: 12px; color: var(--muted); font-weight: 700; }

.language-strip { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 9px; margin-bottom: 16px; }
.language-pill { background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 16px; padding: 12px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.flag { font-size: 22px; }
.auto-pill { font-size: 11px; font-weight: 900; letter-spacing: .08em; background: var(--ink); color: white; padding: 7px 8px; border-radius: 999px; }

.panel { display: none; }
.panel.active { display: block; }
.status-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: rgba(255,255,255,.72); border: 1px solid var(--line); border-radius: 16px; margin-bottom: 14px; }
.status-card strong, .status-card small { display: block; }
.status-card small { margin-top: 3px; color: var(--muted); line-height: 1.35; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; background: #9badbc; box-shadow: 0 0 0 5px rgba(155,173,188,.16); flex: 0 0 auto; }
.status-dot.live { background: var(--green); box-shadow: 0 0 0 5px rgba(19,165,111,.16); }
.status-dot.error { background: var(--red); box-shadow: 0 0 0 5px rgba(232,80,91,.16); }

.conversation-grid { display: grid; gap: 9px; }
.speech-card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 18px; min-height: 130px; box-shadow: var(--shadow); }
.source-card { border-left: 5px solid var(--blue); }
.translation-card { border-left: 5px solid var(--green); }
.card-label { font-size: 12px; font-weight: 900; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.speech-text { margin: 0; font-size: clamp(20px, 5vw, 27px); line-height: 1.35; font-weight: 650; overflow-wrap: anywhere; }
.placeholder { color: #9aacbb; font-weight: 500; }
.arrow { text-align: center; font-size: 26px; color: var(--blue); line-height: 1; }

.mic-button { width: 100%; min-height: 74px; border: 0; border-radius: 22px; margin-top: 18px; background: linear-gradient(135deg, var(--blue), var(--blue-dark)); color: white; font-weight: 900; letter-spacing: .02em; box-shadow: 0 16px 32px rgba(19,121,209,.25); display: flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; }
.mic-button.live { background: linear-gradient(135deg, #16ad76, #0b875a); }
.mic-icon { font-size: 24px; }
.hint { text-align: center; color: var(--muted); font-size: 13px; line-height: 1.45; padding: 0 12px; }

.write-card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 18px; box-shadow: var(--shadow); }
.write-card label { display: block; font-weight: 800; margin-bottom: 10px; }
textarea { width: 100%; border: 1px solid #c8ddeb; border-radius: 16px; padding: 14px; resize: vertical; background: #f9fcff; color: var(--ink); outline: none; line-height: 1.45; }
textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(19,121,209,.10); }
.primary-button { width: 100%; margin-top: 12px; border: 0; border-radius: 15px; min-height: 52px; background: var(--blue); color: white; font-weight: 900; cursor: pointer; }
.primary-button:disabled { opacity: .55; cursor: wait; }
.written-result { margin-top: 14px; }

.history-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.history-head strong, .history-head small { display: block; }
.history-head small { color: var(--muted); margin-top: 3px; }
.ghost-button { border: 1px solid var(--line); background: white; border-radius: 12px; padding: 9px 13px; color: var(--red); font-weight: 750; cursor: pointer; }
.history-list { display: grid; gap: 10px; }
.history-empty { text-align: center; color: var(--muted); background: rgba(255,255,255,.65); border: 1px dashed var(--line); border-radius: 18px; padding: 30px 18px; }
.history-item { background: white; border: 1px solid var(--line); border-radius: 17px; padding: 14px; box-shadow: 0 8px 22px rgba(39,82,115,.08); }
.history-item .from { color: var(--muted); font-size: 13px; margin-bottom: 5px; }
.history-item .to { font-weight: 750; line-height: 1.35; }
.history-item time { display: block; margin-top: 8px; font-size: 11px; color: #9aacbb; }

.bottom-nav { position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(calc(100% - 24px), 596px); display: grid; grid-template-columns: repeat(3, 1fr); background: rgba(255,255,255,.93); backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: 22px; padding: 7px; box-shadow: 0 18px 48px rgba(27,64,92,.18); z-index: 10; }
.nav-button { border: 0; background: transparent; min-height: 56px; border-radius: 16px; color: var(--muted); font-size: 18px; cursor: pointer; }
.nav-button span { display: block; font-size: 11px; margin-top: 3px; font-weight: 750; }
.nav-button.active { background: #e8f4fd; color: var(--blue-dark); }

@media (min-width: 700px) {
  .app-shell { padding-left: 22px; padding-right: 22px; }
  .conversation-grid { grid-template-columns: 1fr 38px 1fr; align-items: stretch; }
  .arrow { display: grid; place-items: center; transform: rotate(-90deg); }
}


.header-actions { display: grid; justify-items: end; gap: 8px; }
.install-button { border: 1px solid #b9d9ee; background: #fff; color: var(--blue-dark); border-radius: 12px; min-height: 36px; padding: 7px 10px; font-size: 11px; font-weight: 900; cursor: pointer; box-shadow: 0 8px 20px rgba(39,82,115,.08); }
.install-button.installed { color: var(--green); cursor: default; }

.install-dialog { width: min(calc(100% - 28px), 460px); border: 0; border-radius: 24px; padding: 0; box-shadow: 0 24px 70px rgba(20,54,78,.28); color: var(--ink); }
.install-dialog::backdrop { background: rgba(14,33,49,.48); backdrop-filter: blur(3px); }
.install-dialog-inner { position: relative; padding: 28px 22px 22px; background: #fff; }
.dialog-close { position: absolute; top: 10px; right: 12px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: #eff6fb; color: var(--ink); font-size: 27px; line-height: 1; cursor: pointer; }
.install-icon { text-align: center; font-size: 44px; margin-bottom: 6px; }
.install-dialog h2 { text-align: center; margin: 0 36px 16px; font-size: 22px; }
.install-instructions { color: #40586d; line-height: 1.5; font-size: 15px; }
.install-instructions ol { margin: 10px 0 0; padding-left: 22px; }
.install-instructions li { margin: 8px 0; }
.install-instructions strong { color: var(--ink); }
.platform-badge { display: inline-block; background: #eaf5fd; color: var(--blue-dark); font-weight: 850; font-size: 12px; padding: 5px 9px; border-radius: 999px; margin-bottom: 8px; }

@media (max-width: 520px) {
  .topbar { gap: 8px; }
  .header-actions { gap: 6px; }
  .install-button { padding: 6px 8px; font-size: 10px; }
  .version { padding: 6px 8px; }
}

/* v1.0.2 - selector de contexto */
.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 14px;
}
.mode-button {
  border: 1px solid rgba(42, 111, 151, .2);
  background: rgba(255,255,255,.78);
  color: #24516b;
  border-radius: 14px;
  padding: 11px 10px;
  font-weight: 800;
  cursor: pointer;
}
.mode-button.active {
  background: #dff3ff;
  border-color: #4aa9da;
  box-shadow: inset 0 0 0 1px rgba(74,169,218,.22);
}
@media (max-width: 520px) {
  .mode-switch { grid-template-columns: 1fr; }
}
