/* Agenda Pibel — tonos cálidos, crema y rosa. Modo oscuro si el sistema lo pide. */
:root {
  --bg: #fbf6f1;
  --surface: #ffffff;
  --surface-2: #f4ece5;
  --line: #eadfd6;
  --text: #2d2522;
  --muted: #8b7d74;
  --accent: #d9566b;
  --accent-soft: #fbe2e5;
  --on-accent: #ffffff;
  --task: #4d8b73;
  --task-soft: #e1efe8;
  --danger: #c4413a;
  --shadow: 0 8px 28px rgba(80, 40, 30, .12);
  --radius: 16px;
  --font-title: "Fraunces", Georgia, serif;
  --font: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1716;
    --surface: #272120;
    --surface-2: #322a28;
    --line: #3d3431;
    --text: #f3ebe6;
    --muted: #a8988f;
    --accent: #f07d8f;
    --accent-soft: #4a2a2f;
    --on-accent: #2a1316;
    --task: #79c2a4;
    --task-soft: #23382f;
    --danger: #f0776f;
    --shadow: 0 8px 28px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--font-title); font-weight: 600; margin: 0; }
.accent { color: var(--accent); }
.hint { color: var(--muted); margin: 0; }
.small { font-size: .85rem; margin-top: -6px; }

/* ── Splash ─────────────────────────── */
.splash { position: fixed; inset: 0; display: grid; place-items: center; }
.splash img { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.9); opacity: .7; } }

/* ── Botones y campos ───────────────── */
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 700;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--danger); background: transparent; }
.btn:disabled { opacity: .6; cursor: default; }
.link { background: none; border: 0; padding: 4px 0; color: var(--accent); font-weight: 600; }
.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 50%;
  background: transparent; fill: currentColor;
}
.icon-btn:hover { background: var(--surface-2); }
.chip {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: .9rem;
}
label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; color: var(--muted); }
input, textarea {
  width: 100%; min-width: 0;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text);
  padding: 12px 14px; font-size: 16px; font-weight: 400;
}
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; }
.form-msg { margin: 0; color: var(--danger); font-size: .9rem; }
.form-msg.ok { color: var(--task); }

/* ── Acceso ─────────────────────────── */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow);
  padding: 32px 24px; text-align: center;
}
.auth-logo { display: block; margin: 0 auto 10px; }
.auth-card h1 { font-size: 2rem; margin-bottom: 22px; }
.auth-form { display: grid; gap: 14px; text-align: left; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.auth-msg { margin: 16px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); font-size: .92rem; text-align: left; }

/* ── Cabecera y semana ──────────────── */
.app { max-width: 640px; margin: 0 auto; padding-bottom: 110px; }
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 6px;
  background: var(--bg);
}
.month-btn {
  display: flex; align-items: center; gap: 4px;
  border: 0; background: none; padding: 6px 4px;
  font: 600 1.5rem var(--font-title); text-transform: capitalize;
}
.top-actions { display: flex; align-items: center; gap: 4px; }

