:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #e3e8ee;
  --text: #142230;
  --muted: #5b6878;
  --line: #d5dce4;
  --accent: #0f6b74;
  --accent-ink: #ffffff;
  --rec: #e0393e;
  --wa: #1e8e4e;
  --ok: #2e8a57;
  --warn: #a86400;
  --err: #c93a3f;
  --hl: #fde9b8;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1820;
    --surface: #16232e;
    --surface-2: #213140;
    --text: #e6edf3;
    --muted: #93a1b0;
    --line: #263746;
    --accent: #5cc8c9;
    --accent-ink: #062226;
    --rec: #ff5c61;
    --wa: #3cc47a;
    --ok: #4cc38a;
    --warn: #f1a10d;
    --err: #ff6369;
    --hl: #3a3216;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent); text-decoration: none; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pad { padding: 32px 0; }
.small { font-size: 14px; }
.error { color: var(--err); }

/* barra superior */
.bar {
  position: sticky; top: var(--rb, 0px); z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.bar h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.bar .bar-title { flex: 1; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--text); }
.icon-btn:active { background: var(--surface-2); }

/* lista */
.list-main { padding: 0 16px calc(160px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 12px; padding: 0 12px; margin: 4px 0 12px; color: var(--muted); }
.search svg { width: 18px; height: 18px; flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: none; padding: 10px 0; outline: none; color: var(--text); }
.card.setup { display: block; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 14px 16px; margin: 4px 0 12px; color: var(--text); }
.card.setup span { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
.day { font-size: 15px; color: var(--text); margin: 22px 4px 8px; font-weight: 650; }
.day::first-letter { text-transform: uppercase; }
.note-row { display: block; background: var(--surface); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; color: var(--text); border: 1px solid var(--line); }
.note-row:active { background: var(--surface-2); }
.row-top { display: flex; justify-content: space-between; gap: 12px; }
.row-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-top .time { color: var(--muted); font-size: 14px; flex: none; }
.row-sub { margin: 2px 0 6px; color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.pill, .tag { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); }
.pill.error { color: var(--err); }
.pill.transcribing, .pill.summarizing { color: var(--accent); }
.pill.recorded, .pill.transcribed { color: var(--warn); }
.empty { text-align: center; padding: 56px 24px; color: var(--muted); }
.empty-mic { display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--surface-2); color: var(--rec); margin-bottom: 8px; }
.empty-mic svg { width: 32px; height: 32px; }
.empty strong { color: var(--text); }

/* dock: el boton de grabar es la pieza principal de la app */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 28px 16px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%);
}
.rec-btn {
  display: flex; align-items: center; justify-content: center; gap: 12px; width: min(100%, 320px); height: 66px; border-radius: 33px;
  background: var(--rec); color: #fff; font-size: 20px; font-weight: 700; letter-spacing: -0.01em;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--rec) 16%, transparent), 0 8px 22px color-mix(in srgb, var(--rec) 35%, transparent);
  transition: transform 0.12s;
}
.rec-key { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: rgb(255 255 255 / 0.18); }
.rec-key svg { width: 24px; height: 24px; }
.rec-btn:active { transform: scale(0.97); }
.import-link { display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--accent); cursor: pointer; padding: 6px 10px; }
.import-link svg { width: 18px; height: 18px; }

