:root {
  color-scheme: light;
  --ink: #182321;
  --muted: #63706d;
  --canvas: #f7f3ea;
  --surface: #fff;
  --line: #d8ded9;
  --brand: #256f68;
  --brand-dark: #194d49;
  --brand-soft: #e0f1ec;
  --terracotta: #d8844c;
  --terracotta-soft: #fbe9dc;
  --danger: #aa3543;
  --shadow: 0 14px 36px rgba(24, 35, 33, .10);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: linear-gradient(180deg, #edf6f2 0%, var(--canvas) 56%, #f9faf6 100%); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button { font: inherit; }
button:focus-visible { outline: 3px solid rgba(37, 111, 104, .34); outline-offset: 2px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 2rem; }
h2 { margin-bottom: 0; font-size: 1.55rem; }
h3 { margin: 0; font-size: 1rem; }

.app-shell { width: min(100%, 480px); min-height: 100vh; margin: 0 auto; padding: 28px 20px calc(120px + env(safe-area-inset-bottom)); }
body.home-view-active { overflow: hidden; }
body.home-view-active .app-shell { display: flex; height: 100svh; min-height: 0; flex-direction: column; }
body.home-view-active #home-view { display: grid; min-height: 0; flex: 1; grid-template-rows: minmax(0, 1fr); padding-top: 12px; padding-bottom: 8px; }
body.home-view-active .tracker-button { height: auto; min-height: 100%; }
.topbar, .intro-row, .section-title-row, .sheet-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.date-label, .eyebrow, .card-kicker, .settings-label { margin: 0 0 5px; color: var(--brand-dark); font-size: .72rem; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.avatar-button { width: 40px; height: 40px; border: 1px solid #b8d7cf; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); font-size: .78rem; font-weight: 900; cursor: pointer; }
.view { animation: fade-in .2s ease; }
.intro-row { margin: 38px 0 18px; }
.entry-count { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: var(--terracotta-soft); color: #9d4f25; font-weight: 900; }

.tracker-button { display: grid; width: 100%; min-height: 228px; place-items: center; align-content: center; gap: 8px; border: 1px solid rgba(255, 255, 255, .8); border-radius: 8px; background: rgba(255, 255, 255, .94); box-shadow: 0 18px 50px rgba(24, 35, 33, .12); color: var(--brand-dark); cursor: pointer; transition: transform .16s ease, box-shadow .16s ease; }
.tracker-button span { display: block; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; font-size: 8.2rem; line-height: 1; filter: drop-shadow(0 12px 10px rgba(88, 55, 44, .13)); transform: translateY(-3%); }
.tracker-button:hover { transform: translateY(-2px); box-shadow: 0 22px 56px rgba(24, 35, 33, .16); }

.summary-card { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: center; margin: 18px 0 32px; padding: 20px; border-radius: 8px; background: var(--brand); color: #fff; box-shadow: var(--shadow); }
.summary-card .card-kicker { color: #c9e6de; }
.summary-card strong, .insight-card strong { display: block; font-size: 2rem; line-height: 1; }
.summary-card span:not(.card-kicker), .insight-card span { display: block; margin-top: 6px; font-size: .78rem; opacity: .86; }
.summary-divider { width: 1px; height: 62px; background: rgba(255, 255, 255, .27); }
.text-button { border: 0; background: transparent; color: var(--brand); font-size: .88rem; font-weight: 900; cursor: pointer; }

.entry-list { display: grid; gap: 10px; margin: 14px 0 0; padding: 0; list-style: none; }
.entry-card { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid rgba(216, 222, 217, .85); border-radius: 8px; background: rgba(255, 255, 255, .94); box-shadow: 0 2px 12px rgba(24, 35, 33, .04); }
.entry-type { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); font-size: 1.1rem; font-weight: 900; }
.entry-content strong { display: block; font-size: .9rem; }
.entry-content p { margin: 3px 0 0; color: var(--muted); font-size: .78rem; }
.delete-entry { width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: #9fa8a5; cursor: pointer; font-size: 1.25rem; }
.empty-state { margin: 16px 0 0; color: var(--muted); font-size: .9rem; }

.view-heading { margin: 30px 0 22px; }
.period-filter { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: -8px 0 16px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: #edf1ee; }
.period-button { min-height: 36px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: .78rem; font-weight: 900; }
.period-button.is-active { background: #fff; color: var(--brand-dark); box-shadow: 0 2px 7px rgba(24, 35, 33, .10); }
.full-list { margin-top: 0; }
.insight-card, .distribution-card, .privacy-card { border: 1px solid rgba(216, 222, 217, .9); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.insight-card { padding: 22px; background: linear-gradient(135deg, #256f68, #3f897e); color: #fff; }
.insight-card .card-kicker { color: #d0ebe4; }
.distribution-card { margin-top: 16px; padding: 20px; }
.distribution-card .section-title-row span { color: var(--muted); font-size: .75rem; font-weight: 800; }
.distribution { display: grid; gap: 12px; margin-top: 20px; }
.distribution-row { display: grid; grid-template-columns: 20px 1fr 18px; align-items: center; gap: 8px; color: var(--muted); font-size: .78rem; font-weight: 800; }
.distribution-row > span { color: var(--brand); }
.distribution-row > div { height: 8px; overflow: hidden; border-radius: 8px; background: #edf1ee; }
.distribution-row i { display: block; height: 100%; border-radius: inherit; background: var(--terracotta); }
.distribution-row b { color: var(--ink); text-align: right; }
.insight-note { margin: 16px 4px 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }

.settings-group { overflow: hidden; border: 1px solid rgba(216, 222, 217, .9); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.settings-label { margin: 0 0 9px 4px; }
.setting-row { display: flex; width: 100%; align-items: center; justify-content: space-between; padding: 17px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; font-size: .92rem; font-weight: 800; }
.setting-row:last-child { border-bottom: 0; }
.setting-row > span:last-child { color: var(--muted); font-size: 1.4rem; }
.setting-row.danger { color: var(--danger); }
.privacy-card { margin-top: 22px; padding: 18px; background: #f0f8f4; }
.privacy-card strong { color: var(--brand-dark); font-size: .9rem; }
.privacy-card p { margin: 7px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }

.bottom-nav { position: fixed; z-index: 40; bottom: 0; left: 50%; display: grid; width: min(100%, 480px); grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; min-height: calc(76px + env(safe-area-inset-bottom)); padding: 7px 10px calc(7px + env(safe-area-inset-bottom)); transform: translateX(-50%); border-top: 1px solid var(--line); background: rgba(255, 255, 255, .96); backdrop-filter: blur(18px); box-shadow: 0 -4px 18px rgba(24, 35, 33, .05); }
.nav-button { display: grid; width: 100%; min-width: 0; min-height: 50px; place-items: center; align-content: center; gap: 3px; border: 0; background: transparent; color: #85918e; cursor: pointer; }
.nav-button span { font-size: 1.35rem; line-height: 1; }
.nav-button small { overflow: hidden; max-width: 100%; font-size: .62rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.nav-button.is-active { color: var(--brand); }
.add-button { width: 56px; height: 56px; justify-self: center; transform: translateY(-16px); border: 0; border-radius: 50%; background: var(--brand); color: #fff; box-shadow: 0 8px 18px rgba(37, 111, 104, .32); cursor: pointer; }
.add-button span { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; font-size: 1.7rem; }

.bristol-sheet[hidden], .confirmation[hidden] { display: none; }
.bristol-sheet { position: fixed; z-index: 20; inset: 0; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(21, 39, 35, .35); }
.sheet-content { position: absolute; right: 0; bottom: 0; left: 0; max-height: 85vh; padding: 12px 20px calc(26px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; background: var(--surface); box-shadow: 0 -18px 50px rgba(0, 0, 0, .16); animation: sheet-up .24s ease; }
.sheet-handle { width: 42px; height: 4px; margin: 0 auto 18px; border-radius: 4px; background: #cfd9d4; }
.sheet-heading { align-items: flex-start; margin-bottom: 18px; }
.sheet-heading h2 { font-size: 1.25rem; }
.sheet-heading p { margin: 4px 0 0; color: var(--muted); font-size: .84rem; }
.close-button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: #e8efeb; color: var(--brand-dark); cursor: pointer; font-size: 1.5rem; line-height: 1; }
.bristol-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.bristol-option { display: grid; min-height: 130px; place-items: center; align-content: center; padding: 7px 4px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer; }
.bristol-option:hover, .bristol-option:focus-visible { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.bristol-option img { width: 100%; height: 53px; object-fit: contain; pointer-events: none; }
.bristol-option span { margin-top: 6px; color: var(--brand-dark); font-size: 1.25rem; font-weight: 900; }
.bristol-option small { margin-top: 2px; color: var(--muted); font-size: .65rem; font-weight: 800; }
.confirmation { position: fixed; z-index: 30; right: 20px; bottom: 96px; left: 20px; margin: 0; padding: 14px 16px; border-radius: 8px; background: var(--brand-dark); color: #fff; box-shadow: var(--shadow); text-align: center; font-size: .88rem; font-weight: 900; }
.rainbow-celebration { position: fixed; z-index: 50; inset: 0; display: grid; visibility: hidden; place-items: center; overflow: hidden; pointer-events: none; background: #fff; opacity: 0; }
.rainbow-celebration img { display: block; width: min(72vw, 460px); max-width: 100%; max-height: 62dvh; object-fit: contain; transform: translateY(-4%); }
.rainbow-celebration.is-playing { animation: rainbow-pop 1.45s ease-out both; }
.entry-sound { position: fixed; top: -220px; left: -220px; width: 200px; height: 200px; border: 0; pointer-events: none; }
.entry-sound iframe { width: 200px; height: 200px; border: 0; }
.sheet-open { overflow: hidden; }

@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes rainbow-pop { 0% { visibility: visible; opacity: 0; transform: scale(1.04); } 16%, 78% { visibility: visible; opacity: 1; transform: scale(1); } 100% { visibility: hidden; opacity: 0; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .rainbow-celebration.is-playing { animation-duration: .01ms; } }
@media (min-width: 700px) { body { background: #e4ebe7; } .app-shell { min-height: 860px; background: linear-gradient(180deg, #edf6f2 0%, var(--canvas) 56%, #f9faf6 100%); box-shadow: 0 0 0 1px rgba(24,35,33,.06); } .sheet-content { width: 480px; left: 50%; right: auto; transform: translateX(-50%); border-radius: 18px 18px 0 0; animation: sheet-up-desktop .24s ease; } @keyframes sheet-up-desktop { from { transform: translate(-50%,100%); } to { transform: translate(-50%,0); } } }
@media (max-width: 370px) { .app-shell { padding-right: 14px; padding-left: 14px; } .bottom-nav { padding-right: 6px; padding-left: 6px; } .nav-button small { font-size: .56rem; } .nav-button span { font-size: 1.2rem; } .add-button { width: 52px; height: 52px; transform: translateY(-14px); } .bristol-option { min-height: 118px; } .bristol-option img { height: 44px; } }
