/* ============================================================
   Treat Yourself — pastel candy-shop styling
   ============================================================ */

:root {
  /* Layout: three columns — picker, today's log, and the scale pinned at the side. */
  --cream:      #fff7f2;
  --cream-deep: #ffeee6;
  --card:       #ffffff;
  --ink:        #4a3340;
  --ink-soft:   #745a69;
  --faint:      #c3aeb8;
  --line:       #f3dcd5;

  --pink:       #ff9ec4;
  --pink-deep:  #f06ea9;
  --lilac:      #c9b3f2;
  --mint:       #8fd8c4;
  --butter:     #ffd98e;
  --peach:      #ffb08a;
  --rose:       #f0768c;

  --glow-a:     #ffe6f1;
  --glow-b:     #eae2ff;
  --tint:       #ffeef5;
  --tint-rose:  #fff0f3;
  --tube-top:   #f6ecff;
  --tube-bottom:#fff1f5;
  --etch:       rgba(122, 80, 102, .45);
  --etch-soft:  rgba(122, 80, 102, .18);
  --label-bg:   rgba(255, 255, 255, .92);
  --toast-bg:   #4a3340;
  --toast-fg:   #ffffff;


  --font-display: "Fredoka", "Nunito", ui-rounded, system-ui, sans-serif;
  --font-logo:    "Pacifico", "Fredoka", cursive;
  --pink-ink:     #c2367a;
  --bg-a:         #ffe1ee;
  --bg-b:         #efe4ff;
  --dot:          rgba(255, 255, 255, .7);
  --glass:        rgba(255, 255, 255, .55);
  --glass-edge:   rgba(255, 255, 255, .95);
  --gloss:        rgba(255, 255, 255, .75);
  --glow:         0 14px 36px rgba(240, 110, 169, .20), 0 2px 0 rgba(255, 255, 255, .8) inset;
  --sparkle:      #ffffff;
  --t-baked:  #ffe9da; --t-candy:  #ffe1ef; --t-frozen: #e2f0ff;
  --t-drinks: #ede4ff; --t-snacks: #fff3cc; --t-fruit:  #def6ec; --t-yours: #ffe4f6;

  --radius:     28px;
  --radius-sm:  20px;
  --shadow:     0 10px 30px rgba(190, 120, 150, .13);
  --shadow-sm:  0 4px 14px rgba(190, 120, 150, .12);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --cream:      #1c1218;
    --cream-deep: #251821;
    --card:       #251821;
    --ink:        #f8e9f0;
    --ink-soft:   #bd9dac;
    --faint:      #7d6572;
    --line:       #3d2a34;

    --pink:       #ff9ec4;
    --pink-deep:  #ff93c2;
    --lilac:      #cfbaf7;
    --mint:       #8fd8c4;
    --butter:     #ffd98e;
    --peach:      #ffb08a;
    --rose:       #ff8a9b;

    --glow-a:     #3a2030;
    --glow-b:     #2a2342;
    --tint:       #3b2130;
    --tint-rose:  #3f2029;
    --tube-top:   #2e2140;
    --tube-bottom:#381f2c;
    --etch:       rgba(255, 220, 236, .40);
    --etch-soft:  rgba(255, 220, 236, .16);
    --label-bg:   rgba(28, 18, 24, .92);
    --toast-bg:   #f8e9f0;
    --toast-fg:   #2a1a22;

    --shadow:     0 10px 30px rgba(0, 0, 0, .40);
    --shadow-sm:  0 4px 14px rgba(0, 0, 0, .34);
    --pink-ink:   #ffa6cf;
    --bg-a:       #2b1233;
    --bg-b:       #170c22;
    --dot:        rgba(255, 170, 215, .07);
    --glass:      rgba(255, 220, 240, .08);
    --glass-edge: rgba(255, 200, 230, .35);
    --gloss:      rgba(255, 220, 240, .10);
    --glow:       0 14px 40px rgba(0, 0, 0, .45), 0 0 26px rgba(255, 140, 200, .12), 0 1px 0 rgba(255, 220, 240, .12) inset;
    --sparkle:    #ffc4e1;
    --cream:      #1f1126;
    --card:       #2a1734;
    --line:       #45294f;
    --t-baked:  rgba(255, 176, 138, .14); --t-candy:  rgba(255, 158, 196, .15); --t-frozen: rgba(158, 201, 255, .14);
    --t-drinks: rgba(201, 179, 242, .16); --t-snacks: rgba(255, 217, 142, .13); --t-fruit:  rgba(143, 216, 196, .14); --t-yours: rgba(255, 127, 200, .15);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --cream:      #1c1218;
  --cream-deep: #251821;
  --card:       #251821;
  --ink:        #f8e9f0;
  --ink-soft:   #bd9dac;
  --faint:      #7d6572;
  --line:       #3d2a34;

  --pink:       #ff9ec4;
  --pink-deep:  #ff93c2;
  --lilac:      #cfbaf7;
  --mint:       #8fd8c4;
  --butter:     #ffd98e;
  --peach:      #ffb08a;
  --rose:       #ff8a9b;

  --glow-a:     #3a2030;
  --glow-b:     #2a2342;
  --tint:       #3b2130;
  --tint-rose:  #3f2029;
  --tube-top:   #2e2140;
  --tube-bottom:#381f2c;
  --etch:       rgba(255, 220, 236, .40);
  --etch-soft:  rgba(255, 220, 236, .16);
  --label-bg:   rgba(28, 18, 24, .92);
  --toast-bg:   #f8e9f0;
  --toast-fg:   #2a1a22;

  --shadow:     0 10px 30px rgba(0, 0, 0, .40);
  --shadow-sm:  0 4px 14px rgba(0, 0, 0, .34);
  --pink-ink:   #ffa6cf;
    --bg-a:       #2b1233;
    --bg-b:       #170c22;
    --dot:        rgba(255, 170, 215, .07);
    --glass:      rgba(255, 220, 240, .08);
    --glass-edge: rgba(255, 200, 230, .35);
    --gloss:      rgba(255, 220, 240, .10);
    --glow:       0 14px 40px rgba(0, 0, 0, .45), 0 0 26px rgba(255, 140, 200, .12), 0 1px 0 rgba(255, 220, 240, .12) inset;
    --sparkle:    #ffc4e1;
    --cream:      #1f1126;
    --card:       #2a1734;
    --line:       #45294f;
    --t-baked:  rgba(255, 176, 138, .14); --t-candy:  rgba(255, 158, 196, .15); --t-frozen: rgba(158, 201, 255, .14);
    --t-drinks: rgba(201, 179, 242, .16); --t-snacks: rgba(255, 217, 142, .13); --t-fruit:  rgba(143, 216, 196, .14); --t-yours: rgba(255, 127, 200, .15);
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Nunito", ui-rounded, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1000px 600px at 12% -5%, var(--glow-a) 0%, transparent 60%),
    radial-gradient(900px 500px at 95% 0%, var(--glow-b) 0%, transparent 55%),
    var(--cream);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; margin: 0; }

