:root {
  --navy: #0B1F3A;
  --navy-row: #122A4A;
  --navy-row-pressed: #18355B;
  --pink: #FF5C93;
  --white: #FFFFFF;
  --dim: rgba(255, 255, 255, 0.42);
  --hair: rgba(255, 255, 255, 0.10);
  --tap: 48px;
}

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

html { background: var(--navy); }

body {
  margin: 0;
  background: var(--navy);
  color: var(--white);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

[hidden] { display: none !important; }

/* ------------------------------------------------------------------ PIN gate */

.gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  padding: calc(env(safe-area-inset-top) + 24px) 24px calc(env(safe-area-inset-bottom) + 24px);
  z-index: 50;
}

.gate-card { width: 100%; max-width: 320px; text-align: center; }
.gate-mark { margin-bottom: 10px; }
.gate-title { margin: 0 0 28px; font-size: 30px; font-weight: 700; letter-spacing: 0.14em; }
.gate-label { display: block; margin-bottom: 10px; font-size: 15px; color: var(--dim); }

.gate-input {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  border: 1px solid var(--hair);
  border-radius: 14px;
  background: var(--navy-row);
  color: var(--white);
  font: inherit;
  font-size: 24px;
  text-align: center;
  letter-spacing: 0.4em;
}
.gate-input:focus { outline: none; border-color: var(--pink); }

.gate-btn {
  width: 100%;
  min-height: var(--tap);
  height: 52px;
  margin-top: 14px;
  border: 0;
  border-radius: 14px;
  background: var(--pink);
  color: #2A0A17;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
}
.gate-btn:active { opacity: 0.8; }
.gate-msg { min-height: 20px; margin: 14px 0 0; font-size: 14px; color: var(--pink); }

/* -------------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 14px) max(env(safe-area-inset-right), 14px) 14px max(env(safe-area-inset-left), 14px);
  background: rgba(11, 31, 58, 0.92);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--hair);
}

.brand { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 22px; font-weight: 700; letter-spacing: 0.1em; }
.brand-heart { flex: none; }
.total { font-size: 15px; font-weight: 600; color: var(--pink); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ sections */

.sections {
  padding: 8px max(env(safe-area-inset-right), 12px) 0 max(env(safe-area-inset-left), 12px);
}

.section { margin-bottom: 18px; }

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--tap);
  padding: 10px 6px;
  border: 0;
  background: none;
  color: var(--white);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.chev {
  flex: none;
  width: 14px;
  color: var(--dim);
  font-size: 12px;
  transition: transform 0.18s ease;
}
.section.collapsed .chev { transform: rotate(-90deg); }

.section-title {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
}

.section-count {
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 92, 147, 0.16);
  color: var(--pink);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.section-count.complete { background: var(--pink); color: #2A0A17; }

.section-body { overflow: hidden; }
.section.collapsed .section-body { display: none; }

.task-list { margin: 0; padding: 0; list-style: none; }

/* ---------------------------------------------------------------------- rows */

.row-wrap {
  position: relative;
  margin-bottom: 6px;
  border-radius: 14px;
  background: #7A1230; /* revealed behind a left swipe */
  overflow: hidden;
}

.row-delete {
  position: absolute;
  inset: 0 0 0 auto;
  width: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: none;
  color: var(--white);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
}

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: var(--tap);
  padding: 13px 14px;
  border: 0;
  border-radius: 14px;
  background: var(--navy-row);
  color: var(--white);
  font: inherit;
  text-align: left;
  touch-action: pan-y;
  transition: transform 0.22s cubic-bezier(0.22, 0.61, 0.36, 1), background-color 0.12s;
  will-change: transform;
}
.row.dragging { transition: none; }
.row.open { transform: translateX(-96px); }
.row:active { background: var(--navy-row-pressed); }

.box {
  flex: none;
  position: relative;
  width: 28px;
  height: 28px;
  border: 2px solid var(--pink);
  border-radius: 9px;
  transition: background-color 0.14s, border-color 0.14s;
}
.box::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 8px;
  width: 7px;
  height: 13px;
  border: solid #2A0A17;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.16s cubic-bezier(0.3, 1.5, 0.6, 1);
}
.row.done .box { background: var(--pink); }
.row.done .box::after { transform: rotate(45deg) scale(1); }

.label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row.done .label { color: var(--dim); text-decoration: line-through; text-decoration-color: var(--dim); }

/* ------------------------------------------------------------------- add task */

.add-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--tap);
  padding: 11px 14px;
  border: 0;
  background: none;
  color: var(--pink);
  font: inherit;
  font-size: 16px;
  text-align: left;
}
.add-plus {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 2px dashed rgba(255, 92, 147, 0.6);
  border-radius: 9px;
  font-size: 18px;
  line-height: 1;
}
.add-btn:active { opacity: 0.65; }

.add-form { display: flex; gap: 8px; padding: 2px 0 4px; }
.add-input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 1px solid var(--pink);
  border-radius: 14px;
  background: var(--navy-row);
  color: var(--white);
  font: inherit;
}
.add-input:focus { outline: none; }
.add-save {
  flex: none;
  min-width: 72px;
  min-height: var(--tap);
  border: 0;
  border-radius: 14px;
  background: var(--pink);
  color: #2A0A17;
  font: inherit;
  font-weight: 700;
}

/* ------------------------------------------------------------------- footer */

