:root {
  --bg: #0e1116;
  --card: #171c24;
  --line: #2a3340;
  --fg: #f2f5f9;
  --muted: #9aa7b8;
  --it: #4338ca;
  --it-hi: #6366f1;
  --pa: #15803d;
  --pa-hi: #22c55e;
  --ok: #86efac;
  --warn: #fbbf24;
  --err: #f87171;
  --live: #67e8f9;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--bg); color: var(--fg); }

body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

main {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  max-width: 720px;
  margin: 0 auto;
}

h1 { margin: 0; font-size: 1.25rem; letter-spacing: .2px; }
h2 { margin: 18px 0 6px; font-size: 1rem; color: var(--muted); }

.status { margin: 4px 0 0; min-height: 1.5em; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.err { color: var(--err); }
.status.live { color: var(--live); }

.result {
  flex: 1 1 auto;
  min-height: 160px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.orig { margin: 0; color: var(--muted); font-size: 1.05rem; overflow-wrap: anywhere; }
.trad { margin: 0; font-size: 1.9rem; line-height: 1.5; font-weight: 600; overflow-wrap: anywhere; }
.orig:empty, .trad:empty { display: none; }
.placeholder { margin: auto 0; text-align: center; color: var(--muted); font-size: 1.05rem; }
.result:has(.orig:not(:empty)) .placeholder { display: none; }
[lang="pa-Arab"], [dir="rtl"] {
  font-family: "Noto Nastaliq Urdu", "Noto Naskh Arabic", "Jameel Noori Nastaleeq", "Scheherazade New", "Segoe UI", serif;
}
.trad[dir="rtl"] { font-size: 2.1rem; line-height: 1.9; }

.replay {
  align-self: flex-start;
  margin-top: auto;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--fg);
  font-size: 1rem;
}

.talk { display: grid; gap: 12px; }

.talk-btn {
  appearance: none;
  border: 0;
  border-radius: 22px;
  min-height: max(120px, 20dvh);
  padding: 14px 18px;
  color: #fff;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 16px;
  align-items: center;
  text-align: start;
  cursor: pointer;
  touch-action: manipulation;
}
.talk-btn .flag { grid-row: 1 / 3; font-size: 3rem; line-height: 1; }
.talk-btn .big { font-size: 1.7rem; font-weight: 700; align-self: end; }
.talk-btn .small { font-size: .95rem; opacity: .85; align-self: start; }
.talk-btn.it { background: linear-gradient(135deg, var(--it), var(--it-hi)); }
.talk-btn.pa { background: linear-gradient(135deg, var(--pa), var(--pa-hi)); }
.talk-btn.pa .big { font-size: 1.9rem; line-height: 1.7; }
.talk-btn:active { transform: scale(.985); }
.talk-btn.on { outline: 4px solid var(--live); outline-offset: 3px; animation: pulse 1.1s ease-in-out infinite; }

@keyframes pulse { 50% { outline-color: transparent; } }
@media (prefers-reduced-motion: reduce) { .talk-btn.on { animation: none; } }

button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--live);
  outline-offset: 2px;
}

.more { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.more summary { cursor: pointer; font-weight: 600; }
.row { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; }
.row.col { flex-direction: column; align-items: stretch; gap: 6px; }
select, textarea, .more button {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
.more button { cursor: pointer; width: auto; flex: 1 1 140px; }
textarea { resize: vertical; }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--it-hi); }
input[type="range"] { width: 100%; }
.pair { display: flex; gap: 8px; margin-top: 8px; }
.pair.wrap { flex-wrap: wrap; }
.hint { margin: 0; color: var(--muted); font-size: .9rem; }
pre {
  margin: 10px 0 0;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: .8rem;
}
pre:empty { display: none; }

footer p { margin: 0; color: var(--muted); font-size: .8rem; }
