:root {
  --bg: #f3f1eb;
  --surface: rgba(255, 255, 255, 0.76);
  --surface-strong: #fffefb;
  --text: #21221f;
  --muted: #777971;
  --line: rgba(44, 47, 40, 0.11);
  --accent: #9dd45b;
  --accent-dark: #648f31;
  --accent-soft: #e7f5d4;
  --violet: #8f83f3;
  --danger: #d95e5e;
  --shadow: 0 24px 70px rgba(63, 65, 54, 0.09);
  --radius: 28px;
  font-family: Inter, ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.ambient {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.22;
  pointer-events: none;
}
.ambient-one { background: var(--accent); top: -180px; right: -120px; }
.ambient-two { background: var(--violet); bottom: -220px; left: -160px; opacity: 0.12; }

.shell { position: relative; max-width: 1360px; margin: 0 auto; padding: 42px 32px 54px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.eyebrow { margin: 0 0 5px; font-size: 11px; font-weight: 800; letter-spacing: .16em; color: var(--muted); }
h1, h2 { margin: 0; letter-spacing: -.045em; }
h1 { font-size: clamp(31px, 4vw, 48px); }
h1 span { color: var(--accent-dark); }
h2 { font-size: 25px; }
.top-actions, .calendar-nav, .modal-actions { display: flex; align-items: center; gap: 10px; }

.icon-button, .primary-button, .secondary-button, .danger-button {
  border: 0;
  border-radius: 14px;
  min-height: 44px;
  transition: transform .16s ease, opacity .16s ease, background .16s ease;
}
.icon-button:hover, .primary-button:hover, .secondary-button:hover, .danger-button:hover { transform: translateY(-1px); }
.icon-button { width: 44px; background: var(--surface); color: var(--text); font-size: 24px; box-shadow: inset 0 0 0 1px var(--line); }
.primary-button { padding: 0 20px; background: var(--text); color: #fff; font-weight: 750; }
.primary-button span { color: var(--accent); font-size: 20px; }
.secondary-button { padding: 0 16px; background: var(--accent-soft); color: var(--accent-dark); font-weight: 750; }
.today-button { white-space: nowrap; }
.danger-button { padding: 0 16px; background: #feeaea; color: var(--danger); font-weight: 750; }
.icon-danger-button { flex: 0 0 44px; padding: 0; font-size: 17px; }

.section-nav {
  display: flex; gap: 7px; margin: -8px 0 18px; padding: 6px; overflow-x: auto;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 12px 35px rgba(63,65,54,.05);
  scrollbar-width: none;
}
.section-nav::-webkit-scrollbar { display: none; }
.section-nav button {
  display: flex; align-items: center; justify-content: center; gap: 7px; min-width: max-content; min-height: 42px; padding: 0 15px;
  border: 0; border-radius: 13px; background: transparent; color: var(--muted); font-weight: 750;
}
.section-nav button:hover { background: rgba(157,212,91,.09); color: var(--text); }
.section-nav button.active { background: var(--text); color: var(--surface-strong); }
.section-nav button b { display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-dark); font-size: 10px; }
.app-section[hidden] { display: none; }

.capture-card {
  display: grid;
  grid-template-columns: auto auto minmax(280px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  margin-bottom: 18px;
  border: 1px solid rgba(100, 143, 49, .2);
  border-radius: 22px;
  background: linear-gradient(115deg, rgba(232, 247, 214, .92), rgba(255, 255, 255, .76));
  box-shadow: var(--shadow);
}
.spark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--text); color: var(--accent); }
.capture-copy { display: flex; flex-direction: column; min-width: 210px; }
.capture-copy span { margin-top: 3px; color: var(--muted); font-size: 13px; }
.capture-card form { display: flex; gap: 8px; }
.capture-card input {
  width: 100%; height: 48px; border: 1px solid var(--line); border-radius: 14px; padding: 0 16px;
  background: rgba(255,255,255,.75); color: var(--text); outline: none;
}
.capture-card input:focus { border-color: var(--accent-dark); box-shadow: 0 0 0 3px rgba(157, 212, 91, .2); }
.capture-card form button { width: 48px; border: 0; border-radius: 14px; background: var(--accent); color: #27320f; font-size: 24px; font-weight: 800; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 18px; align-items: start; }
.calendar-card, .agenda-card {
  background: var(--surface); border: 1px solid rgba(255,255,255,.6); border-radius: var(--radius); box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}
.calendar-card { padding: 26px; }
.calendar-toolbar, .agenda-heading, .notes-heading { display: flex; justify-content: space-between; align-items: center; }
.calendar-toolbar { margin-bottom: 24px; }
.calendar-nav .icon-button { background: transparent; }
.view-switcher {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; max-width: 390px; margin: -8px 0 20px;
  padding: 4px; border-radius: 14px; background: rgba(120, 124, 112, .09);
}
.view-switcher button { border: 0; border-radius: 10px; padding: 8px 12px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 750; }
.view-switcher button.active { background: var(--surface-strong); color: var(--text); box-shadow: 0 3px 12px rgba(30,32,27,.08); }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays.hidden { display: none; }
.weekdays { border-bottom: 1px solid var(--line); }
.weekdays span { padding: 0 10px 12px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .1em; }
.calendar-day {
  position: relative; min-height: 116px; padding: 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  transition: background .15s ease;
}
.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day:hover, .calendar-day.drag-over { background: rgba(157, 212, 91, .11); }
.calendar-day.outside { opacity: .36; }
.calendar-day.selected { background: rgba(143, 131, 243, .08); }
.day-number {
  display: grid; place-items: center; width: 27px; height: 27px; margin-bottom: 5px; border-radius: 50%;
  font-size: 12px; font-weight: 750;
}
.calendar-day.today .day-number { background: var(--text); color: white; }
.day-item {
  display: flex; align-items: center; gap: 4px; width: 100%; margin: 4px 0; padding: 5px 7px; overflow: hidden; white-space: nowrap;
  border: 0; border-radius: 8px; background: var(--accent-soft); color: #3d5224; font-size: 11px; text-align: left;
}
.event-time { flex: 0 0 auto; font-variant-numeric: tabular-nums; opacity: .72; font-size: 9px; font-weight: 800; }
.event-emoji { flex: 0 0 auto; }
.event-title { overflow: hidden; text-overflow: ellipsis; }
.day-item.note { background: #eeeafd; color: #51479a; }
.day-item.done { opacity: .48; text-decoration: line-through; }
.more-items { color: var(--muted); font-size: 10px; padding-left: 6px; }
.calendar-grid.week-view .calendar-day { min-height: 360px; }
.week-day > small { display: block; margin: -25px 0 12px 34px; color: var(--muted); font-size: 9px; }
.mobile-week-list { display: flex; flex-direction: column; gap: 9px; }
.mobile-week-day {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 11px; width: 100%; padding: 14px;
  border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.38); color: var(--text); text-align: left;
}
.mobile-week-day.today { border-color: var(--accent-dark); box-shadow: inset 3px 0 0 var(--accent); }
.mobile-week-day.selected { background: rgba(143,131,243,.08); }
.mobile-week-date, .mobile-week-events { display: flex; flex-direction: column; min-width: 0; }
.mobile-week-date { gap: 3px; }
.mobile-week-date strong { font-size: 13px; }
.mobile-week-date small, .mobile-week-empty { color: var(--muted); font-size: 10px; }
.mobile-week-events { grid-column: 1; gap: 7px; margin-top: 3px; }
.mobile-week-event { display: grid; grid-template-columns: 40px 22px minmax(0,1fr); align-items: center; gap: 5px; }
.mobile-week-event time { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.mobile-week-event b { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.mobile-week-chevron { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--muted); font-size: 24px; }
.calendar-grid.day-view { display: block; }
.day-timeline { display: flex; flex-direction: column; gap: 9px; min-height: 360px; padding: 4px; }
.timeline-item {
  display: grid; grid-template-columns: 55px 36px 1fr; align-items: center; gap: 10px; width: 100%;
  border: 1px solid var(--line); border-radius: 15px; padding: 12px; background: rgba(255,255,255,.45); color: var(--text); text-align: left;
}
.timeline-item time { color: var(--muted); font-size: 12px; font-weight: 750; }
.timeline-item span { font-size: 20px; }
.timeline-item.done { opacity: .5; text-decoration: line-through; }
.calendar-grid.year-view { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.mini-month { padding: 14px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.3); }
.mini-month-title { border: 0; padding: 0 0 10px; background: transparent; color: var(--text); font-weight: 800; }
.mini-weekdays, .mini-days { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.mini-weekdays { margin-bottom: 5px; color: var(--muted); font-size: 8px; font-weight: 800; }
.mini-days button, .mini-days span { position: relative; display: grid; place-items: center; min-height: 25px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font-size: 9px; }
.mini-days button:hover { background: var(--accent-soft); }
.mini-days button.has-tasks::after { content: ''; position: absolute; bottom: 2px; width: 4px; height: 4px; border-radius: 50%; background: var(--violet); }
.mini-days button.today { background: var(--text); color: var(--surface-strong); }

.agenda-card { position: sticky; top: 18px; padding: 24px; min-height: 430px; }
.agenda-heading { margin-bottom: 20px; }
.count-pill { display: grid; place-items: center; min-width: 36px; height: 36px; border-radius: 18px; background: var(--accent); font-weight: 800; }
.agenda-list, #notesList { display: flex; flex-direction: column; gap: 9px; }
.agenda-item {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; width: 100%; padding: 13px;
  border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.48); color: var(--text); text-align: left;
}
.agenda-item:hover { background: var(--surface-strong); }
.agenda-item.done { opacity: .52; }
.agenda-item.done strong { text-decoration: line-through; }
.agenda-emoji { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--accent-soft); font-size: 18px; }
.agenda-text { min-width: 0; }
.agenda-text strong, .agenda-text span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.agenda-text strong { font-size: 13px; }
.agenda-text span, .agenda-time { margin-top: 4px; color: var(--muted); font-size: 11px; }
.notes-block { margin-top: 25px; padding-top: 19px; border-top: 1px solid var(--line); }
.notes-heading { margin-bottom: 10px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.empty-state { padding: 34px 16px; text-align: center; color: var(--muted); }
.empty-state div { margin-bottom: 10px; font-size: 33px; }
.empty-state strong, .empty-state span { display: block; }
.empty-state span { margin-top: 5px; font-size: 12px; line-height: 1.5; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px;
  background: rgba(25, 26, 23, .4); backdrop-filter: blur(8px);
}
.modal-backdrop[hidden] { display: none; }
.task-modal { width: min(610px, 100%); padding: 26px; border-radius: 28px; background: var(--surface-strong); box-shadow: 0 30px 100px rgba(0,0,0,.25); }
.modal-handle { display: none; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field span { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.field input, .field select, .field textarea, .emoji-input {
  width: 100%; border: 1px solid var(--line); border-radius: 13px; padding: 12px 13px; background: #f7f6f2; color: var(--text); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus, .emoji-input:focus { border-color: var(--accent-dark); }
.title-row { display: flex; align-items: end; gap: 10px; margin-bottom: 15px; }
.emoji-input { width: 56px; height: 46px; padding: 0; font-size: 22px; text-align: center; }
.grow { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 10px; margin-bottom: 15px; }
.weekday-picker {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: -3px 0 15px; padding: 0; border: 0;
}
.weekday-picker[hidden] { display: none; }
.weekday-picker legend { margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.weekday-picker label { cursor: pointer; }
.weekday-picker input { position: absolute; opacity: 0; pointer-events: none; }
.weekday-picker span { display: grid; place-items: center; height: 35px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: 11px; font-weight: 800; }
.weekday-picker input:checked + span { border-color: var(--accent-dark); background: var(--accent-soft); color: #3d5224; }
.birthday-summary {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 15px; padding: 13px;
  border: 1px solid rgba(157,212,91,.28); border-radius: 15px; background: var(--accent-soft);
}
.birthday-summary[hidden] { display: none; }
.birthday-summary div { min-width: 0; }
.birthday-summary span, .birthday-summary strong { display: block; }
.birthday-summary span { color: var(--muted); font-size: 9px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.birthday-summary strong { margin-top: 5px; overflow: hidden; text-overflow: ellipsis; font-size: 12px; white-space: nowrap; }
.modal-actions { justify-content: flex-end; margin-top: 22px; }
.save-button { margin-left: auto; }
.settings-modal { max-height: min(880px, 94vh); overflow-y: auto; }
.settings-section { padding: 17px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 18px; background: rgba(120,124,112,.04); }
.settings-section-title { display: flex; align-items: center; gap: 12px; margin-bottom: 15px; }
.settings-section-title strong, .settings-section-title small { display: block; }
.settings-section-title small, .notification-test small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.settings-icon { display: grid; place-items: center; width: 37px; height: 37px; flex: 0 0 auto; border-radius: 12px; background: var(--accent-soft); color: var(--accent-dark); }
.settings-grid { grid-template-columns: 1fr 1fr; }
.settings-section > .field + .field { margin-top: 11px; }
.field-hint { margin: 9px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.api-key-field small { color: var(--accent-dark); font-size: 11px; }
.notification-test { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.notification-test strong, .notification-test small { display: block; }

.collection-card, .tools-card {
  min-height: 560px; padding: 28px; border: 1px solid rgba(255,255,255,.6); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(22px);
}
.collection-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.collection-header p:not(.eyebrow) { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.collection-list { display: flex; flex-direction: column; gap: 9px; }
.collection-item {
  display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 14px; width: 100%;
  padding: 15px 17px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.42); color: var(--text); text-align: left;
}
.collection-item:hover { background: var(--surface-strong); }
.collection-item.done { opacity: .72; }
.collection-item.done strong { text-decoration: line-through; }
.collection-emoji { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--accent-soft); font-size: 21px; }
.collection-copy { min-width: 0; }
.collection-copy strong, .collection-copy small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.collection-copy small, .collection-status { margin-top: 4px; color: var(--muted); font-size: 11px; }
.collection-status { text-align: right; }
.tool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.tool-tile {
  display: flex; flex-direction: column; align-items: flex-start; min-height: 180px; padding: 21px; border: 1px solid var(--line); border-radius: 20px;
  background: rgba(255,255,255,.42); color: var(--text); text-align: left;
}
.tool-tile:hover { background: var(--surface-strong); }
.tool-tile > span { display: grid; place-items: center; width: 45px; height: 45px; margin-bottom: auto; border-radius: 14px; background: var(--accent-soft); font-size: 21px; }
.tool-tile strong { margin-top: 22px; }
.tool-tile small { margin-top: 6px; color: var(--muted); line-height: 1.45; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 20; transform: translate(-50%, 100px); opacity: 0;
  padding: 12px 18px; border-radius: 14px; background: var(--text); color: #fff; font-size: 13px; font-weight: 700;
  transition: .25s ease; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 920px) {
  .shell { padding: 24px 18px 40px; }
  .capture-card { grid-template-columns: auto 1fr; }
  .capture-card form { grid-column: 1 / -1; }
  .workspace { grid-template-columns: 1fr; }
  .agenda-card { position: static; }
  .calendar-grid.year-view { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-grid { grid-template-columns: 1fr; }
  .tool-tile { min-height: 135px; }
}

@media (max-width: 620px) {
  .shell { padding: max(18px, env(safe-area-inset-top)) 12px calc(25px + env(safe-area-inset-bottom)); }
  .topbar { align-items: flex-end; }
  .top-actions { gap: 6px; }
  .top-actions .icon-button { width: 40px; }
  .today-button { min-width: 42px; padding: 0 10px; font-size: 0; }
  .today-button::after { content: '●'; font-size: 15px; }
  .primary-button { padding: 0 14px; }
  .section-nav { position: sticky; top: max(6px, env(safe-area-inset-top)); z-index: 5; margin-top: 0; }
  .section-nav button { min-height: 40px; padding: 0 12px; font-size: 12px; }
  .capture-copy span { display: none; }
  .calendar-card { padding: 17px 10px; border-radius: 22px; }
  .calendar-card { scroll-margin-top: calc(max(6px, env(safe-area-inset-top)) + 58px); }
  .calendar-toolbar { padding: 0 6px; }
  .calendar-day { min-height: 76px; padding: 5px 3px; }
  .calendar-grid.week-view.mobile-week-list { display: flex; }
  .day-number { width: 23px; height: 23px; margin-left: 3px; font-size: 11px; }
  .day-item { justify-content: center; padding: 4px; font-size: 12px; }
  .day-item .event-time, .day-item .event-title { display: none; }
  .more-items { display: none; }
  .agenda-card { padding: 20px 16px; border-radius: 22px; }
  .modal-backdrop { align-items: end; padding: 0; }
  .task-modal { max-height: 92vh; overflow: auto; border-radius: 28px 28px 0 0; padding: 14px 18px calc(20px + env(safe-area-inset-bottom)); }
  .modal-handle { display: block; width: 42px; height: 5px; margin: 0 auto 17px; border-radius: 9px; background: var(--line); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .field:first-child { grid-column: 1 / -1; }
  .modal-actions { flex-wrap: wrap; }
  .view-switcher { max-width: none; }
  .calendar-grid.year-view { grid-template-columns: 1fr; }
  .mini-month { padding: 18px; }
  .mini-month-title { width: 100%; min-height: 34px; text-align: left; }
  .mini-days button, .mini-days span { min-height: 34px; font-size: 11px; }
  .settings-grid { grid-template-columns: 1fr; }
  .birthday-summary { grid-template-columns: 1fr 1fr; }
  .notification-test { align-items: flex-start; flex-direction: column; }
  .collection-card, .tools-card { min-height: 520px; padding: 20px 15px; border-radius: 22px; }
  .collection-header { align-items: flex-start; }
  .collection-item { grid-template-columns: auto minmax(0,1fr); padding: 13px; }
  .collection-status { grid-column: 2; text-align: left; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171914; --surface: rgba(34, 37, 29, .8); --surface-strong: #252820; --text: #f3f4ed;
    --muted: #a5a99b; --line: rgba(235, 240, 224, .12); --accent-soft: #344424; --accent-dark: #b9e680;
  }
  .field input, .field select, .field textarea, .emoji-input { background: #1d2019; }
  .capture-card { background: linear-gradient(115deg, rgba(60, 82, 38, .8), rgba(36, 39, 31, .85)); }
  .capture-card input { background: rgba(20,22,18,.6); }
  .primary-button { background: #f1f4ea; color: #20231d; }
  .agenda-item, .collection-item, .tool-tile { background: rgba(24,26,21,.55); }
  .collection-item:hover, .tool-tile:hover { background: #2d3127; }
  .mini-month { background: rgba(255,255,255,.045); }
}
