/* Conde’s Diary — tokens de diseño: papel frío + tinta, acento ultramar. La línea de categoría es el único elemento de color por fila. */
:root {
  color-scheme: light;
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #eceef3; --ink: #171a21; --ink-2: #565d6e; --ink-3: #606778;
  --line: #e1e4eb; --accent: #3956e8; --accent-ink: #ffffff; --accent-soft: rgba(57, 86, 232, .1);
  --danger: #cf3249; --danger-ink: #ffffff; --ok: #1f9d6b; --warn: #8a5a12; --warn-ink: #ffffff;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06); --shadow-lg: 0 10px 30px rgba(20, 24, 40, .18);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px); --safe-right: env(safe-area-inset-right, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1); --tabbar-h: 58px; --sidebar-w: 272px;
  --font: ui-rounded, "SF Pro Rounded", "SF Pro Text", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12141a; --surface: #1a1d26; --surface-2: #242836; --ink: #eceef4; --ink-2: #a5abbd; --ink-3: #8e95a8;
  --line: #2a2e3c; --accent: #7d93ff; --accent-ink: #0e1220; --accent-soft: rgba(125, 147, 255, .14);
  --danger: #ff6b80; --danger-ink: #1a0a0d; --ok: #4cc791; --warn: #e0a64a; --warn-ink: #1a1205;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 12px 34px rgba(0, 0, 0, .55);
}
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    color-scheme: dark;
    --bg: #12141a; --surface: #1a1d26; --surface-2: #242836; --ink: #eceef4; --ink-2: #a5abbd; --ink-3: #8e95a8;
    --line: #2a2e3c; --accent: #7d93ff; --accent-ink: #0e1220; --accent-soft: rgba(125, 147, 255, .14);
    --danger: #ff6b80; --danger-ink: #1a0a0d; --ok: #4cc791; --warn: #e0a64a; --warn-ink: #1a1205;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 12px 34px rgba(0, 0, 0, .55);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font); -webkit-font-smoothing: antialiased; min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.icon { display: inline-grid; place-items: center; flex: none; }
.skip { position: absolute; left: calc(8px + var(--safe-left)); top: -60px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { top: calc(var(--safe-top) + 8px); }

/* Controles */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 15px; transition: background .15s, transform .1s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn:has(+ input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled, .iconbtn:disabled { opacity: .45; cursor: default; }
.iconbtn { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; color: var(--ink-2); transition: background .15s, color .15s; }
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.iconbtn.small { width: 32px; height: 32px; border-radius: 8px; }
.picker { cursor: pointer; }
.date-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 11px; }
.segmented button { min-height: 32px; padding: 0 12px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--cat, var(--ink-3)); flex: none; }
.dot.big { width: 14px; height: 14px; }
.dot.empty { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-3); }

/* Estructura */
.splash { min-height: 100dvh; display: grid; place-content: center; gap: 12px; justify-items: center; color: var(--ink-3); }
.splash-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); opacity: .85; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.shell { display: block; }
.sidebar { display: none; }
.main { padding: calc(var(--safe-top) + 8px) calc(16px + var(--safe-right)) calc(var(--tabbar-h) + var(--safe-bottom) + 16px) calc(16px + var(--safe-left)); max-width: 760px; margin: 0 auto; outline: none; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin-bottom: 4px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; letter-spacing: -.01em; }
.brand span { display: inline-grid; }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin: 8px 0; border-radius: 12px; background: color-mix(in srgb, var(--warn) 14%, var(--surface)); color: var(--ink); font-size: 14px; }
.sync { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.sync.busy .icon { animation: spin 1s linear infinite; }
.sync.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.sync.error { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.sync.ok .icon { color: var(--ok); }
@keyframes spin { to { transform: rotate(360deg); } }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr); padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.nav-link { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--tabbar-h); color: var(--ink-3); text-decoration: none; font-size: 11px; font-weight: 600; }
.nav-link[aria-current="page"] { color: var(--accent); }
.kb-open .tabbar { display: none; }
.view { min-height: 40vh; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0 8px; flex-wrap: wrap; }
.page-head h1, .day-title { outline: none; }
.page-head h1 { font-size: 30px; letter-spacing: -.02em; font-weight: 750; }
.lead, .hint-text { color: var(--ink-2); font-size: 14px; }
.lead { margin-bottom: 12px; }

