:root {
  --bg: #fbf7f3;
  --card: #ffffff;
  --ink: #24170e;
  --muted: #7a6a5e;
  --line: #efe5dc;
  --brand: #e8590c;
  --brand-2: #ff9f1c;
  --brand-3: #ff4d1f;
  --accent: #ffb347;
  --danger: #dc2626;
  --ok: #059669;
  --grad: linear-gradient(135deg, var(--brand-2), var(--brand-3));
  --radius: 16px;
  --nav-h: 62px;
  --cap-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16100c; --card: #221913; --ink: #fbefe6; --muted: #bfae9f; --line: #3a2c22; --brand: #ff8a3d; color-scheme: dark; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { overscroll-behavior-y: contain; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.hidden { display: none !important; }
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot img { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.92); opacity: .7; } }

/* ---------- cabecera ---------- */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
.top img { width: 30px; height: 30px; border-radius: 8px; }
.top h1 { margin: 0; font-size: 20px; font-weight: 750; letter-spacing: -.01em; flex: 1; }
.top h1 small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.net { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.net i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.net.off i { background: var(--accent); }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:active { background: var(--line); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- lista ---------- */
main { padding: 4px 12px calc(var(--nav-h) + var(--cap-h) + var(--safe-b) + 28px); max-width: 720px; margin: 0 auto; }
.section { margin: 14px 4px 6px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; justify-content: space-between; }
.section.late { color: var(--danger); }
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 2px rgba(36, 23, 14, .06); }
.row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .body { flex: 1; min-width: 0; }
.row .title { word-wrap: break-word; }
.row .meta { font-size: 13px; color: var(--muted); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.row .meta .late { color: var(--danger); font-weight: 600; }
.row .meta .soon { color: var(--brand); font-weight: 600; }
.row.done .title { text-decoration: line-through; color: var(--muted); }
.check { flex: none; width: 26px; height: 26px; margin-top: -1px; border-radius: 50%; border: 2px solid #e6c9b3; display: grid; place-items: center; transition: transform .15s; }
.check:active { transform: scale(.85); }
.row.done .check { background: var(--grad); border-color: transparent; }
.row.done .check::after { content: ""; width: 10px; height: 6px; border: 2.5px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.note-dot { flex: none; width: 26px; height: 26px; border-radius: 8px; background: #fef3c7; display: grid; place-items: center; font-size: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip { padding: 5px 11px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--brand); }
.chip:active { background: var(--line); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty b { display: block; font-size: 18px; color: var(--ink); margin-bottom: 6px; }
.link { color: var(--brand); font-weight: 600; padding: 14px 4px; display: block; }
.banner { display: flex; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; }
.banner p { margin: 0; flex: 1; font-size: 14px; }

/* ---------- barra de captura ---------- */
.capture { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b)); z-index: 6; padding: 8px 12px; }
.capture .inner { max-width: 720px; margin: 0 auto; }
.preview { font-size: 13px; color: var(--muted); padding: 0 8px 6px; min-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview b { color: var(--brand); }
.capbar { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 999px; padding: 6px 6px 6px 16px; box-shadow: 0 6px 24px rgba(232, 89, 12, .16); border: 1px solid var(--line); }
.capbar input { flex: 1; border: 0; outline: 0; background: transparent; min-width: 0; padding: 8px 0; font-size: 16px; }
.mic { width: 48px; height: 48px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; flex: none; box-shadow: 0 4px 12px rgba(255, 77, 31, .38); }
.mic svg { width: 24px; height: 24px; }
.mic.listening { animation: listen 1s ease-in-out infinite; }
@keyframes listen { 50% { box-shadow: 0 0 0 10px rgba(255, 77, 31, .2); } }
.send { width: 40px; height: 40px; border-radius: 50%; background: var(--line); color: var(--brand); display: grid; place-items: center; flex: none; }
.send svg { width: 20px; height: 20px; }

/* ---------- escucha ---------- */
.listen { position: fixed; inset: 0; z-index: 30; background: rgba(31, 19, 0, .84); backdrop-filter: blur(6px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 24px; color: #fff; text-align: center; }
.listen .heard { font-size: 24px; font-weight: 600; min-height: 3em; max-width: 600px; }
.listen .hint { color: #f3d9c6; font-size: 14px; }
.listen .big { width: 96px; height: 96px; border-radius: 50%; background: var(--grad); display: grid; place-items: center; animation: listen 1s ease-in-out infinite; }
.listen .big svg { width: 44px; height: 44px; color: #fff; }
.listen button.stop { color: #fff; border: 1px solid rgba(255, 255, 255, .4); border-radius: 999px; padding: 10px 22px; }

/* ---------- navegación ---------- */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 7; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--card); border-top: 1px solid var(--line); display: flex; }
nav.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 600; color: var(--muted); position: relative; }
nav.tabs button svg { width: 24px; height: 24px; }
nav.tabs button.on { color: var(--brand); }
nav.tabs .badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--brand); color: #fff; font-size: 11px; display: grid; place-items: center; }
nav.tabs .badge.late { background: var(--danger); }

/* ---------- hoja de edición ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 20; background: rgba(31, 19, 0, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 10px 18px calc(18px + var(--safe-b)); animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet h2 { margin: 4px 0 12px; font-size: 18px; }
.sheet textarea, .sheet input, .sheet select { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 10px 12px; outline: 0; }
.sheet textarea:focus, .sheet input:focus, .sheet select:focus { border-color: var(--brand); }
.sheet textarea.t { font-size: 18px; font-weight: 600; resize: none; }
.sheet textarea.b { min-height: 120px; resize: vertical; }
.sheet label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.btn { padding: 12px 16px; border-radius: 12px; font-weight: 700; background: var(--bg); border: 1px solid var(--line); }
.btn.primary { background: var(--grad); color: #fff; border: 0; flex: 1; }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-row p { margin: 0; }
.set-row small { color: var(--muted); display: block; }

/* ---------- entrada ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
.login img { width: 96px; height: 96px; border-radius: 24px; box-shadow: 0 10px 30px rgba(255, 77, 31, .35); }
.login h1 { margin: 6px 0 0; font-size: 26px; }
.login p { margin: 0; color: var(--muted); max-width: 320px; }
.login .box { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.login input { text-align: center; letter-spacing: .2em; text-transform: uppercase; font-size: 20px; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px; outline: 0; }
.login .err { color: var(--danger); font-size: 14px; min-height: 20px; }

/* ---------- aviso ---------- */
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + var(--cap-h) + var(--safe-b) + 34px); z-index: 40; max-width: 560px; margin: 0 auto; background: #24170e; color: #fff; border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); font-size: 15px; }
.toast span { flex: 1; }
.toast button { color: var(--accent); font-weight: 700; padding: 4px 6px; }