/* barra de grabacion activa (en las demas pantallas) */
body.recording { --rb: calc(48px + env(safe-area-inset-top)); }
body.recording #app { padding-top: 48px; }
.recbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30; display: flex; align-items: center; gap: 8px;
  padding: env(safe-area-inset-top) 12px 0; height: calc(48px + env(safe-area-inset-top)); background: var(--rec); color: #fff;
}
.recbar[hidden] { display: none; }
.recbar-open { flex: 1; display: flex; align-items: center; gap: 10px; height: 100%; color: #fff; font-weight: 650; font-size: 16px; text-align: left; }
.recbar .rec-dot { background: #fff; }
.recbar.paused .rec-dot { animation: none; opacity: 0.5; }
.recbar-time { font-variant-numeric: tabular-nums; font-weight: 500; opacity: 0.9; }
.recbar-stop { background: #fff; color: var(--rec); font-weight: 700; font-size: 15px; border-radius: 99px; padding: 6px 14px; }

/* grabador */
.rec-view { min-height: 100dvh; display: flex; flex-direction: column; padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.rec-top { display: flex; justify-content: space-between; align-items: center; height: 44px; }
.link { color: var(--accent); font-size: 17px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--rec); animation: blink 1.2s infinite; }
.rec-view.paused .rec-dot { animation: none; background: var(--muted); }
@keyframes blink { 50% { opacity: 0.25; } }
.rec-title { width: 100%; border: 0; border-bottom: 2px solid var(--line); background: none; font-size: 22px; font-weight: 650; padding: 10px 2px; outline: none; color: var(--text); }
.rec-title:focus { border-bottom-color: var(--accent); }
.rec-title::placeholder { color: var(--muted); font-weight: 500; }
.rec-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.timer-row { display: flex; align-items: center; gap: 14px; }
.timer { font-size: 72px; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.wave { width: 100%; max-width: 420px; height: 72px; }
.tpl { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.tpl select, .settings select, .sheet select { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 8px; }
.live { width: 100%; max-height: 28dvh; overflow: auto; background: var(--surface); border-radius: var(--radius); padding: 12px 14px; }
.live p { margin: 0; }
.hint { color: var(--muted); font-size: 13px; text-align: center; max-width: 340px; }
.rec-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; justify-items: center; }
.round { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; }
.round.secondary { background: var(--surface-2); }
.round.stop { width: auto; height: 68px; padding: 0 28px 0 22px; gap: 10px; display: flex; border-radius: 34px; background: var(--rec); color: #fff; font-size: 20px; font-weight: 700; }
.round.stop svg { width: 26px; height: 26px; }
.round.secondary svg { width: 26px; height: 26px; }

/* detalle */
.note-main { padding: 0 16px 48px; max-width: 720px; margin: 0 auto; }
.title-row { display: flex; align-items: flex-start; gap: 4px; }
.note-title { flex: 1; min-width: 0; font-size: 26px; line-height: 1.2; letter-spacing: -0.02em; margin: 4px 0; padding: 2px 4px; outline: none; border-radius: 8px; }
.edit-title { flex: none; color: var(--muted); margin-top: 2px; }
.edit-title svg { width: 20px; height: 20px; }
.note-title:focus { background: var(--surface); box-shadow: 0 0 0 2px var(--accent); }
.meta { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.player { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; }
.play { width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; }
.play svg { width: 20px; height: 20px; }
.scrub { flex: 1; min-width: 0; }
.scrub input { width: 100%; accent-color: var(--accent); margin: 0; }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rate { flex: none; font-size: 14px; font-weight: 600; background: var(--surface-2); border-radius: 8px; padding: 4px 8px; min-width: 48px; }
.status { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 14px; margin-bottom: 12px; }
.status.working { justify-content: flex-start; color: var(--accent); }
.status.err { color: var(--err); }
.btn { display: inline-block; border-radius: 99px; padding: 6px 14px; background: var(--surface); border: 1px solid var(--line); color: var(--text); font-weight: 600; white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { font-size: 14px; padding: 4px 12px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: 10px; padding: 3px; margin-bottom: 14px; position: sticky; top: calc(60px + var(--rb, 0px)); z-index: 4; }
.tabs button { flex: 1; padding: 7px 4px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 0.1); }

.tab-body h3 { font-size: 16px; font-weight: 650; color: var(--text); margin: 22px 0 6px; }
.tab-body ul, .tab-body ol { margin: 0; padding-left: 20px; }
.tab-body li { margin: 4px 0; }
.overview { font-size: 17px; margin: 0; }
.checks { list-style: none; padding: 0 !important; }
.checks label { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.checks input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--ok); flex: none; }
.checks input:checked + span { text-decoration: line-through; color: var(--muted); }
.checks small { display: block; color: var(--muted); font-size: 13px; }
.chapters { list-style: none; padding: 0 !important; }
.chapters li { margin: 0 0 10px; }
.chapters p { margin: 2px 0 0 56px; color: var(--muted); font-size: 14px; }
.chap { display: flex; gap: 10px; align-items: baseline; text-align: left; }
.ts { display: inline-block; min-width: 46px; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; }

.transcript .seg { margin: 0; padding: 6px 8px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; }
.transcript .seg:active { background: var(--surface-2); }
.transcript .seg.active { background: var(--hl); }
.transcript .seg .ts { flex: none; padding-top: 2px; }
.speaker { margin: 12px 0 2px 8px; font-size: 13px; font-weight: 700; color: var(--accent); }

.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 80px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 18px; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg .li { display: block; }
.ts-link { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px; font-size: 14px; }
.ask {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; max-width: 720px; margin: 0 auto;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line);
}
.ask input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 10px 16px; outline: none; font-size: 16px; }
.ask button { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.ask button:disabled, .ask input:disabled { opacity: 0.5; }
.mynotes { width: 100%; min-height: 50dvh; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 12px 14px; font-size: 16px; resize: vertical; outline: none; }

/* compartir */
.share-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.share-bar[hidden] { display: none; }
.share { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; font-weight: 600; color: var(--text); }
.share svg { width: 22px; height: 22px; color: var(--accent); }
.share.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.share.wa svg { color: #fff; }
.share:active { transform: scale(0.97); }

/* hoja de acciones */
.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 520px; background: transparent; color: var(--text); }
.sheet::backdrop { background: rgb(0 0 0 / 0.35); }
.sheet-body { background: var(--surface); border-radius: 18px 18px 0 0; padding: 8px 8px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.sheet-body button { text-align: left; padding: 13px 14px; border-radius: 10px; font-size: 17px; }
.sheet-body button:active { background: var(--surface-2); }
.sheet-body .danger { color: var(--err); }
.sheet-body .cancel { text-align: center; font-weight: 600; color: var(--accent); }
.sheet-body hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.sheet-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 14px; color: var(--muted); font-size: 15px; }

/* ajustes */
.settings { padding: 0 16px 48px; max-width: 720px; margin: 0 auto; }
.settings h2 { font-size: 15px; color: var(--text); margin: 24px 4px 8px; font-weight: 650; }
.group { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.group > label, .group > .row, .group > .row-btn { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line); min-height: 46px; }
.group > :first-child { border-top: 0; }
.group input:not([type=checkbox]) { flex: 1; min-width: 0; text-align: right; border: 0; background: none; outline: none; color: var(--muted); }
.group select { max-width: 60%; }
.row-btn { width: 100%; color: var(--accent); cursor: pointer; text-align: left; }
.switch input { width: 44px; height: 26px; accent-color: var(--ok); }
.foot { color: var(--muted); font-size: 13px; margin: 6px 4px 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(130px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; max-width: calc(100% - 32px); text-align: center;
}
#print { display: none; }

@media print {
  body > *:not(#print) { display: none !important; }
  #print { display: block; color: #000; font: 12pt/1.5 Georgia, serif; }
  #print h1 { font-size: 20pt; } #print h2 { font-size: 14pt; margin-top: 18pt; }
  #print p { margin: 4pt 0; }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
