@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/atkinson-next.woff2) format('woff2');
}
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url(fonts/bricolage.woff2) format('woff2');
}

/* ---------- tokens ---------- */
:root {
  --bg: #F6F4F1;
  --surface: #FFFFFF;
  --ink: #1E1A1B;
  --muted: #5E5557;
  --line: #E4DEDA;
  --field: #8C8285;
  --empty: #E6DFDB;
  --accent: #7B1E3A;
  --accent-ink: #7B1E3A;
  --on-accent: #FFFFFF;
  --accent-soft: #F6E9ED;
  --danger: #B3261E;
  --shadow: 0 1px 2px rgba(30, 26, 27, .06), 0 2px 8px rgba(30, 26, 27, .04);
  --s1: #E3A33B; /* pranzo */
  --s2: #C8642A; /* pomeriggio */
  --s3: #7B1E3A; /* cena */
  --s4: #2B2440; /* dopo cena */
  --font: 'Atkinson Hyperlegible Next', 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Bricolage Grotesque', var(--font);
  --open: #2E8B57;
  color-scheme: light;
}
:root[data-app="campoblenio"] {
  --bg: #F4F5F1;
  --line: #DEE3DC;
  --empty: #E1E6DF;
  --accent: #2F5D46;
  --accent-ink: #2F5D46;
  --accent-soft: #E4EEE7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141112;
    --surface: #211C1D;
    --ink: #F3ECEC;
    --muted: #B9ADAF;
    --line: #3A3233;
    --field: #857A7C;
    --empty: #3A3233;
    --accent: #A8405C;
    --accent-ink: #F0A3B5;
    --accent-soft: #3A2129;
    --danger: #FF8A80;
    --shadow: none;
    --s3: #D0587A;
    --s4: #8F82D6;
    --open: #4CC38A;
    color-scheme: dark;
  }
  :root[data-app="campoblenio"] {
    --bg: #111412;
    --surface: #1C211E;
    --line: #313A34;
    --empty: #313A34;
    --accent: #3B7558;
    --accent-ink: #94D3B1;
    --accent-soft: #20342A;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 17px/1.45 var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
a { color: var(--accent-ink); }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.015em; line-height: 1.15; }
h1 { font-size: 28px; margin: 4px 0 14px; }
h2 { font-size: 20px; margin: 22px 0 10px; }
.muted { color: var(--muted); }
.pad { padding: 16px 20px; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent-ink); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.skip { position: absolute; left: 12px; top: -60px; background: var(--surface); color: var(--ink); padding: 10px 14px; border-radius: 10px; z-index: 50; }
.skip:focus { top: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 6px max(16px, env(safe-area-inset-left));
  background: var(--bg);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-height: 44px; min-width: 0; }
.brand img { border-radius: 8px; flex: none; }
.brand span { font-family: var(--display); font-weight: 700; font-size: 21px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#nav { display: flex; gap: 6px; align-items: center; flex: none; }
.navbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; height: 44px; padding: 0 12px; border-radius: 22px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 700 15px var(--font); text-decoration: none;
}
.navbtn.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.navbtn svg { flex: none; }

main { max-width: 640px; margin: 0 auto; padding: 0 12px 24px; outline: none; }

/* ---------- controls ---------- */
button, .btn {
  font: 600 16px var(--font); border-radius: 14px; border: 1.5px solid var(--field); background: var(--surface); color: var(--ink);
  padding: 0 18px; cursor: pointer; min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
button.primary, .btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }
button.big, .btn.big { min-height: 56px; font-size: 17px; border-radius: 16px; width: 100%; }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.ghost { border-color: transparent; background: transparent; }
button:disabled { opacity: .55; cursor: default; }
.iconbtn { width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; border-radius: 12px; background: transparent; color: var(--ink); }

input, textarea, select {
  font: 400 17px var(--font); width: 100%; min-height: 52px; padding: 12px 14px; border-radius: 14px;
  border: 1.5px solid var(--field); background: var(--surface); color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent-ink); box-shadow: 0 0 0 1.5px var(--accent-ink); }
