:root {
  --paper: #FFF8F0;
  --card: #FFFFFF;
  --ink: #4E3D34;
  --ink-soft: #97806f;
  --coral: #FF7E67;
  --coral-deep: #E8604A;
  --honey: #FFC85C;
  --line: #F3E4D3;
  --shadow: 0 6px 20px rgba(190, 120, 70, .14);
  --shadow-soft: 0 3px 10px rgba(190, 120, 70, .10);
  --r-card: 22px;
  --r-btn: 16px;
  --font-display: "Shantell Sans", cursive;
  --font-body: "Nunito", sans-serif;

  --peach-bg: #FFE1D3; --peach-dot: #FF9B7B; --peach-deep: #C25E41;
  --butter-bg: #FFF0C2; --butter-dot: #FFC94D; --butter-deep: #A87A17;
  --mint-bg: #D9F2DD; --mint-dot: #6CC48A; --mint-deep: #35784E;
  --sky-bg: #D8EEF9; --sky-dot: #64B6DE; --sky-deep: #2E6E93;
  --lilac-bg: #E9E1FA; --lilac-dot: #A48AE0; --lilac-deep: #6A4FB0;
  --rose-bg: #FBDCE8; --rose-dot: #EE85AC; --rose-deep: #B54875;
}

:root[data-dark="1"] {
  --paper: #262038;
  --card: #322A4A;
  --ink: #F5EADB;
  --ink-soft: #B3A5C4;
  --line: #443A5E;
  --shadow: 0 6px 20px rgba(10, 6, 24, .45);
  --shadow-soft: 0 3px 10px rgba(10, 6, 24, .35);

  --peach-bg: #4A3138; --butter-bg: #4A4130; --mint-bg: #2F4636;
  --sky-bg: #2C4152; --lilac-bg: #3D3455; --rose-bg: #4A3142;
}

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

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  overscroll-behavior-y: none;
}

#ambient-sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; }

#app { max-width: 620px; margin: 0 auto; min-height: 100dvh; position: relative; }

.view { min-height: 100dvh; display: flex; flex-direction: column; }

