:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #111827;
  --muted: #4b5563;
  --primary: #1d4ed8;
  --primary-text: #ffffff;
  --secondary: #e5e7eb;
  --error: #b91c1c;
  --error-bg: #fee2e2;
  --ok: #15803d;
  --warn-bg: #fef3c7;
  --warn: #92400e;
  --key: #ffffff;
  --key-border: #d1d5db;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f1f5f9;
    --muted: #cbd5e1;
    --primary: #3b82f6;
    --secondary: #334155;
    --error: #fca5a5;
    --error-bg: #450a0a;
    --ok: #4ade80;
    --warn-bg: #451a03;
    --warn: #fcd34d;
    --key: #1e293b;
    --key-border: #475569;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 20px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--primary);
  color: var(--primary-text);
}
.top-text { flex: 1; min-width: 0; }
.house { font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.who { font-size: 0.9rem; opacity: 0.9; }
.lang {
  flex: none;
  min-height: 52px;
  min-width: 110px;
  padding: 0 14px;
  border: 2px solid var(--primary-text);
  border-radius: 12px;
  background: transparent;
  color: var(--primary-text);
  font: inherit;
  font-weight: 700;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px max(24px, env(safe-area-inset-bottom));
}
.screen[hidden] { display: none; }
h1 { font-size: 1.5rem; margin: 8px 0 16px; text-align: center; }
.big { font-size: 1.3rem; text-align: center; margin-top: 40px; }

.msg { min-height: 1.4em; margin: 8px 0; text-align: center; font-weight: 600; }
.msg.error { color: var(--error); }
.msg:empty { visibility: hidden; }

.dots { display: flex; justify-content: center; gap: 14px; margin: 8px 0; }
.dots span {
  width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid var(--muted);
}
.dots span.on { background: var(--text); border-color: var(--text); }
.dots.shake { animation: shake 0.35s; }
@keyframes shake {
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

.amount {
  font-size: 3rem; font-weight: 700; text-align: center;
  font-variant-numeric: tabular-nums; margin: 8px 0;
  overflow-wrap: anywhere;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 12px 0 16px;
}
.keypad button {
  min-height: 72px;
  border: 2px solid var(--key-border);
  border-radius: 14px;
  background: var(--key);
  color: var(--text);
  font: inherit;
  font-size: 1.9rem;
  font-weight: 600;
  touch-action: manipulation;
}
.keypad button:active { background: var(--secondary); }
.keypad button:disabled { opacity: 0.4; }
.keypad button.blank { visibility: hidden; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%;
  min-height: 64px;
  margin: 10px 0;
  padding: 12px 16px;
  border: none;
  border-radius: 14px;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  touch-action: manipulation;
}
.btn.primary { background: var(--primary); color: var(--primary-text); }
.btn.secondary { background: var(--secondary); color: var(--text); }
.btn:disabled { opacity: 0.45; }
.btn.camera { min-height: 120px; background: var(--primary); color: var(--primary-text); font-size: 1.3rem; }
.cam-icon { font-size: 2.2rem; }
.btn.send { min-height: 80px; font-size: 1.35rem; }
.row { display: flex; gap: 12px; }
.row .btn { flex: 1; }

.preview {
  display: block; max-width: 100%; max-height: 50vh;
  margin: 12px auto; border-radius: 8px; border: 1px solid var(--key-border);
}
.preview.small { max-height: 30vh; }

.hello { font-size: 1.8rem; font-weight: 700; text-align: center; margin: 32px 0 8px; }
.sub { text-align: center; color: var(--muted); margin: 0 0 24px; }
.check { font-size: 5rem; color: var(--ok); text-align: center; margin-top: 24px; }

.summary {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 14px;
  background: var(--card); padding: 14px; border-radius: 12px; margin: 0 0 8px;
}
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }

.notsent {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--warn-bg); color: var(--warn);
  padding: 14px; border-radius: 12px; margin: 12px 0; text-align: center;
}
.notsent[hidden] { display: none; }
.notsent strong { font-size: 1.2rem; }

.busy { opacity: 0.6; pointer-events: none; }