/* Vista del día */
.day-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding: 8px 0 4px; flex-wrap: wrap; }
.day-title { display: flex; flex-direction: column; line-height: 1.05; }
.day-title .wd { font-size: 38px; font-weight: 800; letter-spacing: -.03em; }
.day-title .dm { font-size: 18px; font-weight: 500; color: var(--ink-3); margin-top: 4px; }
.rel { font-size: 13px; font-weight: 600; color: var(--accent); margin-top: 6px; }
.day-tools { display: flex; align-items: center; gap: 2px; margin-left: -8px; }
.weekstrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 10px 0 6px; }
.ws-day { display: grid; justify-items: center; gap: 2px; padding: 8px 0 6px; border-radius: 12px; min-height: 64px; color: var(--ink-2); transition: background .15s; }
.ws-day:hover { background: var(--surface-2); }
.ws-l { font-size: 12px; font-weight: 600; color: var(--ink-3); }
.ws-n { font-size: 17px; font-weight: 650; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; }
.ws-day.today .ws-n { color: var(--accent); }
.ws-day.selected { background: var(--accent-soft); }
.ws-day.selected .ws-n { background: var(--accent); color: var(--accent-ink); }
.dot.pending { background: var(--accent); }
.dot.done { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.ws-day .dot, .cal-day .dot { width: 5px; height: 5px; background: transparent; }
.ws-day .dot.pending, .cal-day .dot.pending { background: var(--accent); }
.ws-day .dot.done, .cal-day .dot.done { box-shadow: inset 0 0 0 1.2px var(--ink-3); }
.day-sub { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0 10px; flex-wrap: wrap; }
.progress { font-size: 14px; color: var(--ink-3); font-weight: 600; }
.hint { font-size: 13px; color: var(--ink-3); margin-bottom: 8px; }
.loading { padding: 40px 0; text-align: center; color: var(--ink-3); }

/* Lista única */
.task-list { border-top: 1px solid var(--line); }
.task-list.slide-l { animation: slide-l .2s ease-out; }
.task-list.slide-r { animation: slide-r .2s ease-out; }
@keyframes slide-l { from { opacity: 0; transform: translateX(18px); } }
@keyframes slide-r { from { opacity: 0; transform: translateX(-18px); } }
.task-row { position: relative; display: flex; align-items: flex-start; gap: 0; min-height: 56px; padding: 2px 0 2px 10px; border-bottom: 1px solid var(--line); background: var(--bg); scroll-margin-bottom: 150px; touch-action: pan-y; }
.task-row.has-cat::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--cat); }
.grip, .grip-space { flex: none; width: 34px; min-height: 44px; display: grid; place-items: center; color: var(--ink-3); opacity: .55; touch-action: none; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.grip-space { cursor: default; opacity: 0; width: 8px; }
.grip:hover { opacity: 1; }
@media (hover: hover) { .grip { opacity: .25; } .task-row:hover .grip, .grip:focus-visible { opacity: .9; } }
.check { position: relative; flex: none; width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; }
.check input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.box { width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--ink-3); display: grid; place-items: center; color: transparent; transition: background .15s, border-color .15s, color .15s; }
.check input:checked + .box { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }
.just-done .box { animation: pop .32s ease-out; }
@keyframes pop { 40% { transform: scale(1.22); } }
.body { flex: 1; min-width: 0; padding: 2px 0 4px 2px; }
.title { display: flex; align-items: center; width: 100%; min-height: 44px; text-align: left; font-size: 17px; line-height: 1.35; padding: 0 4px 0 0; word-break: break-word; }
.title-text { background: linear-gradient(currentColor, currentColor) no-repeat 0 55% / 0 1.5px; transition: background-size .25s ease, color .2s; }
.done .title-text { background-size: 100% 1.5px; color: var(--ink-3); }
.meta { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.chip.overdue { color: var(--danger); }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 650; background: color-mix(in srgb, var(--cat) 15%, transparent); color: color-mix(in srgb, var(--cat) 35%, var(--ink)); }
.more { flex: none; width: 44px; height: 44px; border-radius: 0; opacity: .7; }
.task-row { transition: scale .2s var(--ease), box-shadow .2s var(--ease), background-color .2s, opacity .2s; }
.task-row.dragging { z-index: 30; scale: 1.02; background: var(--surface); box-shadow: var(--shadow-lg); border-radius: 14px; border-color: transparent; will-change: transform; cursor: grabbing; }
.task-row.over-target { scale: .93; opacity: .78; }
.task-list.is-dragging { user-select: none; -webkit-user-select: none; }
.task-list.is-dragging .task-row:not(.dragging) { pointer-events: none; }
.empty { display: grid; justify-items: center; gap: 10px; padding: 48px 16px 24px; text-align: center; color: var(--ink-2); }
.empty .art { color: var(--ink-3); }
.empty h2 { font-size: 20px; color: var(--ink); }
.empty p { max-width: 30ch; }
.empty-filter { padding: 28px 0; text-align: center; color: var(--ink-3); }