button { font-family: inherit; color: inherit; border: none; background: none; cursor: pointer; }
input {
  font-family: var(--font-body); font-size: 17px; color: var(--ink);
  border: 2px solid var(--line); border-radius: var(--r-btn);
  padding: 13px 16px; width: 100%; background: var(--card);
  transition: border-color .18s ease, box-shadow .18s ease;
}
input:focus { outline: none; border-color: var(--honey); box-shadow: 0 0 0 4px rgba(255, 200, 92, .25); }
input::placeholder { color: #C9B5A4; }
:root[data-dark="1"] input::placeholder { color: #8A7BA0; }

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

/* ============ AUTH ============ */
#view-auth { position: relative; justify-content: center; }
#auth-sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }

.auth-wrap {
  position: relative; z-index: 1; display: flex; flex-direction: column;
  align-items: center; gap: 26px; padding: 40px 24px calc(24px + env(safe-area-inset-bottom));
}

.wordmark { text-align: center; }
.wordmark h1 {
  font-family: var(--font-display); font-weight: 700; font-size: 44px;
  color: #6b4226; letter-spacing: .5px; text-shadow: 0 2px 0 rgba(255,255,255,.5);
}
.tagline { font-family: var(--font-display); font-weight: 400; font-size: 16px; color: #8a6242; margin-top: 2px; }

.wordmark-sun { width: 84px; height: 84px; margin-bottom: 4px; animation: sun-bob 5s ease-in-out infinite; }
.sun-core { fill: var(--honey); stroke: #E8A93B; stroke-width: 2; }
.sun-rays line { stroke: #E8A93B; stroke-width: 3; stroke-linecap: round; transform-origin: 32px 32px; }
.sun-rays { animation: rays-spin 24s linear infinite; transform-origin: center; }
.sun-smile { fill: none; stroke: #A8701C; stroke-width: 2; stroke-linecap: round; }
.sun-eye { fill: #A8701C; }
@keyframes sun-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes rays-spin { to { transform: rotate(360deg); } }

.auth-card {
  width: 100%; max-width: 380px; background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(6px); border-radius: var(--r-card); padding: 26px 24px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px;
}
:root[data-dark="1"] .auth-card { background: rgba(44, 36, 68, .88); }
:root[data-dark="1"] .btn-link { color: #C9B8DC; }
.field span { display: block; font-weight: 800; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 6px; }
.auth-error { color: var(--coral-deep); font-weight: 700; font-size: 14px; min-height: 18px; text-align: center; }
.auth-error:empty { margin: -8px 0; }

.btn-big {
  background: var(--coral); color: #fff; font-weight: 800; font-size: 18px;
  padding: 15px; border-radius: var(--r-btn); box-shadow: 0 5px 0 var(--coral-deep);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-big:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--coral-deep); }
.btn-link { font-weight: 700; font-size: 14px; color: #8a6242; text-decoration: underline; text-underline-offset: 3px; padding: 4px; }

.version-tag { font-size: 11px; color: rgba(110, 80, 50, .55); font-weight: 700; }

/* ============ HOME ============ */
.sky-header { position: relative; height: 168px; border-radius: 0 0 30px 30px; overflow: hidden; box-shadow: var(--shadow-soft); flex-shrink: 0; }
#home-sky { position: absolute; inset: 0; width: 100%; height: 100%; }
.sky-copy { position: absolute; left: 22px; bottom: 18px; }
.sky-copy h2 { font-family: var(--font-display); font-weight: 700; font-size: 28px; color: #5b4020; text-shadow: 0 1px 0 rgba(255,255,255,.45); }
.sky-copy p { font-weight: 700; font-size: 14px; color: #7d5c36; }
:root[data-dark="1"] .sky-copy h2 { color: #FFF3D6; text-shadow: 0 1px 8px rgba(20, 18, 60, .6); }
:root[data-dark="1"] .sky-copy p { color: #D8CBEA; }
:root[data-dark="1"] .wordmark h1 { color: #FFF3D6; text-shadow: 0 2px 10px rgba(20, 18, 60, .55); }
:root[data-dark="1"] .tagline { color: #D8CBEA; }
:root[data-dark="1"] .version-tag { color: rgba(232, 220, 245, .55); }

.chip-btn {
  padding: 8px 14px; border-radius: 999px; font-weight: 800; font-size: 13px;
  background: rgba(255, 255, 255, .78); color: #7d5c36; box-shadow: var(--shadow-soft);
  transition: transform .12s ease;
}
.chip-btn:active { transform: scale(.94); }
:root[data-dark="1"] .chip-btn { background: rgba(50, 42, 78, .82); color: #E6DCF2; }
.chip-coral { background: var(--coral); color: #fff; }
:root[data-dark="1"] .chip-coral { background: var(--coral); color: #fff; }
.theme-chip { font-size: 16px; padding: 7px 12px; }
.header-chips {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 14px;
  display: flex; gap: 8px;
}
#btn-theme-auth { position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 14px; z-index: 2; }

.home-main { flex: 1; padding: 20px 18px 110px; }
#list-cards { display: flex; flex-direction: column; gap: 14px; }

.list-card {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  background: var(--card); border-radius: var(--r-card); padding: 16px 18px;
  box-shadow: var(--shadow-soft); border: 2px solid transparent;
  transition: transform .15s ease, box-shadow .15s ease;
  animation: card-in .35s cubic-bezier(.2, 1.4, .4, 1) both;
}
.list-card:active { transform: scale(.975); }
@keyframes card-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }

.card-doodle {
  width: 52px; height: 52px; border-radius: 18px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 26px;
}
.card-body { flex: 1; min-width: 0; }
.card-body h3 { font-family: var(--font-display); font-weight: 500; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { display: block; font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-top: 2px; }
.card-track { display: block; height: 7px; border-radius: 99px; background: var(--line); margin-top: 8px; overflow: hidden; }
.card-fill { display: block; height: 100%; border-radius: 99px; transition: width .5s cubic-bezier(.2, 1, .3, 1); }
.card-done-badge { font-size: 20px; animation: badge-pop .4s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes badge-pop { from { transform: scale(0) rotate(-30deg); } }

.fab {
  position: fixed; bottom: calc(22px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--coral); color: #fff; font-weight: 800; font-size: 17px;
  padding: 15px 26px; border-radius: 999px; box-shadow: 0 5px 0 var(--coral-deep), 0 12px 26px rgba(232, 96, 74, .35);
  transition: transform .12s ease, box-shadow .12s ease; z-index: 5;
}
.fab:active { transform: translateX(-50%) translateY(4px); box-shadow: 0 1px 0 var(--coral-deep), 0 6px 14px rgba(232, 96, 74, .3); }

/* ============ LIST VIEW ============ */
.list-header {
  display: flex; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 14px 14px;
  border-radius: 0 0 26px 26px; box-shadow: var(--shadow-soft); flex-shrink: 0;
  transition: background .3s ease;
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 15px; display: grid; place-items: center;
  background: rgba(255, 255, 255, .65); box-shadow: var(--shadow-soft);
  transition: transform .12s ease, background .2s ease, color .2s ease; flex-shrink: 0;
}
:root[data-dark="1"] .icon-btn { background: rgba(38, 32, 58, .5); }
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.arming { background: var(--coral); color: #fff; animation: wiggle .3s ease; }
@keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-7deg); } 75% { transform: rotate(7deg); } }

.list-title-wrap { flex: 1; min-width: 0; }
#list-title { font-family: var(--font-display); font-weight: 700; font-size: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#list-count { font-size: 13px; font-weight: 700; color: var(--ink-soft); }

.list-main { flex: 1; padding: 18px 16px 130px; overflow-y: auto; }

.items { list-style: none; display: flex; flex-direction: column; gap: 10px; }

.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 18px; padding: 12px 14px;
  box-shadow: var(--shadow-soft);
}
.item.entering { animation: item-in .35s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes item-in { from { opacity: 0; transform: translateX(-16px) scale(.95); } }
.item.leaving { animation: item-out .25s ease both; }
@keyframes item-out { to { opacity: 0; transform: scale(.85); } }
.item.sweeping { animation: item-sweep .4s cubic-bezier(.5, 0, .8, .4) both; }
@keyframes item-sweep { to { opacity: 0; transform: translateX(70vw) rotate(4deg); } }

.checkbox {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  border: 3px solid; display: grid; place-items: center; background: var(--card);
  transition: transform .15s cubic-bezier(.2, 1.6, .4, 1), background .2s ease;
}
.checkbox:active { transform: scale(.85); }
.checkbox svg { width: 18px; height: 18px; }
.checkbox .tick { fill: none; stroke: #fff; stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; }
.item.done .checkbox .tick { stroke-dashoffset: 0; transition: stroke-dashoffset .3s ease .05s; }
.item.done .checkbox { animation: check-pop .35s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes check-pop { 40% { transform: scale(1.25); } }

.item-text { flex: 1; font-size: 17px; font-weight: 600; word-break: break-word; }
.item-text .txt { position: relative; display: inline-block; max-width: 100%; }
.item-text .txt::after {
  content: ""; position: absolute; left: -2px; right: -2px; top: 54%; height: 2.5px;
  border-radius: 2px; background: var(--ink-soft); transform: scaleX(0); transform-origin: left center;
  transition: transform .35s cubic-bezier(.6, 0, .3, 1);
}
.item.done .item-text { color: var(--ink-soft); }
.item.done .item-text .txt::after { transform: scaleX(1); }

.item-x {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  color: #CBB6A4; flex-shrink: 0; transition: transform .12s ease, color .15s ease, background .15s ease;
}
.item-x:active { transform: scale(.85); color: var(--coral-deep); background: #FFE9E3; }
.item-x svg { width: 16px; height: 16px; }

.done-bar { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 10px; }
#done-label { font-family: var(--font-display); font-weight: 500; font-size: 16px; color: var(--ink-soft); }
.items-done .item { opacity: .78; }

.all-done { text-align: center; padding: 28px 0 6px; animation: card-in .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.all-done svg { width: 110px; }
.all-done p { font-family: var(--font-display); font-size: 18px; color: #a87a17; margin-top: 4px; }
.ad-sun { fill: var(--honey); } .ad-smile { fill: none; stroke: #A8701C; stroke-width: 2; stroke-linecap: round; }
.ad-eye { fill: #A8701C; } .ad-ray { stroke: #E8A93B; stroke-width: 2.4; stroke-linecap: round; }

.add-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 620px; display: flex; gap: 10px;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 75%, transparent);
  z-index: 5;
}
.add-bar input { box-shadow: var(--shadow-soft); border-color: transparent; }
.add-btn {
  width: 52px; height: 52px; border-radius: 17px; flex-shrink: 0; display: grid; place-items: center;
  background: var(--coral); color: #fff; box-shadow: 0 4px 0 var(--coral-deep);
  transition: transform .12s ease, box-shadow .12s ease;
}
.add-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--coral-deep); }
.add-btn svg { width: 22px; height: 22px; }

/* ============ EMPTY STATES ============ */
.empty-state { text-align: center; padding: 46px 20px; color: var(--ink-soft); font-weight: 700; }
.empty-art { width: 130px; margin-bottom: 10px; }
.ea-stem { fill: none; stroke: #6CC48A; stroke-width: 3; stroke-linecap: round; }
.ea-leaf { fill: #A5DDB6; }
.ea-bud { fill: var(--honey); }
.ea-dot { fill: #A8701C; }
.ea-ground { fill: none; stroke: #E5CDB4; stroke-width: 3; stroke-linecap: round; }

/* ============ SHEET ============ */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(78, 61, 52, .35); z-index: 9;
  animation: fade-in .2s ease both;
}
@keyframes fade-in { from { opacity: 0; } }
.sheet {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 620px; background: var(--card);
  border-radius: 26px 26px 0 0; padding: 14px 22px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(120, 70, 30, .2); z-index: 10;
  display: flex; flex-direction: column; gap: 14px;
  animation: sheet-up .35s cubic-bezier(.2, 1.2, .3, 1) both;
}
@keyframes sheet-up { from { transform: translateX(-50%) translateY(100%); } }
.sheet.closing { animation: sheet-down .25s ease both; }
@keyframes sheet-down { to { transform: translateX(-50%) translateY(105%); } }
.sheet-handle { width: 44px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto; }
.sheet h3 { font-family: var(--font-display); font-weight: 700; font-size: 22px; }
.sheet-label { font-weight: 800; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: -6px; }

.picker-row { display: flex; gap: 10px; flex-wrap: wrap; }
.color-dot {
  width: 42px; height: 42px; border-radius: 50%; border: 3px solid transparent;
  transition: transform .15s cubic-bezier(.2, 1.6, .4, 1), border-color .15s ease;
}
.color-dot.picked { transform: scale(1.18); border-color: var(--ink); }
.emoji-opt {
  width: 44px; height: 44px; border-radius: 14px; font-size: 24px; display: grid; place-items: center;
  background: var(--paper); border: 2px solid transparent;
  transition: transform .15s cubic-bezier(.2, 1.6, .4, 1), border-color .15s ease, background .15s ease;
}
.emoji-opt.picked { transform: scale(1.12); border-color: var(--honey); background: #FFF6DF; }
:root[data-dark="1"] .emoji-opt.picked { background: #4A4130; }

.theme-opts { display: flex; flex-direction: column; gap: 10px; }
.theme-opt {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--paper); border: 2px solid transparent; border-radius: 18px;
  padding: 12px 16px; transition: transform .15s cubic-bezier(.2, 1.6, .4, 1), border-color .15s ease;
}
.theme-opt:active { transform: scale(.97); }
.theme-opt.picked { border-color: var(--honey); }
.theme-opt-icon { font-size: 26px; }
.theme-opt-body { display: flex; flex-direction: column; }
.theme-opt-body strong { font-family: var(--font-display); font-weight: 500; font-size: 17px; }
.theme-opt-body small { font-size: 13px; font-weight: 700; color: var(--ink-soft); }

/* ============ BITS ============ */
.toast {
  position: fixed; bottom: calc(96px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: #4E3D34; color: #FFF4E6; font-weight: 700; font-size: 14px;
  padding: 11px 20px; border-radius: 999px; box-shadow: var(--shadow); z-index: 20;
  animation: toast-in .3s cubic-bezier(.2, 1.4, .4, 1) both; max-width: 86vw; text-align: center;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(12px); } }

.confetti-bit { position: fixed; width: 8px; height: 8px; border-radius: 2px; pointer-events: none; z-index: 30; }

.view.slide-in-right { animation: slide-in-right .32s cubic-bezier(.2, 1, .3, 1) both; }
@keyframes slide-in-right { from { transform: translateX(60px); opacity: 0; } }
.view.slide-in-left { animation: slide-in-left .32s cubic-bezier(.2, 1, .3, 1) both; }
@keyframes slide-in-left { from { transform: translateX(-60px); opacity: 0; } }

@media (min-width: 520px) {
  #list-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
}

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