:root {
  --sprout-bg: #F2F7EC;
  --surface: #FFFFFF;
  --ink: #16341B;
  --ink-soft: #4A6150;
  --leaf: #3D8B2F;
  --leaf-deep: #2F6B23;
  --leaf-open: #CDE5B5;
  --leaf-closed: #E4E9DF;
  --line: #D5E2CB;
  --radish: #B8235A;
  --radish-soft: #FBE7EF;
  --danger: #A12A1E;
  --focus: #1B5FBF;
  --r-sm: 8px;
  --r-lg: 18px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--sprout-bg);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --sprout-bg: #0F1A10;
    --surface: #182619;
    --ink: #E6F1E0;
    --ink-soft: #A9BEA6;
    --leaf: #6DBA55;
    --leaf-deep: #8CCF74;
    --leaf-open: #2D4E26;
    --leaf-closed: #243026;
    --line: #2C3D2D;
    --radish: #F07AA6;
    --radish-soft: #3A1726;
    --danger: #F08A7E;
    --focus: #8AB4FF;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--sprout-bg); }
body { min-height: 100dvh; }
main { max-width: 32rem; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); outline: none; }
h1 { font-size: 1.75rem; line-height: 1.15; letter-spacing: -0.02em; margin: 8px 0 8px; }
h2 { font-size: 1.2rem; margin: 24px 0 8px; }
h3 { font-size: 1rem; margin: 0; }
p { margin: 0 0 12px; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.875rem; }
a { color: var(--leaf-deep); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px; }
.skip:focus { left: 8px; }
.loading { color: var(--ink-soft); padding: 40px 0; }

/* Brand bar */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; min-height: 44px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 750; font-size: 1.05rem; text-decoration: none; color: var(--ink); }
.brand img { width: 28px; height: 28px; }

/* Forms */
label { display: block; font-weight: 600; font-size: 0.95rem; margin: 14px 0 4px; }
.hint { display: block; font-weight: 400; color: var(--ink-soft); font-size: 0.85rem; }
input[type=text], input[type=tel], input[type=email], input[type=url], input[type=datetime-local], input[type=number], textarea, select {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: 11px 12px; min-height: 46px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--leaf); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--leaf) 30%, transparent); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--leaf); flex: none; }
.field-error { color: var(--danger); font-size: 0.875rem; margin-top: 4px; }
.code-input { font-size: 1.6rem !important; letter-spacing: 0.12em; text-transform: uppercase; text-align: center; font-weight: 700; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 650; font-size: 1rem;
  min-height: 48px; padding: 0 18px; border-radius: 999px; border: 1.5px solid transparent; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--leaf); color: #fff; }
