:root {
  --bg: #14161a;
  --surface: #1e2127;
  --surface-2: #272b33;
  --text: #eceef2;
  --muted: #8d94a1;
  --accent: #f2b84b;
  --accent-ink: #1a1405;
  --danger: #e5675f;
  --ok: #6cc08b;
  --radius: 14px;
  --tap: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  /* hueco para composer + nav fijos */
  padding: 0 16px calc(var(--bar-h, 190px) + env(safe-area-inset-bottom));
}

main { max-width: 640px; margin: 0 auto; padding-top: calc(16px + env(safe-area-inset-top)); }

h1 { font-size: 1.4rem; margin: 0 0 4px; }
h2 { font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 24px 0 8px; }
.sub { color: var(--muted); margin: 0 0 8px; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }

/* Tareas */
.task {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-radius: var(--radius);
  padding: 6px 8px 6px 6px; margin-bottom: 8px; min-height: var(--tap);
}
.task .check {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--muted); background: transparent; color: var(--accent-ink);
  font-size: 1.2rem; display: grid; place-items: center; cursor: pointer;
}
.task .body { flex: 1; min-width: 0; }
.task .title { overflow-wrap: anywhere; }
.task .meta { font-size: .8rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.task .meta .late { color: var(--danger); }
.task .del {
  flex: none; width: 40px; height: 40px; border: 0; background: transparent;
  color: var(--muted); font-size: 1.1rem; cursor: pointer;
}
.tag {
  background: var(--surface-2); border-radius: 999px; padding: 0 8px; font-size: .75rem; color: var(--text);
}

/* Barra inferior */
#composer[hidden] { display: none; }
#composer {
  position: fixed; left: 0; right: 0; bottom: calc(56px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--surface-2);
  padding: 10px 16px 10px; display: grid; gap: 8px;
}
#composer > * { max-width: 640px; width: 100%; margin: 0 auto; }
#composer .row { display: flex; gap: 8px; }
#capture {
  flex: 1; min-width: 0; height: var(--tap); border-radius: var(--radius);
  border: 2px solid var(--surface-2); background: var(--surface); color: var(--text);
  padding: 0 14px; font: inherit;
}
#capture:focus { outline: none; border-color: var(--accent); }
.send-btn, .icon-btn {
  flex: none; width: var(--tap); height: var(--tap); border-radius: var(--radius);
  border: 0; font-size: 1.5rem; cursor: pointer;
}
.send-btn { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.icon-btn { background: var(--surface); color: var(--text); font-size: 1.3rem; }
.icon-btn.on { outline: 2px solid var(--accent); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--surface-2); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 0 14px; height: 38px; font: inherit; font-size: .9rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
#when-time, .field {
  height: 44px; border-radius: 10px; border: 2px solid var(--surface-2);
  background: var(--surface); color: var(--text); padding: 0 12px; font: inherit; color-scheme: dark;
}
#composer-extra { display: grid; gap: 8px; }
#composer-extra[hidden], #when-time[hidden] { display: none; }

#nav {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(56px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--surface); border-top: 1px solid var(--surface-2);
}
#nav a {
  flex: 1; display: grid; place-items: center; color: var(--muted); text-decoration: none; font-weight: 600;
}
#nav a[aria-current="page"] { color: var(--accent); }

