/* ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
   Tickbox — playful checklist tool
   ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ */

:root {
  --bg:        #eefafa;
  --bg-grad-1: #d6f4f5;
  --bg-grad-2: #e2eefe;
  --surface:   #ffffff;
  --surface-2: #f3fafb;
  --ink:       #15323b;
  --ink-soft:  #4f7079;
  --ink-faint: #92aeb6;
  --line:      #e0eef0;

  --brand:     #0ea5a5;
  --brand-2:   #22d3ee;
  --brand-soft:#d6f3f4;
  --green:     #16b981;
  --green-soft:#d4f5e8;
  --danger:    #ff5d6c;
  --amber:     #f59e0b;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-pill: 999px;

  --shadow-sm: 0 2px 8px rgba(15, 80, 90, 0.08);
  --shadow-md: 0 8px 24px rgba(15, 80, 90, 0.12);
  --shadow-lg: 0 18px 50px rgba(15, 80, 90, 0.18);

  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 100% 0%, var(--bg-grad-1) 0%, transparent 55%),
    radial-gradient(120% 90% at 0% 100%, var(--bg-grad-2) 0%, transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input  { font-family: inherit; }

/* ── Layout ───────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100vh;
  height: 100dvh;
}

/* ── Sidebar ──────────────────────────────────────── */
.sidebar {
  background: rgba(255, 255, 255, 0.66);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 16px;
  z-index: 30;
}

.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Brand card — matches the ToolWizHub tax-calc appbar treatment */
.brand {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: var(--r-md);
  text-decoration: none;
  background: linear-gradient(180deg, #1d2f3a, #142028);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s var(--ease-bounce), box-shadow 0.15s;
}
.brand:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.brand__mark {
  width: 42px; height: 42px; border-radius: 11px; object-fit: cover;
  flex-shrink: 0; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.brand__text { display: flex; flex-direction: column; gap: 3px; line-height: 1.15; min-width: 0; }
.brand__text strong {
  font-size: 16px; font-weight: 800; letter-spacing: -0.01em; color: #fff;
}
.brand__text span {
  font-size: 9.5px; letter-spacing: 0.18em; text-transform: uppercase;
  font-weight: 700; color: #7e9aa5; white-space: nowrap;
}

.sidebar__head .sidebar__close { display: none; }

.lists {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 -6px;
  padding: 2px 6px;
}

.list-pill {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--r-md);
  background: transparent;
  text-align: left;
  width: 100%;
  transition: background 0.16s, transform 0.16s var(--ease-bounce);
}
.list-pill:hover { background: var(--surface); box-shadow: var(--shadow-sm); }
.list-pill.is-active { background: var(--surface); box-shadow: var(--shadow-sm); }
.list-pill.is-active::before {
  content: ""; position: absolute; left: -6px; top: 18%; bottom: 18%;
  width: 4px; border-radius: 4px;
  background: linear-gradient(var(--brand), var(--brand-2));
}
.list-pill__emoji { font-size: 20px; flex-shrink: 0; }
.list-pill__body { flex: 1; min-width: 0; }
.list-pill__name {
  font-weight: 800; font-size: 14.5px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-pill__meta { font-size: 12px; color: var(--ink-faint); font-weight: 700; }
.list-pill__ring { flex-shrink: 0; }

.sidebar__foot { display: flex; flex-direction: column; gap: 10px; }
.link-btn {
  color: var(--brand); font-weight: 800; font-size: 14px;
  padding: 8px; border-radius: var(--r-sm); transition: background 0.15s;
  text-align: left;
}
.link-btn:hover { background: var(--brand-soft); }
.sidebar__note { font-size: 11.5px; color: var(--ink-faint); padding: 0 8px; font-weight: 600; }

/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--r-pill);
  font-weight: 800; font-size: 15px; color: var(--ink);
  background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform 0.15s var(--ease-bounce), box-shadow 0.15s;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn--block { width: 100%; }
.btn--primary {
  color: #fff;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 18px rgba(14, 165, 165, 0.38);
}
.btn__plus { font-size: 18px; line-height: 1; }

.icon-btn {
  width: 40px; height: 40px; border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--ink-soft);
  transition: background 0.15s, transform 0.15s var(--ease-bounce);
}
.icon-btn:hover { background: var(--surface-2); transform: scale(1.08); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn--danger:hover { background: #ffe6e9; }

/* ── Main / topbar ────────────────────────────────── */
.main { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 24px; flex-shrink: 0;
}
.topbar__menu { display: none; }
.topbar__title {
  display: none; /* redundant with the brand card on desktop; shown on mobile */
  flex: 1; font-size: 16px; font-weight: 800; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar__actions { display: flex; gap: 4px; margin-left: auto; }
.topbar__actions[hidden] { display: none; }

/* ── Board ────────────────────────────────────────── */
.board {
  flex: 1; overflow-y: auto;
  padding: 8px 24px 32px;
  display: flex; flex-direction: column; align-items: center;
}
.board__inner { width: 100%; max-width: 680px; }

/* Slim persistent footer */
.app-footer {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 9px 24px; border-top: 1px solid var(--line);
}
.app-footer__brand {
  display: inline-flex; align-items: center; gap: 9px;
  text-decoration: none; opacity: 0.55; transition: opacity 0.15s;
}
.app-footer__brand:hover { opacity: 1; }
.app-footer__label { font-size: 12px; font-weight: 700; color: var(--ink-faint); }
.app-footer__brand img { height: 20px; width: auto; display: block; }

/* List header */
.list-head { margin: 8px 0 22px; }
.list-head__top { display: flex; align-items: center; gap: 14px; }
.emoji-btn {
  font-size: 40px; line-height: 1; flex-shrink: 0;
  width: 64px; height: 64px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform 0.15s var(--ease-bounce);
}
.emoji-btn:hover { transform: rotate(-8deg) scale(1.06); }
.list-title-input {
  flex: 1; min-width: 0;
  font-size: 30px; font-weight: 900; letter-spacing: -0.8px; color: var(--ink);
  background: transparent; border: none; outline: none;
  border-bottom: 2px solid transparent; padding: 4px 0;
  transition: border-color 0.15s;
}
.list-title-input:focus { border-bottom-color: var(--brand-soft); }

/* Progress */
.progress { margin-top: 18px; }
.progress__row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.progress__label { font-weight: 800; font-size: 14px; color: var(--ink-soft); }
.progress__pct { font-weight: 900; font-size: 14px; color: var(--brand); }
.progress__track {
  height: 12px; border-radius: var(--r-pill);
  background: var(--brand-soft); overflow: hidden;
}
.progress__fill {
  height: 100%; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  width: 0%; transition: width 0.5s var(--ease-bounce);
}
.progress__fill.is-complete { background: linear-gradient(90deg, var(--green), #5fe0a8); }

/* Add item */
.add-item {
  display: flex; gap: 10px; align-items: center;
  background: var(--surface); border-radius: var(--r-md);
  padding: 6px 6px 6px 18px; box-shadow: var(--shadow-sm);
  margin: 22px 0 18px;
  transition: box-shadow 0.18s, transform 0.18s;
}
.add-item:focus-within { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.add-item__input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 16px; font-weight: 600; color: var(--ink); padding: 12px 0;
}
.add-item__input::placeholder { color: var(--ink-faint); }
.add-item__btn {
  width: 44px; height: 44px; border-radius: var(--r-sm); flex-shrink: 0;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  color: #fff; font-size: 22px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s var(--ease-bounce);
}
.add-item__btn:hover { transform: scale(1.08) rotate(90deg); }
.add-item__btn:active { transform: scale(0.9); }

/* Items */
.items { display: flex; flex-direction: column; gap: 8px; list-style: none; }

.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-radius: var(--r-md);
  padding: 14px 14px 14px 16px; box-shadow: var(--shadow-sm);
  transition: transform 0.16s var(--ease-bounce), box-shadow 0.16s, opacity 0.3s;
  animation: pop-in 0.3s var(--ease-bounce);
}
.item:hover { box-shadow: var(--shadow-md); }
.item.is-dragging { opacity: 0.5; box-shadow: var(--shadow-lg); transform: scale(1.02); }
.item.drag-over { transform: translateY(2px); box-shadow: 0 0 0 2px var(--brand) inset; }

.item__grip {
  cursor: grab; color: var(--ink-faint); font-size: 16px; line-height: 1;
  flex-shrink: 0; opacity: 0; transition: opacity 0.15s; touch-action: none;
  letter-spacing: -2px;
}
.item:hover .item__grip { opacity: 1; }

/* Checkbox */
.check {
  position: relative; width: 26px; height: 26px; flex-shrink: 0;
  border-radius: 9px; border: 2.5px solid var(--ink-faint);
  background: transparent;
  transition: border-color 0.15s, background 0.2s var(--ease-bounce);
}
.check::after {
  content: ""; position: absolute; left: 7px; top: 3px;
  width: 6px; height: 11px; border: solid #fff;
  border-width: 0 3px 3px 0; transform: rotate(45deg) scale(0);
  transition: transform 0.2s var(--ease-bounce);
}
.check:hover { border-color: var(--brand); }
.item.is-done .check {
  background: linear-gradient(135deg, var(--green), #4fd99b);
  border-color: transparent;
}
.item.is-done .check::after { transform: rotate(45deg) scale(1); }

.item__text {
  flex: 1; font-size: 16px; font-weight: 700; color: var(--ink);
  background: transparent; border: none; outline: none;
  transition: color 0.2s; word-break: break-word;
}
.item.is-done .item__text { color: var(--ink-faint); text-decoration: line-through; }

.item__del {
  width: 32px; height: 32px; border-radius: var(--r-sm); flex-shrink: 0;
  color: var(--ink-faint); font-size: 15px; opacity: 0;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.item:hover .item__del, .item:focus-within .item__del { opacity: 1; }
.item__del:hover { background: #ffe6e9; color: var(--danger); }

/* Completed divider */
.done-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 22px 4px 12px; color: var(--ink-faint);
  font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px;
}
.done-divider::after { content: ""; flex: 1; height: 2px; background: var(--line); border-radius: 2px; }

/* ── Empty states ─────────────────────────────────── */
.empty {
  text-align: center; max-width: 420px; margin: auto;
  padding: 60px 20px; animation: pop-in 0.4s var(--ease-bounce);
}
.empty__art { font-size: 72px; margin-bottom: 12px; filter: drop-shadow(0 8px 14px rgba(14,165,165,0.25)); }
.empty__title { font-size: 26px; font-weight: 900; letter-spacing: -0.5px; margin-bottom: 8px; }
.empty__text { color: var(--ink-soft); font-weight: 600; font-size: 15px; line-height: 1.6; margin-bottom: 24px; }
.empty__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.list-empty {
  text-align: center; color: var(--ink-faint); font-weight: 700;
  padding: 40px 20px; font-size: 15px;
}

/* ── Splash screen ────────────────────────────────── */
.splash {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; cursor: pointer;
  background:
    radial-gradient(58% 48% at 50% 42%, rgba(255, 184, 72, 0.18), transparent 70%),
    radial-gradient(120% 90% at 100% 0%, #123a44 0%, transparent 55%),
    radial-gradient(120% 90% at 0% 100%, #0e2c35 0%, transparent 55%),
    #0b1c22;
  transition: opacity 0.55s ease, visibility 0.55s ease;
  /* Failsafe: if JS never dismisses it, reveal the app anyway. */
  animation: splash-failsafe 0s linear 5s forwards;
}
html.no-splash .splash { display: none; }
.splash.is-hiding { opacity: 0; visibility: hidden; pointer-events: none; }
.splash.is-hiding .splash__stage { transform: scale(1.08); }

.splash__stage {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 22px;
  transition: transform 0.55s var(--ease-bounce);
}

.splash__glow {
  position: absolute; top: 42%; left: 50%;
  width: 340px; height: 340px; transform: translate(-50%, -50%);
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 184, 72, 0.38), rgba(34, 211, 238, 0.16) 45%, transparent 70%);
  filter: blur(10px);
  animation: splash-glow 2.4s ease-in-out infinite;
}
@keyframes splash-glow {
  0%, 100% { opacity: 0.55; transform: translate(-50%, -50%) scale(0.9); }
  50%      { opacity: 1;    transform: translate(-50%, -50%) scale(1.1); }
}

.splash__logo {
  position: relative;
  width: clamp(150px, 42vw, 210px); height: auto;
  filter: drop-shadow(0 14px 34px rgba(0, 0, 0, 0.55));
  animation:
    splash-in 0.8s var(--ease-bounce) both,
    splash-float 3.2s ease-in-out 0.8s infinite;
}
@keyframes splash-in {
  from { opacity: 0; transform: scale(0.6) rotate(-8deg); }
  to   { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes splash-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}

.splash__tagline {
  font-weight: 900; font-size: 14px; letter-spacing: 7px; text-transform: uppercase;
  color: #ffd486; text-shadow: 0 2px 12px rgba(255, 184, 72, 0.45);
  opacity: 0; padding-left: 7px;
  animation: splash-fade 0.6s ease 0.55s forwards;
}
@keyframes splash-fade { to { opacity: 0.95; } }

.splash__bar {
  width: 168px; height: 5px; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.14); overflow: hidden;
}
.splash__bar > span {
  display: block; height: 100%; width: 0; border-radius: var(--r-pill);
  background: linear-gradient(90deg, #ffb648, #22d3ee, #0ea5a5);
  animation: splash-bar 1.5s ease 0.3s forwards;
}
@keyframes splash-bar { from { width: 0; } to { width: 100%; } }

.splash__sparkles { position: absolute; inset: -10% -20%; pointer-events: none; }
.splash__sparkles span {
  position: absolute; width: 9px; height: 9px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 10px 2px rgba(255, 212, 134, 0.9);
  opacity: 0; animation: sparkle 1.9s ease-in-out infinite;
}
.splash__sparkles span:nth-child(1) { top: 26%; left: 28%; animation-delay: 0s; }
.splash__sparkles span:nth-child(2) { top: 20%; left: 70%; animation-delay: 0.45s; }
.splash__sparkles span:nth-child(3) { top: 58%; left: 20%; animation-delay: 0.9s; }
.splash__sparkles span:nth-child(4) { top: 62%; left: 78%; animation-delay: 0.25s; }
.splash__sparkles span:nth-child(5) { top: 36%; left: 86%; animation-delay: 0.65s; }
.splash__sparkles span:nth-child(6) { top: 78%; left: 48%; animation-delay: 1.1s; }
@keyframes sparkle {
  0%, 100% { opacity: 0; transform: scale(0); }
  40%      { opacity: 1; transform: scale(1.25); }
  70%      { opacity: 0.6; transform: scale(0.9); }
}

@keyframes splash-failsafe { to { opacity: 0; visibility: hidden; pointer-events: none; } }

/* ── Modal ────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal[hidden] { display: none; }
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(43, 36, 64, 0.4); backdrop-filter: blur(4px);
  animation: fade-in 0.2s ease;
}
.modal__card {
  position: relative; width: 100%; max-width: 640px;
  max-height: 86vh; overflow-y: auto;
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: 24px;
  animation: pop-in 0.3s var(--ease-bounce);
}
.modal__card--narrow { max-width: 460px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal__head h2 { font-size: 20px; font-weight: 900; letter-spacing: -0.4px; }
.modal__text { color: var(--ink-soft); font-weight: 600; font-size: 14px; line-height: 1.6; margin-bottom: 16px; }
.modal__brand { display: flex; justify-content: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.modal__brand img { height: 22px; width: auto; opacity: 0.5; }

.template-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
.template-card {
  text-align: left; padding: 16px; border-radius: var(--r-md);
  background: var(--surface-2); border: 2px solid transparent;
  transition: transform 0.15s var(--ease-bounce), border-color 0.15s, box-shadow 0.15s;
}
.template-card:hover { transform: translateY(-3px); border-color: var(--brand-soft); box-shadow: var(--shadow-md); }
.template-card__emoji { font-size: 30px; }
.template-card__name { font-weight: 900; font-size: 15px; margin: 6px 0 2px; }
.template-card__count { font-size: 12.5px; color: var(--ink-faint); font-weight: 700; }

.share-row { display: flex; gap: 10px; }
.input {
  flex: 1; padding: 12px 14px; border-radius: var(--r-sm);
  border: 2px solid var(--line); background: var(--surface-2);
  font-size: 14px; font-weight: 600; color: var(--ink); outline: none;
}
.input:focus { border-color: var(--brand-soft); }

/* ── Toast ────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; font-weight: 800; font-size: 14px;
  padding: 13px 22px; border-radius: var(--r-pill);
  box-shadow: var(--shadow-lg); z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s var(--ease-bounce);
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Confetti ─────────────────────────────────────── */
#confetti-canvas {
  position: fixed; inset: 0; pointer-events: none; z-index: 300;
}

/* ── Animations ───────────────────────────────────── */
@keyframes pop-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@keyframes wobble {
  0%,100% { transform: rotate(0); }
  25% { transform: rotate(-6deg); }
  75% { transform: rotate(6deg); }
}
.wobble { animation: wobble 0.4s ease; }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 84%; max-width: 320px;
    transform: translateX(-105%); transition: transform 0.28s var(--ease-bounce);
    box-shadow: var(--shadow-lg);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar__head .sidebar__close { display: inline-flex; }
  .topbar__menu { display: inline-flex; }
  .topbar__title { display: block; }
  .scrim {
    position: fixed; inset: 0; background: rgba(43,36,64,0.4); z-index: 25;
    opacity: 0; pointer-events: none; transition: opacity 0.25s;
  }
  .app.sidebar-open .scrim { opacity: 1; pointer-events: auto; }
  .board { padding: 4px 16px 24px; }
  .list-title-input { font-size: 24px; }
  .template-grid { grid-template-columns: 1fr; }
}

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