:root {
  color-scheme: dark;
  --canvas: #203443;
  --ink: #f2f6f8;
  --muted: #abbcc7;
  --accent: #a4ead6;
  --surface: #22313a;
  --glass: rgba(221, 237, 250, .10);
  --line: rgba(225, 239, 252, .16);
  --glass-rim: rgba(231, 246, 255, .23);
  --ease-out: cubic-bezier(.2, .72, .24, 1);
  --tone-rgb: 197, 207, 218;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  min-height: 100%;
  /* Paint the whole canvas, including the home indicator area in iOS standalone mode. */
  background-color: var(--canvas);
  background-image:
    linear-gradient(to bottom, transparent calc(100% - 70px), var(--canvas)),
    radial-gradient(ellipse 18rem 11rem at calc(50% + 6rem) -1%, #3d5971 0%, transparent 100%),
    radial-gradient(ellipse 22rem 25rem at -6% 34%, #28574e 0%, transparent 83%),
    radial-gradient(ellipse 22rem 22rem at 86% 68%, #263d58 0%, transparent 83%),
    radial-gradient(ellipse 12rem 11rem at calc(50% - 7rem) 99%, #37655e 0%, transparent 96%),
    radial-gradient(ellipse 16rem 12rem at calc(50% + 9rem) 103%, #405978 0%, transparent 97%),
    linear-gradient(146deg, #13222d, #0a1118 77%);
}
[data-tone="mint"] { --tone-rgb: 160, 233, 193; }
[data-tone="sky"] { --tone-rgb: 150, 204, 255; }
[data-tone="rose"] { --tone-rgb: 253, 170, 205; }
[data-tone="amber"] { --tone-rgb: 249, 211, 132; }
[data-tone="violet"] { --tone-rgb: 203, 183, 255; }
[data-tone="teal"] { --tone-rgb: 125, 223, 221; }
[data-tone="peach"] { --tone-rgb: 255, 174, 148; }

*, *::before, *::after { box-sizing: border-box; }
html, body { overscroll-behavior-y: contain; }
body {
  min-width: 280px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
img { display: block; }
a { color: inherit; }
p, h1, h2 { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.shell {
  width: min(calc(100% - max(18px, env(safe-area-inset-left)) - max(18px, env(safe-area-inset-right))), 864px);
  margin-inline: auto;
}

.site-header {
  padding-top: max(6px, env(safe-area-inset-top));
}
.header-inner {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  min-height: 70px;
  align-items: center;
  gap: 12px;
}
.brand {
  grid-column: 2;
  font-size: 23px;
  font-weight: 750;
  letter-spacing: .13em;
  text-align: center;
}
.brand a {
  text-decoration: none;
}
.toolbar-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--glass-rim);
  border-radius: 50%;
  background-color: var(--surface);
  background-image: linear-gradient(150deg, rgba(239, 250, 255, .21), transparent 74%);
  color: var(--ink);
  box-shadow: inset 0 1px 1px rgba(242, 252, 255, .21), 0 6px 19px rgba(4, 11, 17, .27);
}
#filter-toggle { grid-column: 1; grid-row: 1; }
#layout-toggle { grid-column: 3; grid-row: 1; }
.toolbar-button:hover, .toolbar-button[aria-expanded="true"] { background-color: rgba(221, 237, 250, .17); }
.toolbar-button[data-active="true"]::after {
  position: absolute;
  inset: 7px 7px auto auto;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}
.control-icon { position: relative; display: block; width: 22px; height: 22px; }
.control-icon::before, .control-icon::after { position: absolute; content: ""; }
.filter-icon::before {
  inset: 4px 2px;
  background:
    linear-gradient(currentColor, currentColor) center top / 18px 1.5px,
    linear-gradient(currentColor, currentColor) center / 12px 1.5px,
    linear-gradient(currentColor, currentColor) center bottom / 6px 1.5px;
  background-repeat: no-repeat;
}
.layout-icon::before {
  inset: 3px;
  background:
    linear-gradient(currentColor, currentColor) left top / 6px 6px,
    linear-gradient(currentColor, currentColor) right top / 6px 6px,
    linear-gradient(currentColor, currentColor) left bottom / 6px 6px,
    linear-gradient(currentColor, currentColor) right bottom / 6px 6px;
  background-repeat: no-repeat;
}
#layout-toggle[aria-pressed="true"] .layout-icon::before {
  border-block: 2px solid currentColor;
  background: linear-gradient(currentColor, currentColor) center / 100% 2px no-repeat;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease;
}
.button-outline { color: var(--ink); background-color: var(--surface); border-color: var(--line); }
.button-outline:hover { background-color: #304452; }
.button-primary { color: #102c27; background-color: var(--accent); }
.button-primary:hover { background-color: #b9f3e3; }
.privacy-note img, .empty-state img, .install-steps img {
  filter: brightness(0) invert(1);
  opacity: .78;
}

.events, .settings { margin-top: 7px; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 13px; }
.type-filters {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background-color: var(--surface);
}
.filter {
  min-height: 44px;
  padding: 0 13px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}
.filter:hover { color: var(--ink); }
.filter[aria-pressed="true"] { background: rgba(229, 242, 255, .15); color: var(--ink); font-weight: 700; }
.category-filter {
  width: 128px;
  max-width: 100%;
  min-height: 44px;
  padding: 0 29px 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: var(--surface);
  color: var(--ink);
  font-size: 16px;
  text-overflow: ellipsis;
}
select {
  -webkit-appearance: none;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 48%, var(--muted) 52%),
    linear-gradient(135deg, var(--muted) 48%, transparent 52%);
  background-position: right 17px center, right 12px center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
select option { background-color: #202f39; color: var(--ink); }
.event-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.event-list[data-layout="grid"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.event-list:empty { display: none; }
.event-card, .empty-state {
  border: 1px solid var(--glass-rim);
  border-radius: 22px;
  background-color: var(--surface);
  box-shadow: inset 0 1px 0 rgba(240, 249, 255, .12), 0 12px 30px rgba(3, 9, 16, .23);
}
.event-card {
  min-width: 0;
  background-image:
    linear-gradient(160deg, rgba(238, 249, 255, .075), transparent 68%),
    radial-gradient(ellipse at 0 0, rgba(var(--tone-rgb), .22), transparent 76%);
}
.event-open {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 134px;
  height: 100%;
  padding: 16px 20px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  text-align: left;
}
.event-open:hover { background: rgba(225, 239, 252, .04); }
.event-list[data-layout="grid"] .event-open { grid-template-columns: minmax(0, 1fr); align-content: space-between; }
.event-list[data-layout="grid"] .event-count { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px 7px; }
.event-list[data-layout="grid"] .event-count strong { font-size: clamp(27px, 7vw, 40px); }
.category-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 3px 8px;
  border: 1px solid rgba(var(--tone-rgb), .26);
  border-radius: 999px;
  background: rgba(var(--tone-rgb), .105);
  color: rgb(var(--tone-rgb));
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.category-tag::before, .category-dot {
  flex: 0 0 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgb(var(--tone-rgb));
  content: "";
}
.event-info { display: block; min-width: 0; }
.event-name { display: block; margin-top: 8px; font-size: 16px; font-weight: 620; line-height: 1.36; overflow-wrap: anywhere; }
.event-date {
  display: block;
  margin-top: 4px;
  font-size: clamp(17px, 5vw, 24px);
  font-weight: 740;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.035em;
  line-height: 1.14;
  white-space: nowrap;
}
.event-detail { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.event-count { display: grid; justify-items: end; gap: 4px; color: rgb(var(--tone-rgb)); text-align: right; }
.event-count strong {
  font-size: clamp(34px, 10.7vw, 58px);
  font-weight: 725;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.072em;
  line-height: .92;
}
.event-count span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.event-card[data-state="past"] .event-count { color: var(--muted); }
.event-card[data-state="today"] .event-count span { color: rgb(var(--tone-rgb)); font-weight: 700; }
.empty-state {
  display: grid;
  justify-items: center;
  gap: 11px;
  padding: 35px 16px;
  background-image: linear-gradient(150deg, rgba(227, 246, 255, .11), transparent 72%);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}
.settings h2 { margin: 2px 0 13px; font-size: 24px; }
.settings-panel {
  padding-inline: 15px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background-color: var(--surface);
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-block: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.settings-note, .privacy-note { color: var(--muted); font-size: 13px; }
.privacy-note { display: flex; align-items: center; gap: 7px; padding-block: 13px; }

.bottom-nav {
  --nav-inset: 5px;
  --nav-gap: 4px;
  position: fixed;
  z-index: 2;
  inset-inline: 0;
  bottom: max(13px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--nav-gap);
  width: min(68%, 280px);
  margin-inline: auto;
  padding: var(--nav-inset);
  border: 1px solid var(--glass-rim);
  border-radius: 24px;
  background-color: var(--surface);
  background-image: linear-gradient(154deg, rgba(230, 247, 255, .17), transparent 70%);
  box-shadow: inset 0 1px 1px rgba(240, 249, 255, .22), 0 12px 36px rgba(3, 9, 16, .40);
}
.bottom-nav::before {
  position: absolute;
  inset-block: var(--nav-inset);
  inset-inline-start: var(--nav-inset);
  width: calc((100% - 2 * var(--nav-inset) - 2 * var(--nav-gap)) / 3);
  border: 1px solid rgba(164, 234, 214, .24);
  border-radius: 18px;
  background: linear-gradient(150deg, rgba(164, 234, 214, .17), rgba(7, 23, 28, .39));
  pointer-events: none;
  content: "";
}
.bottom-nav[data-view="settings"]::before { transform: translateX(calc(100% + var(--nav-gap))); }
.nav-item {
  position: relative;
  display: grid;
  min-height: 56px;
  padding: 6px 4px;
  align-content: center;
  justify-items: center;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: 18px;
  background-color: transparent;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}
.nav-item:hover { color: var(--ink); background-color: rgba(225, 239, 252, .08); }
#add-button .control-icon { color: var(--accent); }
.nav-item[aria-current="page"] {
  color: var(--accent);
  font-weight: 700;
}
.home-icon::before { inset: 8px 4px 3px; border: 1.6px solid currentColor; border-top: 0; border-radius: 0 0 3px 3px; }
.home-icon::after {
  inset: 4px 5px auto;
  height: 12px;
  transform: rotate(45deg);
  border: solid currentColor;
  border-width: 1.6px 0 0 1.6px;
  border-radius: 2px 0 0;
}
.settings-icon::before {
  inset: 5px 2px;
  border-block: 1.5px solid currentColor;
  background: linear-gradient(currentColor, currentColor) center / 100% 1.5px no-repeat;
}
.settings-icon::after {
  inset: 3px auto auto 6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 6px 6px currentColor, -1px 12px currentColor;
}
.add-icon { border: 1.6px solid currentColor; border-radius: 7px; }
.add-icon::before, .add-icon::after {
  inset: 50% auto auto 50%;
  width: 10px;
  height: 1.6px;
  border-radius: 1px;
  transform: translate(-50%, -50%);
  background: currentColor;
}
.add-icon::after { transform: translate(-50%, -50%) rotate(90deg); }

dialog {
  width: min(calc(100% - 30px), 470px);
  max-height: calc(100% - 30px);
  max-height: calc(100dvh - 30px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: 21px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background-color: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(240, 249, 255, .12) inset, 0 24px 80px rgba(0, 0, 0, .40);
  overflow: auto;
  overscroll-behavior-y: contain;
}
dialog::backdrop { background: rgba(4, 10, 15, .55); }
body:has(dialog[open]) { overflow: hidden; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.dialog-heading h2 { font-size: 22px; }
.icon-button {
  display: grid;
  flex: 0 0 44px;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
}
.icon-button:hover { background: rgba(229, 242, 255, .12); }
.close-button { font-size: 26px; line-height: 1; }
.field { display: block; min-width: 0; padding: 0; margin: 0 0 13px; border: 0; }
.field > span:first-child, .field > legend {
  display: block;
  padding: 0;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 650;
}
.field input:not([type="radio"], [type="checkbox"]), .field select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background-color: rgba(10, 18, 25, .32);
  color: var(--ink);
  font-size: 16px;
}
.field select { padding-right: 29px; }
.field input::placeholder { color: var(--muted); }
.field input[type="date"] { -webkit-appearance: none; appearance: none; }
.category-choice { position: relative; display: block; }
.category-choice .category-dot { position: absolute; top: 50%; left: 13px; width: 8px; height: 8px; transform: translateY(-50%); pointer-events: none; }
.field .category-choice select { padding-left: 29px; }
.new-category { margin-bottom: 13px; padding: 12px 11px 6px; border: 1px solid var(--line); border-radius: 13px; }
.new-category .field:last-child { margin-bottom: 0; }
.color-options { display: flex; flex-wrap: wrap; gap: 3px; }
.color-options label { position: relative; display: grid; width: 40px; height: 44px; place-items: center; cursor: pointer; }
.color-options input, .segments input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.color-options label span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgb(var(--tone-rgb));
}
.color-options input:checked + span { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px rgb(var(--tone-rgb)); }
.color-options input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 6px; }
.segments {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  border-radius: 12px;
  background: rgba(10, 18, 25, .28);
}
.segments label { position: relative; cursor: pointer; }
.segments span { display: grid; min-height: 44px; place-items: center; border-radius: 9px; color: var(--muted); font-size: 14px; }
.segments input:checked + span { background: rgba(229, 242, 255, .16); color: var(--ink); font-weight: 700; }
.segments input:focus-visible + span { outline: 2px solid var(--accent); }
.date-parts { display: flex; gap: 8px; }
.date-parts .field { flex: 1; margin-bottom: 0; }
.checkbox { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-top: 2px; font-size: 14px; }
.checkbox input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.date-note { margin: -3px 0 12px; color: var(--muted); font-size: 13px; line-height: 1.55; }
#event-converter:not([hidden]) + .form-error { margin-top: 8px; }
.conversion-result {
  display: block;
  padding: 11px 12px;
  border: 1px solid rgba(164, 234, 214, .24);
  border-radius: 12px;
  background-color: rgba(164, 234, 214, .09);
  color: var(--accent);
  font-size: 17px;
  font-weight: 650;
}
.form-error, .storage-error { color: #ffb9b3; font-size: 14px; line-height: 1.5; }
.storage-error { margin-bottom: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 15px; }
.save-button { flex: 1; }
.button-danger { color: #ffc2bb; background: rgba(255, 177, 169, .12); }
.button-danger:hover { background: rgba(255, 177, 169, .2); }
.install-steps { color: var(--muted); font-size: 15px; line-height: 1.8; }
.install-steps p + p { margin-top: 9px; }
.install-steps img { display: inline-block; vertical-align: -.2em; }

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .toolbar-button, .button-outline, .type-filters, .category-filter, .event-card, .empty-state, .settings-panel, .bottom-nav, dialog {
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    backdrop-filter: blur(22px) saturate(150%);
  }
  .button-outline, .type-filters, .category-filter, .event-card, .empty-state, .settings-panel { background-color: var(--glass); }
  .toolbar-button { background-color: rgba(209, 237, 251, .105); }
  .toolbar-button:hover, .toolbar-button[aria-expanded="true"] { background-color: rgba(209, 237, 251, .21); }
  .button-outline:hover { background-color: rgba(229, 242, 255, .16); }
  .bottom-nav { background-color: rgba(29, 45, 58, .37); }
  dialog { background-color: rgba(29, 43, 53, .81); }
}
@media (max-width: 460px) {
  .header-inner { min-height: 65px; }
  .install-button { padding-inline: 11px; font-size: 13px; }
  .filter { padding-inline: 9px; font-size: 13px; }
  .category-filter { width: 107px; padding-left: 9px; }
  .event-card { border-radius: 19px; }
  .event-open { min-height: 120px; padding: 13px 15px; }
  .event-list[data-layout="grid"] .event-open { padding-inline: 11px; }
  .event-list[data-layout="grid"] .event-date { font-size: clamp(14px, 4.2vw, 19px); }
  dialog { padding: 15px; }
}

@keyframes surface-in {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes grid-in {
  from { opacity: .25; transform: scale(.96); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(20px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  .event-card, .empty-state, .settings-panel, .filters {
    animation: surface-in .38s var(--ease-out) backwards;
  }
  .event-card:nth-child(2) { animation-delay: .04s; }
  .event-card:nth-child(3) { animation-delay: .08s; }
  .event-card:nth-child(n + 4) { animation-delay: .12s; }
  .event-list[data-layout="grid"] .event-card { animation-name: grid-in; }
  .bottom-nav::before { transition: transform .37s cubic-bezier(.22, .8, .26, 1.12); }
  .toolbar-button, .event-open, .nav-item, .button {
    transition: transform .16s var(--ease-out), color .2s ease, background-color .2s ease;
  }
  .toolbar-button:active, .nav-item:active, .button:active { transform: scale(.94); }
  .event-open:active { transform: scale(.985); }
  dialog[open] { animation: dialog-in .34s var(--ease-out) backwards; }
  dialog[open]::backdrop { animation: backdrop-in .26s ease backwards; }
}
@media (prefers-reduced-transparency: reduce) {
  .toolbar-button, .button-outline, .type-filters, .category-filter, .event-card, .empty-state, .settings-panel, .bottom-nav, dialog {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background-color: var(--surface);
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
