:root {
  --bg: #f6f4ef;
  --card: #fffdf9;
  --ink: #23201c;
  --muted: #7b7469;
  --line: #e4ded2;
  --accent: #2f6f4e;
  --accent-soft: #e4efe7;
  --warn: #b4541f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(35, 32, 28, .05), 0 8px 24px rgba(35, 32, 28, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --card: #201e1b;
    --ink: #ece8e1;
    --muted: #9d968a;
    --line: #34302a;
    --accent: #6bbf90;
    --accent-soft: #22322a;
    --warn: #e08a54;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: 78px; }

a { color: var(--accent); }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 14px;
}

/* ---- header ---- */

header.app {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

header.app .inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

header.app h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 650;
  letter-spacing: -.01em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.who {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px 4px 5px;
  font-size: 13px;
  cursor: pointer;
  color: inherit;
}

/* ---- cards ---- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 15px;
  margin: 14px 0;
}

.card h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 650;
}

.card h3 { font-size: 16px; margin: 0 0 4px; font-weight: 650; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap-row { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.hidden { display: none !important; }

/* ---- forms ---- */

input, select, textarea, button {
  font-family: inherit;
  font-size: 16px;
  color: inherit;
}

input[type=text], input[type=tel], input[type=date], input[type=password], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
}

textarea { resize: vertical; min-height: 70px; }

label.field { display: block; }
label.field > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}

button {
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 10px 14px;
  font-weight: 600;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.ghost { background: transparent; }

button.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

button.danger { color: var(--warn); }

button:disabled { opacity: .5; cursor: default; }

.err {
  color: var(--warn);
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}

/* ---- nav ---- */

nav.tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

nav.tabs .inner {
  max-width: 720px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

nav.tabs button {
  border: none;
  background: none;
  border-radius: 0;
  padding: 9px 2px 11px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

nav.tabs button .ic { font-size: 19px; line-height: 1; }
nav.tabs button[aria-current="true"] { color: var(--accent); }

/* ---- people chips ---- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 10px 3px 4px;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: inline-block;
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

/* ---- calendar ---- */

.month + .month { margin-top: 20px; }
.month h3 { margin: 0 0 8px; font-size: 15px; }

.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.grid .dow {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  font-weight: 650;
  padding-bottom: 2px;
}

.day {
  aspect-ratio: 1 / 1.12;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  padding: 3px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  font-size: 12px;
  cursor: pointer;
  overflow: hidden;
}

.day.empty { border: none; background: none; cursor: default; }
.day.out { opacity: .38; }
.day.today { border-color: var(--accent); border-width: 2px; }
.day .num { font-weight: 650; line-height: 1.1; }
.day .dots { display: flex; flex-wrap: wrap; gap: 2px; }
.day .dots .dot { width: 7px; height: 7px; }
.day .bin {
  height: 4px;
  border-radius: 2px;
  margin-top: auto;
}

.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.legend .chip { font-size: 12px; }

/* ---- lists ---- */

.item {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: none; }

.check {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 2px solid var(--line);
  background: var(--bg);
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: transparent;
  padding: 0;
}
.check.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.week-head {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin: 16px 0 2px;
}
.week-head.current { color: var(--accent); }

.bin-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.bin-row:last-child { border-bottom: none; }
.bin-swatch { width: 10px; height: 34px; border-radius: 4px; flex: 0 0 auto; }
.bin-row.soon { background: var(--accent-soft); border-radius: 8px; padding: 10px 8px; }

/* ---- modal ---- */

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 15, .55);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal {
  background: var(--card);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 18px 16px calc(22px + env(safe-area-inset-bottom));
}

@media (min-width: 560px) {
  .modal-bg { align-items: center; padding: 20px; }
  .modal { border-radius: 18px; }
}

.modal h2 { font-size: 17px; margin: 0 0 12px; text-transform: none; letter-spacing: 0; color: var(--ink); }

/* ---- login ---- */

.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 21px; margin: 0 0 4px; }