/* Ajustes */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card p { margin: 0 0 12px; color: var(--muted); font-size: .9rem; }
.btn {
  min-height: var(--tap); padding: 0 20px; border-radius: var(--radius); border: 0;
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.block { width: 100%; }
.btn + .btn { margin-top: 8px; }

details > summary { color: var(--muted); cursor: pointer; padding: 8px 0; }

/* Estados de tarea: hecha (a medias) vs cerrada (100 %) */
.list { padding: 0; margin: 0; list-style: none; }
.task.hecha .check { background: var(--accent); border-color: var(--accent); font-size: 1rem; }
.task.cerrada .check { background: var(--ok); border-color: var(--ok); font-size: .85rem; }
.task.cerrada .title { text-decoration: line-through; color: var(--muted); }
.task .btn.small { min-height: 40px; padding: 0 14px; font-size: .9rem; flex: none; }
.task .btn[disabled] { opacity: .4; }
.hint { color: var(--muted); font-size: .85rem; margin: -4px 0 8px; }

/* Lo siguiente */
.next { border: 2px solid var(--accent); border-radius: var(--radius); padding: 16px; margin: 12px 0 4px; background: var(--surface); }
.next .label { color: var(--accent); font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.next .nt { font-size: 1.25rem; font-weight: 600; margin: 6px 0; overflow-wrap: anywhere; }
.next .meta { font-size: .8rem; color: var(--muted); display: flex; gap: 8px; margin-bottom: 12px; }
.next .meta .late { color: var(--danger); }

/* Diálogo */
dialog { border: 0; border-radius: 18px; background: var(--surface); color: var(--text); padding: 0; width: min(92vw, 420px); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dlg-in { padding: 20px; display: grid; gap: 10px; }
.dlg-in h3 { margin: 0; font-size: 1.15rem; }
.dlg-in .sub { margin: 0; overflow-wrap: anywhere; }
.btn.ghost { background: transparent; color: var(--muted); }
.field.wide { width: 100%; }

/* Volcado */
textarea.big {
  width: 100%; min-height: 38vh; border-radius: var(--radius); border: 2px solid var(--surface-2);
  background: var(--surface); color: var(--text); padding: 14px; font: inherit; resize: vertical; margin-bottom: 12px;
}
textarea.big:focus { outline: none; border-color: var(--accent); }
.prop { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border-radius: var(--radius); padding: 10px; margin-bottom: 8px; }
.prop > input[type=checkbox] { width: 24px; height: 24px; margin-top: 10px; accent-color: var(--accent); flex: none; }
.prop .pbody { flex: 1; min-width: 0; display: grid; gap: 6px; }
.prop .ptitle { width: 100%; }
.prop .prow { display: flex; gap: 6px; flex-wrap: wrap; }
.prop .prow .field { flex: 1; min-width: 100px; }
.nota { background: var(--surface); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; color: var(--muted); font-size: .9rem; }

/* Chips de captura: una fila desplazable, selector de fecha nativo superpuesto */
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; flex: none; }
.chip.pick { position: relative; display: inline-flex; align-items: center; }
.chip.pick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.mini { background: var(--surface-2); color: var(--text); border: 0; border-radius: 999px; padding: 2px 10px; font: inherit; font-size: .75rem; cursor: pointer; }
.mini.late { color: var(--danger); }
.tag-comida-hint { color: var(--muted); font-size: .8rem; }

/* Comidas */
.weeknav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.weeknav .icon-btn { width: 48px; height: 48px; }
.day { background: var(--surface); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; display: grid; gap: 8px; }
.day.hoy { outline: 2px solid var(--accent); }
.dayhead { display: flex; justify-content: space-between; align-items: center; }
.day h3 { margin: 0; text-transform: capitalize; font-size: 1.05rem; }
.line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.line .lbl { width: 84px; flex: none; color: var(--muted); font-size: .85rem; }
.line .grow { flex: 1; min-width: 170px; }
.aviso { background: var(--surface-2); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 12px; margin: 8px 0; font-size: .9rem; }
.btn.block + .btn.block, .btn.block + .list, button.block + button.block { margin-top: 8px; }
.btn.cerrar { margin-top: 20px; }
.btn.small { min-height: 44px; padding: 0 16px; }
#nav a { font-size: .9rem; }

/* ---------- Rediseño de captura: etiqueta (color) vs día (calendario) ---------- */
.tag { display: inline-flex; align-items: center; gap: 6px; background: transparent; padding: 0; color: var(--text); font-size: .78rem; }
.tag::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); flex: none; }
.pills { display: flex; gap: 8px; }
.pill { height: 38px; border-radius: 999px; padding: 0 14px; font: inherit; font-size: .9rem; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.tagpill { background: var(--surface); border: 1px solid var(--surface-2); color: var(--text); }
.tagpill i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.datepill { background: transparent; border: 1px dashed var(--muted); color: var(--muted); }
.datepill.set { border: 1px solid var(--accent); color: var(--accent); background: rgba(242, 184, 75, .08); }
.datepill small { opacity: .7; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; }
#composer { gap: 10px; }

/* Hojas inferiores */
dialog.sheet { margin: auto auto 0; width: min(100%, 640px); max-width: 100%; border-radius: 22px 22px 0 0; max-height: 92dvh; overflow-y: auto; }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .55); }
.sheet-in { padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 14px; }
.sheet-in h3 { margin: 0; font-size: 1.15rem; }
.grab { width: 40px; height: 4px; border-radius: 4px; background: var(--surface-2); margin: 4px auto 0; }
.tagopts { display: grid; gap: 8px; }
.tagopt { display: flex; align-items: center; gap: 12px; height: 56px; border-radius: 14px; border: 2px solid var(--surface-2); background: var(--surface-2); color: var(--text); font: inherit; font-size: 1.05rem; padding: 0 16px; cursor: pointer; }
.tagopt i { width: 14px; height: 14px; border-radius: 50%; background: var(--c); }
.tagopt[aria-pressed="true"] { border-color: var(--c); }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.qopt { height: 46px; border-radius: 12px; border: 0; background: var(--surface-2); color: var(--text); font: inherit; font-size: .85rem; cursor: pointer; }
.qopt[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.cal { background: var(--surface-2); border-radius: 16px; padding: 10px; display: grid; gap: 6px; }
.calhead { display: flex; align-items: center; justify-content: space-between; }
.calhead strong { display: inline-block; }
.calhead strong::first-letter { text-transform: uppercase; }
.calhead .icon-btn { width: 44px; height: 44px; background: transparent; }
.calgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.calgrid.dow span { color: var(--muted); font-size: .75rem; padding: 2px 0; }
.daybtn { aspect-ratio: 1; border: 0; border-radius: 50%; background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.daybtn.is-today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.daybtn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.timerow { display: flex; align-items: center; justify-content: space-between; color: var(--muted); }
.sheet-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }

/* Voz */
.recwrap { display: grid; justify-items: center; gap: 8px; margin: 14px 0 18px; }
.rec { width: 104px; height: 104px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 2.4rem; cursor: pointer; display: grid; place-items: center; }
.rec.on { background: var(--danger); color: #fff; animation: pulso 1.2s ease-in-out infinite; }
.rec:disabled { opacity: .6; }
@keyframes pulso { 0%, 100% { box-shadow: 0 0 0 0 rgba(229, 103, 95, .55); } 50% { box-shadow: 0 0 0 18px rgba(229, 103, 95, 0); } }
#rectime { font-variant-numeric: tabular-nums; font-size: 1.2rem; }
#recstate { color: var(--muted); margin: 0; text-align: center; min-height: 1.4em; }

/* Revisión IA */
.coach { background: var(--surface); border: 2px solid var(--accent); border-radius: var(--radius); padding: 16px; margin: 12px 0; display: grid; gap: 10px; }
.coach .label { color: var(--accent); font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.coach .nt { font-size: 1.15rem; font-weight: 600; overflow-wrap: anywhere; }
.coach p, .coach ul { margin: 0; color: var(--muted); font-size: .92rem; }
.coach ul { padding-left: 18px; }
.coach h4 { margin: 6px 0 0; font-size: .85rem; color: var(--text); }
.coach textarea { width: 100%; min-height: 80px; border-radius: 12px; border: 2px solid var(--surface-2); background: var(--surface-2); color: var(--text); padding: 10px; font: inherit; }

/* Gesto del día, toast, pasos */
.gesto { background: linear-gradient(135deg, rgba(236, 127, 176, .14), rgba(242, 184, 75, .10)); border: 1px solid rgba(236, 127, 176, .35); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; display: grid; gap: 8px; }
.gesto .label { color: #ec7fb0; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.gesto .gt { font-size: 1.05rem; }
.gbtns { display: flex; gap: 8px; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(190px + env(safe-area-inset-bottom)); background: var(--surface-2); color: var(--text); border: 1px solid var(--accent); border-radius: 999px; padding: 10px 18px; z-index: 50; box-shadow: 0 6px 20px rgba(0, 0, 0, .4); }
#toast[hidden] { display: none; }
.pasos { margin: 0 0 10px; padding-left: 20px; color: var(--muted); font-size: .9rem; }
.pasos li { margin-bottom: 4px; }
.card + .card { margin-top: 0; }
