:root {
  --cream: #fffaf3;
  --paper: #ffffff;
  --peach: #f9ded0;
  --peach-deep: #c96d55;
  --sun: #f3c96b;
  --sage: #dce9dc;
  --sage-deep: #52725c;
  --lavender: #e9e2f2;
  --denim: #6f8796;
  --berry: #a95768;
  --gold-thread: #d99d35;
  --ink: #3e3732;
  --muted: #756b64;
  --line: #eadfd4;
  --shadow: 0 12px 30px rgba(91, 64, 45, .09);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background-color: var(--cream); background-image: linear-gradient(45deg, rgba(169,87,104,.025) 25%, transparent 25%), linear-gradient(-45deg, rgba(111,135,150,.025) 25%, transparent 25%); background-size: 32px 32px; font-family: "Segoe UI", Tahoma, sans-serif; font-size: 17px; line-height: 1.5; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 4px solid rgba(201,109,85,.32); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; left: 1rem; top: -5rem; color: white; background: var(--ink); padding: .8rem 1rem; border-radius: 10px; }
.skip-link:focus { top: 1rem; }

.topbar { position: sticky; top: 0; z-index: 20; height: 86px; display: flex; align-items: center; justify-content: space-between; padding: 0 2rem; background: rgba(255,250,243,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 4px; background: repeating-linear-gradient(90deg, var(--berry) 0 38px, var(--sun) 38px 76px, var(--denim) 76px 114px, var(--sage-deep) 114px 152px); opacity: .72; }
.brand { display: flex; gap: .8rem; align-items: center; border: 0; background: none; cursor: pointer; text-align: left; padding: .25rem; }
.brand-mark { position: relative; width: 52px; height: 52px; display: grid; place-items: center; border: 2px solid white; border-radius: 10px; color: white; background: conic-gradient(from 45deg, var(--berry) 0 25%, var(--denim) 0 50%, var(--peach-deep) 0 75%, var(--sage-deep) 0); font-weight: 800; text-shadow: 0 1px 2px rgba(40,30,25,.4); box-shadow: 0 0 0 2px var(--gold-thread), 0 5px 12px rgba(100,70,55,.2); }
.brand-mark::after { content: ""; position: absolute; inset: 5px; border: 1px dashed rgba(255,255,255,.85); border-radius: 5px; }
.brand strong { display: block; font: 700 1.35rem Georgia, serif; }
.brand small { display: block; color: var(--muted); font-size: .77rem; }
.topbar-actions { display: flex; gap: 1rem; align-items: center; }
.today-label { margin: 0; color: var(--muted); }
.icon-button { min-width: 46px; min-height: 46px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 14px; background: white; cursor: pointer; font-size: 1.35rem; }
.menu-button { display: none; }

.app-shell { display: grid; grid-template-columns: 285px minmax(0, 1fr); min-height: calc(100vh - 86px); }
.site-nav { position: sticky; top: 86px; height: calc(100vh - 86px); overflow-y: auto; padding: 1.4rem 1rem; border-right: 1px solid var(--line); background: #fffdf9; }
.nav-item { width: 100%; min-height: 58px; display: grid; grid-template-columns: 30px minmax(0,1fr) auto; align-items: center; gap: .65rem; padding: .7rem .9rem; margin-bottom: .35rem; border: 0; border-radius: 15px; background: transparent; text-align: left; cursor: pointer; color: #5b514b; }
.nav-item:hover { background: #f7eee5; }
.nav-item.active { color: #70402f; background-color: var(--peach); background-image: linear-gradient(45deg, rgba(255,255,255,.28) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.28) 75%); background-size: 18px 18px; font-weight: 700; box-shadow: inset 0 0 0 1px rgba(169,87,104,.08); }
.nav-item > span:first-child { font-size: 1.25rem; text-align: center; }
.nav-count { min-width: 27px; padding: .05rem .38rem; border-radius: 99px; background: rgba(255,255,255,.7); text-align: center; font-size: .78rem; }
.nav-count:empty { display: none; }
.nav-note { display: flex; gap: .6rem; margin: 1.5rem .45rem 0; padding: .85rem; color: var(--muted); background: var(--sage); border-radius: 15px; font-size: .82rem; }
.nav-note p { margin: 0; }

main { min-width: 0; padding: 2.2rem clamp(1rem, 4vw, 4rem) 4rem; }
.page { display: none; max-width: 1180px; margin: auto; animation: rise .25s ease; }
.page.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.6rem; }
.eyebrow { margin: 0 0 .2rem; color: var(--peach-deep); font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; line-height: 1.15; }
h1 { margin: 0; font-size: clamp(2rem, 4vw, 3.25rem); letter-spacing: -.025em; }
h2 { margin: 0; font-size: 1.55rem; }
h3 { margin: 0; font-size: 1.12rem; }
.subhead { max-width: 680px; margin: .5rem 0 0; color: var(--muted); }
.button { min-height: 50px; border: 0; border-radius: 14px; padding: .7rem 1.1rem; cursor: pointer; font-weight: 700; }
.button.primary { color: white; background: var(--peach-deep); box-shadow: inset 0 0 0 2px rgba(255,255,255,.22), 0 5px 12px rgba(201,109,85,.2); }
.button.primary:hover { background: #b95e48; }
.button.secondary { background: #f4eee8; }
.button.success { color: white; background: var(--sage-deep); }
.button.small { min-height: 42px; padding: .5rem .75rem; font-size: .9rem; }
.button:disabled { opacity: .55; cursor: not-allowed; }

.welcome { position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(220px, .6fr); gap: 2rem; padding: clamp(1.5rem, 4vw, 3rem); margin-bottom: 1.5rem; background-color: #f9ded0; background-image: linear-gradient(135deg, rgba(255,255,255,.3) 25%, transparent 25%), linear-gradient(315deg, rgba(243,201,107,.24) 25%, transparent 25%); background-size: 54px 54px; border: 1px solid #e7c7b8; border-radius: 28px; box-shadow: var(--shadow), inset 0 0 0 5px rgba(255,255,255,.34); }
.welcome::before { content: ""; position: absolute; left: 16px; right: 16px; bottom: 12px; border-bottom: 2px dashed rgba(169,87,104,.3); }
.welcome::after { content: ""; position: absolute; width: 210px; height: 210px; right: -55px; top: -70px; border-radius: 50%; background: rgba(255,255,255,.34); }
.welcome h1 { max-width: 670px; }
.welcome p { max-width: 620px; color: #6a554a; }
.date-card { position: relative; z-index: 1; align-self: center; justify-self: end; width: 190px; padding: 1.25rem; border: 1px solid rgba(255,255,255,.7); border-radius: 22px; background: rgba(255,255,255,.58); text-align: center; }
.date-card strong { display: block; font: 700 3.5rem Georgia, serif; line-height: 1; }
.date-card span { color: var(--muted); }
.dashboard-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 1.15rem; }
.card { padding: 1.35rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: 0 5px 16px rgba(91,64,45,.045), inset 0 0 0 4px rgba(255,250,243,.8); }
.dashboard-card { grid-column: span 6; min-height: 210px; }
.dashboard-card.wide { grid-column: span 8; }
.dashboard-card.narrow { grid-column: span 4; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.card-heading .emoji { width: 44px; height: 44px; display: grid; place-items: center; border: 1px dashed rgba(111,135,150,.45); border-radius: 8px; background: var(--cream); font-size: 1.25rem; transform: rotate(-1deg); }
.text-button { border: 0; padding: .25rem; color: var(--peach-deep); background: transparent; cursor: pointer; font-weight: 700; }
.summary-list, .item-list { list-style: none; margin: 0; padding: 0; }
.summary-list li { display: flex; align-items: center; gap: .75rem; padding: .62rem 0; border-top: 1px solid #f0e8df; }
.summary-list li:first-child { border: 0; padding-top: 0; }
.dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: var(--peach-deep); }
.empty-compact { color: var(--muted); margin: .5rem 0; }
.quote { margin: 0; font: italic 1.15rem/1.55 Georgia, serif; color: #60534b; }

.toolbar { display: flex; flex-wrap: wrap; gap: .8rem; justify-content: space-between; margin-bottom: 1rem; }
.filter-group { display: flex; flex-wrap: wrap; gap: .5rem; }
.filter { min-height: 44px; padding: .5rem .85rem; border: 1px solid var(--line); border-radius: 99px; background: white; cursor: pointer; }
.filter.active { color: #70402f; background: var(--peach); border-color: transparent; font-weight: 700; }
.list-switcher { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: .65rem; margin-bottom: 1rem; }
.list-tab { min-height: 68px; display: flex; align-items: center; justify-content: center; gap: .45rem; padding: .55rem; border: 1px solid var(--line); border-radius: 14px; background: white; cursor: pointer; font-weight: 700; }
.list-tab span { font-size: 1.2rem; }
.list-tab.active { color: #6d4638; border-color: #e1b8a6; background: var(--peach); box-shadow: inset 0 0 0 3px rgba(255,255,255,.4); }
.content-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; }
.item-card { position: relative; padding: 1.2rem; border: 1px solid var(--line); border-radius: 18px; background: white; box-shadow: inset 0 0 0 4px rgba(255,250,243,.7); }
.item-card::after { content: ""; position: absolute; pointer-events: none; inset: 7px; border: 1px dashed rgba(201,109,85,.15); border-radius: 12px; }
.item-card > * { position: relative; z-index: 1; }
.item-card.completed { opacity: .66; background: #f7f5f2; }
.item-card.completed h3 { text-decoration: line-through; }
.item-top { display: flex; align-items: flex-start; gap: .8rem; }
.check-button { flex: 0 0 auto; width: 34px; height: 34px; border: 2px solid #cbbdb2; border-radius: 50%; background: white; cursor: pointer; font-weight: 800; }
.completed .check-button { color: white; border-color: var(--sage-deep); background: var(--sage-deep); }
.item-copy { min-width: 0; flex: 1; }
.item-copy p { margin: .4rem 0 0; color: var(--muted); white-space: pre-wrap; }
.meta { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .75rem; }
.tag { display: inline-flex; padding: .25rem .55rem; border-radius: 99px; color: #66564d; background: #f4eee8; font-size: .78rem; }
.item-actions { display: flex; gap: .35rem; margin-top: 1rem; padding-top: .75rem; border-top: 1px solid #f0e8df; }
.action-link { min-height: 40px; border: 0; padding: .35rem .55rem; border-radius: 9px; color: var(--muted); background: transparent; cursor: pointer; }
.action-link:hover { background: #f6f0ea; color: var(--ink); }
.action-link.danger:hover { color: #9f3e36; background: #fce9e6; }
.empty-state { grid-column: 1 / -1; padding: 3rem 1.5rem; border: 2px dashed var(--line); border-radius: var(--radius); color: var(--muted); text-align: center; }
.empty-state span { display: block; font-size: 2.5rem; margin-bottom: .5rem; }
.task-list-label { display: inline-block; margin-bottom: .35rem; color: var(--peach-deep); font-size: .76rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.date-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; margin-top: .9rem; }
.date-pair div { padding: .65rem .75rem; border-radius: 11px; background: #f8f3ed; }
.date-pair small, .date-pair strong { display: block; }
.date-pair small { color: var(--muted); font-size: .72rem; text-transform: uppercase; }
.date-pair strong { margin-top: .08rem; font-size: .9rem; }
.today-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin-top: .85rem; padding: .65rem; border-radius: 11px; background: var(--sage); font-size: .82rem; }
.today-assignment { margin-right: auto; color: #34513c; font-weight: 800; }
.today-task-list, .event-summary { list-style: none; margin: 0; padding: 0; }
.today-task-list li { display: grid; grid-template-columns: 36px minmax(0,1fr) auto; gap: .65rem; align-items: center; padding: .65rem 0; border-top: 1px solid var(--line); }
.today-task-list li:first-child { border-top: 0; }
.today-task-list .check-button { width: 34px; height: 34px; }
.today-task-list small, .event-summary small { display: block; color: var(--muted); }
.event-summary li { display: grid; grid-template-columns: 48px minmax(0,1fr); gap: .8rem; align-items: center; padding: .55rem 0; border-top: 1px solid var(--line); }
.event-summary li:first-child { border-top: 0; }
.event-day { display: grid; place-items: center; min-height: 48px; border-radius: 9px; color: #70402f; background: var(--peach); line-height: 1.05; }
.event-day strong { font-size: .68rem; text-transform: uppercase; }
.completed-section, .story-section { margin-top: 2rem; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: .85rem; }
.completed-list { list-style: none; margin: 0; padding: .35rem 1rem; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.72); }
.completed-list li { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; align-items: center; gap: .7rem; min-height: 54px; padding: .4rem 0; border-top: 1px solid var(--line); color: var(--muted); }
.completed-list li:first-child { border-top: 0; }
.completed-list strong { display: block; text-decoration: line-through; }
.completed-list small { display: block; }
.completed-list .check-button { width: 30px; height: 30px; color: white; border-color: var(--sage-deep); background: var(--sage-deep); font-size: .8rem; }

.grocery-add { display: grid; grid-template-columns: minmax(0,1fr) 150px auto; gap: .65rem; margin-bottom: 1.2rem; }
.grocery-add input, .grocery-add select { min-height: 52px; }
.field, .grocery-add input, .grocery-add select { width: 100%; padding: .72rem .85rem; color: var(--ink); border: 1px solid #d9ccc1; border-radius: 12px; background: white; }
.shopping-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.2rem; margin-bottom: 1rem; border-radius: 16px; color: #294331; background: var(--sage); }
.shopping-banner p { margin: 0; }
.grocery-group { margin: 1rem 0 1.35rem; }
.grocery-group h2 { padding-bottom: .5rem; border-bottom: 2px solid var(--peach); font-size: 1.15rem; }
.grocery-row { display: grid; grid-template-columns: 44px minmax(0,1fr) auto; gap: .7rem; align-items: center; min-height: 62px; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.grocery-row.checked .grocery-name { color: var(--muted); text-decoration: line-through; }
.grocery-check { width: 42px; height: 42px; border: 2px solid #b9aa9f; border-radius: 13px; background: white; cursor: pointer; font-size: 1.2rem; }
.grocery-row.checked .grocery-check { color: white; border-color: var(--sage-deep); background: var(--sage-deep); }
.grocery-name { font-weight: 700; }
.grocery-name small { display: block; color: var(--muted); font-weight: 400; }
.shopping-mode .site-nav, .shopping-mode .topbar .brand, .shopping-mode .today-label { display: none; }
.shopping-mode .app-shell { grid-template-columns: 1fr; }
.shopping-mode main { padding-top: 1rem; }
.shopping-mode .topbar { justify-content: flex-end; height: 66px; }
.shopping-mode .page-header, .shopping-mode .grocery-add, .shopping-mode .grocery-edit { display: none; }

.story-card { display: grid; grid-template-columns: 100px minmax(0,1fr); gap: 1.1rem; }
.story-year { display: grid; place-items: center; align-self: start; min-height: 86px; padding: .5rem; border: 2px solid white; outline: 1px dashed var(--berry); outline-offset: -7px; border-radius: 10px; color: #705b4b; background-color: var(--lavender); background-image: linear-gradient(45deg, rgba(255,255,255,.3) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.3) 75%); background-size: 20px 20px; font: 700 1.2rem Georgia, serif; text-align: center; }
.story-card .story-text { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 4; }
.header-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .65rem; }
.prompt-card { border-left: 6px solid var(--berry); background: #fffdfc; }
.prompt-ribbon { display: inline-block; margin-bottom: .8rem; padding: .3rem .6rem; border-radius: 7px; color: #734050; background: #f4e4e8; font-size: .78rem; font-weight: 800; }
.prompt-text { font: italic 1.05rem/1.55 Georgia, serif; }
.story-prompt { margin: 0 0 .55rem !important; padding-left: .65rem; border-left: 3px solid var(--sun); font-size: .82rem; font-style: italic; }
.calendar-list { display: grid; gap: .9rem; }
.calendar-event { display: grid; grid-template-columns: 92px minmax(0,1fr); gap: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 18px; background: white; box-shadow: 0 5px 16px rgba(91,64,45,.045); }
.calendar-date { display: grid; place-items: center; align-content: center; min-height: 110px; border: 1px dashed var(--denim); border-radius: 12px; color: #435965; background: #e7eef1; line-height: 1; }
.calendar-date strong { font-size: .75rem; text-transform: uppercase; }
.calendar-date span { margin: .15rem 0; font: 700 2.2rem Georgia, serif; }
.calendar-date small { color: var(--muted); }
.event-copy { min-width: 0; }
.event-title-line { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.event-time { color: var(--peach-deep); font-weight: 800; white-space: nowrap; }
.event-copy p { margin: .4rem 0; color: var(--muted); }
.note-card { border-left: 5px solid var(--sun); }
.shared-card { cursor: pointer; transition: transform .16s ease, box-shadow .16s ease; }
.shared-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.modal-backdrop { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 1rem; background: rgba(46,37,32,.55); }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(620px, 100%); max-height: 90vh; overflow-y: auto; padding: 1.4rem; border-radius: 22px; background: white; box-shadow: 0 24px 70px rgba(30,20,15,.3); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.form-row { margin-bottom: 1rem; }
.form-row label { display: block; margin-bottom: .35rem; font-weight: 700; }
.form-row textarea { min-height: 110px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: .7rem; margin-top: 1.2rem; }
.toast { position: fixed; z-index: 80; left: 50%; bottom: -100px; transform: translateX(-50%); padding: .75rem 1.1rem; border-radius: 12px; color: white; background: var(--ink); box-shadow: var(--shadow); transition: bottom .25s ease; }
.toast.show { bottom: 1.5rem; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 230px minmax(0,1fr); }
  .site-nav { padding-inline: .65rem; }
  .nav-item { font-size: .92rem; }
  main { padding-inline: 1.4rem; }
  .dashboard-card, .dashboard-card.wide, .dashboard-card.narrow { grid-column: span 6; }
}

@media (max-width: 760px) {
  body { font-size: 16px; }
  .topbar { height: 74px; padding: 0 1rem; }
  .brand-mark { width: 44px; height: 44px; border-radius: 14px; }
  .today-label { display: none; }
  .menu-button { display: inline-grid; }
  .app-shell { display: block; min-height: calc(100vh - 74px); }
  .site-nav { position: fixed; z-index: 30; top: 74px; left: 0; width: min(330px, 88vw); height: calc(100vh - 74px); padding: 1rem; transform: translateX(-110%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .site-nav.open { transform: translateX(0); }
  .nav-item { min-height: 54px; font-size: 1rem; }
  main { padding: 1.4rem 1rem 5.5rem; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .page-header .button { width: 100%; }
  .header-buttons { width: 100%; }
  .header-buttons .button { flex: 1 1 220px; }
  .welcome { grid-template-columns: 1fr; gap: 1rem; }
  .date-card { justify-self: start; width: 100%; display: flex; align-items: center; justify-content: center; gap: .7rem; padding: .8rem; }
  .date-card strong { font-size: 2.3rem; }
  .dashboard-card, .dashboard-card.wide, .dashboard-card.narrow { grid-column: 1 / -1; }
  .content-grid { grid-template-columns: 1fr; }
  .list-switcher { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .list-tab:first-child { grid-column: 1 / -1; }
  .grocery-add { grid-template-columns: 1fr; }
  .story-card { grid-template-columns: 72px minmax(0,1fr); }
  .calendar-event { grid-template-columns: 74px minmax(0,1fr); }
  .calendar-date { min-height: 96px; }
  .shopping-mode .topbar { height: 58px; }
  .shopping-mode main { padding-bottom: 2rem; }
}

@media (max-width: 430px) {
  .brand small { display: none; }
  h1 { font-size: 2rem; }
  .welcome { padding: 1.35rem; border-radius: 22px; }
  .card { padding: 1.05rem; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .filter-group { display: grid; grid-template-columns: repeat(3, 1fr); }
  .filter { padding-inline: .35rem; }
  .date-pair { grid-template-columns: 1fr; }
  .event-title-line { align-items: flex-start; flex-direction: column; gap: .15rem; }
  .calendar-event { padding: .75rem; }
}

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