.wrap { width: min(1180px, 100% - 2rem); margin-inline: auto; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 50;
  background: var(--card); color: var(--ink); padding: .6rem 1rem; border-radius: 0 0 12px 0;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 3px solid var(--lilac); outline-offset: 2px; border-radius: 6px; }

/* ---------------- header ---------------- */

.site-header { padding: 1.6rem 0 .4rem; }

.header-inner {
  display: flex; flex-wrap: wrap; gap: 1rem;
  align-items: center; justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: .85rem; }
.brand-mark { font-size: 2.6rem; line-height: 1; filter: drop-shadow(0 4px 6px rgba(240,110,169,.3)); }

.site-header h1 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); letter-spacing: -.01em; }
.tagline { margin: .6rem 0 0; color: var(--ink-soft); font-size: .95rem; }

.header-actions { display: flex; align-items: center; gap: .8rem; }
.today-label { margin: 0; color: var(--ink-soft); font-size: .9rem; font-weight: 600; }

/* ---------------- buttons ---------------- */

button { font: inherit; cursor: pointer; }

.primary-btn {
  border: none; border-radius: 999px; padding: .62rem 1.3rem;
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  color: #fff; font-weight: 700; box-shadow: var(--shadow-sm);
  transition: transform .14s ease, filter .14s ease;
}
.primary-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.primary-btn:active { transform: translateY(0); }
.primary-btn.small { padding: .45rem 1rem; font-size: .9rem; }

.ghost-btn {
  border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink);
  padding: .5rem 1rem; font-weight: 600; font-size: .9rem;
  transition: border-color .14s ease, color .14s ease;
}
.ghost-btn:hover { border-color: var(--pink); color: var(--pink-deep); }
.ghost-btn.danger:hover { border-color: var(--rose); color: var(--rose); }

.chip-btn {
  border: 1.5px solid var(--line); background: var(--card);
  border-radius: 999px; padding: .34rem .9rem; font-weight: 600; font-size: .88rem;
  color: var(--ink-soft);
}
.chip-btn:hover { border-color: var(--pink); color: var(--pink-deep); }

/* ---------------- settings ---------------- */

.settings-panel {
  margin-top: .9rem; background: var(--card); border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow-sm);
}
.settings-panel > label { font-weight: 700; display: block; margin-bottom: .5rem; }
.settings-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.settings-row input {
  width: 6.5rem; padding: .5rem .7rem; font: inherit; font-weight: 700;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--cream);
  color: var(--ink);
}
.unit { color: var(--ink-soft); font-size: .92rem; }
.settings-note { margin: .7rem 0 0; color: var(--ink-soft); font-size: .85rem; line-height: 1.45; }
.preset-limits { display: flex; gap: .5rem; margin-top: .7rem; }

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

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) 260px;
  gap: 1.1rem;
  align-items: start;
  padding: 1.1rem 0 2rem;
}

.panel {
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow);
}

.panel-head {
  display: flex; flex-wrap: wrap; gap: .7rem;
  align-items: center; justify-content: space-between; margin-bottom: .9rem;
}
.panel h2 { font-size: 1.22rem; }

/* ---------------- picker ---------------- */

.search input {
  font: inherit; padding: .45rem .9rem; width: 11rem;
  border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--cream); color: var(--ink);
}
.search input::placeholder { color: var(--faint); }

.categories { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .95rem; }

.cat-btn {
  border: 1.5px solid var(--line); background: var(--cream);
  color: var(--ink-soft); border-radius: 999px;
  padding: .32rem .85rem; font-size: .86rem; font-weight: 700;
  transition: all .14s ease;
}
.cat-btn:hover { border-color: var(--pink); color: var(--pink-deep); }
.cat-btn[aria-selected="true"] {
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  border-color: transparent; color: #fff;
}

