:root {
  color-scheme: light dark;
  --controls-height: 2.5rem;
  scrollbar-gutter: stable;
}

body {
  font-family: system-ui, sans-serif;
  margin: 0 auto;
  padding: 1rem;
  max-width: 600px;
}

h2 {
  font-size: 1.1rem;
  margin: 0;
  padding: 0.5rem 0;
}

h2 label {
  font-weight: 600;
}

#controls {
  position: sticky;
  top: 0;
  background: Canvas;
  height: var(--controls-height);
  margin-bottom: 0.75rem;
}

#add-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 100%;
}

#add-wrapper {
  position: relative;
  flex: 1;
}

#add-input {
  width: 100%;
  font-size: 1rem;
  padding: 0.5rem;
  box-sizing: border-box;
}

#suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  background: Canvas;
  border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
  border-radius: 0.375rem;
  max-height: 12rem;
  overflow-y: auto;
}

#suggestions[hidden] {
  display: none;
}

#suggestions li {
  padding: 0.5rem;
  cursor: pointer;
}

#suggestions li:hover {
  background: color-mix(in srgb, currentColor 10%, transparent);
}

button {
  font-size: 0.95rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
  background: color-mix(in srgb, currentColor 6%, transparent);
  color: inherit;
  white-space: nowrap;
}

#menu-wrapper {
  position: relative;
}

#menu-button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
}

#menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 10;
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0.25rem;
  background: Canvas;
  border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
  border-radius: 0.375rem;
  min-width: 8rem;
}

#menu[hidden] {
  display: none;
}

#menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: none;
  background: none;
  white-space: nowrap;
}

#menu button:hover {
  background: color-mix(in srgb, currentColor 10%, transparent);
}

section {
  margin-bottom: 1.5rem;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid color-mix(in srgb, currentColor 12%, transparent);
}

/* scroll-margin-top accounts for #controls's height plus a viewport-relative
   buffer, so j/k scrolling (scrollIntoView) keeps the selected row clear of
   the sticky controls bar and the screen edges. scroll-margin-bottom is just
   the buffer. */
h2,
li {
  scroll-margin-top: calc(var(--controls-height) + 20vh);
  scroll-margin-bottom: 20vh;
}

.selected {
  background-color: #333;
}

@media (pointer: coarse) {
  #app li {
    user-select: none;
  }

  /* The whole row is the tap target on mobile; the checkbox is just a visual indicator. */
  #app li input[type="checkbox"] {
    pointer-events: none;
  }

  /* Clips items as they slide out during the swipe-to-delete action. */
  ul {
    overflow: hidden;
  }
}

#login-form {
  display: flex;
  justify-content: center;
  margin-top: 30vh;
}

#login-form input {
  font-size: 1.1rem;
  padding: 0.6rem 0.75rem;
  width: 100%;
  max-width: 240px;
  box-sizing: border-box;
}

label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
}

a {
  color: #2563eb;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
