:root {
  --bg: #0b0b0c;
  --surface: #151517;
  --surface-2: #1d1d20;
  --line: #2a2a2e;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --faint: #71717a;
  --accent: #e3141b;
  --accent-ink: #ffffff;
  --ok: #22c55e;
  --warn: #f59e0b;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: Inter, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: calc(76px + var(--safe-bottom));
}
a { color: inherit; }
button { font: inherit; color: inherit; }
img { display: block; }

h1, h2, h3, .display {
  font-family: Oswald, Inter, sans-serif;
  text-transform: uppercase;
  letter-spacing: .02em;
  line-height: 1.1;
  margin: 0;
}
h1 { font-size: 30px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

/* ---------- top bar & tab bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: rgba(11, 11, 12, .88);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand-logo { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #fff; }
.brand-name { font-family: Oswald, sans-serif; font-weight: 600; font-size: 18px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); text-decoration: none; }
.icon-btn:active { background: var(--surface-2); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 4px calc(6px + var(--safe-bottom));
  background: rgba(15, 15, 17, .96);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; text-decoration: none; color: var(--faint); font-size: 11px; font-weight: 600; }
.tabbar svg { width: 22px; height: 22px; }
.tabbar a.active { color: var(--text); }
.tabbar a.active svg { color: var(--accent); }

main { max-width: 640px; margin: 0 auto; padding: 18px 16px 24px; }

/* ---------- building blocks ---------- */
.stack > * + * { margin-top: 12px; }
.section { margin-top: 26px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.section-title a { color: var(--muted); font-size: 14px; text-decoration: none; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 14px; }
.small { font-size: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card.tap { cursor: pointer; transition: border-color .15s, background .15s; text-align: left; width: 100%; display: block; }
.card.tap.row, .card.tap.service { display: flex; }
.card.tap.barber-tile { display: flex; }
a.card { text-decoration: none; }
.card.tap:hover { border-color: #3f3f46; }
.card.tap:active { background: var(--surface-2); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

.row { display: flex; align-items: center; gap: 12px; }
.row .grow { flex: 1; min-width: 0; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chev { color: var(--faint); flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; width: 100%;
  border-radius: 12px; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 16px; letter-spacing: .01em;
  text-decoration: none; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.danger { background: transparent; color: #f87171; border-color: #3f1d1d; }
.btn.sm { min-height: 40px; font-size: 14px; padding: 0 14px; width: auto; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.link-btn { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 14px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; }
.pill.ok { color: #86efac; background: #0f2a18; }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: 20px; padding: 26px 20px 22px;
  background:
    radial-gradient(120% 90% at 85% 0%, rgba(227, 20, 27, .55), transparent 60%),
    linear-gradient(160deg, #1b0a0b 0%, #0f0f11 70%);
  border: 1px solid #2c1415;
}
.hero h1 { font-size: 34px; }
.hero p { margin: 8px 0 18px; color: #d4d4d8; }
.hero .btn + .btn { margin-top: 10px; }

/* ---------- avatars & barbers ---------- */
.avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex: none; background: var(--surface-2); }
.avatar.lg { width: 76px; height: 76px; }
.avatar.initials { display: grid; place-items: center; font-family: Oswald, sans-serif; font-weight: 600; font-size: 20px; color: #fff; background: linear-gradient(145deg, #3a0d0f, #1d1d20); }
.avatar.any { display: grid; place-items: center; background: linear-gradient(145deg, var(--accent), #7a0a0e); color: #fff; }

.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.barber-tile { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 16px 10px; }
.barber-tile .name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.barber-tile .title { font-size: 12px; color: var(--muted); }

/* ---------- steps ---------- */
.stepper { display: flex; gap: 6px; margin: 2px 0 16px; }
.stepper span { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.stepper span.on { background: var(--accent); }
.step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.back { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; flex: none; }
.summary-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }

/* ---------- date & time ---------- */
.dates { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.dates::-webkit-scrollbar { display: none; }
.date-chip {
  flex: none; width: 62px; padding: 10px 0; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  scroll-snap-align: start; cursor: pointer;
}
.date-chip .dow { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.date-chip .dom { font-family: Oswald, sans-serif; font-size: 22px; font-weight: 600; }
.date-chip .mon { font-size: 11px; color: var(--faint); }
.date-chip.on { background: var(--accent); border-color: var(--accent); }
.date-chip.on .dow, .date-chip.on .mon { color: #ffe4e6; }
.date-chip.none { opacity: .4; }

.slot-group { margin-top: 16px; }
.slot-group h3 { font-family: Inter, sans-serif; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slot { min-height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; }
.slot:active, .slot.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- forms ---------- */
label.field { display: block; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=tel], textarea {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 16px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.code-input { font-family: Oswald, sans-serif; font-size: 28px !important; letter-spacing: 10px; text-align: center; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: #d4d4d8; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex: none; }
.error { color: #fca5a5; font-size: 14px; margin: 8px 0 0; }

/* ---------- lists ---------- */
.kv { display: grid; grid-template-columns: 84px 1fr; gap: 8px 12px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.hours { width: 100%; border-collapse: collapse; font-size: 14px; }
.hours td { padding: 5px 0; border-bottom: 1px solid var(--line); }
.hours td:last-child { text-align: right; color: var(--muted); }
.hours tr.today td { color: var(--text); font-weight: 700; }
.service { display: flex; align-items: center; gap: 12px; }
.service .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.service .price { font-weight: 700; white-space: nowrap; }
.visit { padding: 12px 0; border-bottom: 1px solid var(--line); }
.visit:last-child { border-bottom: 0; }

.policy { white-space: pre-line; font-size: 14px; color: #d4d4d8; }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.success-mark { width: 74px; height: 74px; border-radius: 50%; background: #0f2a18; color: var(--ok); display: grid; place-items: center; margin: 10px auto 16px; }
.banner { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.banner .grow { flex: 1; }
.banner button.x { background: none; border: 0; color: var(--faint); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px; }

.loading { display: grid; place-items: center; min-height: 40vh; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.spinner.sm { width: 20px; height: 20px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #f4f4f5; color: #18181b; padding: 12px 16px; border-radius: 12px;
  font-weight: 600; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(0,0,0,.4);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; background: var(--surface); border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + var(--safe-bottom)); border-top: 1px solid var(--line); }
.sheet h2 { margin-bottom: 8px; }

@media (min-width: 560px) {
  .grid2 { grid-template-columns: repeat(3, 1fr); }
  .slots { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

.barber-chip { flex: none; width: 76px; display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: 0; padding: 0; cursor: pointer; color: var(--text); font-weight: 600; line-height: 1.2; }
.barber-chip:active .avatar { outline: 2px solid var(--accent); outline-offset: 2px; }
