:root {
  color-scheme: light;
  --bg: #f5f2eb;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #1e2a26;
  --muted: #6e7772;
  --line: #dedfd9;
  --primary: #20352f;
  --primary-2: #38584e;
  --accent: #d39b58;
  --danger: #a4463e;
  --warning: #b67831;
  --success: #3e755f;
  --shadow: 0 16px 42px rgba(31, 45, 40, .09);
  --radius: 20px;
  --sidebar: 260px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, .clickable { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: 28px 20px;
  background: var(--primary);
  color: #f8f4e9;
}
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; padding: 0 8px 30px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.25); border-radius: 14px; background: rgba(255,255,255,.08); font-family: Georgia, serif; font-size: 24px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; }
.brand small { margin-top: 3px; color: rgba(255,255,255,.62); font-size: 11px; }
.nav-list { display: grid; gap: 7px; }
.nav-item { width: 100%; border: 0; background: transparent; color: rgba(255,255,255,.72); padding: 13px 14px; border-radius: 12px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; text-align: left; }
.nav-item:hover, .nav-item.is-active { background: rgba(255,255,255,.1); color: #fff; }
.nav-item kbd { border: 0; background: rgba(255,255,255,.08); border-radius: 6px; min-width: 22px; padding: 3px 5px; color: rgba(255,255,255,.5); text-align: center; font-size: 10px; }
.sidebar-footer { margin-top: auto; padding: 18px 10px 0; border-top: 1px solid rgba(255,255,255,.12); color: rgba(255,255,255,.58); font-size: 11px; line-height: 1.5; }
.storage-status { display: flex; align-items: center; gap: 7px; margin-top: 10px; }
.storage-status i { width: 7px; height: 7px; border-radius: 50%; background: #8fc5a9; box-shadow: 0 0 0 4px rgba(143,197,169,.12); }
.workspace { grid-column: 2; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 15; display: flex; justify-content: space-between; align-items: center; min-height: 104px; padding: 22px clamp(22px, 5vw, 72px); background: rgba(245,242,235,.9); backdrop-filter: blur(16px); border-bottom: 1px solid rgba(222,223,217,.7); }
.topbar h1 { margin: 2px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(29px, 4vw, 42px); font-weight: 500; letter-spacing: -.035em; }
.eyebrow { margin: 0; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }
.topbar-actions { display: flex; gap: 10px; }
.button { border: 0; border-radius: 12px; padding: 11px 16px; cursor: pointer; font-weight: 700; font-size: 13px; transition: transform .16s ease, background .16s ease, opacity .16s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--primary); box-shadow: 0 8px 20px rgba(32,53,47,.16); }
.button-primary:hover { background: var(--primary-2); }
.button-ghost { background: var(--surface); border: 1px solid var(--line); }
.button-danger { background: #f7e9e6; color: var(--danger); }
.button-small { padding: 8px 11px; font-size: 11px; }
.icon-button { width: 37px; height: 37px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); cursor: pointer; font-size: 21px; line-height: 1; }
#app-content { width: min(1440px, 100%); margin: 0 auto; padding: 28px clamp(22px, 5vw, 72px) 90px; outline: none; }

.hero-card { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(260px, .7fr); gap: 30px; align-items: center; padding: clamp(26px, 5vw, 52px); min-height: 245px; border-radius: 28px; color: #fff; background: linear-gradient(135deg, #20352f 0%, #36584d 72%, #496f61 100%); box-shadow: var(--shadow); overflow: hidden; position: relative; }
.hero-card::after { content: ""; position: absolute; width: 310px; height: 310px; right: -80px; top: -100px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; box-shadow: 0 0 0 55px rgba(255,255,255,.035), 0 0 0 110px rgba(255,255,255,.025); }
.hero-card > * { position: relative; z-index: 1; }
.hero-card h2 { max-width: 720px; margin: 8px 0 13px; font-family: Georgia, serif; font-size: clamp(30px, 5vw, 55px); line-height: 1.04; font-weight: 400; letter-spacing: -.04em; }
.hero-card p { max-width: 600px; margin: 0; color: rgba(255,255,255,.72); line-height: 1.65; }
.hero-progress { align-self: stretch; display: grid; place-content: center; text-align: center; border-left: 1px solid rgba(255,255,255,.16); }
.hero-progress strong { font-family: Georgia, serif; font-size: 65px; font-weight: 400; }
.hero-progress span { color: rgba(255,255,255,.67); font-size: 12px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 18px 0 30px; }
.stat-card { padding: 19px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.stat-card span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.stat-card strong { display: block; margin-top: 8px; font-family: Georgia, serif; font-size: 31px; font-weight: 500; }
.stat-card.danger strong { color: var(--danger); }
.section { margin-top: 34px; }
.section-header { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin-bottom: 14px; }
.section-header h2 { margin: 0; font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.section-header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.text-button { border: 0; background: transparent; color: var(--primary-2); cursor: pointer; font-size: 12px; font-weight: 750; }

.panel { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); box-shadow: 0 8px 25px rgba(31,45,40,.035); overflow: hidden; }
.panel-body { padding: 20px; }
.empty-state { padding: 45px 22px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 7px; color: var(--ink); font-family: Georgia, serif; font-size: 21px; font-weight: 500; }
.empty-state p { margin: 0 auto 16px; max-width: 430px; line-height: 1.6; font-size: 13px; }

.task-list { display: grid; }
.task-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 13px; align-items: center; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.task-row:last-child { border-bottom: 0; }
.task-row.is-complete .task-title { color: var(--muted); text-decoration: line-through; }
.check-control { width: 21px; height: 21px; accent-color: var(--success); cursor: pointer; }
.task-title { margin: 0 0 5px; font-size: 14px; font-weight: 750; }
.task-meta { display: flex; flex-wrap: wrap; gap: 7px 12px; align-items: center; color: var(--muted); font-size: 11px; }
.category-dot { display: inline-flex; align-items: center; gap: 6px; }
.category-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--category-color, #84918b); }
.priority { display: inline-block; border-radius: 999px; padding: 4px 8px; font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.priority-high { color: #8c3d36; background: #f5ded9; }
.priority-medium { color: #8c5c22; background: #f6e9d6; }
.priority-low { color: #4b665d; background: #e2ece7; }
.row-actions { display: flex; gap: 4px; opacity: .3; transition: opacity .15s; }
.task-row:hover .row-actions, .list-card:hover .row-actions { opacity: 1; }
.row-actions button { border: 0; background: transparent; cursor: pointer; border-radius: 8px; padding: 6px 8px; font-size: 11px; }
.row-actions button:hover { background: #eeeae2; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .55fr); gap: 20px; align-items: start; }
.filters { display: grid; grid-template-columns: minmax(180px, 1fr) repeat(2, minmax(130px, .35fr)); gap: 10px; margin-bottom: 16px; }
.search-input, .filter-select { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 11px 13px; outline: none; }
.search-input:focus, .filter-select:focus, input:focus, select:focus, textarea:focus { border-color: #78988c; box-shadow: 0 0 0 3px rgba(74,111,97,.1); }

.calendar-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.calendar-toolbar h2 { margin: 0; font-family: Georgia, serif; font-size: 23px; font-weight: 500; text-transform: capitalize; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekday { padding: 12px 8px; color: var(--muted); text-align: center; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--line); }
.calendar-day { min-height: 104px; padding: 9px; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; text-align: left; position: relative; }
.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day:hover { background: #f8f5ef; }
.calendar-day.is-outside { color: #afb4b0; background: #fbfaf6; }
.calendar-day.is-selected { box-shadow: inset 0 0 0 2px var(--primary-2); }
.calendar-day.is-today .day-number { color: #fff; background: var(--primary); }
.day-number { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 9px; font-size: 11px; font-weight: 800; }
.day-events { display: grid; gap: 4px; margin-top: 8px; }
.day-event { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border-left: 3px solid var(--category-color, #84918b); padding: 3px 5px; border-radius: 4px; background: #f0ede6; font-size: 9px; }
.selected-day-panel h3 { margin: 0 0 5px; font-family: Georgia, serif; font-size: 22px; font-weight: 500; }
.selected-day-panel > p { margin: 0 0 16px; color: var(--muted); font-size: 12px; text-transform: capitalize; }

.list-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.list-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.list-card-header { display: flex; justify-content: space-between; gap: 12px; padding: 19px 19px 14px; }
.list-card h3 { margin: 0; font-family: Georgia, serif; font-size: 22px; font-weight: 500; }
.list-card-header p { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.progress-track { height: 5px; margin: 0 19px 14px; border-radius: 99px; background: #e9e6df; overflow: hidden; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--category-color, var(--success)); }
.list-items { border-top: 1px solid var(--line); }
.list-item { display: grid; grid-template-columns: auto minmax(0,1fr) auto auto; gap: 10px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--line); font-size: 12px; }
.list-item.is-complete .list-item-name { text-decoration: line-through; color: var(--muted); }
.list-item-qty { color: var(--muted); font-size: 10px; }
.delete-mini { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.add-list-item { display: grid; grid-template-columns: minmax(0, 1fr) 78px auto; gap: 7px; padding: 13px; }
.add-list-item input { min-width: 0; border: 1px solid var(--line); border-radius: 9px; padding: 9px; background: #fff; }

.category-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.category-card { padding: 20px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); }
.category-swatch { width: 35px; height: 35px; border-radius: 11px; background: var(--category-color); box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.category-card h3 { margin: 16px 0 5px; font-size: 15px; }
.category-card p { margin: 0 0 14px; color: var(--muted); font-size: 11px; }
.category-card-footer { display: flex; justify-content: space-between; align-items: center; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings-card { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.settings-card h2 { margin: 0 0 8px; font-family: Georgia, serif; font-weight: 500; }
.settings-card p { margin: 0 0 18px; color: var(--muted); line-height: 1.65; font-size: 12px; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.info-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12px; line-height: 1.8; }

.dialog { width: min(600px, calc(100vw - 28px)); border: 0; border-radius: 22px; padding: 0; background: var(--surface-strong); box-shadow: 0 30px 100px rgba(14, 24, 20, .28); }
.compact-dialog { width: min(460px, calc(100vw - 28px)); }
.dialog::backdrop { background: rgba(22, 31, 27, .5); backdrop-filter: blur(4px); }
.dialog form, .dialog > div:not(.dialog-header) { margin: 0; }
.dialog-header { display: flex; justify-content: space-between; gap: 20px; align-items: start; padding: 23px 24px 16px; }
.dialog-header h2 { margin: 4px 0 0; font-family: Georgia, serif; font-size: 26px; font-weight: 500; }
.dialog form > .field, .dialog form > .form-grid { margin-left: 24px; margin-right: 24px; }
.field { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 750; }
.field-wide { margin-bottom: 15px; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; background: #fff; color: var(--ink); outline: none; resize: vertical; font-weight: 500; }
.field input[type="color"] { min-height: 45px; padding: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.dialog-actions { display: flex; justify-content: end; gap: 9px; padding: 20px 24px 24px; }
.quick-actions { display: grid; gap: 9px; padding: 0 24px 24px; }
.quick-actions button { display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 13px; padding: 15px; background: #fff; cursor: pointer; text-align: left; }
.quick-actions button:hover { border-color: #9daea7; background: #faf8f2; }
.quick-actions span { color: var(--muted); font-size: 11px; }
.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: 360px; padding: 13px 17px; border-radius: 12px; color: #fff; background: var(--primary); box-shadow: var(--shadow); opacity: 0; transform: translateY(15px); pointer-events: none; transition: .2s ease; font-size: 12px; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.mobile-nav { display: none; }

@media (max-width: 1100px) {
  :root { --sidebar: 220px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .category-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 780px) {
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .app-shell { display: block; }
  .sidebar { display: none; }
  .workspace { min-height: 100vh; }
  .topbar { min-height: 86px; padding: 17px 18px; }
  .topbar h1 { font-size: 30px; }
  .topbar-actions .button-ghost { display: none; }
  #quick-add-button { display: none; }
  #app-content { padding: 18px 14px 55px; }
  .hero-card { grid-template-columns: 1fr; padding: 28px 23px; min-height: 245px; }
  .hero-card h2 { font-size: 36px; }
  .hero-progress { display: none; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; margin-top: 10px; }
  .stat-card { padding: 15px; }
  .stat-card strong { font-size: 27px; }
  .filters { grid-template-columns: 1fr; }
  .list-grid, .settings-grid, .category-grid { grid-template-columns: 1fr; }
  .calendar-day { min-height: 72px; padding: 5px; }
  .day-event { height: 5px; padding: 0; border: 0; border-radius: 99px; background: var(--category-color, #84918b); font-size: 0; }
  .calendar-weekday { font-size: 8px; }
  .task-row { padding: 14px 13px; }
  .row-actions { opacity: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .mobile-nav { position: fixed; inset: auto 0 0; z-index: 40; display: grid; grid-template-columns: 1fr 1fr 64px 1fr 1fr; align-items: center; height: calc(65px + env(safe-area-inset-bottom)); padding: 5px 7px env(safe-area-inset-bottom); background: rgba(255,253,248,.96); border-top: 1px solid var(--line); backdrop-filter: blur(18px); }
  .mobile-nav-item { border: 0; background: transparent; padding: 10px 2px; color: var(--muted); font-size: 9px; font-weight: 750; }
  .mobile-nav-item.is-active { color: var(--primary); }
  .mobile-add { width: 50px; height: 50px; justify-self: center; margin-top: -24px; border: 5px solid var(--bg); border-radius: 50%; color: #fff; background: var(--primary); font-size: 27px; box-shadow: 0 8px 20px rgba(32,53,47,.2); }
  .toast { left: 14px; right: 14px; bottom: calc(78px + env(safe-area-inset-bottom)); text-align: center; }
}