textarea { min-height: 80px; resize: vertical; }
label, .label { display: block; margin: 16px 0 6px; font-weight: 600; font-size: 15px; }
legend.label { padding: 16px 0 0; margin: 0 0 6px; }
.opt { font-weight: 400; color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 0 0 auto; }
.grow { flex: 1 1 0; min-width: 0; }
.err { color: var(--danger); margin-top: 12px; min-height: 1em; font-weight: 600; }
.err:empty { margin: 0; min-height: 0; }

.card { background: var(--surface); border-radius: 20px; padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.narrow { max-width: 440px; margin: 12px auto; }

/* toggle chips (real checkboxes) */
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggle { position: relative; display: block; margin: 0; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.toggle span {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 14px; border-radius: 14px;
  border: 1.5px solid var(--field); background: var(--surface); font-weight: 600; font-size: 16px; cursor: pointer;
}
.toggle span::before { content: ''; width: 12px; height: 12px; border-radius: 6px; background: var(--c, var(--accent)); flex: none; }
.toggle span::after { content: ''; margin-left: auto; width: 10px; height: 18px; border: solid transparent; border-width: 0 3px 3px 0; transform: rotate(45deg) translate(-2px, -2px); }
.toggle input:checked + span { border: 2px solid var(--accent-ink); background: var(--accent-soft); }
.toggle input:checked + span::after { border-color: var(--accent-ink); }
.toggle input:focus-visible + span { outline: 3px solid var(--accent-ink); outline-offset: 2px; }
.toggle input:disabled + span { opacity: .6; cursor: default; }
.toggle.all { grid-column: 1 / -1; }
.toggle.all span { justify-content: center; font-weight: 700; border-style: dashed; }
.toggle.all span::before { width: 28px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--s1), var(--s2), var(--s3), var(--s4)); }
.toggle.all span::after { margin-left: 0; }
.toggle.all input:checked + span { border-style: solid; }

/* switch */
.switch { display: flex; align-items: center; gap: 12px; min-height: 48px; margin: 12px 0 0; font-weight: 600; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; min-height: 0; padding: 0; border-radius: 15px; background: var(--field); border: 0; position: relative; flex: none; cursor: pointer; transition: background .15s; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 12px; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(20px); }
.switch input:focus-visible { outline: 3px solid var(--accent-ink); outline-offset: 2px; }

