/* Shared styles, mobile first. Colours come from tokens.css / theme.css variables only. */
*, *::before, *::after { box-sizing: border-box; }
html { text-size-adjust: 100%; }

body {
  margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg); color: var(--color-text);
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--brand); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0.2rem 0 0.4rem; }
h2 { font-size: 1.3rem; margin: 0.4rem 0; }
h3 { font-size: 1.1rem; margin: 0.8rem 0 0.4rem; }
h4 { margin: 0.8rem 0 0.3rem; }
.wrap { max-width: 760px; margin: 0 auto; padding: 1rem; }
.wrap.wide { max-width: 1180px; }
.muted { color: var(--color-muted); }
.small { font-size: 0.9rem; }
.fine { font-size: 0.85rem; color: var(--color-muted); }
.hint { display: block; color: var(--color-muted); font-size: 0.85rem; margin-top: 0.2rem; }
.lead { font-size: 1.05rem; }
.is-hidden { display: none !important; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }

/* header */
.site-header {
  background: var(--brand); color: var(--color-on-brand);
  padding: max(0.8rem, env(safe-area-inset-top)) 1rem 0.8rem;
}
.site-header a, .site-header .muted { color: var(--color-on-brand); }
.brand { max-width: 760px; margin: 0 auto; display: flex; gap: 0.8rem; align-items: center; }

.logo { height: 52px; width: auto; max-width: 120px; object-fit: contain; border-radius: 8px;
  background: var(--color-surface); padding: 3px; }
.site-title { font-weight: 700; font-size: 1.2rem; text-decoration: none; }
.tagline { margin: 0.1rem 0 0; opacity: 0.92; font-size: 0.95rem; white-space: pre-line; }

/* cards, pills, alerts */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 14px;
  padding: 1rem; margin: 0.8rem 0; box-shadow: 0 1px 3px var(--color-shadow);
}

.pill { display: inline-block; font-size: 0.78rem; padding: 0.1rem 0.55rem; border-radius: 999px;
  background: var(--color-soft); color: var(--color-muted); white-space: nowrap; margin-left: 0.3rem; }
.pill-open { background: var(--color-ok-bg); color: var(--color-ok); }
.pill-closed { background: var(--color-danger-bg); color: var(--color-danger); }
.pill-draft { background: var(--color-warn-bg); color: var(--color-warn); }
.alert { background: var(--color-warn-bg); color: var(--color-warn); border-radius: 10px; padding: 0.7rem 0.9rem; }
.alert.ok { background: var(--color-ok-bg); color: var(--color-ok); }

.badge { background: var(--brand-accent); color: var(--color-on-brand); border-radius: 999px; font-style: normal;
  font-size: 0.75rem; padding: 0 0.45rem; }

/* buttons */
button, .btn-primary, .btn-secondary, .btn-danger { font: inherit; }

.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; min-height: 44px;
  padding: 0.55rem 1.1rem; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  text-decoration: none; font-weight: 600;
}
.btn-primary { background: var(--brand); color: var(--color-on-brand); }
.btn-secondary { background: var(--color-surface); color: var(--brand); border-color: var(--color-border); }
.btn-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.btn-block { width: 100%; margin-top: 1rem; }

.btn-link { background: none; border: 0; color: var(--brand); padding: 0.4rem 0.2rem; cursor: pointer;
  text-decoration: underline; min-height: 36px; }
.btn-link.danger, .danger { color: var(--color-danger); }

.btn-icon { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--color-muted);
  min-width: 44px; min-height: 44px; }
button:disabled { opacity: 0.55; cursor: default; }
:focus-visible { outline: 3px solid var(--brand-accent); outline-offset: 2px; }

/* forms */
.form .field, .field { display: block; margin: 0.55rem 0; }
.field-label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 0.2rem; }

input, select, textarea {
  font: inherit; width: 100%; min-height: 44px; padding: 0.5rem 0.65rem; border: 1px solid var(--color-border);
  border-radius: 9px; background: var(--color-surface); color: var(--color-text);
}
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; flex: none; accent-color: var(--brand); }
input[type="color"] { padding: 0.2rem; height: 44px; }
textarea { min-height: 0; }
.grid-2, .grid-3 { display: grid; gap: 0 0.8rem; grid-template-columns: 1fr; }