.footer {
  padding: 10px max(env(safe-area-inset-right), 16px) calc(env(safe-area-inset-bottom) + 28px) max(env(safe-area-inset-left), 16px);
}

.danger-btn {
  width: 100%;
  min-height: var(--tap);
  height: 52px;
  border: 1px solid rgba(255, 92, 147, 0.5);
  border-radius: 14px;
  background: none;
  color: var(--pink);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
}
.danger-btn:active { background: rgba(255, 92, 147, 0.12); }

/* ------------------------------------------------------------------- status */

.status {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  z-index: 40;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(255, 92, 147, 0.95);
  color: #2A0A17;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.35);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------------------------------------------------------------- quick add */

.quickadd {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  gap: 8px;
  padding: 10px max(env(safe-area-inset-right), 12px) 10px max(env(safe-area-inset-left), 12px);
  background: rgba(11, 31, 58, 0.94);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--hair);
}

.quickadd-input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 12px 16px;
  border: 1px solid var(--hair);
  border-radius: 14px;
  background: var(--navy-row);
  color: var(--white);
  font-family: inherit;
  /* 17px: iOS zooms the page on focus for anything under 16px. */
  font-size: 17px;
}
.quickadd-input::placeholder { color: var(--dim); }
.quickadd-input:focus { outline: none; border-color: var(--pink); }

.quickadd-btn {
  flex: none;
  width: var(--tap);
  min-height: var(--tap);
  border: 0;
  border-radius: 14px;
  background: var(--pink);
  color: #2A0A17;
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}
.quickadd-btn:disabled { opacity: 0.45; }
.quickadd-btn:active:not(:disabled) { opacity: 0.75; }

/* ------------------------------------------------------------ sorting state */

.pending { padding: 0 max(env(safe-area-inset-right), 12px) 0 max(env(safe-area-inset-left), 12px); }

.pending-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  padding: 13px 14px;
  border: 1px dashed rgba(255, 92, 147, 0.45);
  border-radius: 14px;
  color: var(--dim);
  animation: pending-pulse 1.4s ease-in-out infinite;
}
@keyframes pending-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

.pending-row .label { color: rgba(255, 255, 255, 0.72); }

.pending-tag {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pink);
}

.spinner {
  flex: none;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 92, 147, 0.3);
  border-top-color: var(--pink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------- landing highlight */

/* Slides the new row in, then flashes it so its destination is obvious. */
.row-wrap.just-added { animation: drop-in 0.34s cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes drop-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.row.just-added {
  animation: flash 1.9s ease-out;
}
@keyframes flash {
  0%, 55% { background: rgba(255, 92, 147, 0.30); box-shadow: 0 0 0 2px var(--pink) inset; }
  100%    { background: var(--navy-row); box-shadow: none; }
}

.section.just-added > .section-head .section-count { animation: flash-count 1.9s ease-out; }
@keyframes flash-count {
  0%, 55% { background: var(--pink); color: #2A0A17; }
  100%    { background: rgba(255, 92, 147, 0.16); color: var(--pink); }
}

/* --------------------------------------------------------------- move sheet */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 12, 24, 0.66);
  animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  padding: 8px max(env(safe-area-inset-right), 12px) calc(env(safe-area-inset-bottom) + 12px) max(env(safe-area-inset-left), 12px);
  background: #0E2546;
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--hair);
  animation: rise 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }

.sheet-grip { width: 38px; height: 4px; margin: 6px auto 10px; border-radius: 2px; background: rgba(255, 255, 255, 0.25); }
.sheet-title { margin: 0 6px 4px; font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.sheet-task { margin: 0 6px 12px; font-size: 16px; font-weight: 600; }
.sheet-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.sheet-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: var(--tap);
  margin-bottom: 6px;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--navy-row);
  color: var(--white);
  font: inherit;
  font-size: 16px;
  text-align: left;
}
.sheet-opt:active { background: var(--navy-row-pressed); }
.sheet-opt[aria-current="true"] { color: var(--dim); }
.sheet-opt .tick { color: var(--pink); font-weight: 700; }

.sheet-cancel {
  flex: none;
  width: 100%;
  min-height: var(--tap);
  margin-top: 6px;
  border: 1px solid var(--hair);
  border-radius: 14px;
  background: none;
  color: var(--white);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
}

/* ------------------------------------------------- checkbox is the only toggle */

/* The box draws at 28px but needs a 44px+ touch target. This invisible
   ::before expands the hit area without affecting layout or the row's look.
   (::after is already the checkmark.) */
.box::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
}

.box { cursor: pointer; }

.box:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 3px;
}

/* The label is no longer interactive — let text behave like text. */
.label { cursor: default; }

/* ------------------------------------------------------------------ tagline */

/* Sits between the BKW mark and the counter, on the same single line.
   The sides are fixed-width; the tagline takes the gap in between and
   centres itself there. nowrap keeps the whole bar to one line. */
.tagline {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  font-style: italic;
  /* Fluid so the whole bar still fits one line on a 320px iPhone SE,
     without shrinking needlessly on larger phones. */
  font-size: clamp(7.5px, 2.4vw, 11px);
  letter-spacing: 0.01em;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.58);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;   /* last-resort guard; should never trigger */
}

.brand, .total { flex: none; }

/* Give the tagline a little more room on the narrowest phones. */
@media (max-width: 360px) {
  .brand { font-size: 19px; }
  .total { font-size: 14px; }
}