.btn-primary:active { background: var(--leaf-deep); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-radish { background: var(--radish); color: #fff; }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.linkbtn { background: none; border: none; font: inherit; color: var(--leaf-deep); text-decoration: underline; padding: 8px 0; cursor: pointer; min-height: 44px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stack > * + * { margin-top: 10px; }

/* Event header */
.event-head { padding: 4px 0 12px; }
.event-head .meta { color: var(--ink-soft); font-size: 0.9rem; }

/* Tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs button { background: none; border: none; font: inherit; font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); padding: 10px 2px 12px; min-height: 56px; position: relative; cursor: pointer; }
.tabs button[aria-current=page] { color: var(--leaf-deep); }
.tabs button[aria-current=page]::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; border-radius: 0 0 3px 3px; background: var(--leaf); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--radish); color: #fff; font-size: 0.75rem; line-height: 20px; margin-left: 4px; }

/* People list */
.people { list-style: none; padding: 0; margin: 0; }
.person { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid var(--line);
  padding: 12px 2px; font: inherit; color: inherit; cursor: pointer; min-height: 64px; }
.person .who { flex: 1; min-width: 0; }
.person .name { font-weight: 650; }
.person .headline { color: var(--ink-soft); font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 44px; height: 44px; border-radius: 50%; flex: none; object-fit: cover; display: grid; place-items: center;
  background: var(--leaf-open); color: var(--leaf-deep); font-weight: 750; border: 2px solid var(--leaf); }
.avatar.lg { width: 84px; height: 84px; font-size: 1.6rem; border-width: 3px; }
.mini-leaves { display: flex; gap: 3px; margin-top: 3px; }
.mini-leaf { font-size: 0.7rem; font-weight: 700; padding: 1px 6px; border-radius: 10px 2px 10px 2px; background: var(--leaf-open); color: var(--leaf-deep); }
.pill { font-size: 0.75rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill.incoming { background: var(--radish-soft); color: var(--radish); }
.pill.outgoing { background: var(--leaf-closed); color: var(--ink-soft); }
.pill.accepted { background: var(--leaf-open); color: var(--leaf-deep); }
.pill.closed { background: var(--leaf-closed); color: var(--ink-soft); }
.empty { padding: 28px 4px; color: var(--ink-soft); }

/* The Lettuce Head: avatar ringed by Leaf toggles */
.head { position: relative; width: 288px; height: 288px; margin: 8px auto 4px; }
.head .center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.leaf-toggle { position: absolute; width: 84px; height: 84px; left: 50%; top: 50%; margin: -42px 0 0 -42px; border: none; background: none; padding: 0; cursor: pointer; color: var(--ink); }
.leaf-toggle svg { width: 100%; height: 100%; display: block; transition: transform .18s ease; }
.leaf-toggle .leaf-shape { fill: var(--leaf-closed); stroke: var(--line); stroke-width: 3; transition: fill .18s ease; }
.leaf-toggle .vein { stroke: var(--sprout-bg); stroke-width: 2; fill: none; opacity: .0; }
.leaf-toggle[aria-pressed=true] .leaf-shape { fill: var(--leaf-open); stroke: var(--leaf); }
.leaf-toggle[aria-pressed=true] .vein { opacity: .9; stroke: var(--surface); }
.leaf-toggle .glyph { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 0.95rem; pointer-events: none; }
.leaf-toggle .state { position: absolute; left: 0; right: 0; bottom: -16px; font-size: 0.7rem; font-weight: 700; text-align: center; color: var(--ink-soft); }
.leaf-toggle[aria-pressed=true] .state { color: var(--leaf-deep); }
.leaf-toggle[disabled] { opacity: .45; cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) { .leaf-toggle svg, .leaf-toggle .leaf-shape { transition: none; } }
.leaf-legend { text-align: center; color: var(--ink-soft); font-size: 0.875rem; margin: 20px 0 8px; }

/* Panels and sheets */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; margin: 12px 0; }
.panel.incoming { border-color: var(--radish); }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 25, 12, 0.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 32rem; border-radius: 22px 22px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92dvh; overflow: auto; }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: -8px auto 12px; }
.share-list { list-style: none; padding: 0; margin: 8px 0 14px; }
.share-list li { border-bottom: 1px solid var(--line); }
.share-list label { margin: 0; padding: 12px 0; font-weight: 600; }
.exchange-note { background: var(--sprout-bg); border-radius: var(--r-sm); padding: 10px 12px; font-size: 0.9rem; }

/* Connected cards */
.conn { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; margin: 12px 0; }
.conn-top { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.handoffs { display: grid; gap: 8px; }
.handoff { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 48px; padding: 0 14px; border-radius: 12px;
  background: var(--sprout-bg); color: var(--ink); text-decoration: none; font-weight: 600; border: 1px solid var(--line); }
.handoff span:last-child { color: var(--ink-soft); font-weight: 500; font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }

/* Organizer */
.code-display { font-size: 2.4rem; font-weight: 800; letter-spacing: 0.08em; text-align: center; margin: 4px 0; font-variant-numeric: tabular-nums; }
.qr { display: grid; place-items: center; background: #fff; border-radius: var(--r-lg); padding: 14px; margin: 8px auto; width: fit-content; }
.qr img { width: 220px; height: 220px; image-rendering: pixelated; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 1.5rem; }
.stat span { color: var(--ink-soft); font-size: 0.85rem; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { font: inherit; font-weight: 600; background: none; border: none; padding: 10px 14px; min-height: 44px; color: var(--ink); cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--leaf); color: #fff; }

#toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--sprout-bg);
  padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 0.9rem; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); z-index: 30; }
#toast.show { opacity: 1; }
.banner { background: var(--radish-soft); color: var(--ink); border-left: 4px solid var(--radish); padding: 10px 12px; border-radius: var(--r-sm); margin: 8px 0; }
.offline { background: var(--leaf-closed); }
hr { border: none; border-top: 1px solid var(--line); margin: 24px 0; }
