:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f1eee7;
  --text: #1f1d1a;
  --muted: #6b665d;
  --border: #e3ded3;
  --accent: #2f5d50;
  --accent-soft: #e3eee9;
  --ok: #2e7d4f;
  --ok-soft: #e2f3e8;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --warn: #9a5b00;
  --warn-soft: #fdf0d9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* "True Black": pure black background with a brighter green. */
    --bg: #000000;
    --surface: #111111;
    --surface-2: #1b1b1b;
    --text: #f2f2f2;
    --muted: #9a9a9a;
    --border: #262626;
    --accent: #6fcf97;
    --accent-soft: #11291c;
    --ok: #6fcf97;
    --ok-soft: #11291c;
    --bad: #f08a80;
    --bad-soft: #3a1f1c;
    --warn: #e8b35c;
    --warn-soft: #362a15;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px 80px; }

header.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.logo { display: block; width: 120px; max-width: 100%; height: auto; margin: 4px auto 26px; }
header.top h1 { font-size: 15px; font-weight: 600; color: var(--muted); margin: 0; letter-spacing: 0; }

/* Section labels: small, all caps, quiet. Use h2.title for a real heading. */
h2.title { font-size: 21px; font-weight: 700; text-transform: none; letter-spacing: -0.02em; color: var(--text); }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 34px 0 12px; }
p.muted, .muted { color: var(--muted); }
.small { font-size: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type="email"], input[type="password"], input[type="text"], input[type="search"], select {
  width: 100%;
  font: inherit;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { button.primary { color: #10201a; } }
button.link { border: none; background: none; color: var(--accent); padding: 4px 0; font-size: 14px; }
button:disabled { opacity: 0.55; cursor: default; }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap-row { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

.error { color: var(--bad); margin-top: 10px; font-size: 14px; }

/* Tags */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
  white-space: normal;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }

/* Lists */
.list { display: flex; flex-direction: column; gap: 10px; }

/* Segmented availability control */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; flex-shrink: 0; }
.seg button { border: none; border-radius: 0; padding: 8px 12px; font-size: 14px; background: var(--surface); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"].yes { background: var(--ok); color: #fff; }
.seg button[aria-pressed="true"].no { background: var(--bad); color: #fff; }
@media (prefers-color-scheme: dark) {
  .seg button[aria-pressed="true"].yes, .seg button[aria-pressed="true"].no { color: #111; }
}

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all 0.2s ease; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--bad); color: #fff; }

.hidden { display: none !important; }

.spinner { color: var(--muted); padding: 24px 0; text-align: center; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 18px; }
.tabs button { flex: 1; border: none; background: none; padding: 9px 10px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
    .dates { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px; scrollbar-width: thin; }
    .date-chip {
      flex: 0 0 auto; text-align: left; padding: 8px 12px; min-width: 104px;
      display: flex; flex-direction: column; gap: 4px;
    }
    .date-chip .d { font-weight: 600; font-size: 15px; }
    .date-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
    .date-chip .tag { font-size: 11px; padding: 1px 6px; }

    .toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0 14px; }
    .toolbar select { width: auto; min-width: 180px; }
    .summary { display: flex; gap: 6px; flex-wrap: wrap; }
    .day-block { padding-top: 6px; margin-bottom: 26px; }
    .day-block + .day-block { border-top: 1px solid var(--border); padding-top: 18px; }
    .day-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 12px; }
    .day-head h2 { margin: 0; font-size: 19px; font-weight: 700; text-transform: none; letter-spacing: -0.02em; color: var(--text); }
    .avail-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }

    .roles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
    .role h3 { font-size: 16px; font-weight: 700; margin: 0; letter-spacing: -0.015em; }
    .role .team { font-size: 13px; color: var(--muted); }
    .role.open { border-color: var(--warn); }
    .role.has-conflict { border-color: var(--bad); }
    .people { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
    .person {
      display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px;
      border-radius: 8px; background: var(--surface-2);
    }
    .person.conflict { background: var(--bad-soft); }
    .person.unavail { background: var(--warn-soft); }
    .person .nm { font-weight: 500; }
    .person .why { font-size: 12.5px; }
    .person.conflict .why { color: var(--bad); }
    .person.unavail .why { color: var(--warn); }
    .person .x { border: none; background: none; padding: 2px 8px; font-size: 18px; line-height: 1; color: var(--muted); }
    .add { width: 100%; border-style: dashed; color: var(--accent); }
    .slot-group + .slot-group { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }
    .role > .row + .slot-group { margin-top: 14px; }
    .slot-label { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
    .slot-label .tag { text-transform: none; letter-spacing: 0; }
    .slot-group .people { margin: 8px 0; }

    /* "Schedule my team": two weeks side by side (same page width as the rest of the app), one on phones. */
    @media (min-width: 640px) {
      #content { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-items: start; }
      #content .day-block, #content .day-block + .day-block { border-top: none; padding-top: 6px; margin-bottom: 24px; min-width: 0; }
      #content .roles { grid-template-columns: 1fr; }
      #content .day-head h2 { font-size: 17px; }
    }

    .alert { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }
    .alert.bad { background: var(--bad-soft); color: var(--bad); }
    .alert ul { margin: 6px 0 0; padding-left: 18px; }

    dialog {
      width: min(520px, calc(100% - 24px)); max-height: 82vh; padding: 0;
      border: 1px solid var(--border); border-radius: 16px;
      background: var(--surface); color: var(--text);
    }
    dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
    .dlg-head { padding: 16px 16px 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
    .dlg-head h3 { margin: 0 0 2px; font-size: 17px; }
    .dlg-body { padding: 8px 8px 16px; overflow-y: auto; max-height: calc(82vh - 130px); }
    .pick-section { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 12px 8px 6px; }
    .pick {
      width: 100%; text-align: left; border: none; background: none; border-radius: 8px;
      display: flex; align-items: center; gap: 8px; padding: 10px 8px; flex-wrap: wrap;
    }
    .pick:hover { background: var(--surface-2); }
    .pick .nm { flex: 1; min-width: 120px; }
    .pick .tag { white-space: normal; text-align: left; }
    .pick .note { width: 100%; font-size: 12.5px; color: var(--muted); padding-left: 2px; }
  
/* Worship set (leader view) */
.set-card { margin-top: 12px; }
.set-card h3 { margin: 0; font-size: 16px; }
.set-head, .set-row { display: grid; grid-template-columns: 1fr 76px; gap: 8px; }
.set-head { font-size: 13px; color: var(--muted); font-weight: 600; margin: 14px 0 6px; }
.set-row { margin-bottom: 8px; }
.set-row input { width: 100%; font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }

/* "Report a problem" (report.js) */
.app-footer { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--border); text-align: center; }
.app-footer .link { font-size: 14px; color: var(--muted); }
.report-form { padding: 18px 16px 16px; }
.report-form h3 { margin: 0 0 4px; font-size: 18px; }
.report-form textarea { width: 100%; font: inherit; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); resize: vertical; }
.report-form .row { gap: 12px; }
.ok-text { color: var(--ok); }

/* Team icons (icons.js): one quiet style for every team. */
.team-badge { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; flex: none; background: var(--surface-2); color: var(--accent); }
.team-badge svg { width: 21px; height: 21px; }
.team-badge.lg { width: 52px; height: 52px; border-radius: 14px; }
.team-badge.lg svg { width: 27px; height: 27px; }
.team-badge.sm { width: 26px; height: 26px; border-radius: 8px; }
.team-badge.sm svg { width: 16px; height: 16px; }

/* Calendar-style date block */
.date-block { flex: none; width: 68px; border-radius: 12px; overflow: hidden; text-align: center; border: none; background: var(--surface-2); }
.date-block .mon { background: var(--accent); color: var(--surface); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 3px 0; }
.date-block .day { font-size: 26px; font-weight: 800; line-height: 1.1; padding-top: 4px; }
.date-block .dow { font-size: 12px; color: var(--muted); padding-bottom: 5px; }
.person.spot-open { background: none; border: 1px dashed var(--border); color: var(--muted); font-size: 14px; }