/* ---------- month view ---------- */
.month-head { display: flex; align-items: center; gap: 2px; padding: 4px 0 8px 8px; }
.month-head h1 { margin: 0; flex: 1; font-size: 24px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 6px; border-radius: 20px;
  background: var(--surface); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; font-weight: 700; font-size: 15px; white-space: nowrap; line-height: 1;
}
.chip b { min-width: 28px; height: 28px; padding: 0 6px; border-radius: 14px; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font-size: 14px; }
.chip.c-inv b { background: var(--open); color: #fff; }
.chip.c-shop b { background: #C77D12; color: #fff; }
.chip.late b { background: var(--danger); color: #fff; }
.chip:active { transform: scale(.97); }
.cta:not([hidden]) { animation: enter .2s ease-out; }
.month-head h1 .y { color: var(--muted); font-weight: 600; }
.month-head .today { font-size: 14px; min-height: 36px; padding: 0 12px; border-radius: 18px; border-width: 1px; margin-right: 4px; }
.calcard { background: var(--surface); border-radius: 22px; padding: 10px 6px 12px; box-shadow: var(--shadow); }
.dows, .week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); column-gap: 2px; }
.dows abbr { text-decoration: none; text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); padding: 4px 0 6px; }
.week { row-gap: 3px; padding-bottom: 3px; }
.day {
  grid-row: 1; height: 54px; min-height: 0; padding: 0; border: 0; border-radius: 14px; background: transparent; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; font: 500 17px/1 var(--font);
}
.day.other { color: var(--muted); opacity: .75; }
.day { position: relative; }
.day .num { width: 30px; height: 30px; margin-bottom: -4px; border-radius: 15px; display: grid; place-items: center; }
.stays .day .num { margin-bottom: 0; }
.day.mine .num { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.day.joined .num { background: var(--open); color: #fff; font-weight: 700; }
.legend li.lg-joined::before { width: 14px; height: 14px; border-radius: 7px; background: var(--open); }
.pill.rel.joined { background: var(--open); color: #fff; }
.item.joined { box-shadow: inset 5px 0 0 var(--open), var(--shadow); }
.day.ask::after {
  content: ''; position: absolute; inset: 1px; border-radius: 14px; border: 2.5px solid var(--open); pointer-events: none;
  animation: ask-pulse 1.8s ease-in-out infinite;
}
@keyframes ask-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .25; transform: scale(.9); } }
@media (prefers-reduced-motion: reduce) { .day.ask::after { animation: none; border-style: dashed; } }
.legend li.lg-mine::before { width: 14px; height: 14px; border-radius: 7px; background: var(--accent); }
.legend li.lg-ask::before { width: 12px; height: 12px; border-radius: 4px; background: transparent; border: 2.5px solid var(--open); animation: ask-pulse 1.8s ease-in-out infinite; }
.pill.rel::before { display: none; }
.pill.rel.mine { background: var(--accent); color: var(--on-accent); }
.pill.rel.ask { background: var(--open); color: #fff; }
.item.mine { box-shadow: inset 5px 0 0 var(--accent), var(--shadow); }
.item.ask { box-shadow: inset 0 0 0 2.5px var(--open), var(--shadow); }
.day.today { box-shadow: inset 0 0 0 1.5px var(--ink); font-weight: 700; }
.day[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent-ink); font-weight: 700; }
.ind { display: flex; gap: 2px; height: 5px; }
.ind i { width: 8px; height: 5px; border-radius: 3px; background: var(--empty); }
.day.other .ind i { background: transparent; }
.ind i.on { background: var(--c); }
.ind i.tent { opacity: .45; }
.ind.full i { display: none; }
.ind.full::before { content: ''; width: 38px; height: 5px; border-radius: 3px; background: linear-gradient(90deg, var(--s1), var(--s2), var(--s3), var(--s4)); }
.ind.full.tent::before { opacity: .45; }
.stays .day { height: 42px; gap: 0; }
.bar {
  height: 20px; border-radius: 10px; background: var(--c); color: #fff; font-size: 12px; font-weight: 700; line-height: 20px;
  padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 0; min-height: 0; justify-content: flex-start;
}
.bar.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.bar.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.bar.tent { background: repeating-linear-gradient(135deg, var(--c) 0 6px, color-mix(in srgb, var(--c) 70%, #fff) 6px 12px); }
.stays .week .day, .stays .week .bar { position: relative; z-index: 1; }
.band { z-index: 0; border-radius: 14px 14px 10px 10px; background: color-mix(in srgb, var(--c) 26%, transparent); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 55%, transparent); pointer-events: none; }
.band.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.band.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.band.tent { background: color-mix(in srgb, var(--c) 14%, transparent); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 8px 10px 0; font-size: 12px; color: var(--muted); margin: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend li::before { content: ''; width: 16px; height: 6px; border-radius: 3px; background: var(--c); }
.legend li.full::before { width: 26px; background: linear-gradient(90deg, var(--s1), var(--s2), var(--s3), var(--s4)); }

.agenda { padding: 18px 4px 0; }
.agenda h2 { margin: 0; min-width: 0; }
.dayhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 4px 10px; min-height: 44px; }
.daynew { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 40px; padding: 0 16px 0 12px; border-radius: 20px; font-weight: 700; font-size: 15px; box-shadow: var(--shadow); animation: enter .2s ease-out; }
.daynew svg { width: 18px; height: 18px; }
.dayfull { flex: none; font-size: 14px; font-weight: 600; color: var(--muted); }
.list { display: grid; gap: 10px; }
.item {
  display: flex; gap: 14px; align-items: stretch; text-align: left; width: 100%;
  background: var(--surface); border: 0; border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow);
  font: inherit; color: inherit; min-height: 0; justify-content: flex-start;
}
.item .stripe { width: 6px; border-radius: 3px; background: var(--c); flex: none; }
.item .what { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.item .t { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.item .who { color: var(--muted); font-size: 15px; }
.item .who b.host { color: var(--ink); font-weight: 700; }
.item .who.maybe { font-size: 14px; }
.item .note { color: var(--muted); font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); }
.pill::before { content: ''; width: 8px; height: 8px; border-radius: 4px; background: var(--c); }
.pill.full::before { width: 18px; background: linear-gradient(90deg, var(--s1), var(--s2), var(--s3), var(--s4)); }
.pill.tent { background: transparent; border: 1.5px dashed var(--field); color: var(--muted); }
.pill.tent::before { display: none; }
.pill.open { background: var(--accent); color: var(--on-accent); }
.pill.open::before { display: none; }
.empty { color: var(--muted); padding: 4px 4px 0; }
.monthlist { margin-top: 26px; }
.monthlist summary { cursor: pointer; font-family: var(--display); font-weight: 700; font-size: 18px; padding: 10px 4px; min-height: 44px; list-style-position: inside; }

.cta {
  position: sticky; bottom: 0; z-index: 4; margin: 18px -12px 0;
  padding: 12px max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: linear-gradient(to bottom, transparent, var(--bg) 22%);
}

/* read-only booking */
.details { padding-top: 10px; }
.details .dt { font-size: 22px; font-weight: 700; margin: 12px 0 6px; overflow-wrap: anywhere; }
.details dl { margin: 0; display: grid; gap: 2px; }
.details dt { font-size: 14px; font-weight: 700; color: var(--muted); margin-top: 12px; }
.details dd { margin: 0; font-size: 17px; }
.details .note { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- dialog: bottom sheet on phones ---------- */
dialog {
  border: 0; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(var(--vvh, 100dvh) * .92); border-radius: 24px;
  background: var(--surface); color: var(--ink); box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(20, 16, 17, .5); }
#dlg-body { padding: 10px 20px 20px; max-height: calc(var(--vvh, 100dvh) * .92); overflow: auto; overscroll-behavior: contain; scroll-padding: 24px 0 96px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0 2px; }
.sheet-head h2 { margin: 0; font-size: 24px; }
.sheet-head .iconbtn { background: color-mix(in srgb, var(--ink) 7%, transparent); border-radius: 22px; flex: none; }
.actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.actions > * { flex: 1 1 0; }
.actions .primary { flex-grow: 2; }
.actions .danger { flex-basis: 100%; }
@media (max-width: 600px) {
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 var(--kb, 0px); border-radius: 24px 24px 0 0; transition: margin-bottom .15s; }
  dialog::before { content: ''; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 10px auto 0; }
  #dlg-body { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
}

#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600;
  opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100vw - 32px); z-index: 60;
}
#toast.show { opacity: 1; }

/* ---------- login ---------- */
.hero {
  margin: 0 -12px; padding: max(56px, calc(env(safe-area-inset-top) + 40px)) 28px 34px; border-radius: 0 0 32px 32px;
  background: var(--accent); color: var(--on-accent); display: flex; flex-direction: column; gap: 10px;
}
.hero img { width: 64px; height: 64px; border-radius: 18px; box-shadow: 0 0 0 2px rgba(255, 255, 255, .25); }
.hero h1 { margin: 6px 0 0; font-size: 36px; }
.hero p { margin: 0; font-size: 17px; opacity: .95; }
.login { padding: 12px 12px 0; max-width: 440px; margin: 0 auto; }
.pw { position: relative; }
.pw input { padding-right: 56px; }
.pw .iconbtn { position: absolute; right: 4px; top: 4px; color: var(--muted); }
.hint { text-align: center; color: var(--muted); font-size: 15px; margin: 18px 0 0; }
.install { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); margin-top: 22px; font-size: 15px; }
.install svg { color: var(--accent-ink); flex: none; }
.install .grow { line-height: 1.35; }
.install button { min-height: 44px; padding: 0 14px; font-size: 15px; }

