/* =========================================================
   Tareas — hoja de estilos única
   Referencia visual: Microsoft To Do. Móvil primero.
   ========================================================= */

:root {
  --accent: #2564cf;
  --accent-soft: #2564cf1a;

  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --sidebar-bg: #ffffff;
  --text: #1b1d21;
  --text-dim: #61656e;
  --text-faint: #8b909a;
  --border: #e4e7ee;
  --border-strong: #d2d7e2;
  --danger: #d13438;
  --warning: #c8811a;
  --success: #107c41;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-2: 0 8px 24px rgba(16, 24, 40, .12);
  --shadow-3: 0 20px 48px rgba(16, 24, 40, .22);

  --sidebar-w: 288px;
  --detail-w: 380px;
  --safe-b: env(safe-area-inset-bottom, 0px);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #101216;
  --surface: #191c22;
  --surface-2: #1f232b;
  --sidebar-bg: #14171c;
  --text: #e9ecf2;
  --text-dim: #a2a9b6;
  --text-faint: #767d8b;
  --border: #262b34;
  --border-strong: #333a46;
  --danger: #ff6b6f;
  --warning: #e0a34a;
  --success: #4ec27f;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, .5);
  --shadow-3: 0 20px 48px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }

::selection { background: var(--accent-soft); }

/* --------------------------- controles base --------------------------- */

.btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: background .15s, border-color .15s, transform .06s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-size: 16px;
  color: var(--text-dim);
  flex: 0 0 auto;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 5px;
  letter-spacing: .01em;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { resize: vertical; min-height: 84px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }

/* ------------------------------- login -------------------------------- */

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 12% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    radial-gradient(800px 500px at 100% 110%, color-mix(in srgb, #7b61c9 20%, transparent), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 30px 26px 26px;
  box-shadow: var(--shadow-2);
}
.login-logo {
  width: 52px; height: 52px;
  border-radius: 15px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-size: 26px; font-weight: 700;
  margin-bottom: 16px;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent);
}
.login-card h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.login-sub { margin: 4px 0 22px; color: var(--text-dim); font-size: 14px; }
.login-error {
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 13.5px;
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
}

/* ------------------------------- layout ------------------------------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100dvh;
  overflow: hidden;
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, .45);
  z-index: 40;
  backdrop-filter: blur(2px);
  animation: fade-in .18s ease;
}

/* ------------------------------ sidebar ------------------------------- */

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 50;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 12px 8px;
}
.profile {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 10px;
  text-align: left;
  min-width: 0;
}
.profile:hover { background: var(--surface-2); }
.profile-meta { min-width: 0; display: block; }
.profile-meta strong {
  display: block;
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-meta small { color: var(--text-faint); font-size: 11.5px; }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex: 0 0 auto;
  text-transform: uppercase;
}
.avatar.xs { width: 20px; height: 20px; font-size: 9.5px; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }

.search-wrap { position: relative; padding: 4px 12px 10px; }
.search-icon {
  position: absolute;
  left: 24px; top: 50%;
  transform: translateY(-60%);
  font-size: 12.5px;
  opacity: .6;
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 9px 12px 9px 32px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--surface-2);
  outline: none;
}
.search-input:focus { border-color: var(--accent); background: var(--surface); }

.smart-views { padding: 0 8px 6px; }
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
  scrollbar-width: thin;
}
.sidebar-scroll::-webkit-scrollbar { width: 8px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: 9px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  position: relative;
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); font-weight: 600; }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}
.nav-item .nav-icon { font-size: 16px; width: 22px; text-align: center; flex: 0 0 auto; }
.nav-item .nav-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item .nav-count {
  font-size: 12px;
  color: var(--text-faint);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 8px;
  font-variant-numeric: tabular-nums;
}
.nav-item.active .nav-count { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.nav-item.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }

.cat-group { margin-top: 10px; }
.cat-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  color: var(--text-faint);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.cat-head .cat-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.cat-head .icon-btn { width: 24px; height: 24px; font-size: 13px; opacity: 0; }
.cat-group:hover .cat-head .icon-btn { opacity: 1; }

.sidebar-foot {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px 12px calc(10px + var(--safe-b));
  border-top: 1px solid var(--border);
}
.foot-btn {
  flex: 1;
  text-align: left;
  border: none;
  background: transparent;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}
.foot-btn:hover { background: var(--surface-2); }

/* ------------------------------ contenido ----------------------------- */

.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 9%, transparent), transparent 220px),
    var(--bg);
}