.treat-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: .6rem;
  max-height: 420px; overflow-y: auto; padding-right: .2rem;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}

.treat-card {
  position: relative;
  width: 100%; text-align: left;
  border: 1.5px solid var(--line); background: var(--cream);
  border-radius: var(--radius-sm); padding: .65rem .7rem .6rem;
  display: flex; flex-direction: column; gap: .15rem;
  transition: transform .13s ease, border-color .13s ease, background .13s ease;
}
.treat-card:hover { transform: translateY(-2px); border-color: var(--pink); background: var(--card); }
.treat-card:active { transform: translateY(0) scale(.98); }

.treat-emoji { font-size: 1.5rem; line-height: 1.1; }
.treat-name { font-weight: 700; font-size: .88rem; line-height: 1.25; }
.treat-sugar { font-size: .78rem; color: var(--pink-deep); font-weight: 700; }
.treat-serving { font-size: .7rem; color: var(--ink-soft); }

.treat-card .remove-custom {
  position: absolute; top: .3rem; right: .35rem;
  border: none; background: transparent; color: var(--ink-soft);
  font-size: .9rem; line-height: 1; padding: .2rem; border-radius: 50%;
}
.treat-card .remove-custom:hover { color: var(--rose); background: var(--tint-rose); }

.empty-note { color: var(--ink-soft); font-size: .9rem; text-align: center; padding: .8rem 0; margin: 0; }

.custom-treat {
  margin-top: 1rem; border-top: 1.5px dashed var(--line); padding-top: .9rem;
}
.custom-treat summary {
  cursor: pointer; font-weight: 700; color: var(--pink-deep); list-style: none;
}
.custom-treat summary::-webkit-details-marker { display: none; }

.custom-form {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-top: .8rem;
}
.field { display: flex; flex-direction: column; gap: .25rem; flex: 1 1 10rem; }
.field.short { flex: 0 0 6rem; }
.field label { font-size: .78rem; font-weight: 700; color: var(--ink-soft); }
.field input {
  font: inherit; padding: .45rem .7rem; border: 1.5px solid var(--line);
  border-radius: 12px; background: var(--cream); color: var(--ink); width: 100%;
}

/* Health profile: use the same soft surfaces and rounded controls as the picker. */
#profile-form { gap: 1rem; }
#profile-form .field { min-width: 0; flex-basis: 16rem; }
#profile-form .field.short { flex: 0 1 8rem; }
#profile-form input,
#profile-form select {
  width: 100%; min-width: 0; min-height: 46px;
  font: inherit; font-size: 1rem; line-height: 1.4;
  padding: .65rem .85rem;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background-color: var(--cream); color: var(--ink);
}
#profile-form select {
  appearance: none; -webkit-appearance: none;
  padding-right: 2.5rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--pink-deep) 50%),
                    linear-gradient(135deg, var(--pink-deep) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
#profile-form select:hover { border-color: var(--pink); }
#profile-form select:focus-visible,
#profile-form input:focus-visible {
  border-color: var(--pink-deep); outline: 3px solid var(--lilac); outline-offset: 2px;
}
#profile-form option { background: var(--card); color: var(--ink); }
#profile-form button { min-height: 46px; }
@media (max-width: 600px) {
  #profile-form .field { flex: 1 1 100%; }
  #profile-form .field.short { flex: 1 1 5rem; }
}
@media (forced-colors: active) {
  #profile-form select { appearance: auto; background-image: none; }
}

/* ---------------- log ---------------- */

.total-line { margin: 0 0 .9rem; display: flex; align-items: baseline; gap: .3rem; }
.total-number { font-family: var(--font-display); font-size: 2.9rem; font-weight: 700; line-height: 1; }
.total-unit { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; color: var(--pink-deep); }
.total-of { margin-left: .4rem; color: var(--ink-soft); font-size: .92rem; font-weight: 600; }

.log-list { list-style: none; margin: 0; padding: 0; max-height: 230px; overflow-y: auto; }

.log-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .25rem; border-bottom: 1px solid var(--line);
  animation: slide-in .22s ease;
}
.log-item:last-child { border-bottom: none; }
.log-emoji { font-size: 1.25rem; }
.log-body { flex: 1; min-width: 0; }
.log-name { font-weight: 700; font-size: .9rem; display: block; }
.log-time { font-size: .74rem; color: var(--ink-soft); }
.log-count {
  font-size: .72rem; font-weight: 700; color: var(--pink-deep);
  background: var(--tint); border-radius: 999px; padding: .08rem .45rem; margin-left: .3rem;
}
.log-sugar { font-weight: 700; font-size: .9rem; color: var(--pink-deep); white-space: nowrap; }
.log-remove {
  border: none; background: transparent; color: var(--ink-soft);
  font-size: 1.05rem; line-height: 1; padding: .2rem .35rem; border-radius: 50%;
}
.log-remove:hover { color: var(--rose); background: var(--tint-rose); }

@keyframes slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------------- history ---------------- */

.history { margin-top: 1.1rem; border-top: 1.5px dashed var(--line); padding-top: .9rem; }
.history h3 { font-size: .95rem; margin-bottom: .6rem; }