@media (min-width: 520px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.switch { display: flex; gap: 0.6rem; align-items: flex-start; margin: 0.8rem 0; cursor: pointer; }
.switch span { padding-top: 0.05rem; }
details.optional, details.lost { margin: 0.6rem 0; }
details > summary { cursor: pointer; font-weight: 600; color: var(--brand); min-height: 36px; padding: 0.3rem 0; }
.member { border: 1px dashed var(--color-border); border-radius: 12px; padding: 0.4rem 0.8rem 0.6rem; margin: 0.8rem 0; }
.member-title { font-weight: 700; padding: 0 0.3rem; }
.group-box { background: var(--color-soft); border-radius: 12px; padding: 0.6rem 0.8rem; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.row.spread { justify-content: space-between; }
.actions { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1rem; }

@media (min-width: 520px) { .actions { flex-direction: row; } }

/* public event page */
.intro .meta { color: var(--color-muted); margin: 0; }
.description { white-space: pre-line; }

.day-tabs { display: flex; gap: 0.5rem; overflow-x: auto; padding: 0.3rem 0 0.6rem; position: sticky; top: 0;
  background: var(--color-bg); z-index: 2; }

.day-tab {
  flex: 1 0 auto; display: flex; flex-direction: column; align-items: flex-start; gap: 0; padding: 0.55rem 0.9rem;
  border-radius: 12px; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text);
  cursor: pointer; text-align: left; position: relative; min-width: 130px;
}
.day-tab span, .day-tab small { color: var(--color-muted); font-size: 0.85rem; }
.day-tab.is-active { border-color: var(--brand); box-shadow: inset 0 0 0 2px var(--brand); }
.day-tab .badge { position: absolute; top: 0.4rem; right: 0.5rem; }
.job h3 { margin-top: 0; }
.job p { margin: 0 0 0.5rem; }
.shifts { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }

.shift {
  width: 100%; display: flex; align-items: center; gap: 0.75rem; text-align: left; cursor: pointer;
  padding: 0.7rem 0.8rem; min-height: 56px; border-radius: 12px; border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text);
}

.shift .check {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  border: 2px solid var(--brand); color: var(--brand);
}
.shift.is-on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 9%, var(--color-surface)); }
.shift.is-on .check { background: var(--brand); color: var(--color-on-brand); }
.shift.is-full { opacity: 0.6; cursor: not-allowed; }
.shift.is-full .check { border-color: var(--color-border); color: var(--color-muted); }
.shift-main { flex: 1; display: flex; flex-direction: column; }
.shift-main small { color: var(--color-muted); }
.names { font-style: italic; }
.spots { flex: none; font-size: 0.82rem; font-weight: 600; color: var(--color-ok); text-align: right; max-width: 7.5rem; }
.spots.is-low { color: var(--color-warn); }
.spots.is-zero { color: var(--color-muted); }
.why { display: block; color: var(--color-warn); font-size: 0.8rem; padding: 0.1rem 0.8rem; }

.sticky-bar {
  position: sticky; bottom: 0; margin: 0.8rem -1rem -1rem; padding: 0.8rem 1rem calc(0.8rem + env(safe-area-inset-bottom));
  background: var(--color-surface); border-top: 1px solid var(--color-border); display: flex; align-items: center;
  justify-content: space-between; gap: 1rem; box-shadow: 0 -4px 12px var(--color-shadow); font-weight: 600; z-index: 3;
}
.chosen, .people { padding-left: 1.1rem; margin: 0.3rem 0; }
.chosen li, .people li { margin: 0.2rem 0; }
.event-list { display: grid; gap: 0.6rem; }
.event-link { display: flex; flex-direction: column; gap: 0.2rem; text-decoration: none; color: var(--color-text); }
.done { text-align: center; }
.done .summary { text-align: left; }

.big-check {
  width: 64px; height: 64px; margin: 0.4rem auto; border-radius: 50%; display: grid; place-items: center;
  background: var(--color-ok-bg); color: var(--color-ok); font-size: 2rem; font-weight: 700;
}

.manage-link { display: block; word-break: break-all; background: var(--color-soft); padding: 0.6rem; border-radius: 10px;
  margin: 0.4rem 0; text-align: left; }

/* toast and dialogs */
.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translate(-50%, 200%); max-width: min(92vw, 480px);
  padding: 0.75rem 1rem; border-radius: 12px; background: var(--color-text); color: var(--color-surface);
  transition: transform 0.2s ease, visibility 0s linear 0.2s; z-index: 50; box-shadow: 0 6px 20px var(--color-shadow);
  visibility: hidden;
}

.toast.is-shown { transform: translate(-50%, 0); visibility: visible; transition: transform 0.2s ease; }
.toast-error { background: var(--color-danger); color: var(--color-on-brand); }
.toast-ok { background: var(--color-ok); color: var(--color-on-brand); }
.modal { border: 0; border-radius: 16px; padding: 0; width: min(96vw, 760px); max-height: 92vh; }
.modal::backdrop { background: var(--color-backdrop); }

.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--color-border); position: sticky; top: 0; background: var(--color-surface); z-index: 4; }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-body { padding: 0.6rem 1rem 1rem; }
.narrow-card { max-width: 420px; margin: 2rem auto; }
