* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--brand-font, Cairo), sans-serif;
  background: var(--brand-bg, #FAF7F2);
  color: var(--brand-text, #222);
  line-height: 1.5;
  padding: 16px;
}

[dir="rtl"] { text-align: right; }
[dir="ltr"] { text-align: left; }

.wrap { max-width: 480px; margin-inline: auto; }

/* ---------- top bar: houses the language switch with visual grounding
   (a bottom border + bottom margin) instead of two pills floating alone in
   a corner. justify-content:flex-end follows the logical end edge, which
   CSS already flips correctly for RTL vs LTR -- so this sits at the same
   *reading* position (trailing edge) in both directions. ---------- */
.topbar {
  display: flex;
  justify-content: flex-end;
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--brand-border, #F4E9DC);
}
.lang-switch { display: flex; gap: 6px; }
.lang-switch a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 4px 12px;
  border-radius: var(--brand-radius, 999px);
  border: 1px solid var(--brand-primary, #8B2E2E);
  color: var(--brand-primary, #8B2E2E);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
}
.lang-switch a.active {
  background: var(--brand-primary, #8B2E2E);
  color: #fff;
}

h1 {
  font-size: 1.3rem;
  margin-bottom: 16px;
  color: var(--brand-primary, #8B2E2E);
}

/* ---------- visible keyboard focus, consistent everywhere -----------
   :focus-visible (not plain :focus) so a mouse click doesn't ring every
   button -- keyboard/assistive navigation still gets a clear indicator.
   box-shadow (not outline) so it never shifts layout or gets clipped by
   overflow:hidden on rounded-corner elements. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-bg, #FAF7F2), 0 0 0 5px var(--brand-primary, #8B2E2E);
}

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }
.field input,
.field textarea,
.field select {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--brand-radius, 8px);
  border: 2px solid var(--brand-border, #F4E9DC);
  background: var(--brand-panel, #fff);
  color: inherit;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--brand-primary, #8B2E2E);
}
.field textarea { resize: vertical; min-height: 70px; }

.field-error {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #B3261E;
}
.field.has-error input,
.field.has-error textarea,
.field.has-error select {
  border-color: #B3261E;
}

/* Visually-hidden honeypot -- NOT left:-9999px: a large physical offset
   inflates document.documentElement.scrollWidth hugely on RTL pages (the
   RTL scroll origin is on the right, so a far-off-screen-left element reads
   as enormous rightward overflow -- confirmed: this exact rule used to
   blow the page out to ~10000px wide on every RTL page). Clip-rect masking
   in place keeps the element at its normal position (zero layout impact,
   zero overflow) while still being invisible and untabbable in practice. */
.honeypot-field {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}
@media (min-width: 420px) {
  .slots { grid-template-columns: repeat(4, 1fr); }
}
.slot-btn {
  font: inherit;
  font-size: 0.85rem;
  min-height: 44px;
  padding: 8px 4px;
  border-radius: var(--brand-radius, 8px);
  border: 2px solid var(--brand-border, #F4E9DC);
  background: var(--brand-panel, #fff);
  color: var(--brand-text, #222);
  cursor: pointer;
}
.slot-btn.selected {
  background: var(--brand-primary, #8B2E2E);
  border-color: var(--brand-primary, #8B2E2E);
  color: #fff;
  font-weight: 700;
}
.slot-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  text-decoration: line-through;
}
.slots-empty { opacity: 0.7; font-size: 0.9rem; padding: 8px 0; }

.btn-primary {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  min-height: 48px;
  padding: 12px;
  border-radius: var(--brand-radius, 10px);
  border: none;
  background: var(--brand-primary, #8B2E2E);
  color: #fff;
  cursor: pointer;
}
.btn-primary[disabled] { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  min-height: 44px;
  padding: 10px;
  border-radius: var(--brand-radius, 10px);
  border: 2px solid var(--brand-primary, #8B2E2E);
  background: transparent;
  color: var(--brand-primary, #8B2E2E);
  cursor: pointer;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 4px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brand-primary, #8B2E2E);
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
}

.alert {
  padding: 10px 12px;
  border-radius: var(--brand-radius, 8px);
  background: #fdecea;
  color: #a33;
  font-size: 0.9rem;
  margin-bottom: 12px;
}
.alert[hidden] { display: none; }

.dev-banner {
  padding: 8px 12px;
  border-radius: var(--brand-radius, 8px);
  background: #FFF4CE;
  color: #6B5900;
  font-size: 0.78rem;
  text-align: center;
  margin-bottom: 14px;
}
.dev-banner[hidden] { display: none; }

.panel {
  background: var(--brand-panel, #F4E9DC);
  border-radius: var(--brand-radius, 12px);
  padding: 20px;
  text-align: center;
}
.panel[hidden] { display: none; }
.panel h2 { font-size: 1.1rem; margin-bottom: 8px; color: var(--brand-primary, #8B2E2E); }
.countdown { font-size: 1.6rem; font-weight: 700; margin: 10px 0; color: var(--brand-primary, #8B2E2E); }

.card {
  background: var(--brand-panel, #fff);
  border-radius: var(--brand-radius, 12px);
  padding: 20px;
  margin-top: 8px;
}
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--brand-border, #F4E9DC); }
.kv:last-child { border-bottom: none; }
.kv .k { opacity: 0.7; font-size: 0.85rem; }
.kv .v { font-weight: 700; }

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--brand-radius, 999px);
  background: var(--brand-secondary, #F4E9DC);
  color: var(--brand-primary, #8B2E2E);
  font-size: 0.8rem;
  font-weight: 700;
}

/* ---------- standalone message page (not-found / invalid-link / root) --
   same card language as the rest of the app instead of bare black-on-white
   text, plus a clear way back in. */
.message-page { padding-top: 48px; text-align: center; }
.message-page .icon { font-size: 2.4rem; margin-bottom: 12px; }
.message-page p { font-size: 1.05rem; margin-bottom: 20px; }
.message-page .btn-primary { display: inline-flex; align-items: center; justify-content: center; width: auto; padding-inline: 24px; text-decoration: none; }

.result-text { margin-top: 14px; font-weight: 700; }
.result-text[hidden] { display: none; }

form[hidden] { display: none; }
