:root {
  --bg: #fff8f1;
  --surface: #ffffff;
  --surface-2: #fdf0e4;
  --text: #3b2a22;
  --muted: #8a7366;
  --border: #f0dfd0;
  --accent: #e8603c;
  --accent-strong: #c94a28;
  --accent-soft: #fde3d8;
  --green: #3f8f4a;
  --green-soft: #e1f2e1;
  --danger: #c0392b;
  --radius: 18px;
  --shadow: 0 1px 2px rgb(59 42 34 / 6%), 0 4px 16px rgb(59 42 34 / 6%);
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1714;
    --surface: #2a221e;
    --surface-2: #332924;
    --text: #f6ebe3;
    --muted: #b49e91;
    --border: #3e322c;
    --accent: #f07a55;
    --accent-strong: #ff9470;
    --accent-soft: #4a2c22;
    --green: #7cc784;
    --green-soft: #22382a;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent-strong); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 .75rem; }
[hidden] { display: none !important; }

/* Layout */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
}
.page--with-nav { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar__actions { display: flex; align-items: center; gap: 8px; }
.topbar__me { text-decoration: none; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; min-width: 0; }
.brand__logo { font-size: 1.4rem; }
.brand__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav__link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: .72rem;
  font-weight: 600;
}
.nav__icon { font-size: 1.3rem; filter: grayscale(1); opacity: .7; }
.nav__link--active { color: var(--accent-strong); }
.nav__link--active .nav__icon { filter: none; opacity: 1; }
@media (min-width: 720px) {
  .nav { inset: auto 50% 16px auto; transform: translateX(50%); width: 560px; border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow); padding: 0 12px; }
}

/* Components */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card__header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card__title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1.15rem; }
.card__emoji { font-size: 1.5rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-strong); }
.btn--ghost { background: transparent; color: var(--accent-strong); border-color: var(--border); }
.btn--ghost:hover { background: var(--accent-soft); }
.btn--soft { background: var(--accent-soft); color: var(--accent-strong); }
.btn--soft:hover { background: var(--accent-soft); filter: brightness(.97); }
.btn--small { min-height: 34px; padding: 6px 12px; font-size: .875rem; }
.btn--block { width: 100%; }
.btn--danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-link { background: none; border: 0; padding: 4px; color: var(--muted); font: inherit; cursor: pointer; }
.btn-link:hover { color: var(--danger); }
form.inline { display: inline; }

.flash { padding: 12px 16px; border-radius: 14px; font-weight: 600; margin-bottom: 16px; animation: flash-in .2s ease-out; }
.flash--notice { background: var(--green-soft); color: var(--green); }
.flash--alert { background: var(--accent-soft); color: var(--danger); }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } }

.avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: hsl(var(--hue) 70% 85%);
  color: hsl(var(--hue) 50% 25%);
  font-weight: 700;
  flex: none;
}
.avatar--sm { width: 28px; height: 28px; font-size: .7rem; }
.avatar--md { width: 40px; height: 40px; font-size: .9rem; }
.avatars { display: inline-flex; }
.avatars .avatar { margin-left: -6px; border: 2px solid var(--surface); }
.avatars .avatar:first-child { margin-left: 0; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
}
.chip--green { background: var(--green-soft); color: var(--green); }
.chip--accent { background: var(--accent-soft); color: var(--accent-strong); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }

/* Day page */
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.daynav h1 { margin: 0; text-align: center; }
.daynav__sub { display: block; font-size: .85rem; font-weight: 500; color: var(--muted); }
.daynav__arrow { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); text-decoration: none; font-size: 1.1rem; color: var(--text); }

.plate {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--green-soft);
}
.plate + .plate { margin-top: 8px; }
.plate__name { font-weight: 700; font-size: 1.05rem; }
.plate__meta { font-size: .8rem; color: var(--muted); }
.plate__body { flex: 1; min-width: 0; }

.suggestions { display: grid; gap: 8px; margin-top: 4px; }
.suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 14px;
}
.suggestion__body { flex: 1; min-width: 0; }
.suggestion__name { font-weight: 650; }
.suggestion__why { font-size: .78rem; color: var(--muted); }

.section-label { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

details.more > summary { cursor: pointer; color: var(--accent-strong); font-weight: 600; list-style: none; padding: 6px 0; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary { margin-bottom: 8px; }

.poll-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--text);
  text-decoration: none;
  margin-bottom: 8px;
}
.poll-banner__body { flex: 1; }

/* Polls */
.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
  font: inherit;
  color: inherit;
  text-align: left;
}
button.option { cursor: pointer; }
button.option:hover { border-color: var(--accent); }
.option + .option, form + form .option { margin-top: 8px; }
.option--mine { border-color: var(--accent); }
.option--winner { border-color: var(--green); }
.option__bar { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); z-index: 0; transition: width .4s ease; }
.option--winner .option__bar { background: var(--green-soft); }
.option > *:not(.option__bar) { position: relative; z-index: 1; }
.option__name { flex: 1; font-weight: 650; }
.option__count { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Forms */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label, .label { font-weight: 650; font-size: .9rem; }
.hint { font-size: .8rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* prevents iOS zoom */
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .option:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
}
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.check input { accent-color: var(--accent); }
.pick-list { display: grid; gap: 6px; max-height: 50vh; overflow-y: auto; }
.pick-list .check { border-radius: 12px; justify-content: flex-start; }
.errors { background: var(--accent-soft); color: var(--danger); border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; }
.errors ul { margin: 0; padding-left: 18px; }
.inline-form { display: flex; gap: 8px; }
.inline-form > input, .inline-form > select { flex: 1; min-width: 0; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list__item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list__item:last-child { border-bottom: 0; }
.list__body { flex: 1; min-width: 0; }
.list__title { font-weight: 650; text-decoration: none; color: var(--text); }
.list__meta { font-size: .8rem; color: var(--muted); }

.timeline-day { margin-bottom: 16px; }
.timeline-day h2 { font-size: .95rem; color: var(--muted); margin-bottom: 6px; }

.empty { text-align: center; padding: 32px 16px; }
.empty__emoji { font-size: 3rem; display: block; margin-bottom: 8px; }

.share-link { font-family: ui-monospace, monospace; font-size: .8rem; word-break: break-all; background: var(--surface-2); padding: 10px 12px; border-radius: 10px; user-select: all; }

/* Landing */
.hero { text-align: center; padding: 32px 0 8px; }
.hero__logo { width: 96px; height: 96px; border-radius: 24px; box-shadow: var(--shadow); }
.hero h1 { font-size: 2rem; margin-top: 16px; }
.features { display: grid; gap: 12px; margin: 24px 0; }
.feature { display: flex; gap: 12px; align-items: flex-start; }
.feature__icon { font-size: 1.6rem; }

.install-hint {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  font-size: .9rem;
}
.install-hint p { margin: 0; flex: 1; }
.install-hint .btn--ghost { color: var(--bg); border-color: color-mix(in srgb, var(--bg) 40%, transparent); }
.auth { max-width: 420px; margin: 0 auto; }
