/* Notion-like: white page, system font, hairline dividers, Notion tag colours. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #37352f;
  --muted: #787774;
  --faint: #9b9a97;
  --line: #e9e9e7;
  --input: #dcdcd9;
  --hover: rgba(55, 53, 47, 0.06);
  --focus: #2383e2;
  --red: #d44c47;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display", "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Top bar */
.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(48px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 10px 0 16px;
  background: rgb(255 255 255 / 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.bar-title { font-size: 14px; font-weight: 500; }

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
}
.icon-btn:active { background: var(--hover); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.is-busy svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Page */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 16px calc(40px + env(safe-area-inset-bottom));
}
.page-head h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.page-meta { margin: 6px 0 0; font-size: 14px; color: var(--muted); }

/* Groups (Stiege) */
.group { margin-top: 28px; }
.group-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}
.group-count { font-weight: 400; color: var(--faint); }

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.rows li + li { border-top: 1px solid var(--line); }

.row {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 16px;
  border: 0;
  background: none;
  text-align: left;
}
.row:active { background: var(--hover); }
.row:focus-visible { outline-offset: -2px; }
.row-top { flex: 1; font-weight: 500; font-variant-numeric: tabular-nums; }
.row.is-done .row-top { color: var(--faint); }
.row.is-saving { opacity: 0.5; pointer-events: none; }
.chev { width: 16px; height: 16px; flex: none; color: var(--faint); }

@media (hover: hover) {
  .row:hover, .icon-btn:hover, .menu-item:hover, .link-btn:hover { background: var(--hover); }
}

/* Notion select tags */
.tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--tag-bg);
  color: var(--tag-fg);
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
}

.empty { margin: 28px 0 0; color: var(--muted); font-size: 15px; }
.foot { margin-top: 32px; }
.link-btn {
  margin-left: -8px;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 14px;
}

/* Login */
.login { max-width: 380px; display: grid; gap: 16px; }
.login h1 { margin: 0; font-size: 26px; line-height: 1.2; font-weight: 700; }
.login-sub { margin: 6px 0 0; font-size: 15px; color: var(--muted); }
.field { display: grid; gap: 6px; font-size: 14px; font-weight: 500; }
.field input {
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--input);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 400;
}
.field input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgb(35 131 226 / 0.2); }
.login-error { margin: 0; color: var(--red); font-size: 14px; }

.btn-primary, .btn-secondary {
  width: 100%;
  height: 44px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
}
.btn-primary { border: 0; background: var(--ink); color: #fff; }
.btn-secondary { margin-top: 12px; border: 1px solid var(--line); background: #fff; }
.btn-primary:active { background: #2a2925; }
.btn-secondary:active { background: var(--hover); }

/* Bottom sheet with a Notion-style option menu */
.sheet {
  inset: auto 0 0 0;
  width: 100%;
  max-width: 640px;
  max-height: 85dvh;
  margin: 0 auto;
  padding: 18px 12px calc(12px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 12px 12px 0 0;
  background: #fff;
  color: var(--ink);
}
.sheet[open] { animation: sheet-in 0.18s ease-out; }
.sheet::backdrop { background: rgb(15 15 15 / 0.4); }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }

.sheet-title { margin: 0 8px; font-size: 18px; font-weight: 600; line-height: 1.3; }
.sheet-sub { margin: 2px 8px 0; font-size: 14px; color: var(--muted); }
.menu-label { margin: 18px 8px 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.menu { display: grid; }
.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: none;
}
.menu-item:active, .menu-item[aria-current] { background: var(--hover); }
.check { width: 18px; height: 18px; color: var(--ink); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 4px 12px rgb(15 15 15 / 0.15);
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .sheet[open], .icon-btn.is-busy svg { animation: none; }
  .toast { transition: none; }
}