.list-header {
  padding: 20px 26px 12px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.header-main { flex: 1; min-width: 0; }
.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 0;
  min-width: 0;
}
.header-title .h-icon { font-size: 24px; }
.header-title .h-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: none;
  background: transparent;
  padding: 2px 4px;
  border-radius: 6px;
  font: inherit;
  color: inherit;
  min-width: 40px;
  max-width: 100%;
}
.header-title .h-name:focus { outline: 2px solid var(--accent); background: var(--surface); }
.header-sub {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  color: var(--text-dim);
}
.menu-btn { font-size: 18px; }
.hamburger { display: none; }

.task-area {
  flex: 1;
  overflow-y: auto;
  padding: 0 26px 12px;
  scrollbar-width: thin;
}
.task-area::-webkit-scrollbar { width: 10px; }
.task-area::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }

.group-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
  margin: 18px 2px 8px;
}

/* --------------------------------- tareas ------------------------------ */

.task-list { display: flex; flex-direction: column; gap: 6px; }

.task-row {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  touch-action: pan-y;
  animation: pop-in .18s ease;
}
.task-row.dragging { opacity: .45; }
.task-row.drag-over { box-shadow: 0 -2px 0 var(--accent) inset, var(--shadow-1); }
.task-row.leaving { animation: fade-out .18s ease forwards; }

.task-inner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 14px;
  background: var(--surface);
  position: relative;
  z-index: 1;
  transition: transform .18s cubic-bezier(.2, .8, .3, 1);
}
.task-row.swiping .task-inner { transition: none; }

/* Fondo que asoma al deslizar: izquierda destaca, derecha elimina. */
.swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  font-size: 17px;
  color: #fff;
  background: var(--surface-2);
  transition: background .18s;
}
.swipe-action {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: .35;
  transition: opacity .15s, transform .15s;
}
.swipe-label { font-size: 13px; font-weight: 600; letter-spacing: .01em; }
.swipe-action.armed { opacity: 1; transform: scale(1.06); }

.task-row.sw-star .swipe-bg { background: #e8a33d; }
.task-row.sw-sun .swipe-bg { background: #2f9bd8; }
.task-row.sw-delete .swipe-bg { background: var(--danger); }

.check {
  width: 21px; height: 21px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
  cursor: pointer;
  flex: 0 0 auto;
  margin-top: 2px;
  display: grid;
  place-items: center;
  transition: border-color .15s, background .15s, transform .12s;
  position: relative;
}
.check:hover { border-color: var(--accent); }
.check::after {
  content: "";
  width: 10px; height: 6px;
  border-left: 2.2px solid #fff;
  border-bottom: 2.2px solid #fff;
  transform: rotate(-45deg) scale(.2);
  opacity: 0;
  transition: transform .18s cubic-bezier(.2, .9, .3, 1.4), opacity .12s;
  margin-top: -2px;
}
.check.done { background: var(--accent); border-color: var(--accent); }
.check.done::after { opacity: 1; transform: rotate(-45deg) scale(1); }
.check.pulse { animation: check-pop .32s ease; }

.task-body { flex: 1; min-width: 0; cursor: pointer; }
.task-title {
  word-break: break-word;
  transition: color .2s;
}
.task-row.done .task-title { color: var(--text-faint); text-decoration: line-through; }
.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-dim);
  align-items: center;
}
.task-meta .due.overdue { color: var(--danger); font-weight: 600; }
.task-meta .due.today { color: var(--accent); font-weight: 600; }
.prio {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.prio.high { color: var(--danger); }
.prio.medium { color: var(--warning); }
.prio.low { color: var(--text-dim); }

.task-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }

/* Estrella de "importante" */
.star {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px 5px;
  border-radius: 7px;
  color: var(--text-faint);
  opacity: .55;
  transition: opacity .15s, color .15s, transform .12s;
}
.star:hover { opacity: 1; color: var(--warning); background: var(--surface-2); }
.star.on { opacity: 1; color: #e8a33d; }
.star.on:hover { color: #e8a33d; }
.star:active { transform: scale(1.25); }
.star:disabled { cursor: default; opacity: .25; }
.star.big { font-size: 22px; padding: 6px 8px; }
.task-row:hover .star { opacity: 1; }

/* Sol de "Mi día" */
.sun {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 4px 5px;
  border-radius: 7px;
  opacity: .4;
  filter: grayscale(1);
  transition: opacity .15s, filter .15s, transform .12s;
}
.sun:hover { opacity: 1; filter: none; background: var(--surface-2); }
.sun.on { opacity: 1; filter: none; }
.sun:active { transform: scale(1.2); }
.sun:disabled { cursor: default; opacity: .2; }
.sun.big { font-size: 19px; padding: 6px 7px; }
.task-row:hover .sun { opacity: 1; }
@media (max-width: 860px) { .star, .sun { opacity: 1; } }

/* Grupo plegable (completadas) */
.group-title.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
  padding: 4px 2px;
}
.group-title.toggle:hover { color: var(--text-dim); }
.group-title .caret { font-size: 10px; }

.toggle-chip { cursor: pointer; font-family: inherit; }
.toggle-chip:hover { border-color: var(--accent); color: var(--accent); }
.toggle-chip.on { border-color: var(--border-strong); }

/* Confeti al completar */
.confetti-layer {
  position: fixed;
  z-index: 300;
  pointer-events: none;
  width: 0;
  height: 0;
}
.confetti-layer i {
  position: absolute;
  width: 7px;
  height: 9px;
  border-radius: 2px;
  opacity: 0;
  animation: confetti-fly .85s cubic-bezier(.15, .8, .35, 1) var(--delay, 0ms) forwards;
}
@keyframes confetti-fly {
  0% { transform: translate(0, 0) rotate(0deg) scale(.4); opacity: 1; }
  70% { opacity: 1; }
  100% {
    transform: translate(var(--dx), calc(var(--dy) + 26px)) rotate(var(--rot)) scale(1);
    opacity: 0;
  }
}
.drag-handle {
  cursor: grab;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity .15s;
  font-size: 14px;
  padding: 2px 4px;
  touch-action: none;
}
.task-row:hover .drag-handle { opacity: 1; }
.drag-handle:active { cursor: grabbing; }

.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-faint);
}
.empty .emoji { font-size: 40px; display: block; margin-bottom: 10px; }

/* Sugerencias del campo de añadir */
.add-wrap { position: relative; }

.suggestions {
  position: absolute;
  left: 26px;
  right: 26px;
  bottom: calc(100% - 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  max-height: min(46dvh, 340px);
  overflow-y: auto;
  z-index: 30;
  padding: 4px;
  animation: pop-in .14s ease;
}
.suggestions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 4px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
}
.suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  text-align: left;
  font-size: 14.5px;
}
.suggestion:hover, .suggestion.on { background: var(--accent-soft); }
.sug-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug-cat { font-size: 12px; flex: 0 0 auto; }
.sug-uses {
  font-size: 11.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}
.sug-forget { opacity: 0; font-size: 13px; flex: 0 0 auto; padding: 0 2px; }
.suggestion:hover .sug-forget, .suggestion.on .sug-forget { opacity: .6; }
.sug-forget:hover { opacity: 1; }

.add-task {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 26px calc(18px + var(--safe-b));
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}
.add-plus { color: var(--accent); font-size: 18px; font-weight: 700; }
.add-task-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  padding: 4px 0;
  min-width: 0;
}

/* ---------------------------- panel de detalle ------------------------- */

.detail {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: var(--detail-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-3);
  transform: translateX(102%);
  transition: transform .24s cubic-bezier(.2, .8, .3, 1);
  z-index: 60;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.detail.open { transform: translateX(0); }
.detail-scroll { flex: 1; overflow-y: auto; padding: 18px 20px; }
.detail-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 12px 18px;
  border-bottom: 1px solid var(--border);
}
.detail-head strong { flex: 1; font-size: 14px; color: var(--text-dim); font-weight: 600; }
.detail-foot {
  border-top: 1px solid var(--border);
  padding: 10px 16px calc(12px + var(--safe-b));
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  color: var(--text-faint);
  font-size: 12px;
}
.detail-title-row { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 6px; }
.detail-title {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 6px 8px;
  resize: none;
  overflow: hidden;
  outline: none;
  min-height: 38px;
}
.detail-title:focus { border-color: var(--accent); background: var(--surface-2); }

.sub-list { display: flex; flex-direction: column; gap: 2px; margin: 8px 0 4px; }
.sub-row { display: flex; align-items: center; gap: 10px; padding: 5px 4px; border-radius: 8px; }
.sub-row:hover { background: var(--surface-2); }
.sub-row .check { width: 17px; height: 17px; margin-top: 0; }
.sub-row .check::after { width: 8px; height: 5px; }
.sub-row span { flex: 1; font-size: 14px; word-break: break-word; }
.sub-row.done span { color: var(--text-faint); text-decoration: line-through; }
.sub-add {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 4px;
}
.sub-add input {
  flex: 1;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  outline: none;
  padding: 4px 0;
  font-size: 14px;
}
.sub-add input:focus { border-color: var(--accent); }