/* Alta rápida */
.quickadd { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px); z-index: 10; margin-top: 16px; padding-bottom: 2px; }
.kb-open .quickadd { bottom: 8px; }
.qa-row { display: flex; align-items: center; gap: 2px; padding: 4px 4px 4px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); }
.qa-input { flex: 1; min-width: 0; height: 44px; border: 0; background: transparent; outline: none; font-size: 16px; }
.qa-input::placeholder { color: var(--ink-3); }
.qa-cat { display: inline-flex; align-items: center; gap: 6px; max-width: 120px; height: 36px; padding: 0 8px; border-radius: 10px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.qa-cat:hover { background: var(--surface-2); }
.qa-cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa-add { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); transition: opacity .15s, transform .1s; }
.qa-add:active { transform: scale(.94); }
.qa-add:disabled { opacity: .35; }
.qa-error { margin: 8px 6px 0; font-size: 14px; color: var(--danger); background: var(--bg); }

/* Calendario */
.cal { display: grid; gap: 2px; }
.cal-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-wd { text-align: center; font-size: 12px; font-weight: 700; color: var(--ink-3); padding: 6px 0; }
.cal-day { display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 58px; border-radius: 12px; color: var(--ink); transition: background .15s; }
.cal-day:hover { background: var(--surface-2); }
.cal-day .num { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; font-size: 16px; font-weight: 600; }
.cal-day.other { color: var(--ink-3); }
.cal-day.today .num { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent); }
.cal-day.selected .num { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.cal.compact .cal-day { min-height: 32px; gap: 0; border-radius: 8px; }
.cal.compact .cal-day .num { width: 26px; height: 24px; font-size: 13px; }
.cal.compact .cal-wd { padding: 2px 0; font-size: 11px; }
.cal.compact .dot { width: 4px; height: 4px; margin-top: -2px; }
.cal-nav { display: flex; align-items: center; gap: 0; flex-wrap: wrap; }
.month-title { font-size: 17px; font-weight: 700; padding: 0 8px; min-height: 44px; border-radius: 10px; }
.month-title:hover { background: var(--surface-2); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 14px; font-size: 13px; color: var(--ink-3); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 8px; height: 8px; }
.legend-tip { margin-left: auto; }

/* Búsqueda, categorías, ajustes */
.search-box { display: flex; align-items: center; gap: 8px; padding: 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; color: var(--ink-3); }
.search-input { flex: 1; height: 48px; border: 0; background: transparent; outline: none; font-size: 16px; color: var(--ink); min-width: 0; }
.search-status { padding: 12px 2px; font-size: 14px; color: var(--ink-3); }
.result { width: 100%; min-height: 52px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; padding: 8px 4px; text-align: left; border-bottom: 1px solid var(--line); }
.result:hover { background: var(--surface-2); }
.result.done .r-title { color: var(--ink-3); text-decoration: line-through; }
.r-title { flex: 1; min-width: 40%; }
.cat-row { display: flex; align-items: center; gap: 12px; min-height: 60px; border-bottom: 1px solid var(--line); }
.cat-info { flex: 1; display: grid; }
.cat-info small, .backup small, .setting small { color: var(--ink-3); font-size: 13px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; padding: 6px 0 10px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; background: var(--cat); display: grid; place-items: center; color: #fff; }
.swatch.on { outline: 2px solid var(--ink); outline-offset: 2px; }
.settings-section { padding: 14px 0 18px; border-bottom: 1px solid var(--line); display: grid; gap: 12px; }
.settings-section h2 { font-size: 13px; font-weight: 700; color: var(--ink-3); }
.settings-section h3 { font-size: 15px; margin-top: 6px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.setting-label { display: grid; font-weight: 600; }
.setting select { max-width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.backup { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.b-info { flex: 1; display: grid; min-width: 0; }
.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: 14px; }
.shortcuts dd { margin: 0; color: var(--ink-2); }
kbd { font: 600 12px var(--font); padding: 2px 7px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); }
.err-list { margin: 8px 0 0 18px; padding: 0; list-style: disc; font-size: 14px; color: var(--ink-2); }

/* Formularios */
.field { display: grid; gap: 6px; margin: 14px 0 0; border: 0; padding: 0; min-width: 0; }
.field > label, .field > legend, .field .label, .inline-check { font-size: 13px; font-weight: 650; color: var(--ink-2); padding: 0; }
input[type="text"], input[type="search"], input[type="password"], input[type="date"], input[type="time"], input[type="number"], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; font-size: 16px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; outline: none; transition: border-color .15s, box-shadow .15s; appearance: none; -webkit-appearance: none; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
textarea { resize: vertical; min-height: 84px; }
textarea.mono { font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="color"] { width: 48px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-inline { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.row-inline input[type="number"] { width: 84px; }
.inline-check { display: flex; align-items: center; gap: 8px; min-height: 22px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; }
.repeat-details { display: grid; gap: 12px; margin-top: 10px; padding: 12px; background: var(--surface-2); border-radius: 12px; }
.repeat-details .field { margin: 0; }
.weekdays { display: flex; gap: 6px; }
.wd-btn { width: 40px; height: 40px; border-radius: 50%; font-weight: 700; font-size: 14px; background: var(--bg); border: 1px solid var(--line); }
.wd-btn[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.cat-options { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-opt { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; }
.cat-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.cat-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.cat-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.choices { display: grid; gap: 4px; margin-top: 10px; }
.choice { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 4px; cursor: pointer; }
.choice small { display: block; color: var(--ink-3); font-size: 13px; }
.form-error, .form-conflict { margin-top: 14px; padding: 10px 12px; border-radius: 10px; font-size: 14px; background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); }
.form-conflict { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); color: var(--ink); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* Diálogos y menús */
dialog.dlg { border: 0; padding: 0; background: var(--surface); color: var(--ink); border-radius: 22px; width: min(520px, calc(100% - 24px)); max-height: none; box-shadow: var(--shadow-lg); overflow: hidden; animation: dlg-in .2s ease-out; }
dialog.dlg.small { width: min(420px, calc(100% - 24px)); }
dialog.dlg::backdrop { background: rgba(10, 12, 20, .45); animation: fade .2s ease-out; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes fade { from { opacity: 0; } }
.dlg-inner { display: flex; flex-direction: column; max-height: min(88vh, calc(var(--vvh, 100dvh) - 32px)); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 4px 20px; }
.dlg-head h2 { font-size: 19px; letter-spacing: -.01em; }
.dlg-content { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.dlg-body { overflow-y: auto; padding: 0 20px 16px; -webkit-overflow-scrolling: touch; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px calc(14px + var(--safe-bottom)); border-top: 1px solid var(--line); }
.dlg-text { margin-top: 8px; color: var(--ink-2); }
.menu { position: fixed; z-index: 60; min-width: 220px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); animation: fade .12s ease-out; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px; border-radius: 9px; text-align: left; font-size: 15px; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item.danger { color: var(--danger); }
.menu-item:disabled { opacity: .4; }
#toasts { position: fixed; z-index: 80; left: calc(12px + var(--safe-left)); right: calc(12px + var(--safe-right)); bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 76px); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 12px; max-width: 460px; padding: 12px 16px; border-radius: 14px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 550; box-shadow: var(--shadow-lg); pointer-events: auto; animation: dlg-in .2s ease-out; }
.toast.error { background: var(--danger); color: var(--danger-ink); }
.toast.warn { background: var(--warn); color: var(--warn-ink); }
.toast.out { opacity: 0; transition: opacity .18s; }
.toast-action { font-weight: 750; text-decoration: underline; color: inherit; min-height: 32px; }

/* Acceso */
.login {
  position: relative; min-height: 100dvh; display: grid; place-items: center; overflow: hidden;
  padding: calc(var(--safe-top) + 24px) calc(20px + var(--safe-right)) calc(var(--safe-bottom) + 24px) calc(20px + var(--safe-left));
  background:
    radial-gradient(680px 420px at 50% -12%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 62%),
    radial-gradient(520px 340px at 88% 8%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%),
    var(--bg);
}
.login::before {
  content: ""; position: absolute; width: 620px; height: 620px; border-radius: 50%;
  top: -300px; left: 50%; transform: translateX(-50%); pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 22%, transparent) 0%, transparent 68%);
  filter: blur(8px); opacity: .55;
}
.login-card {
  position: relative; width: min(400px, 100%); display: grid; gap: 18px;
  padding: 42px 34px; border-radius: 24px; text-align: left;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--line));
  box-shadow: var(--shadow-lg), 0 0 0 1px color-mix(in srgb, var(--accent) 7%, transparent), inset 0 1px rgba(255, 255, 255, .35);
  backdrop-filter: blur(22px) saturate(118%);
  animation: login-in .45s var(--ease);
}
html[data-theme="dark"] .login-card,
html[data-theme="system"] .login-card { border-color: color-mix(in srgb, var(--accent) 34%, var(--line)); box-shadow: var(--shadow-lg), 0 0 0 1px color-mix(in srgb, var(--accent) 12%, transparent), inset 0 1px rgba(255, 255, 255, .05); }
@keyframes login-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.login-head { display: grid; justify-items: center; text-align: center; gap: 6px; margin-bottom: 14px; }
.login-card h1 { font-size: 29px; letter-spacing: -.03em; font-weight: 700; }
.login-card .sub { color: var(--ink-3); font-size: 14px; max-width: 270px; }
.login-field { display: grid; gap: 9px; }
.login-label { font-size: 11px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-3); }
.login-card input {
  width: 100%; text-align: center; font-size: 22px; font-weight: 600; letter-spacing: .32em;
  min-height: 56px; padding: 0 16px; border-radius: 14px; color: var(--ink);
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
  border: 1px solid var(--line); transition: border-color .18s, box-shadow .18s, background .18s;
}
.login-card input::placeholder { letter-spacing: 0; font-size: 16px; font-weight: 400; color: var(--ink-3); }
.login-card input:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 62%, var(--line)); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 13%, transparent); }
.login-card .btn.primary { min-height: 50px; border-radius: 14px; font-size: 15px; box-shadow: 0 12px 30px -12px color-mix(in srgb, var(--accent) 65%, transparent); }
.login-foot { text-align: center; font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.login-error {
  color: var(--danger); font-size: 13px; text-align: center; padding: 10px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 34%, transparent);
}
.brand-mark { display: grid; filter: drop-shadow(0 10px 22px color-mix(in srgb, var(--accent) 42%, transparent)); }

