/* Band Booking Helper — mobile-first, no build step. */

:root {
  --bg: #f6f7f9;
  --bg-elev: #ffffff;
  --bg-sunk: #eceef2;
  --line: #dde1e8;
  --text: #171b22;
  --text-dim: #626b7a;
  --accent: #b4531b;
  --accent-soft: #fdeee2;
  --ok: #1d7a4c;
  --ok-soft: #dff3e7;
  --warn: #9a6b00;
  --warn-soft: #fbf0d2;
  --bad: #a32b2b;
  --bad-soft: #fadfdf;
  --radius: 14px;
  --tap: 46px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c;
    --bg-elev: #1b1f28;
    --bg-sunk: #0d1015;
    --line: #2b323e;
    --text: #eef1f6;
    --text-dim: #98a2b3;
    --accent: #ff9a52;
    --accent-soft: #3a2416;
    --ok: #58d69a;
    --ok-soft: #14331f;
    --warn: #e8bd54;
    --warn-soft: #3a2f10;
    --bad: #ff8080;
    --bad-soft: #3a1a1a;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
button { font: inherit; color: inherit; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(var(--safe-top) + 10px) 8px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-title { flex: 1; text-align: center; min-width: 0; }
.topbar-title h1 { font-size: 18px; }
.topbar-title p {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar.no-nav .icon-btn { visibility: hidden; }

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 22px;
  line-height: 1;
  background: transparent;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}
.icon-btn:active { background: var(--bg-sunk); }

/* ---------- view ---------- */

.view {
  flex: 1;
  padding: 14px 14px 96px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

.muted { color: var(--text-dim); }
.small { font-size: 13px; }
.center { text-align: center; }
.stack > * + * { margin-top: 10px; }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-dim);
}
.empty-ico { font-size: 34px; display: block; margin-bottom: 10px; }

.section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 22px 2px 8px;
}
.section-label:first-child { margin-top: 4px; }

/* ---------- calendar ---------- */

.cal-dows {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}
.cal-dow {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-day {
  position: relative;
  aspect-ratio: 1 / 1.12;
  min-height: 46px;
  padding: 5px 4px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
}
.cal-day:active { transform: scale(0.97); }
.cal-day.is-out { background: transparent; border-color: transparent; }
.cal-day.is-out .cal-num { color: var(--text-dim); opacity: 0.45; }
.cal-day.is-weekend:not(.is-out) { background: color-mix(in srgb, var(--accent-soft) 45%, var(--bg-elev)); }
.cal-day.is-today { border-color: var(--accent); border-width: 2px; }
.cal-day.is-today .cal-num { color: var(--accent); font-weight: 800; }

.cal-num { font-size: 14px; font-weight: 600; line-height: 1.1; }

.cal-dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
.dot {
  display: inline-block;   /* so it keeps its size outside a flex row too */
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
}
.dot.s-confirmed { background: var(--ok); }
.dot.s-enquiry   { background: var(--warn); }
.dot.s-declined  { background: var(--bad); }

.cal-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-dim);
}
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- cards / rows ---------- */

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-height: var(--tap);
  cursor: pointer;
}
.row:active { background: var(--bg-sunk); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-chev { color: var(--text-dim); font-size: 20px; flex: 0 0 auto; }

.avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
}

.date-badge {
  flex: 0 0 auto;
  width: 46px;
  padding: 5px 0;
  border-radius: 11px;
  text-align: center;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  line-height: 1.1;
}
.date-badge b { display: block; font-size: 17px; }
.date-badge span { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); }

.chip {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.chip.s-confirmed { background: var(--ok-soft); color: var(--ok); }
.chip.s-enquiry   { background: var(--warn-soft); color: var(--warn); }
.chip.s-declined  { background: var(--bad-soft); color: var(--bad); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  font-weight: 600;
  cursor: pointer;
}
.btn:active { transform: scale(0.985); }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #201206; } }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); background: transparent; }
.btn.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); background: transparent; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.btn-row { display: flex; gap: 8px; }
.btn-row > .btn { flex: 1; padding: 0 10px; }

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--safe-bot) + 78px);
  z-index: 25;
  height: 54px;
  padding: 0 20px;
  border-radius: 27px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(0,0,0,0.28);
  cursor: pointer;
}
@media (prefers-color-scheme: dark) { .fab { color: #201206; } }

/* ---------- forms ---------- */

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field input, .field textarea, .field select {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 13px;
  font: inherit;
  font-size: 16px; /* prevents iOS zoom-on-focus */
  color: var(--text);
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 12px;
  appearance: none;
}
.field textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.field-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1;
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-sunk);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .seg button[aria-pressed="true"] { color: #201206; } }

/* ---------- tab bar ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  padding-bottom: var(--safe-bot);
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  position: relative;
  flex: 1;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
}
.tab-ico { font-size: 19px; line-height: 1; filter: grayscale(1); opacity: 0.75; }
.tab.is-active { color: var(--accent); }
.tab.is-active .tab-ico { filter: none; opacity: 1; }
.tab-badge {
  position: absolute;
  top: 7px;
  left: 50%;
  margin-left: 6px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--bad);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

/* ---------- sheet ---------- */

.sheet-host { position: fixed; inset: 0; z-index: 60; }
.sheet-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  animation: fade 0.18s ease;
}
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--line);
  animation: rise 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (min-width: 640px) {
  .sheet { left: 50%; transform: translateX(-50%); width: 560px; border-radius: 20px; bottom: 16px; }
  @keyframes rise { from { transform: translate(-50%, 22px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
}
@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet-grab {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: 8px auto 0;
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 18px;
}
.sheet-head h2 { flex: 1; font-size: 17px; }
.sheet-body {
  padding: 4px 18px calc(var(--safe-bot) + 22px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--safe-bot) + 84px);
  z-index: 80;
  max-width: 88vw;
  padding: 11px 18px;
  border-radius: 999px;
  background: #22262f;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 8px 22px rgba(0,0,0,0.3);
  animation: fade 0.15s ease;
}

/* ---------- misc ---------- */

.msg-preview {
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px;
}

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--text-dim); font-size: 14px; }
.kv b { font-weight: 600; text-align: right; }

.note {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  padding: 10px 12px;
  background: var(--bg-sunk);
  border-radius: 10px;
}

/* ---------- the access code screen ---------- */

.lock {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bot) + 24px);
  background: var(--bg);
  animation: fade 0.2s ease;
}

.lock.is-going { opacity: 0; transition: opacity 0.18s ease; }

.lock-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.lock-title { font-size: 21px; margin-bottom: 8px; }

.lock-blurb {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 22px;
}

.lock-form { display: flex; flex-direction: column; gap: 12px; }

.lock-input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 14px;
  font: inherit;
  font-size: 17px;              /* 17px or iOS zooms the page on focus */
  text-align: center;
  letter-spacing: 0.04em;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.lock-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.lock-reveal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-dim);
}

.lock-reveal input { width: 17px; height: 17px; accent-color: var(--accent); }

.lock-btn {
  min-height: var(--tap);
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  font-size: 16px;
}

@media (prefers-color-scheme: dark) { .lock-btn { color: #201206; } }

.lock-btn:disabled { opacity: 0.6; }

.lock-note {
  min-height: 20px;
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-dim);
}

.lock-note.is-bad { color: var(--bad); }
