/* Reset, type, form controls and buttons. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--body); font-size: 15px; line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
body.locked { overflow: hidden; }
img { max-width: 100%; }
p { margin: 0; }
h1, h2, h3 { font-family: var(--display); margin: 0; text-wrap: balance; }
h1 { font-size: 2.2rem; font-weight: 800; letter-spacing: -.025em; line-height: 1.05; }
h2 { font-size: 1.08rem; font-weight: 600; }

.label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
/* Letter-spacing breaks joined Arabic letters. */
:lang(ar) .label, :lang(ar) .badge span { letter-spacing: 0; text-transform: none; font-size: .8rem; }
:lang(ar) h1, :lang(ar) h2 { letter-spacing: 0; }
/* Monospace fonts have no Arabic letters either; keep numbers aligned with the body font instead. */
:lang(ar) .mono { font-family: var(--body); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .84rem; }
.hint { font-size: .86rem; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Buttons: .btn + one variant. Every button is at least 44px tall for thumbs. */
button { font: inherit; color: inherit; cursor: pointer; }
.btn {
  min-height: 44px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid transparent; background: transparent;
  font-weight: 600; font-size: .9rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:hover { border-color: var(--primary); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-icon { width: 44px; padding: 0; }
.btn-danger { background: var(--rejected); color: var(--surface); }
.btn:disabled { opacity: .6; cursor: progress; }

/* Form controls */
input, textarea, select { font: inherit; color: inherit; }
input:not([type=radio]):not([type=file]), textarea, select {
  width: 100%; min-width: 0; min-height: 46px; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; font-size: 1rem;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
input[aria-invalid="true"] { border-color: var(--rejected) !important; box-shadow: 0 0 0 3px var(--rejected-soft); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.err { color: var(--rejected); font-size: .86rem; font-weight: 500; display: flex; gap: 6px; align-items: flex-start; }
.err::before { content: "!"; flex: none; display: grid; place-items: center; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; background: var(--rejected); color: var(--surface); font-size: .75rem; font-weight: 700; }
.row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.row.start { justify-content: flex-start; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