/* ---------- admin ---------- */
.tabs { display: flex; gap: 6px; margin: 0 4px 16px; padding: 4px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); }
.tabs a { flex: 1; text-align: center; min-height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 12px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 15px; }
.tabs a.on { background: var(--accent); color: var(--on-accent); }
.hist { background: var(--surface); border-radius: 16px; padding: 12px 16px; box-shadow: var(--shadow); border-left: 5px solid var(--accent); display: flex; flex-direction: column; gap: 3px; overflow-wrap: anywhere; }
.hist.delete { border-left-color: var(--danger); }
.hist.create { border-left-color: #3F7D4E; }
.hist .meta { color: var(--muted); font-size: 14px; }
.diff { margin: 6px 0 0; padding-left: 18px; font-size: 15px; display: grid; gap: 2px; }
.users { display: grid; gap: 10px; }
.user { background: var(--surface); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.user .name { font-size: 18px; font-weight: 700; }
.user .meta { color: var(--muted); font-size: 15px; }
.user .acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.user .acts button { min-height: 44px; font-size: 15px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); vertical-align: 2px; margin-left: 6px; }
.badge.off { background: transparent; border: 1px solid var(--field); color: var(--muted); }
.checks { display: grid; gap: 8px; }
.linkbox { word-break: break-all; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 15px; user-select: all; }

@media (min-width: 700px) {
  main { padding: 0 20px 32px; }
  .day { height: 64px; }
  .stays .day { height: 48px; }
  .top { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
}

/* ---------- admin mode ---------- */
:root[data-admin] { --accent: #B3261E; --accent-ink: #9C1F18; --accent-soft: #FBE7E5; --bg: #FBF3F2; }
.adminbar {
  display: flex; align-items: center; gap: 10px;
  margin: 0 12px 8px; padding: 8px 8px 8px 14px; border-radius: 14px;
  background: #B3261E; color: #FFFFFF; font-size: 15px;
}
.adminbar svg { flex: none; }
.adminbar button { min-height: 40px; padding: 0 14px; border-radius: 12px; border: 0; background: #FFFFFF; color: #9C1F18; font: 700 14px var(--font); cursor: pointer; }
.adminbar button:focus-visible { outline: 3px solid #FFFFFF; outline-offset: 2px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-admin] { --accent: #C9372C; --accent-ink: #FF9C92; --accent-soft: #3D1E1C; --bg: #1C1515; }
}

/* ---------- year list ---------- */
.yearcount { margin: -4px 4px 12px; }
.yearmonth { margin-bottom: 18px; }
.yearmonth h2 { font-family: var(--display); font-weight: 700; font-size: 19px; margin: 0 4px 10px; }
.yearmonth h2 .muted { font-family: var(--font); font-size: 15px; font-weight: 600; margin-left: 4px; }

/* ---------- bottom tab bar ---------- */
:root { --tabbar: 0px; }
body.tabs-on { --tabbar: calc(64px + max(16px, env(safe-area-inset-bottom))); }
body.tabs-on main { padding-bottom: calc(var(--tabbar) + 24px); }
body.tabs-on .cta { bottom: var(--tabbar); padding-bottom: 12px; }
body.tabs-on #toast { bottom: calc(var(--tabbar) + 90px); }
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 7; display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 0 env(safe-area-inset-right) max(16px, env(safe-area-inset-bottom)) env(safe-area-inset-left);
}
#tabs[hidden] { display: none; }
#tabs a {
  flex: 1 1 0; max-width: 128px; height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 12.5px; font-weight: 600;
}
#tabs a.on { color: var(--accent-ink); font-weight: 700; }
#tabs a.on svg { background: var(--accent-soft); border-radius: 12px; }
#tabs svg { width: 44px; height: 28px; padding: 3px 0; }

/* ---------- notes ---------- */
.notecard { background: var(--surface); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.notecard h2 { margin: 0; font-size: 19px; overflow-wrap: anywhere; }
.nbody { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.45; }
.nfoot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.nfoot .edit { min-height: 40px; padding: 0 10px; color: var(--accent-ink); font-weight: 700; }
.photos { display: flex; flex-wrap: wrap; gap: 8px; }
.photos .ph { position: relative; width: 96px; height: 96px; padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: var(--empty); min-height: 0; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .rm { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; min-height: 32px; padding: 0; border: 0; border-radius: 16px; background: rgba(0, 0, 0, .6); color: #fff; }
.photos .rm svg { width: 16px; height: 16px; }
.photos.edit:empty { display: none; }
.addph { margin-top: 8px; width: 100%; }
.bigphoto { width: 100%; height: auto; border-radius: 14px; display: block; margin-top: 10px; }

/* ---------- to-dos ---------- */
.todo { display: flex; align-items: flex-start; gap: 4px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 6px 8px; }
.todo .tick { width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; background: transparent; flex: none; margin-top: 2px; }
.todo .tick svg { width: 28px; height: 28px; border-radius: 14px; border: 2px solid var(--field); padding: 3px; color: transparent; box-sizing: border-box; }
.todo .tick[aria-checked="true"] svg { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.todo .tick:disabled { opacity: .45; }
.shoprow { align-items: center; }
.shoprow .tbody { padding: 10px 6px; }
.shoprow .sdel { width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--muted); flex: none; }
.shopadd { display: flex; gap: 8px; margin: 0 0 10px; }
.shopadd input { flex: 1; min-width: 0; margin: 0; }
.shopadd button { width: 52px; min-width: 52px; padding: 0; flex: none; }
.ideas { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; }
.ideas .idea { min-height: 36px; padding: 0 12px; border-radius: 18px; font-size: 14px; font-weight: 600; border: 1px dashed var(--field); background: transparent; color: var(--ink); }
.ideas .ideaedit { display: inline-flex; align-items: center; gap: 4px; border: 0; background: var(--accent); color: #fff; }
.ideabox { border: 1px solid var(--field); border-radius: 14px; padding: 10px 12px 12px; margin: 0 0 10px; }
.ideabox .muted { margin: 0 0 8px; font-size: 14px; }
.ideas .idea.editing, .ideas .ideanew { display: inline-flex; align-items: center; gap: 6px; border-style: solid; }
.ideas .idea.editing svg { color: var(--muted); }
.ideas .ideanew { color: var(--accent-ink); border-color: currentColor; }
.ideas .ideanew svg { width: 16px; height: 16px; }
.ideabox .big { margin-top: 12px; width: 100%; }
.tbadge.shopb { background: #C77D12; color: #fff; }
.shoprow.pending { box-shadow: inset 0 0 0 1.5px var(--field); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--field) 70%, transparent); }
.shoprow .wait { color: #A35F00; font-weight: 700; }
@media (prefers-color-scheme: dark) { .shoprow .wait { color: #F0B35A; } }
.shopwait { margin: 10px 4px 0; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); color: var(--ink); font-size: 14px; }
.sect { font-size: 18px; margin: 18px 4px 10px; }
.navrow { display: flex; align-items: center; gap: 12px; margin: 14px 0 0; padding: 14px 14px 14px 12px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; min-height: 64px; }
.navrow:active { transform: scale(.98); }
.navrow .navico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); flex: none; }
.navrow .navtxt { flex: 1; min-width: 0; display: grid; gap: 2px; }
.navrow .navtxt b { font-size: 17px; }
.navrow .navtxt .muted { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navrow .navn { min-width: 28px; height: 28px; padding: 0 8px; border-radius: 14px; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 14px; flex: none; }
.navrow > svg { color: var(--muted); flex: none; }
.backlink { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 8px 0 0; color: var(--accent-ink); font-weight: 700; text-decoration: none; }
.todo .tbody { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; border: 0; background: transparent; padding: 10px 6px; min-height: 0; }
.todo .t { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.todo .who, .todo .note { color: var(--muted); font-size: 15px; font-weight: 400; }
.todo .note { white-space: pre-wrap; overflow-wrap: anywhere; }
.todo.done .t { text-decoration: line-through; color: var(--muted); }
.donehead { font-size: 18px; margin: 26px 4px 10px; }
.icsbox { display: grid; gap: 10px; }
.icsbox .btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.icsbox p { margin: 6px 0 0; }
.linkbtn { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent-ink); text-decoration: underline; font: inherit; cursor: pointer; }
.donehead .count { color: var(--muted); font-weight: 600; font-size: 15px; margin-left: 4px; }
.searchbox { position: relative; margin: 0 4px 6px; }
.searchbox svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.searchbox input { padding-left: 46px; border-radius: 18px; -webkit-appearance: none; appearance: none; }
#res > .donehead:first-child { margin-top: 18px; }
mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; border-radius: 4px; padding: 0 1px; }

/* sheet buttons stay reachable while typing */
#dlg-body .actions { position: sticky; bottom: calc(-1 * max(20px, env(safe-area-inset-bottom))); z-index: 2; background: var(--surface); margin: 20px -20px 0; padding: 12px 20px max(20px, env(safe-area-inset-bottom)); box-shadow: 0 -1px 0 var(--line); }
@media (min-width: 601px) { #dlg-body .actions { bottom: -20px; padding-bottom: 20px; } }

/* ---------- upcoming bookings under the calendar ---------- */
.upcoming { margin-top: 26px; }
.upcoming h2 { font-family: var(--display); font-weight: 700; font-size: 20px; margin: 0 4px 12px; }
.upcoming #more { margin-top: 12px; }

.yearmonth { scroll-margin-top: 76px; }

.updbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar, 0px) + 12px); z-index: 61; max-width: 616px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 16px;
  background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}
.updbar button { min-height: 40px; border: 0; background: var(--accent); color: var(--on-accent); font-weight: 700; }

/* ---------- to-do deadlines + home banner ---------- */
.todo .due { font-size: 14px; font-weight: 700; color: var(--muted); }
.todo .due.soon { color: #A35F00; }
.todo .due.late { color: var(--danger); }
.todo.late { box-shadow: inset 4px 0 0 var(--danger), var(--shadow); }
.todobanner {
  display: flex; align-items: center; gap: 14px; margin: 4px 0 6px; padding: 12px 14px; border-radius: 18px;
  background: var(--surface); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; font-size: 16px; line-height: 1.3;
}
.todobanner .bignum {
  flex: none; width: 44px; height: 44px; border-radius: 22px; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); font: 700 20px var(--display);
}
.todobanner.late .bignum { background: var(--danger); }
.todobanner.late span span { color: var(--danger); font-weight: 700; }
.todobanner svg { color: var(--muted); flex: none; }
.todobanner.invite .bignum { background: var(--open); color: #fff; }
.todobanner.invite span span { color: var(--muted); }
article.invite { background: var(--surface); box-shadow: var(--shadow); border-radius: 18px; padding: 14px 16px; margin: 0 0 12px; }
article.invite .dt { font: 700 20px var(--display); margin: 0; }
article.invite .when { margin: 2px 0 8px; color: var(--muted); font-weight: 600; }
article.invite dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0 0 12px; }
article.invite dt { color: var(--muted); }
article.invite dd { margin: 0; }
.answers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.answers button { min-height: 48px; border-radius: 14px; font-weight: 700; padding: 0 6px; }
.answers button.on { color: #fff; border-color: transparent; }
.answers button.yes.on { background: #2E8B57; }
.answers button.maybe.on { background: #C98A1B; }
.answers button.no.on { background: var(--muted); }
.answers button:disabled { opacity: .45; }
.answers button.on:disabled { opacity: 1; }
article.invite { overflow: hidden; transition: height .5s ease, opacity .4s ease, margin .5s ease, padding .5s ease, transform .5s ease, background .3s; }
article.invite.a-yes { background: color-mix(in srgb, #2E8B57 14%, var(--surface)); }
article.invite.a-no { background: color-mix(in srgb, var(--muted) 14%, var(--surface)); }
article.invite .done { margin: 10px 0 0; font-weight: 700; text-align: center; animation: enter .25s ease-out; }
article.invite.a-yes .done { color: #2E8B57; }
article.invite.leaving { opacity: 0; transform: translateX(24px); margin-bottom: 0; padding-top: 0; padding-bottom: 0; }
.opensw { margin: 6px 0 2px; }
.opensw p { margin: 2px 0 0; }
#tabs a { position: relative; }
.tbadge {
  position: absolute; top: 6px; left: calc(50% + 6px); min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; line-height: 20px; text-align: center;
}
.tbadge.late { background: var(--danger); }
@media (prefers-color-scheme: dark) { .todo .due.soon { color: #F0B35A; } }

/* ---------- motion ---------- */
@keyframes enter { from { opacity: 0; transform: translateY(10px); } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop { 40% { transform: scale(1.25); } }
main.enter > * { animation: enter .24s cubic-bezier(.2, .8, .2, 1) both; }
main.enter > *:nth-child(2) { animation-delay: .03s; }
main.enter > *:nth-child(3) { animation-delay: .06s; }
dialog[open] { animation: fade-in .18s ease-out; }
dialog[open]::backdrop { animation: fade-in .2s ease-out; }
@media (max-width: 600px) { dialog[open] { animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1); } }
.todo .tick.pop svg { animation: pop .3s ease-out; background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.todo .tick svg { transition: background .15s, border-color .15s; }
#tabs a svg { transition: background .2s; }
button:active:not(:disabled), .btn:active, #tabs a:active, .item:active, .todobanner:active { transform: scale(.97); }
button, .btn, .item, .todobanner { transition: transform .1s; }
.gone { display: none !important; }
.snack {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar, 0px) + 88px); z-index: 62; max-width: 616px; margin: 0 auto; overflow: hidden;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 16px;
  background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); animation: enter .2s ease-out;
}
.snack button { min-height: 40px; border: 0; background: transparent; color: var(--bg); font-weight: 700; text-decoration: underline; }
.snack i { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--accent); transform-origin: left; animation: snack-time 5s linear forwards; }
@keyframes snack-time { to { transform: scaleX(0); } }
.todo .who b.anyone { color: var(--open); }
.archrow { margin-top: 14px; }
.shoprow.archived { align-items: flex-start; }
.archdot { width: 28px; height: 28px; margin: 2px 0 0; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--open); color: #fff; }
.archdot svg { width: 16px; height: 16px; }

/* Conteggi */
.countcard h2 { margin: 0 0 12px; font-size: 1.1rem; }
.countlist { display: grid; gap: 14px; margin-bottom: 10px; }
.countrow .ctop { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.countrow .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 8px; }
.countrow .cbar { height: 10px; border-radius: 6px; background: color-mix(in srgb, var(--c) 18%, transparent); margin-top: 6px; overflow: hidden; }
.countrow .cbar span { display: block; height: 100%; border-radius: 6px; background: var(--c); }
.countrow.srow { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid color-mix(in srgb, currentColor 10%, transparent); }
.countrow.srow strong { grid-column: 2; grid-row: 1 / 3; align-self: center; font-size: 1.05rem; }
.countlist.split { margin-top: 14px; gap: 0; }
.ctot { margin: 8px 0 0; }
.small { font-size: .88rem; }
.countcard .field { display: grid; gap: 6px; font-weight: 600; }
.extbox { grid-column: 1 / -1; margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--c) 12%, transparent); }
.extbox p { display: flex; justify-content: space-between; gap: 10px; margin: 0; }
.extbox p + p { margin-top: 4px; opacity: .8; }

/* ---------- delete confirmation: a red second step before an event goes away ---------- */
button.dangerfill { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 700; }
@media (prefers-color-scheme: dark) { button.dangerfill { color: #2A0B08; } }
.delask { animation: delask-in 400ms cubic-bezier(0.22, 1, 0.36, 1) both; }
.delbox {
  margin-top: 6px; padding: 18px 18px 16px; border-radius: 16px; text-align: center;
  background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border: 2px solid var(--danger);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 25%, transparent);
}
.delicon { color: var(--danger); display: block; margin: 0 auto 6px; animation: delask-shake 400ms 150ms both; }
.delbox p { margin: 0; }
.delbox .dq { color: var(--danger); font: 700 19px/1.25 var(--display); }
.delbox .dt { font-weight: 700; font-size: 17px; margin-top: 10px; overflow-wrap: anywhere; }
.delbox .dw { color: var(--muted); margin-top: 2px; }
.delbox #dd { margin-top: 12px; text-align: left; display: grid; gap: 6px; }
.delbox .dp { background: var(--surface); border-radius: 10px; padding: 8px 12px; }
.delbox .dp b { color: var(--danger); }
.delbox .dn { color: var(--muted); font-size: 15px; text-align: center; }
.delask .actions > * { flex-basis: 100%; }
@keyframes delask-in { from { opacity: 0; transform: translateY(8px); filter: blur(2px); } }
@keyframes delask-shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { .delask, .delicon { animation: none; } }
