:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --background: #252525;
  --glass: rgb(55 55 55 / 66%);
  --ink: #dbdbdb;
  --secondary: #b1b1b1;
  --rim: rgb(255 255 255 / 16%);
  --rule: rgb(191 191 191 / 14%);
  --line: 1.5625rem;
}

:root[data-theme="light"] {
  color-scheme: light;
  --background: #d8d8d8;
  --glass: rgb(255 255 255 / 48%);
  --ink: #393939;
  --secondary: #5f5f5f;
  --rim: rgb(255 255 255 / 74%);
  --rule: rgb(115 115 115 / 20%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--background);
  color: var(--ink);
  overscroll-behavior-x: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.sheet {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: 0.625rem clamp(1.125rem, 5vw, 2rem) 0.375rem;
  background: var(--glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--rim);
  border-radius: 22px;
  overflow: clip;
}
.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  color: var(--secondary);
  font-size: 0.8125rem;
}
.controls { display: flex; gap: 0.375rem; }
#settings { position: relative; z-index: 2; }
#settings-toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  list-style: none;
  color: var(--ink);
  cursor: pointer;
}
#settings-toggle::-webkit-details-marker { display: none; }
.settings-icon {
  display: flex;
  flex-direction: column;
  align-items: end;
  gap: 4px;
}
.settings-icon::before, .settings-icon::after {
  content: "";
  display: block;
  height: 0.09375rem;
  background: currentColor;
}
.settings-icon::before { width: 1.1875rem; }
.settings-icon::after { width: 0.8125rem; }
#settings:not([open]) .settings-list { display: none; }
.settings-list {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 4px);
  display: grid;
  width: max-content;
  min-width: 9rem;
  padding: 0.25rem;
  background: var(--background);
  border: 1px solid var(--rim);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 16%);
  color: var(--ink);
}
.settings-list button {
  text-align: start;
  padding-inline: 0.75rem;
  border-radius: 6px;
}
.settings-list button[aria-pressed="true"] { background: var(--rim); }
#account { border-top: 1px solid var(--rule); }
button {
  min-width: 44px;
  min-height: 44px;
  padding-inline: 0.5rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  white-space: nowrap;
}
button:focus-visible, input:focus-visible, #settings-toggle:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: -2px;
  border-radius: 4px;
}
#calendar {
  display: flex;
  flex: 1;
  flex-direction: column;
  margin-top: 0.875rem;
  touch-action: pan-y pinch-zoom;
}
.day-heading { position: relative; display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
#save { position: absolute; inset-inline-end: 0; top: 50%; transform: translateY(-50%); }
.day-heading h1 { margin: 0 0 4px; font-size: 0.8125rem; font-weight: 400; }
#day { display: flex; align-items: baseline; gap: 7px; }
.day-number { font-size: 1rem; font-weight: 500; }
#day[aria-current="date"]::after {
  content: "";
  align-self: center;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
}
.paper {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background: repeating-linear-gradient(to bottom,
    transparent 0 calc(var(--line) - 1px), var(--rule) calc(var(--line) - 1px) var(--line));
  background-position: 0 3px;
}
.entry {
  grid-area: 1 / 1;
  min-width: 0;
  padding: 3px 0;
  font-size: 0.9375rem;
  line-height: var(--line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#note-input {
  align-self: stretch;
  width: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  resize: none;
  touch-action: pan-y pinch-zoom;
  background: transparent;
  font-family: inherit;
  color: transparent;
  caret-color: var(--ink);
}
.paper.is-editing #entry { visibility: hidden; }
.paper.is-editing #note-input { color: var(--ink); }
#note-input:focus { outline: none; }
#status { margin: 0; }
footer { min-height: 44px; margin-top: 0.25rem; }
#sign-in { margin-block: 0.875rem auto; max-width: 24rem; }
#sign-in h1 { font-size: 1rem; font-weight: 500; }
#sign-in label { display: block; margin-top: 1rem; font-size: 0.875rem; }
#sign-in input {
  display: block;
  min-height: 44px;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  border: 1px solid var(--rim);
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}
#sign-in button { margin-top: 0.75rem; border: 1px solid var(--rim); border-radius: 6px; }
.visually-hidden:not(:focus) {
  position: absolute;
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

#conflict {
  width: min(calc(100vw - 2rem), 36rem);
  max-height: min(85dvh, 44rem);
  padding: 1rem;
  border-radius: 16px;
  border: 1px solid var(--rim);
  background: var(--background);
  color: var(--ink);
}
dialog::backdrop { background: rgb(0 0 0 / 42%); }
dialog h2 { margin-top: 0; font-size: 1rem; font-weight: 500; }
dialog pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 20dvh;
  overflow: auto;
  font: inherit;
}
dialog form { margin: 0; }
