:root {
  color-scheme: light dark;
  --bg: #f2f1ef;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.9);
  --text: #1d1d20;
  --muted: #707078;
  --hairline: rgba(40, 40, 45, 0.11);
  --accent: #2f3035;
  --accent-text: #ffffff;
  --shadow: 0 18px 45px rgba(49, 45, 42, 0.08);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --safe-bottom: max(14px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 5%, rgba(255, 255, 255, 0.9), transparent 32%),
    radial-gradient(circle at 95% 15%, rgba(192, 185, 191, 0.3), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button {
  color: inherit;
}

button,
.nav-item,
.calendar-day,
.agenda-item,
.note-card {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 2px;
}

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(72px);
  opacity: 0.28;
  pointer-events: none;
}

.ambient-one {
  top: 8vh;
  left: -90px;
  width: 230px;
  height: 230px;
  background: #d8cbd2;
}

.ambient-two {
  right: -80px;
  bottom: 16vh;
  width: 210px;
  height: 210px;
  background: #cdd4d7;
}

.app-shell {
  width: min(100%, 860px);
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 18px calc(110px + var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 26px;
}

.eyebrow,
.section-kicker,
.hero-kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: 690;
  letter-spacing: -0.045em;
}

h2 {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.date-line {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.primary-button,
.secondary-button,
.danger-button,
.text-button,
.icon-button {
  border: 0;
  cursor: pointer;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 44px;
  border-radius: 15px;
  padding: 0 16px;
  font-weight: 650;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 8px 24px rgba(30, 30, 35, 0.14);
}

.secondary-button {
  background: rgba(127, 127, 127, 0.12);
}

.danger-button {
  background: rgba(185, 54, 60, 0.12);
  color: #a83239;
}

.text-button {
  padding: 7px 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.text-button:hover {
  color: var(--text);
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: var(--surface);
  font-size: 1.7rem;
  line-height: 1;
  backdrop-filter: blur(22px);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
  animation: view-in 180ms ease-out;
}

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

.hero-card,
.calendar-panel,
.content-section,
.notes-tools {
  border: 1px solid var(--hairline);
  background: var(--surface);
  backdrop-filter: blur(26px) saturate(120%);
  box-shadow: var(--shadow);
}

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 148px;
  padding: 26px;
  border-radius: var(--radius-lg);
}

.hero-date {
  margin: 0;
  font-size: clamp(2.1rem, 9vw, 3.7rem);
  font-weight: 680;
  letter-spacing: -0.06em;
}

.hero-progress {
  display: flex;
  min-width: 118px;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.hero-progress span {
  font-size: 1.4rem;
  font-weight: 680;
}

.hero-progress small {
  color: var(--muted);
  font-size: 0.76rem;
}

.content-section {
  margin-top: 18px;
  padding: 20px;
  border-radius: var(--radius-lg);
}

.section-heading,
.sheet-heading,
.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-heading {
  margin-bottom: 15px;
}

.agenda-list {
  display: grid;
  gap: 10px;
}

.agenda-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 62px;
  padding: 11px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.33);
  text-align: left;
}

.agenda-item.is-done .agenda-copy {
  opacity: 0.46;
}

.agenda-item.is-done .agenda-title {
  text-decoration: line-through;
}

.completion-button {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1.5px solid rgba(80, 80, 85, 0.3);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.completion-button.is-complete {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.agenda-copy {
  min-width: 0;
}

.agenda-title {
  display: block;
  margin-bottom: 4px;
  font-weight: 630;
}

.agenda-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.type-chip {
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.1);
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
}

.empty-state {
  padding: 30px 18px;
  border: 1px dashed var(--hairline);
  border-radius: var(--radius-md);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.note-card {
  position: relative;
  min-height: 146px;
  padding: 17px;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  text-align: left;
  cursor: pointer;
}

.note-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--note-accent, #999);
  content: "";
}

.note-card[data-accent="silver"] { --note-accent: #8f9096; }
.note-card[data-accent="rose"] { --note-accent: #aa7f8e; }
.note-card[data-accent="amber"] { --note-accent: #b58b4a; }
.note-card[data-accent="sage"] { --note-accent: #748b77; }
.note-card[data-accent="blue"] { --note-accent: #718a9a; }

.note-card h3 {
  margin: 0 28px 9px 0;
  font-size: 1rem;
}

.note-card p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.note-date {
  display: block;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.72rem;
}

.pin-button {
  position: absolute;
  top: 11px;
  right: 11px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(127, 127, 127, 0.09);
  cursor: pointer;
}

.pin-button.is-pinned {
  background: var(--accent);
  color: var(--accent-text);
}

.calendar-panel {
  padding: 20px;
  border-radius: var(--radius-lg);
}

.calendar-title-wrap {
  text-align: center;
}

.calendar-title-wrap .section-kicker {
  margin-bottom: 3px;
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row {
  margin-top: 21px;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

.calendar-grid {
  gap: 5px;
  margin-top: 8px;
}

.calendar-day {
  position: relative;
  display: grid;
  min-height: 60px;
  place-items: center;
  border: 0;
  border-radius: 17px;
  background: transparent;
  cursor: pointer;
}

.calendar-day:hover {
  background: rgba(127, 127, 127, 0.08);
}

.calendar-day.is-outside {
  color: var(--muted);
  opacity: 0.38;
}

.calendar-day.is-today {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.calendar-day.is-selected {
  background: var(--accent);
  color: var(--accent-text);
}

.calendar-day-number {
  align-self: center;
  font-size: 0.9rem;
  font-weight: 620;
}

.calendar-dots {
  position: absolute;
  bottom: 8px;
  display: flex;
  gap: 3px;
}

.calendar-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.62;
}

.notes-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border-radius: var(--radius-md);
}

.search-field {
  flex: 1;
}

.search-field input,
.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.42);
  color: var(--text);
}

.search-field input {
  min-height: 44px;
  padding: 0 13px;
}

.switch-row,
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.notes-grid-all {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(calc(100% - 24px), 520px);
  margin: 0 auto var(--safe-bottom);
  padding: 7px;
  border: 1px solid var(--hairline);
  border-radius: 24px;
  background: rgba(244, 243, 241, 0.83);
  box-shadow: 0 18px 45px rgba(20, 20, 24, 0.16);
  backdrop-filter: blur(28px) saturate(145%);
}

.nav-item {
  display: flex;
  min-height: 54px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  cursor: pointer;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.65;
}

.nav-item.is-active {
  background: var(--accent);
  color: var(--accent-text);
}

.modal-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 18px 14px max(14px, env(safe-area-inset-bottom));
  background: rgba(15, 15, 18, 0.38);
  backdrop-filter: blur(12px);
}

.modal-backdrop[hidden] {
  display: none;
}

.editor-sheet {
  width: min(100%, 620px);
  max-height: min(88vh, 760px);
  overflow-y: auto;
  padding: 12px 20px 20px;
  border: 1px solid var(--hairline);
  border-radius: 30px;
  background: var(--surface-strong);
  box-shadow: 0 28px 80px rgba(14, 14, 18, 0.28);
  backdrop-filter: blur(32px);
}

.sheet-handle {
  width: 42px;
  height: 5px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.3);
}

.sheet-heading {
  margin-bottom: 18px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.field input,
.field textarea,
.field select {
  min-height: 46px;
  padding: 11px 12px;
  resize: vertical;
}

.field textarea {
  min-height: 118px;
}

.date-time-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.note-only-fields {
  margin-bottom: 16px;
}

.sheet-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
}

.action-spacer {
  flex: 1;
}

.toast {
  position: fixed;
  z-index: 80;
  right: 20px;
  bottom: calc(92px + var(--safe-bottom));
  left: 20px;
  width: fit-content;
  max-width: calc(100% - 40px);
  margin: auto;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 12px 35px rgba(20, 20, 24, 0.2);
  font-size: 0.84rem;
}

.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 20px 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(214, 69, 69, 0.12);
  border: 1px solid rgba(214, 69, 69, 0.35);
  color: var(--text-strong, inherit);
  font-size: 0.86rem;
  line-height: 1.4;
}

.error-banner[hidden] {
  display: none;
}

.error-banner button {
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  background: rgba(214, 69, 69, 0.85);
  color: #fff;
  font-size: 0.8rem;
}

.local-only-notice {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(120, 120, 130, 0.12);
  border: 1px solid rgba(120, 120, 130, 0.25);
  font-size: 0.8rem;
  line-height: 1.45;
  opacity: 0.85;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 680px) {
  .app-shell {
    padding-right: 14px;
    padding-left: 14px;
  }

  .hero-card {
    padding: 22px 19px;
  }

  .notes-grid,
  .notes-grid-all {
    grid-template-columns: 1fr 1fr;
  }

  .calendar-day {
    min-height: 52px;
    border-radius: 14px;
  }
}

@media (max-width: 430px) {
  .topbar .primary-button {
    min-width: 44px;
    padding: 0 12px;
  }

  .hero-card {
    align-items: flex-end;
  }

  .hero-progress {
    min-width: auto;
  }

  .content-section,
  .calendar-panel {
    padding: 17px;
  }

  .notes-grid,
  .notes-grid-all {
    grid-template-columns: 1fr;
  }

  .notes-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .switch-row {
    min-height: 36px;
  }

  .calendar-day {
    min-height: 46px;
  }

  .calendar-dots {
    bottom: 5px;
  }

  .date-time-fields {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .sheet-actions {
    flex-wrap: wrap;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114;
    --surface: rgba(32, 32, 37, 0.7);
    --surface-strong: rgba(38, 38, 44, 0.94);
    --text: #f3f2f0;
    --muted: #aaa8af;
    --hairline: rgba(255, 255, 255, 0.09);
    --accent: #ece9e5;
    --accent-text: #17171a;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
  }

  body {
    background:
      radial-gradient(circle at 12% 4%, rgba(92, 81, 91, 0.28), transparent 30%),
      radial-gradient(circle at 94% 18%, rgba(65, 74, 79, 0.25), transparent 26%),
      var(--bg);
  }

  .agenda-item,
  .search-field input,
  .field input,
  .field textarea,
  .field select {
    background: rgba(255, 255, 255, 0.035);
  }

  .bottom-nav {
    background: rgba(28, 28, 33, 0.86);
  }

  .danger-button {
    color: #ff9ca1;
  }
}

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

.text-button-reset {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