.history-chart {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: .35rem;
  height: 86px; align-items: end;
}
.hist-col { display: flex; flex-direction: column; align-items: center; gap: .25rem; height: 100%; justify-content: flex-end; }
.hist-bar {
  width: 100%; border-radius: 8px 8px 4px 4px; min-height: 4px;
  background: linear-gradient(180deg, var(--pink), var(--lilac));
  transition: height .3s ease;
}
.hist-bar.empty { background: var(--line); }
.hist-bar.over { background: linear-gradient(180deg, var(--rose), var(--peach)); }
.hist-bar.today { outline: 2px solid var(--pink-deep); outline-offset: 1px; }
.hist-label { font-size: .66rem; color: var(--ink-soft); font-weight: 700; }
.hist-val { font-size: .62rem; color: var(--ink-soft); }
.history-avg { margin: .6rem 0 0; font-size: .82rem; color: var(--ink-soft); }

/* ---------------- the scale ---------------- */

.scale-panel { position: sticky; top: 1rem; text-align: center; }
.scale-panel h2 { margin-bottom: .9rem; }

.scale { display: flex; flex-direction: column; align-items: center; gap: .85rem; }

.scale-track {
  position: relative;
  width: 72px; height: 300px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--tube-top), var(--tube-bottom));
  border: 2px solid var(--line);
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(190,120,150,.12);
}

.scale-fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 0%;
  background: linear-gradient(180deg, var(--pink), var(--mint));
  transition: height .5s cubic-bezier(.3,.9,.3,1), background .5s ease;
}
.scale-fill::after {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 8px;
  background: rgba(255,255,255,.65); border-radius: 999px;
}

.scale-track.zone-easy    .scale-fill { background: linear-gradient(180deg, #a8e6cf, var(--mint)); }
.scale-track.zone-going   .scale-fill { background: linear-gradient(180deg, var(--butter), #ffe9b5); }
.scale-track.zone-close   .scale-fill { background: linear-gradient(180deg, var(--peach), var(--butter)); }
.scale-track.zone-at      .scale-fill { background: linear-gradient(180deg, var(--pink-deep), var(--peach)); }
.scale-track.zone-over    .scale-fill { background: linear-gradient(180deg, var(--rose), var(--pink-deep)); }

.scale-limit-line {
  position: absolute; left: 0; right: 0; bottom: 100%;
  border-top: 2px dashed var(--etch);
}
.scale-limit-line span {
  position: absolute; right: 5px; top: -9px;
  font-size: .58rem; font-weight: 700; color: var(--ink);
  letter-spacing: .05em; text-transform: uppercase;
  background: var(--label-bg); border-radius: 999px;
  padding: .05rem .34rem; line-height: 1.35;
}

.scale-ticks { position: absolute; inset: 0; pointer-events: none; }
.scale-tick {
  position: absolute; left: 0; width: 10px;
  border-top: 1.5px solid var(--etch-soft);
}

.scale-readout { line-height: 1.15; }
.scale-pct { margin: 0; font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; }
.scale-zone { margin: .1rem 0 0; font-size: .85rem; font-weight: 700; color: var(--pink-deep); }

.scale-message { margin: .9rem 0 0; font-size: .88rem; line-height: 1.45; }
.scale-remaining { margin: .45rem 0 0; font-size: .8rem; color: var(--ink-soft); }

.scale-key {
  margin-top: 1rem; padding: .7rem .85rem;
  border: 1.5px dashed var(--etch-soft); border-radius: 14px;
  font-size: .78rem; line-height: 1.45; color: var(--ink-soft);
}
.scale-key p { margin: 0; }
.scale-key p + p { margin-top: .35rem; }
.scale-key-goal { font-size: .88rem; color: var(--ink); }
.scale-key strong { color: var(--pink-deep); }

.scale-track.pulse { animation: pulse .5s ease; }
@keyframes pulse {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.035); }
  100% { transform: scale(1); }
}

/* ---------------- toast ---------------- */

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 2rem);
  background: var(--toast-bg); color: var(--toast-fg); padding: .6rem 1.1rem; border-radius: 999px;
  font-size: .88rem; font-weight: 600; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
  z-index: 40; max-width: calc(100% - 2rem); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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

.site-footer { padding: 0 0 2.5rem; color: var(--ink-soft); font-size: .82rem; text-align: center; }
.site-footer p { margin: .25rem 0; }
.disclaimer { font-size: .76rem; opacity: .85; }

/* ============================================================
   Glow-up: pastel candy shop meets cozy journal
   ============================================================ */

body {
  background:
    radial-gradient(circle, var(--dot) 1.6px, transparent 2.2px) 0 0 / 26px 26px,
    radial-gradient(circle, var(--dot) 1.6px, transparent 2.2px) 13px 13px / 26px 26px,
    linear-gradient(160deg, var(--bg-a) 0%, var(--bg-b) 100%);
  background-attachment: fixed;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: 0; }

/* Floating sparkles and hearts */
.sky { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.sky span {
  position: absolute; left: var(--x); bottom: -2rem;
  font-size: var(--s); color: var(--sparkle); opacity: .75;
  text-shadow: 0 0 10px rgba(255, 140, 200, .55);
  animation: drift var(--d) linear var(--delay) infinite;
}
.sky span:nth-child(even) { color: #ffb3d1; }
@keyframes drift {
  0%   { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  10%  { opacity: .8; }
  50%  { transform: translate(18px, -55vh) rotate(160deg); }
  90%  { opacity: .7; }
  100% { transform: translate(-12px, -110vh) rotate(320deg); opacity: 0; }
}
.site-header, .layout, .site-footer { position: relative; z-index: 1; }

/* Header + Honey */
.brand { gap: .6rem; }
.brand-mark {
  width: 84px; height: 84px; flex: 0 0 auto; display: block; font-size: 0;
  filter: drop-shadow(0 6px 10px rgba(240, 110, 169, .28));
  animation: bob 3.2s ease-in-out infinite;
  transform-origin: 50% 90%;
}
.brand-mark .bear { width: 100%; height: 100%; display: block; }
.site-header h1 {
  font-family: var(--font-logo); font-weight: 400;
  font-size: clamp(2rem, 4.4vw, 2.9rem); line-height: 1.15;
  color: var(--pink-ink);
  text-shadow: 0 3px 0 rgba(255, 255, 255, .7), 0 6px 18px rgba(240, 110, 169, .25);
}
.tagline { font-weight: 700; }
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-5px) rotate(2deg); }
}
.brand-mark.wiggle { animation: wiggle .7s ease, bob 3.2s ease-in-out .7s infinite; }
@keyframes wiggle {
  0%   { transform: rotate(0) scale(1); }
  20%  { transform: rotate(-14deg) scale(1.08); }
  40%  { transform: rotate(12deg) scale(1.1); }
  60%  { transform: rotate(-8deg) scale(1.05); }
  80%  { transform: rotate(5deg); }
  100% { transform: rotate(0) scale(1); }
}

/* Blink every few seconds */
.bear-eyes { transform-box: fill-box; transform-origin: center; animation: blink 4.6s infinite; }
@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95%           { transform: scaleY(.1); }
}
.bear-z text { animation: snooze 2.4s ease-in-out infinite; }
.bear-z text + text { animation-delay: .6s; }
@keyframes snooze { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }

/* Sweet streak */
.streak-badge {
  display: inline-flex; align-items: center; gap: .4rem; margin: 0 0 0 .4rem; white-space: nowrap;
  padding: .4rem .9rem .4rem .55rem; border-radius: 999px;
  background: linear-gradient(135deg, #fff2c4, #ffd7ea);
  color: #6b3e2e; font-weight: 700; font-size: .9rem;
  box-shadow: 0 4px 14px rgba(240, 160, 90, .25), inset 0 2px 0 rgba(255, 255, 255, .8);
  animation: badge-in .5s cubic-bezier(.3, 1.6, .5, 1);
}
.streak-badge[hidden] { display: none; }
.streak-crown { font-size: 1.15rem; animation: bob 2.6s ease-in-out infinite; }
@keyframes badge-in { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Cards */
.panel {
  position: relative;
  border: 2px solid var(--glass-edge);
  background: linear-gradient(180deg, var(--card), var(--card));
  box-shadow: var(--glow);
}
.panel::before {
  content: ""; position: absolute; left: 10px; right: 10px; top: 6px; height: 46px;
  border-radius: 22px 22px 60% 60% / 22px 22px 100% 100%;
  background: linear-gradient(180deg, var(--gloss), transparent);
  pointer-events: none;
}
.panel > * { position: relative; }
.panel h2 { font-size: 1.35rem; display: inline-flex; align-items: center; gap: .45rem; }
.panel h2::before {
  content: ""; width: 26px; height: 18px; flex: 0 0 auto;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 18'%3E%3Cpath d='M13 9 L2 2 Q-1 9 2 16 Z' fill='%23ff8fb6'/%3E%3Cpath d='M13 9 L24 2 Q27 9 24 16 Z' fill='%23ff8fb6'/%3E%3Ccircle cx='13' cy='9' r='3.6' fill='%23f0609c'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Pills: buttons, chips, inputs */
.primary-btn {
  background: linear-gradient(180deg, #f27bb4, #d84a8f);
  box-shadow: 0 6px 16px rgba(216, 74, 143, .3), inset 0 2px 0 rgba(255, 255, 255, .45);
  min-height: 44px;
}
.ghost-btn, .chip-btn, .cat-btn {
  background: var(--glass); border: 2px solid var(--glass-edge);
  box-shadow: 0 3px 10px rgba(240, 110, 169, .12), inset 0 2px 0 rgba(255, 255, 255, .6);
  color: var(--ink); min-height: 40px;
}
.ghost-btn:hover, .chip-btn:hover, .cat-btn:hover { border-color: var(--pink); color: var(--pink-ink); transform: translateY(-1px); }
.ghost-btn:disabled { opacity: .6; cursor: progress; }
.cat-btn[aria-selected="true"] {
  background: linear-gradient(180deg, #f27bb4, #d84a8f); color: #fff; border-color: transparent;
  box-shadow: 0 5px 14px rgba(216, 74, 143, .3), inset 0 2px 0 rgba(255, 255, 255, .45);
}
.head-btns { display: flex; flex-wrap: wrap; gap: .45rem; }
.search input, .field input, .settings-row input {
  border: 2px solid var(--glass-edge); background: var(--glass);
  box-shadow: inset 0 2px 6px rgba(190, 120, 150, .1); min-height: 42px;
}
.search input { border-radius: 999px; }
.custom-treat summary { color: var(--pink-ink); padding: .5rem 0; }
.settings-panel { border: 2px solid var(--glass-edge); box-shadow: var(--glow); position: relative; z-index: 2; }

/* Treat tiles: candy buttons */
.treat-grid { padding: .35rem .3rem .4rem; gap: .7rem; }
.treat-card {
  --tile: var(--t-candy);
  border: 2px solid var(--glass-edge); border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 45%),
    var(--tile);
  box-shadow: 0 4px 12px rgba(240, 110, 169, .12), inset 0 -3px 0 rgba(120, 60, 90, .06), inset 0 2px 0 rgba(255, 255, 255, .7);
  min-height: 44px;
  transition: transform .18s cubic-bezier(.3, 1.5, .5, 1), box-shadow .18s ease, border-color .18s ease;
}
.treat-card { color: var(--ink); }
.treat-card[data-cat="Baked"]  { --tile: var(--t-baked); }
.treat-card[data-cat="Candy"]  { --tile: var(--t-candy); }
.treat-card[data-cat="Frozen"] { --tile: var(--t-frozen); }
.treat-card[data-cat="Drinks"] { --tile: var(--t-drinks); }
.treat-card[data-cat="Snacks"] { --tile: var(--t-snacks); }
.treat-card[data-cat="Fruit"]  { --tile: var(--t-fruit); }
.treat-card[data-cat="Yours"]  { --tile: var(--t-yours); }
.treat-card:hover {
  transform: translateY(-4px); border-color: var(--pink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .65), rgba(255, 255, 255, 0) 45%),
    var(--tile);
  box-shadow: 0 10px 22px rgba(240, 110, 169, .22), inset 0 2px 0 rgba(255, 255, 255, .8);
}
.treat-card:active { transform: scale(.93); }
.treat-card.squish { animation: squish .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes squish {
  0%   { transform: scale(1); }
  30%  { transform: scale(.88, .84); }
  60%  { transform: scale(1.07, 1.05); }
  100% { transform: scale(1); }
}
.treat-emoji { font-size: 1.75rem; filter: drop-shadow(0 2px 2px rgba(120, 60, 90, .15)); }
.treat-sugar, .log-sugar, .total-unit, .scale-zone { color: var(--pink-ink); }

/* Confetti + flying treat */
.sprinkle-bit {
  position: fixed; width: 9px; height: 4px; border-radius: 4px;
  pointer-events: none; z-index: 60;
}
.sprinkle-bit.round { width: 7px; height: 7px; border-radius: 50%; }
.flying-treat {
  position: fixed; font-size: 2rem; line-height: 1; pointer-events: none; z-index: 61;
  filter: drop-shadow(0 4px 6px rgba(240, 110, 169, .35));
}

/* Today's log */
.total-number { font-weight: 700; color: var(--ink); }
.log-item { border-bottom: 1.5px dashed var(--line); }
.log-remove { min-width: 36px; min-height: 36px; }
.log-empty { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .4rem 0 .6rem; }
.log-empty[hidden] { display: none; }
.log-empty p { margin: 0; }
.peek-bear {
  display: block; width: 92px; height: 60px; overflow: hidden;
  border-bottom: 3px solid var(--pink); border-radius: 0 0 6px 6px;
}
.peek-bear .bear { width: 92px; height: 92px; display: block; animation: peek 3.4s ease-in-out infinite; }
@keyframes peek {
  0%, 100% { transform: translateY(18px); }
  40%, 70% { transform: translateY(2px); }
}
.hist-bar { border-radius: 10px 10px 5px 5px; }

/* The sugar scale: a glass candy jar */
.scale-panel h2 { justify-content: center; font-size: 1.2rem; white-space: nowrap; }
.jar-row { display: flex; align-items: flex-end; justify-content: center; gap: .2rem; }
.jar { display: flex; flex-direction: column; align-items: center; }
.jar-lid {
  position: relative; z-index: 2;
  width: 92px; height: 24px; margin-bottom: -5px; border-radius: 12px 12px 8px 8px;
  background: repeating-linear-gradient(90deg, #ff9ec4 0 10px, #ffc2dc 10px 20px);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .55), 0 4px 10px rgba(240, 110, 169, .25);
}
.jar-lid::before {
  content: ""; position: absolute; left: 50%; top: -11px; width: 20px; height: 13px;
  transform: translateX(-50%); border-radius: 10px 10px 4px 4px;
  background: #f27bb4; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .5);
}
.scale-track {
  width: 108px; height: 270px;
  border-radius: 30px 30px 48px 48px;
  border: 3px solid var(--glass-edge);
  background: linear-gradient(90deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, .15) 40%, rgba(255, 255, 255, .35)), var(--glass);
  box-shadow: 0 12px 30px rgba(240, 110, 169, .22), inset 0 0 0 2px rgba(255, 255, 255, .25), inset 0 -10px 20px rgba(201, 179, 242, .25);
}
.scale-track::after {
  content: ""; position: absolute; left: 14px; top: 18px; width: 11px; height: 62%;
  border-radius: 999px; background: linear-gradient(180deg, rgba(255, 255, 255, .85), rgba(255, 255, 255, .1));
  pointer-events: none; z-index: 3;
}
.scale-fill { overflow: hidden; border-radius: 0 0 44px 44px; }
.scale-fill::after { display: none; }
.scale-fill .wave {
  position: absolute; top: 0; left: 0; width: 200%; height: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 14' preserveAspectRatio='none'%3E%3Cpath d='M0 7 Q15 0 30 7 T60 7 T90 7 T120 7 V0 H0 Z' fill='white' fill-opacity='.75'/%3E%3C/svg%3E") 0 0 / 50% 100% repeat-x;
  animation: wave 3s linear infinite;
}
@keyframes wave { to { transform: translateX(-50%); } }
.jar-sprinkles { position: absolute; inset: 14px 0 0; }
.jar-sprinkles i {
  position: absolute; width: 10px; height: 4px; border-radius: 4px; opacity: .9;
  animation: float-sprinkle 4s ease-in-out infinite;
}
.jar-sprinkles i:nth-child(1) { left: 18%; top: 20%; background: #ff7fa8; transform: rotate(30deg); }
.jar-sprinkles i:nth-child(2) { left: 62%; top: 12%; background: #ffffff; animation-delay: -1s; }
.jar-sprinkles i:nth-child(3) { left: 40%; top: 45%; background: #9ec9ff; animation-delay: -2s; }
.jar-sprinkles i:nth-child(4) { left: 74%; top: 58%; background: #c9b3f2; animation-delay: -.5s; }
.jar-sprinkles i:nth-child(5) { left: 24%; top: 70%; background: #ffd65c; animation-delay: -2.5s; }
.jar-sprinkles i:nth-child(6) { left: 55%; top: 82%; background: #ff7fa8; animation-delay: -3s; }
.jar-sprinkles i:nth-child(7) { left: 12%; top: 40%; background: #ffffff; width: 6px; height: 6px; border-radius: 50%; animation-delay: -1.5s; }
.jar-sprinkles i:nth-child(8) { left: 80%; top: 30%; background: #7fd8be; animation-delay: -3.5s; }
@keyframes float-sprinkle {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  50%      { translate: 3px -8px; rotate: 50deg; }
}
.scale-track.zone-easy  .scale-fill { background: linear-gradient(180deg, #b9eedb, var(--mint)); }
.scale-track.zone-going .scale-fill { background: linear-gradient(180deg, #ffe7a8, var(--butter)); }
.scale-limit-line { z-index: 2; border-top: 2.5px dashed var(--etch); }
.scale-limit-line span { right: 50%; transform: translateX(50%); top: -11px; font-size: .62rem; color: var(--pink-ink); box-shadow: 0 2px 6px rgba(240, 110, 169, .2); }
.scale-ticks { z-index: 2; }
.scale-pct { font-size: 2rem; }

.scale-bear { position: relative; width: 86px; margin-left: -10px; margin-bottom: -6px; }
.scale-bear .bear { width: 86px; height: 86px; display: block; filter: drop-shadow(0 5px 8px rgba(240, 110, 169, .25)); }
.scale-bear.bear-pop .bear { animation: bear-pop .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bear-pop { 0% { transform: scale(.7); } 100% { transform: scale(1); } }
.bear-says {
  position: absolute; bottom: 88px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: .72rem; font-weight: 800; color: var(--pink-ink);
  background: var(--card); border: 2px solid var(--glass-edge); border-radius: 999px;
  padding: .15rem .55rem; box-shadow: 0 4px 10px rgba(240, 110, 169, .18);
}

.toast { border-radius: 999px; box-shadow: 0 10px 26px rgba(240, 110, 169, .3); font-weight: 700; }

/* Midnight candy shop */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .site-header h1 { text-shadow: 0 0 18px rgba(255, 140, 200, .45); }
  :root:not([data-theme="light"]) .treat-card { background: var(--tile); box-shadow: 0 4px 14px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 220, 240, .12); }
  :root:not([data-theme="light"]) .scale-track { background: linear-gradient(90deg, rgba(255, 220, 240, .12), rgba(255, 220, 240, .03) 40%, rgba(255, 220, 240, .08)), var(--glass); box-shadow: 0 0 30px rgba(255, 140, 200, .2); }
  :root:not([data-theme="light"]) .streak-badge { color: #4a2a20; }
}
:root[data-theme="dark"] .site-header h1 { text-shadow: 0 0 18px rgba(255, 140, 200, .45); }
:root[data-theme="dark"] .treat-card { background: var(--tile); box-shadow: 0 4px 14px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 220, 240, .12); }
:root[data-theme="dark"] .scale-track { background: linear-gradient(90deg, rgba(255, 220, 240, .12), rgba(255, 220, 240, .03) 40%, rgba(255, 220, 240, .08)), var(--glass); box-shadow: 0 0 30px rgba(255, 140, 200, .2); }

/* ---------------- responsive ---------------- */

@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr) 240px; }
  .picker { grid-column: 1 / -1; }
  .scale-panel { position: static; }
}

@media (max-width: 680px) {
  .layout { grid-template-columns: 1fr; }
  .header-inner { align-items: flex-start; }
  .search input { width: 100%; }
  .panel-head .search { flex: 1 1 100%; }
  .treat-grid { max-height: 52vh; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
  .scale { flex-direction: row; justify-content: center; gap: 1.4rem; }
  .scale-track { height: 220px; }
  body { background-attachment: scroll; }
  .brand { flex-wrap: wrap; }
  .brand-mark { width: 66px; height: 66px; }
  .streak-badge { margin: 0; }
  .header-actions { flex-wrap: wrap; }
  .scale { gap: .8rem; }
  .bear-says { font-size: .66rem; }
  .scale-readout { text-align: left; }
}

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

/* Intake guidance and source labels use the existing palette. */
.sugar-insights { margin-top: 1.3rem; padding-top: 1rem; border-top: 1.5px dashed var(--line); text-align: left; }
.sugar-insights h3 { margin: 0 0 .6rem; }
.intake-tips { padding-left: 1.15rem; font-size: .88rem; line-height: 1.5; }
.intake-tips li + li { margin-top: .6rem; }
.source-select { font: inherit; font-size: .85rem; width: 100%; min-width: 0; min-height: 44px; padding: .5rem .6rem; border: 1.5px solid var(--line); border-radius: 12px; background: var(--cream); color: var(--ink); }
.source-label { display: block; margin-top: .4rem; color: var(--ink-soft); font-size: .75rem; }
.source-label select { display: block; margin-top: .2rem; }
.source-row { display: flex; justify-content: space-between; gap: .7rem; font-size: .82rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
.source-row strong { white-space: nowrap; }
.source-help { font-size: .82rem; margin-top: .7rem; }
.source-help summary { cursor: pointer; color: var(--pink-deep); }
.sugar-insights a { color: var(--ink); }
#source-breakdown { margin-top: .8rem; font-size: .85rem; }

/* Compact dashboard: insights get full-width cards instead of a long sidebar. */
.layout { grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: stretch; }
.layout > .picker { grid-column: span 5; }
.layout > .log { grid-column: span 4; }
.layout > .scale-panel { grid-column: span 3; position: static; }
.layout > .sugar-insights { grid-column: span 6; margin-top: 0; border-top: 1.5px solid var(--line); padding: 1.25rem; }
.layout > * { min-width: 0; }
.treat-grid { max-height: 390px; }
.log-list { max-height: 300px; }
.scale-track { height: 260px; }
#source-period { width: auto; max-width: 100%; margin-left: .5rem; }
#source-breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
.source-row { margin: .5rem 0; align-items: baseline; }
.intake-tips { line-height: 1.45; }
.source-label select { min-height: 36px; font-size: .78rem; padding: .35rem .5rem; }
#health-profile { padding-top: .6rem; margin-top: .5rem; }
#profile-form { gap: .65rem; }
#profile-status:empty { display: none; }
@media (max-width: 1000px) {
  .layout > .picker { grid-column: span 12; }
  .layout > .log { grid-column: span 8; }
  .layout > .scale-panel { grid-column: span 4; }
  .treat-grid { max-height: 280px; }
}
@media (max-width: 680px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .layout > .picker, .layout > .log, .layout > .scale-panel, .layout > .sugar-insights { grid-column: 1; }
  .scale-track { height: 200px; }
  #source-breakdown { grid-template-columns: 1fr; }
}

.purpose-banner { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.5rem; padding: 1rem 1.25rem; margin-bottom: 1rem; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); }
.purpose-banner h2 { font-size: 1.1rem; margin: 0 0 .4rem; }
.purpose-banner p { font-size: .86rem; line-height: 1.5; color: var(--ink-soft); margin: 0; }
.purpose-banner strong, .purpose-banner a { color: var(--ink); }
.purpose-evidence { border-left: 2px solid var(--pink); padding-left: 1rem; }
@media (max-width: 680px) { .purpose-banner { grid-template-columns: 1fr; gap: .8rem; } }

/* Separate daily logging from deeper insights and setup. */
.app-views { position: relative; z-index: 1; padding-bottom: 2rem; }
.page-tabs { display: flex; gap: .5rem; position: relative; z-index: 1; margin-bottom: 1.4rem; padding-bottom: .75rem; border-bottom: 1px solid var(--line); }
.page-tabs button { flex: 0 1 auto; padding: .7rem 1.4rem; border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--ink-soft); font: inherit; font-weight: 700; cursor: pointer; }
.page-tabs button[aria-selected="true"] { background: var(--tint); color: var(--ink); border-color: var(--pink); }
.page-tabs button:hover { background: var(--card); color: var(--ink); }
.app-views [hidden] { display: none !important; }
.app-views .layout { padding-top: 0; gap: 1.5rem; }
.insights-view { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.insights-view .sugar-insights { margin: 0; padding: 1.5rem; border-top-style: solid; }
#view-profile { max-width: 900px; margin: 0 auto; }
#health-profile { margin: 0; padding: 1.5rem; }
#profile-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.2rem; }
#profile-form .field:not(.short) { grid-column: span 3; }
#profile-form button { justify-self: start; }
#view-about .purpose-banner { margin: 0; padding: 2rem; gap: 2rem; }
#view-about { max-width: 1000px; margin: 0 auto; }
@media(max-width: 680px) {
  .page-tabs { gap: .15rem; }
  .page-tabs button { flex: 1; padding: .65rem .3rem; font-size: .82rem; }
  .insights-view { grid-template-columns: 1fr; }
  #profile-form { gap: .7rem; }
  #profile-form button { grid-column: span 3; }
  #view-about .purpose-banner { padding: 1.25rem; }
}

.sugar-glossary { margin-top: 1.5rem; padding: 1.5rem; }
.glossary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem 2rem; margin: 1.25rem 0; }
.glossary-grid > div { border-top: 1px solid var(--line); padding-top: .8rem; }
.glossary-grid dt { font-weight: 800; color: var(--ink); margin-bottom: .35rem; }
.glossary-grid dd { margin: 0; color: var(--ink-soft); font-size: .9rem; line-height: 1.55; }
.glossary-sources { font-size: .8rem; line-height: 1.7; }
.glossary-sources a { color: var(--ink); }
@media(max-width: 680px) { .glossary-grid { grid-template-columns: 1fr; gap: 1rem; } }
