:root {
  --system-bar: #1e1b4b;
  --safe-bottom-max: env(safe-area-max-inset-bottom, max(36px, env(safe-area-inset-bottom, 0px)));
}
html {
  background: var(--system-bar);
  touch-action: pan-x pan-y;
  -webkit-user-select: none;
  user-select: none;
}
input, textarea, [contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}
body { min-height: 100dvh; background: var(--system-bar); }
.app-shell {
  min-height: 100dvh;
  background: radial-gradient(ellipse at 90% 0, #ede9fe 0, transparent 42%), var(--paper);
}
.has-bottom-nav .app-shell { padding-bottom: calc(96px + var(--safe-bottom-max)); }
.shared-editing-option { display: flex; align-items: center; gap: 12px; min-height: 48px; margin: 16px 0; cursor: pointer; }
.shared-editing-option input { width: 22px; height: 22px; flex-shrink: 0; accent-color: var(--primary); }

/* The dock and the system inset share an opaque dark background. */
.system-bottom-edge {
  position: fixed;
  inset-inline: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) - var(--safe-bottom-max));
  height: var(--safe-bottom-max);
  background: var(--system-bar);
  pointer-events: none;
  z-index: 19;
}
.bottom-nav {
  position: fixed;
  inset-inline: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) - var(--safe-bottom-max));
  height: calc(64px + var(--safe-bottom-max));
  padding: 8px max(8px, env(safe-area-inset-right, 0px)) calc(8px + var(--safe-bottom-max)) max(8px, env(safe-area-inset-left, 0px));
  background: var(--system-bar);
  color: #fff;
  border-radius: 26px 26px 0 0;
  border-top: 1px solid #ffffff18;
  box-shadow: 0 -8px 30px #1e1b4b20;
  z-index: 20;
}
.bottom-nav-items {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  max-width: 560px;
  height: 48px;
  margin: auto;
}
.nav-link {
  position: relative;
  min-width: 0;
  min-height: 44px;
  height: 48px;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 2px;
  border-radius: 17px;
  color: #c7d2fe;
  font-size: 11px;
  white-space: nowrap;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav-link > .icon { width: 24px; height: 24px; }
.nav-link:hover { color: #fff; background: #ffffff0c; }
.nav-link:active { transform: scale(.96); }
.nav-link.active { color: #fff; background: #ffffff16; font-weight: 700; }
.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 3px;
  border-radius: 3px;
  background: #a5b4fc;
}
.nav-link:focus-visible { outline-color: #fbbf24; outline-offset: -2px; }
.nav-add { color: #fff; }
.nav-add-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #fde68a, #fbbf24 55%, #f59e0b);
  color: #312e81;
}
.nav-add-icon .icon { width: 24px; height: 24px; }
.nav-add.active::after { background: #fbbf24; }

.install-sheet {
  position: fixed;
  inset: auto 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  margin: 0 auto;
  padding: 14px 24px calc(24px + env(safe-area-inset-bottom, 0px));
  border: 1px solid var(--line);
  border-radius: 28px 28px 0 0;
  color: var(--ink);
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 -16px 60px #1e1b4b26;
}
.install-sheet, .date-sheet {
  background: linear-gradient(to top, var(--system-bar) env(safe-area-inset-bottom, 0px), #fff env(safe-area-inset-bottom, 0px));
}
.install-sheet[open] { animation: install-sheet-enter .2s ease-out; }
.install-sheet::backdrop { background: #1e1b4b80; backdrop-filter: blur(3px); }
.install-intro { display: flex; align-items: center; gap: 14px; margin: 24px 0 18px; }
.install-intro img { border-radius: 16px; flex-shrink: 0; }
.install-intro p { font-size: 14px; font-weight: 650; }
.install-intro small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.install-status { border-radius: 12px; padding: 12px 14px; font-size: 12px; background: #eef2ff; color: var(--deep); margin-bottom: 16px; }
.install-steps { padding-inline-start: 22px; margin: 20px 0 12px; font-size: 12px; }
.install-steps li { padding-inline-start: 5px; margin-bottom: 12px; }
.install-steps li::marker { color: var(--primary); font-weight: 700; }
.install-note { font-size: 11px; color: var(--muted); margin-top: 12px; }
.pwa-installed #install-app, .pwa-installed .install-help { display: none; }

@keyframes install-sheet-enter { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@media (min-width: 761px) {
  body { background: var(--paper); }
  .bottom-nav { --safe-bottom-max: 0px; left: 50%; right: auto; bottom: 18px; width: min(560px, calc(100% - 36px)); transform: translateX(-50%); border: 1px solid #ffffff18; border-radius: 24px; }
}
@media (max-width: 380px) {
  .bottom-nav-items { gap: 4px; }
  .nav-link { font-size: 10px; gap: 3px; }
  .install-sheet { padding-inline: 18px; }
}
@media (display-mode: standalone), (display-mode: fullscreen) {
  #install-app, .install-help { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .nav-link { transition: none; }
  .install-sheet[open] { animation: none; }
}
@media print {
  html { background: #fff; }
  body, .app-shell { background: #fff; }
  .bottom-nav, .system-bottom-edge, .install-sheet { display: none !important; }
  .has-bottom-nav .app-shell { padding-bottom: 0; }
}
