:root {
  color-scheme: light dark;
  --bg: #f4f5ef; --surface: #fff; --soft: #e9ede3; --line: #dde3d7;
  --text: #1d2b23; --muted: #5f6d64;
  --accent: #2f6b4c; --on-accent: #fff;
  --soon: #855300; --soon-bg: #fdefd3;
  --late: #a93a28; --late-bg: #fbe3dd;
  font: 16px/1.45 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151b17; --surface: #1e2621; --soft: #29332c; --line: #35413a;
    --text: #e6eee7; --muted: #9dab9f;
    --accent: #8fcca5; --on-accent: #12291c;
    --soon: #f2c274; --soon-bg: #42341d;
    --late: #f3a08e; --late-bg: #472822;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; }
h1, h2, p { margin: 0; }
h1 { font-size: 30px; line-height: 1.15; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  min-height: 46px; padding: 10px 17px; border: 0; border-radius: 14px;
  background: var(--soft); font-weight: 600; cursor: pointer;
}
button:disabled { opacity: .55; cursor: wait; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input, select, textarea {
  display: block; width: 100%; min-width: 0; min-height: 48px; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
}
label { display: block; min-width: 0; margin-top: 14px; color: var(--muted); font-size: 14px; font-weight: 600; }
label > input, label > select, label > textarea { margin-top: 6px; font-size: 16px; font-weight: 400; color: var(--text); }

.primary { background: var(--accent); color: var(--on-accent); }
.wide { width: 100%; margin-top: 18px; }
.link { padding: 8px; background: none; color: var(--accent); }
.icon { flex: none; width: 46px; padding: 0; border-radius: 50%; }
.muted { color: var(--muted); }
.error { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--late-bg); color: var(--late); }

.center {
  min-height: 100dvh; padding: 24px 16px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; text-align: center;
}
.auth-card { width: 100%; max-width: 390px; padding: 30px 26px; border-radius: 28px; background: var(--surface); }
.auth-card h1 { margin: 12px 0 4px; }
.auth-card form { margin-top: 18px; text-align: left; }
.auth-card > .link { margin-top: 10px; }

.shell { max-width: 700px; margin: auto; padding: 0 16px calc(90px + env(safe-area-inset-bottom)); }
header { display: flex; align-items: center; justify-content: space-between; padding: calc(16px + env(safe-area-inset-top)) 0 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-size: 21px; font-weight: 750; }
.heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 24px 0; }
.heading p { min-height: 23px; margin-top: 5px; }

nav { display: flex; gap: 6px; overflow-x: auto; padding: 3px; scrollbar-width: none; }
nav button { flex: none; padding: 8px 13px; background: none; color: var(--muted); }
nav button[aria-pressed=true] { background: var(--accent); color: var(--on-accent); }
nav span { margin-left: 3px; opacity: .75; font-weight: 400; }
#search { margin-top: 12px; }

.group h2 { margin: 24px 4px 8px; color: var(--muted); font-size: 14px; }
.list { margin: 0; padding: 0; list-style: none; border-radius: 20px; background: var(--surface); overflow: hidden; }
.item { display: flex; align-items: center; padding-right: 12px; }
.item + .item { border-top: 1px solid var(--line); }
.open {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 0; background: none; text-align: left; font-weight: 400;
}
.open:focus-visible { outline-offset: -3px; }
.emoji { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--soft); font-size: 25px; }
.info { flex: 1; min-width: 0; }
.name { display: block; font-weight: 650; overflow-wrap: anywhere; }
.details { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 8px; margin-top: 3px; color: var(--muted); font-size: 13px; }
.badge { padding: 2px 8px; border-radius: 8px; background: var(--soft); white-space: nowrap; }
.badge.soon { background: var(--soon-bg); color: var(--soon); }
.badge.late { background: var(--late-bg); color: var(--late); }
.eat { color: var(--accent); font-size: 20px; }
.empty { padding: 64px 20px; text-align: center; }
.empty .big { display: block; margin-bottom: 12px; font-size: 56px; }
.empty p { margin-top: 5px; }

dialog {
  width: calc(100% - 32px); max-width: 460px; max-height: calc(100dvh - 32px); padding: 22px;
  border: 0; border-radius: 28px; background: var(--bg); color: var(--text);
}
dialog::backdrop { background: #0c140f80; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { font-size: 22px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
fieldset { min-width: 0; margin: 14px 0 0; padding: 0; border: 0; }
legend { padding: 0 0 6px; color: var(--muted); font-size: 14px; font-weight: 600; }
.segmented { display: flex; gap: 8px; }
.segmented label { position: relative; flex: 1; margin: 0; }
.segmented input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.segmented span { display: grid; place-items: center; min-height: 48px; padding: 6px; border-radius: 14px; background: var(--surface); text-align: center; }
.segmented input:checked + span { background: var(--accent); color: var(--on-accent); }
.segmented input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button { min-height: 36px; padding: 6px 11px; font-size: 14px; }
#other-ways { display: block; margin: 6px auto 0; }
.draft { padding-bottom: 14px; border-bottom: 1px solid var(--line); }

#toast {
  position: fixed; z-index: 10; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom));
  width: fit-content; max-width: calc(100% - 32px); margin: auto; padding: 8px 10px 8px 18px;
  display: flex; align-items: center; gap: 12px; min-height: 54px;
  border-radius: 18px; background: var(--text); color: var(--bg);
}
#toast button { background: none; color: inherit; text-decoration: underline; }

@media (max-width: 560px) {
  h1 { font-size: 27px; }
  .heading { padding: 14px 0 22px; }
  /* The add button moves under the thumb */
  #add { position: fixed; z-index: 2; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); min-height: 54px; border-radius: 27px; box-shadow: 0 5px 18px #0003; }
  #toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  nav button { padding: 8px 10px; font-size: 14px; }
  dialog { width: 100%; max-width: none; max-height: 94dvh; margin: auto 0 0; border-radius: 26px 26px 0 0; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
}