/* Escritorio e iPad horizontal */
@media (min-width: 600px) {
  .main { padding-left: calc(28px + var(--safe-left)); padding-right: calc(28px + var(--safe-right)); }
  #toasts { bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 84px); }
}
@media (max-width: 599px) {
  dialog.dlg.sheet { margin: auto 0 0; width: 100%; max-width: 100%; border-radius: 22px 22px 0 0; animation: sheet-in .26s cubic-bezier(.2, .8, .2, 1); }
  dialog.dlg.sheet .dlg-inner { max-height: calc(var(--vvh, 100dvh) - var(--safe-top) - 12px); }
  dialog.dlg.small { margin-bottom: calc(var(--safe-bottom) + 12px); }
  .day-title .wd { font-size: 34px; }
  .legend-tip { margin-left: 0; width: 100%; }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }
  .sidebar { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100dvh; padding: 22px 16px 16px; border-right: 1px solid var(--line); overflow-y: auto; }
  .sidebar .brand { padding: 0 8px; font-size: 17px; }
  .side-nav { display: grid; gap: 2px; }
  .nav-link.side { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 42px; padding: 0 10px; border-radius: 11px; font-size: 15px; color: var(--ink-2); }
  .nav-link.side:hover { background: var(--surface-2); }
  .nav-link.side[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
  .mini { padding: 0 2px; }
  .mini-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 6px; font-size: 14px; }
  .side-foot { margin-top: auto; }
  .topbar, .tabbar { display: none; }
  .main { width: 100%; max-width: 820px; padding: 40px calc(40px + var(--safe-right)) 120px calc(40px + var(--safe-left)); margin: 0 auto; }
  .quickadd { bottom: 20px; }
  .view { min-height: 60vh; }
  #toasts { bottom: 100px; left: calc(var(--sidebar-w) + var(--safe-left)); }
  .day-title .wd { font-size: 44px; }
}
@media (hover: hover) { .check:hover .box { border-color: var(--accent); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* Transiciones suaves y arrastre sobre un día */
html.dragging-task .weekstrip { position: sticky; top: var(--safe-top); z-index: 60; background: var(--bg); box-shadow: 0 10px 14px -12px rgba(10, 12, 20, .35); }
html.dragging-task body { cursor: grabbing; }
.ws-day, .cal-day { transition: background-color .15s, transform .18s var(--ease), box-shadow .18s var(--ease); }
.ws-day.drop-target, .cal-day.drop-target { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); transform: scale(1.08); }
.view.enter { animation: view-in .24s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } }
.day-title.swap .wd, .day-title.swap .dm { animation: fade-up .24s var(--ease); }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } }
.task-list.slide-l { animation: slide-l .26s var(--ease); }
.task-list.slide-r { animation: slide-r .26s var(--ease); }
.menu { animation: menu-in .16s var(--ease); transform-origin: top right; }
@keyframes menu-in { from { opacity: 0; transform: scale(.96) translateY(-4px); } }
dialog.dlg { animation: dlg-in .26s var(--ease); }
dialog.dlg.closing { animation: dlg-out .17s ease-in forwards; pointer-events: none; }
dialog.dlg.closing::backdrop { animation: fade-out .17s ease-in forwards; }
@keyframes dlg-out { to { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes fade-out { to { opacity: 0; } }
@media (max-width: 599px) {
  dialog.dlg.sheet.closing { animation: sheet-out .2s ease-in forwards; }
}
@keyframes sheet-out { to { transform: translateY(40px); opacity: 0; } }
.qa-cat-icon { display: inline-grid; place-items: center; width: 16px; color: var(--ink-3); }
.who { margin: -8px 0 0; padding: 0 10px; font-size: 13px; color: var(--ink-3); }
.badge { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; }
.badge.off { background: var(--surface-2); color: var(--ink-3); }