.detail-section { margin-top: 18px; }
.detail-section > h4 {
  margin: 0 0 8px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
}
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 13px;
}
.seg button.on { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
.quick-dates { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }

/* -------------------------------- modales ------------------------------ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, .5);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 16px;
  animation: fade-in .16s ease;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-3);
  width: min(520px, 100%);
  max-height: min(88dvh, 760px);
  display: flex;
  flex-direction: column;
  animation: modal-in .2s cubic-bezier(.2, .8, .3, 1);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 17px; flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  padding: 12px 18px calc(14px + var(--safe-b));
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--border); }
.tabs button {
  border: none;
  background: transparent;
  padding: 11px 12px;
  cursor: pointer;
  color: var(--text-dim);
  font-weight: 600;
  border-bottom: 2px solid transparent;
  font-size: 14px;
}
.tabs button.on { color: var(--accent); border-color: var(--accent); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform .12s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 4px;
  max-height: 148px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.emoji-grid button {
  border: none;
  background: transparent;
  font-size: 19px;
  padding: 5px;
  border-radius: 7px;
  cursor: pointer;
}
.emoji-grid button:hover { background: var(--surface); }
.emoji-grid button.on { background: var(--accent); }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row small { display: block; color: var(--text-faint); font-size: 12px; }
.switch {
  position: relative;
  width: 42px; height: 24px;
  border-radius: 999px;
  background: var(--border-strong);
  border: none;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background .18s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s cubic-bezier(.2, .8, .3, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(18px); }

.share-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.share-row .grow { flex: 1; min-width: 0; }
.share-row .grow strong { display: block; font-size: 14px; }
.share-row .grow small { color: var(--text-faint); font-size: 12px; }

.token-box {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  word-break: break-all;
}
.token-box code { flex: 1; min-width: 0; }
.hint { color: var(--text-faint); font-size: 12.5px; margin: 6px 0 0; }

.menu-sheet {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-3);
  padding: 6px;
  z-index: 110;
  min-width: 208px;
  animation: pop-in .12s ease;
}
.menu-sheet button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 9px 11px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
}
.menu-sheet button:hover { background: var(--surface-2); }
.menu-sheet button.danger { color: var(--danger); }
.menu-sheet hr { border: none; border-top: 1px solid var(--border); margin: 5px 2px; }

/* -------------------------------- toasts ------------------------------- */

.toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
  width: min(420px, calc(100vw - 32px));
}
.toast {
  background: #23262d;
  color: #fff;
  border-radius: 10px;
  padding: 11px 15px;
  box-shadow: var(--shadow-2);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toast-in .2s cubic-bezier(.2, .8, .3, 1);
  pointer-events: auto;
}
.toast.error { background: var(--danger); }
.toast button {
  border: none;
  background: transparent;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
  padding: 0;
}
:root[data-theme="dark"] .toast { background: #32363f; }

/* ----------------------------- animaciones ----------------------------- */

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; transform: translateY(-4px); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(4px) scale(.995); } to { opacity: 1; transform: none; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes check-pop { 0% { transform: scale(1); } 45% { transform: scale(1.28); } 100% { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* -------------------------------- móvil -------------------------------- */

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: min(84vw, 320px);
    transform: translateX(-102%);
    transition: transform .24s cubic-bezier(.2, .8, .3, 1);
    box-shadow: var(--shadow-3);
  }
  .sidebar.open { transform: translateX(0); }

  .hamburger { display: grid; }
  .list-header { padding: 14px 16px 8px; align-items: center; }
  .header-title { font-size: 21px; }
  .task-area { padding: 0 14px 8px; }
  .add-task { margin: 0 14px calc(14px + var(--safe-b)); }
  .suggestions { left: 14px; right: 14px; }

  .detail {
    width: 100%;
    top: auto;
    height: 88dvh;
    border-radius: 20px 20px 0 0;
    border-left: none;
    border-top: 1px solid var(--border);
    transform: translateY(102%);
  }
  .detail.open { transform: translateY(0); }

  .drag-handle { opacity: 1; }
  .modal { width: 100%; max-height: 92dvh; }
}

@media (min-width: 861px) {
  .detail-open .content { padding-right: 0; }
}
