:root {
  --ink: #1d1d1f;
  --gray: #86868b;
  --light: #f5f5f7;
  --line: #e5e5ea;
  --accent: #0071e3;
  --bg: #ffffff;
  --card: #ffffff;
  --eve: #f3ecff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f5f5f7; --gray: #98989d; --light: #1c1c1e; --line: #2c2c2e;
    --accent: #2997ff; --bg: #000000; --card: #1c1c1e; --eve: #2a2238;
  }
}
:root[data-theme="dark"] {
  --ink: #f5f5f7; --gray: #98989d; --light: #1c1c1e; --line: #2c2c2e;
  --accent: #2997ff; --bg: #000000; --card: #1c1c1e; --eve: #2a2238;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 17px/1.47 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  letter-spacing: -.01em;
  min-height: 100svh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }

.view { max-width: 640px; margin: 0 auto; padding: 0 16px 40px; min-height: 100svh; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 56px; }
h1 { font-size: 28px; font-weight: 600; letter-spacing: -.025em; margin: 0; }
h2 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin: 0; }
.muted { color: var(--gray); }
.center { text-align: center; }
.small { font-size: 14px; }

.icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; }
.icon svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.big svg { width: 28px; height: 28px; }

/* Inicio */
.hero { font-size: 34px; line-height: 1.12; font-weight: 600; letter-spacing: -.025em; margin: 48px 0 40px; }
.library { list-style: none; margin: 0; padding: 0; }
.library li {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 0; border-bottom: 1px solid var(--line);
}
.library .t { flex: 1; min-width: 0; }
.library .t b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.library .t span { color: var(--gray); font-size: 14px; }
.library .del { color: var(--gray); font-size: 14px; padding: 8px; }
.add {
  display: block; margin-top: 28px; text-align: center; padding: 16px;
  border-radius: 18px; background: var(--light); font-weight: 600; cursor: pointer;
}

/* Lector */
.chapter { flex: 1; text-align: center; margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--gray); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page { min-height: 46svh; display: flex; flex-direction: column; justify-content: center; padding: 24px 4px; }
.prev { color: var(--gray); font-size: 17px; margin: 0 0 20px; max-height: 5.9em; overflow: hidden; }
.line { font-size: 26px; line-height: 1.3; font-weight: 600; letter-spacing: -.02em; margin: 0; }
.progress { height: 3px; background: var(--light); border-radius: 3px; overflow: hidden; margin: 8px 0 24px; }
#bar { height: 100%; width: 0; background: var(--ink); transition: width .3s; }
.controls { display: flex; align-items: center; justify-content: center; gap: 36px; margin-bottom: 28px; }
.play { width: 76px; height: 76px; border-radius: 50%; background: var(--ink); display: grid; place-items: center; }
.play svg { width: 30px; height: 30px; fill: var(--bg); }

.talk {
  display: block; width: 100%; padding: 18px; border-radius: 18px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 18px;
}
.talk.listening { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.ghost { display: block; width: 100%; padding: 16px; border-radius: 18px; background: var(--light); font-weight: 600; }
.text { color: var(--accent); font-weight: 600; padding: 8px; }

/* Sheets */
.sheet {
  position: fixed; inset: 0; z-index: 10; background: var(--bg); overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 8px) 16px calc(env(safe-area-inset-bottom) + 24px);
}
.sheet > * { max-width: 640px; margin-left: auto; margin-right: auto; }
.sheet-top { display: flex; align-items: center; justify-content: space-between; height: 56px; margin-bottom: 8px; }
.row { display: flex; gap: 12px; margin-top: 24px; }

/* Conversacion */
.full { display: flex; flex-direction: column; }
.convo-body { flex: 1; width: 100%; padding-top: 24px; }
.quote { font-size: 20px; line-height: 1.35; font-weight: 600; letter-spacing: -.015em; margin: 0 0 24px; }
.turns { display: flex; flex-direction: column; gap: 12px; }
.turn { padding: 12px 16px; border-radius: 18px; max-width: 88%; }
.turn.me { align-self: flex-end; background: var(--light); }
.turn.eve { align-self: flex-start; background: var(--eve); }
.status { color: var(--gray); font-size: 14px; min-height: 1.4em; margin: 16px 0; }
.convo-actions { width: 100%; display: flex; flex-direction: column; gap: 12px; }

/* Notas */
.note { padding: 16px 0; border-bottom: 1px solid var(--line); }
.note q { display: block; font-weight: 600; quotes: none; margin-bottom: 6px; }
.note p { margin: 4px 0; font-size: 15px; }
.note .who { color: var(--gray); }
.note h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--gray); font-weight: 600; margin: 24px 0 8px; }
.note.summary { background: var(--light); border-radius: 18px; padding: 16px; border: 0; margin: 12px 0; white-space: pre-line; font-size: 15px; }

/* Ajustes */
.field { display: block; margin: 0 0 20px; }
.field span { display: block; font-size: 14px; color: var(--gray); margin-bottom: 6px; }
.field textarea, .field input[type=password], .field select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  font-size: 16px;
}
.field input[type=range] { width: 100%; }
.switch { display: flex; align-items: center; justify-content: space-between; margin: 0 0 20px; }
.switch input { width: 22px; height: 22px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
