:root {
  --ink: #14202b;
  --muted: #5b6b78;
  --brand: #0f3d63;
  --accent: #1f7a8c;
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #dfe5ea;
  --danger: #b3261e;
  --he-font: "Noto Sans Hebrew", "Arial Hebrew", "SBL Hebrew", "Times New Roman", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

header h1 { margin: 4px 0 0; font-size: 22px; color: var(--brand); }
header .sub { margin: 0 0 16px; color: var(--muted); }
h2 { font-size: 18px; margin: 0 0 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
}

label { display: block; font-weight: 600; margin-bottom: 6px; }

input[type="password"] {
  width: 100%;
  font-size: 18px; /* >= 16px stops iOS from zooming the page */
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 12px;
}

fieldset { border: 0; padding: 0; margin: 0 0 12px; }
legend { font-weight: 600; margin-bottom: 4px; }
.radio { font-weight: 400; display: inline-flex; gap: 6px; align-items: center; margin-right: 14px; }

button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 12px;
  padding: 14px 20px;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { opacity: 0.55; cursor: default; }
.primary { background: var(--brand); color: #fff; width: 100%; }
.danger { background: var(--danger); color: #fff; width: 100%; margin-top: 12px; }
.link { background: none; color: var(--accent); padding: 10px 0; }

.error { color: var(--danger); font-weight: 600; }
.goal { background: #eef6f8; border-radius: 10px; padding: 10px 12px; }

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--brand);
  color: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.timer { font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 700; }
.timer.warn { color: #ffd166; }

.captions {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 180px;
  max-height: 45vh;
  overflow-y: auto;
  padding: 14px 16px;
  font-family: var(--he-font);
  font-size: 28px;
  line-height: 1.6;
}
.captions p { margin: 0 0 10px; unicode-bidi: plaintext; }
.captions p:not(:last-child) { color: var(--muted); font-size: 22px; }
.captions .placeholder { color: var(--muted); font-size: 18px; font-family: inherit; }

.phrases { margin-top: 20px; }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.chip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.chip .he {
  font-family: var(--he-font);
  font-size: 24px;
  line-height: 1.5;
  text-align: right;
  direction: rtl;
}
.chip .tr { color: var(--accent); font-style: italic; }
.chip .en { color: var(--muted); font-size: 14px; }

[hidden] { display: none !important; }