.week {
  position: sticky; top: calc(58px + env(safe-area-inset-top)); z-index: 4;
  display: flex; align-items: center; gap: 2px;
  padding: 4px 6px 10px; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.week-days { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; list-style: none; margin: 0; padding: 0; min-width: 0; }
.wd {
  width: 100%; border: 0; background: transparent; border-radius: 14px;
  display: grid; justify-items: center; gap: 2px; padding: 6px 0 7px;
}
.wd-name { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.wd-num { font: 600 1.15rem var(--font-title); width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; }
.wd-dots { display: flex; gap: 3px; height: 6px; }
.wd-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.wd-dots i.t { background: var(--task); }
.wd.today .wd-num { color: var(--accent); }
.wd.sel { background: var(--surface); box-shadow: var(--shadow); }
.wd.sel .wd-num { background: var(--accent); color: var(--on-accent); }

/* ── Día ────────────────────────────── */
.day { padding: 18px 16px 0; touch-action: pan-y; }
.day-title { font-size: 1.35rem; margin-bottom: 14px; }
.day-title::first-letter { text-transform: uppercase; }
.sec { margin-bottom: 22px; }
.sec h3 { font: 700 .8rem var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; display: flex; gap: 8px; align-items: baseline; }
.note-status { font-weight: 600; text-transform: none; letter-spacing: 0; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.empty { color: var(--muted); font-size: .92rem; padding: 2px 2px 4px; }

.item {
  display: flex; align-items: stretch; gap: 10px;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
  border: 1px solid var(--line);
  min-width: 0;
}
.item-open { flex: 1; min-width: 0; display: flex; gap: 12px; align-items: center; text-align: left; border: 0; background: none; padding: 12px 14px; border-radius: var(--radius); }
.item-time { flex: none; min-width: 48px; font-weight: 700; font-size: .92rem; color: var(--accent); line-height: 1.25; }
.item-time small { display: block; color: var(--muted); font-weight: 600; }
.item-body { min-width: 0; flex: 1; }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.item-notes { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-from { color: var(--muted); font-size: .8rem; }
.item.event { border-left: 4px solid var(--accent); }

.check {
  flex: none; align-self: center; margin-left: 12px;
  width: 26px; height: 26px; border-radius: 8px;
  border: 2px solid var(--task); background: transparent;
  display: grid; place-items: center; padding: 0;
}
.check svg { opacity: 0; }
.item.done .check { background: var(--task); }
.item.done .check svg { opacity: 1; }
.item.done .item-title { text-decoration: line-through; color: var(--muted); }
.item.task .item-open { padding-left: 2px; }
.move-today { flex: none; align-self: center; margin-right: 10px; }

.add-inline { margin-top: 8px; border: 1px dashed var(--line); background: transparent; color: var(--muted); border-radius: 12px; padding: 10px 14px; width: 100%; text-align: left; font-weight: 600; }
.add-inline:hover { color: var(--accent); border-color: var(--accent); }

.day-note { min-height: 90px; line-height: 1.5; }

.free-day {
  display: flex; align-items: center; gap: 14px;
  background: var(--accent-soft); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 22px;
}
.free-day img { flex: none; animation: bob 2.6s ease-in-out infinite; }
.free-day p { margin: 0; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-3deg); } }
.auth-logo { animation: bob 2.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .free-day img, .auth-logo, .splash img { animation: none; } }

.fab {
  position: fixed; z-index: 6;
  right: max(18px, calc(50% - 320px + 18px)); bottom: calc(22px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; box-shadow: var(--shadow);
}

/* ── Hojas (dialog) ─────────────────── */
.sheet {
  border: 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  width: 100%; max-width: 520px; max-height: 92dvh;
  margin: auto auto 0; border-radius: 22px 22px 0 0;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgba(30, 15, 12, .4); }
.sheet[open] { animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@media (min-width: 700px) {
  .sheet { margin: auto; border-radius: 22px; }
}
.sheet form, .sheet > .auth-form { display: grid; gap: 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.sheet-head h2 { font-size: 1.3rem; text-transform: capitalize; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.sheet-actions .danger { margin-right: auto; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; }
.seg label { display: block; color: var(--text); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: block; text-align: center; padding: 9px; border-radius: 9px; font-weight: 700; font-size: 1rem; }
.seg input:checked + span { background: var(--surface); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); color: var(--accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }

/* ── Mes ────────────────────────────── */
.month-grid-head, .month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.month-grid-head span { font-size: .75rem; font-weight: 700; color: var(--muted); padding-bottom: 4px; }
.md {
  aspect-ratio: 1; border: 0; border-radius: 12px; background: transparent;
  display: grid; place-items: center; align-content: center; gap: 2px; padding: 0;
  font-weight: 600;
}
.md.out { color: var(--muted); opacity: .45; }
.md.today { color: var(--accent); font-weight: 800; }
.md.sel { background: var(--accent); color: var(--on-accent); }
.md .wd-dots { height: 5px; }
.md .wd-dots i { width: 5px; height: 5px; }
.md.sel .wd-dots i { background: var(--on-accent); }

/* ── Aviso ──────────────────────────── */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 20;
  bottom: calc(96px + env(safe-area-inset-bottom));
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: .92rem;
  max-width: calc(100% - 32px); box-shadow: var(--shadow);
}
