/* ilmoo.academy. Black on white, built for phones first. */

:root {
  --ink: #0a0a0a;
  --ink-2: #3a3a3a;
  --muted: #6e6e6e;
  --faint: #b8b8b8;
  --line: #e6e6e6;
  --soft: #f3f3f3;
  --paper: #ffffff;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --s10: 40px;

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;

  --gutter: 16px;
  --max: 560px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}


/* ---------- Top bar ---------- */

.bar { border-bottom: 1px solid var(--line); }

.bar__in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  max-width: var(--max);
  height: 56px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}

.brand__name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.brand__name span { color: var(--muted); font-weight: 500; }

.bar__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-left: -6px;
  padding: 0 6px;
  border-radius: var(--r-sm);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}

.bar__title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.bar__title span { margin-left: 4px; color: var(--muted); font-size: 14px; font-weight: 500; }

/* ---------- Home ---------- */

/* The home page is just the subject card(s), centred in the space between header and footer. */
.home {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: var(--s8) var(--gutter);
}

.cards { display: grid; gap: var(--s3); width: 100%; max-width: 440px; }

.card {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "art go" "body body";
  gap: var(--s5) var(--s4);
  padding: var(--s5);
  border-radius: var(--r-lg);
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

a.card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14); }
a.card:active { transform: translateY(0) scale(0.99); }

.card__art {
  grid-area: art;
  display: grid;
  grid-template-columns: repeat(2, 30px);
  gap: 4px;
}

.card__art span {
  display: grid;
  place-items: center;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
}

.card__go {
  grid-area: go;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
}

.card__body { grid-area: body; display: flex; flex-direction: column; }

.card__kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.6;
}

.card__title {
  margin-top: 2px;
  font-size: 30px;
  font-weight: 750;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.card__text { margin-top: var(--s2); font-size: 15px; line-height: 1.45; opacity: 0.75; }



/* ---------- Footer ---------- */

.foot { border-top: 1px solid var(--line); }

.foot__in {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3) var(--s4);
  max-width: var(--max);
  margin: 0 auto;
  padding: var(--s5) var(--gutter) calc(var(--s6) + env(safe-area-inset-bottom));
}

.foot__links { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); }

.foot__links a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: var(--ink-2);
  font-size: 14px;
  text-decoration: none;
}

.foot__links a:hover { text-decoration: underline; }
.foot__copy { color: var(--muted); font-size: 13px; }

/* ---------- Legal pages ---------- */

html.lang-applied[lang="en"] [data-lang-block="ms"],
html.lang-applied[lang="ms"] [data-lang-block="en"] { display: none; }

.legal {
  flex: 1;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: var(--s8) var(--gutter) var(--s10);
}

.legal h1 { margin-bottom: var(--s4); font-size: 32px; font-weight: 750; line-height: 1.15; letter-spacing: -0.02em; }
.legal h2 { margin: var(--s6) 0 var(--s1); font-size: 17px; font-weight: 700; }
.legal p { margin-bottom: var(--s3); color: var(--ink-2); text-wrap: pretty; }
.legal .updated { margin: calc(-1 * var(--s2)) 0 var(--s5); color: var(--muted); font-size: 14px; }
.legal ul { margin: 0 0 var(--s3); padding-left: 22px; list-style: disc; color: var(--ink-2); }
.legal li { margin-bottom: var(--s2); padding-left: 2px; }
.legal li::marker { color: var(--muted); }
.legal p a { color: var(--ink); font-weight: 600; text-underline-offset: 3px; }
.legal .back-row { margin-top: var(--s8); }
.legal .back { color: var(--ink); font-weight: 600; text-underline-offset: 3px; }

.langtog {
  display: flex;
  flex: none;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--soft);
}

.langtog button {
  min-width: 40px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.langtog button[aria-checked="true"] { background: var(--ink); color: var(--paper); }

/* ---------- Kira ---------- */

/* The Kira page is a fixed app screen: only the problem area scrolls. */
.page-kira {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.kira {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  max-width: var(--max);
  margin: 0 auto;
  padding: 10px var(--gutter);
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.pick { display: grid; flex: none; gap: var(--s2); }

/* One sideways-scrolling line of chips, running to the screen edges. */
.chips {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 calc(-1 * var(--gutter));
  padding: 0 var(--gutter);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chips::-webkit-scrollbar { display: none; }

.chips__label {
  flex: none;
  margin-right: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chip {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 var(--chip-x, 14px);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chip__sym { margin-left: -2px; font-size: 16px; font-weight: 600; line-height: 1; }
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); }

/* All chips fit: stretch them so the row spans the same width as the card below. */
.chips.is-fit .chip { flex: 1 1 0; }

/* Difficulty: never scrolls; the three choices share the full row. */
.chips--fill { margin: 0; padding: 0; overflow: visible; }
.chips--fill .chip { flex: 1 1 0; min-width: 0; padding: 0 var(--s2); }

/* Problem card: the heading stays put, the sheet and working scroll inside. */

.problem {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  margin-top: var(--s3);
  padding-top: var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.problem__top {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: 0 var(--s3) 0 var(--s4);
}

.problem__top { padding-bottom: var(--s2); border-bottom: 1px solid transparent; transition: border-color 0.15s ease; }
.problem.is-scrolled .problem__top { border-bottom-color: var(--line); }

.problem__scroll {
  flex: 1;
  min-height: 0;
  padding: 0 var(--s4) var(--s4);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.problem__sum {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.btn-quiet {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 var(--s3);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-size: 13px;
  font-weight: 600;
}

.btn-quiet:active { background: var(--soft); }

.sheet-wrap {
  display: flex;
  justify-content: center;
  margin-top: var(--s2);
  padding: var(--s2) 0;
}

.sheet {
  --w: 44px;
  --row-big: calc(var(--w) * 1.08);
  --row-small: calc(var(--w) * 0.6);
  --row-line: 12px;
  --row-head: 20px;
  position: relative;
  display: grid;
  font-variant-numeric: tabular-nums;
}

.band {
  z-index: 0;
  margin: 0 1px;
  border-radius: var(--r-sm);
  background: var(--soft);
}

.cell,
.mark {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.cell {
  margin: 2px;
  border-radius: 8px;
  font-size: calc(var(--w) * 0.6);
  font-weight: 500;
}

.cell--small {
  align-items: flex-end;
  padding-bottom: 2px;
  color: var(--muted);
  font-size: calc(var(--w) * 0.36);
  font-weight: 600;
}

.cell.is-wide { letter-spacing: -0.04em; }

.cell.is-active {
  background: var(--paper);
  box-shadow: inset 0 0 0 2px var(--ink);
  color: var(--ink);
}

.cell--small.is-active { align-items: center; padding-bottom: 0; }

.cell.is-good { background: var(--ink); color: var(--paper); box-shadow: none; }
.cell.is-bad { animation: shake 0.4s ease; }

.cell.is-struck { color: var(--faint); }
.cell.is-struck::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 22%;
  right: 22%;
  height: 1.5px;
  background: var(--ink-2);
  transform: rotate(-38deg);
}

.cell.is-faint { color: var(--faint); }
.cell.final { font-weight: 700; }

/* Digits being used in the current step: bold and underlined, whatever their width. */
.cell.is-ref {
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: calc(var(--w) * 0.1);
}
.cell.rlabel { color: var(--ink-2); font-size: calc(var(--w) * 0.46); }
.cell.rem { justify-content: flex-start; padding-left: 4px; }
.cell.divisor { justify-content: flex-end; padding-right: 6px; }
.cell.rem.is-active { justify-content: center; padding-left: 0; }

.cell.vinc::before {
  content: "";
  position: absolute;
  top: -2px;
  left: -3px;
  right: -3px;
  height: 2px;
  background: var(--ink);
}

.mark.head { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; }
.mark.sign { font-size: calc(var(--w) * 0.52); font-weight: 400; }

.rule {
  z-index: 1;
  align-self: center;
  height: 2px;
  margin: 0 3px;
  border-radius: 2px;
  background: var(--ink);
}

.bracket { position: relative; z-index: 1; }

.bracket svg {
  position: absolute;
  top: 0;
  left: 30%;
  width: 40%;
  height: calc(100% - 2px);
  color: var(--ink);
}

.bracket::before {
  content: "";
  position: absolute;
  top: 0;
  left: 36%;
  right: 0;
  height: 2px;
  background: var(--ink);
}

/* Working list */

.working { margin-top: var(--s5); border-top: 1px solid var(--line); }

.working__sum {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 44px;
  padding-top: var(--s2);
  cursor: pointer;
  list-style: none;
  user-select: none;
  -webkit-user-select: none;
}

.working__sum::-webkit-details-marker { display: none; }
.working__h { font-size: 15px; font-weight: 700; }
.working__count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.working__chev { margin-left: auto; color: var(--muted); transition: transform 0.2s ease; }
.working[open] .working__chev { transform: rotate(180deg); }
.working[open] .working__list { padding-top: var(--s1); }

.working__list { counter-reset: line; }

.working__list li {
  position: relative;
  padding: 3px 0 3px 28px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

.working__list li::before {
  counter-increment: line;
  content: counter(line);
  position: absolute;
  top: 3px;
  left: 0;
  width: 20px;
  color: var(--faint);
  font-size: 12px;
  line-height: 20px;
  text-align: right;
}

.working__list li.is-last { color: var(--ink); font-weight: 600; }

/* Dock: step prompt and keypad, always within thumb reach */

.dock {
  flex: none;
  z-index: 10;
  border-top: 1px solid var(--line);
  background: var(--paper);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.05);
}

.dock__in {
  position: relative;
  max-width: var(--max);
  margin: 0 auto;
  padding: var(--s3) var(--gutter) calc(var(--s3) + env(safe-area-inset-bottom));
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.progress {
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 2px;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.3s ease;
}

.step__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  min-height: 28px;
}

.step__toggle {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 32px;
  margin-left: -2px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
}

.step__chev { flex: none; color: var(--muted); transition: transform 0.2s ease; }

.step__head {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.step__count {
  flex: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.btn-link {
  flex: none;
  min-height: 32px;
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.step__say {
  min-height: 21px;
  margin-top: 2px;
  font-size: 15px;
  line-height: 1.4;
}

.step__work {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 48px;
  margin-top: var(--s2);
}

.step__expr {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.step__box {
  display: inline-grid;
  place-items: center;
  min-width: 60px;
  height: 46px;
  padding: 0 var(--s3);
  border: 2px solid var(--ink);
  border-radius: var(--r-sm);
  font-size: 24px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s ease, color 0.15s ease;
}

.step__box.is-good { background: var(--ink); color: var(--paper); }
.step__box.is-bad { animation: shake 0.4s ease; }

.step__where {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 46px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.step__show { margin-left: auto; }

.switch {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--s2);
  min-height: 32px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 13px;
  font-weight: 600;
}

.switch__track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #d4d4d4;
  transition: background 0.15s ease;
}

.switch__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}

.switch[aria-checked="true"] .switch__track { background: var(--ink); }
.switch[aria-checked="true"] .switch__knob { transform: translateX(14px); }

/* Collapsed step panel: one line, with the sum being worked on in the header. */
.step-compact .step__body { display: none; }
.step-compact .step__chev { transform: rotate(180deg); }

.step__head.is-expr {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}

.step__head.is-bad { animation: shake 0.4s ease; }

/* Guide off: the learner works from the sheet alone. */
.no-guide .step__say,
.no-guide .step__show { display: none; }

.step__msg {
  flex: 1 1 0;
  min-width: 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.35;
}

.step__msg.is-error { color: var(--ink); font-weight: 600; }

.pad {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--s2);
  margin-top: var(--s3);
  user-select: none;
  -webkit-user-select: none;
}

.pad button {
  display: grid;
  place-items: center;
  height: 52px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--soft);
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: background 0.1s ease, transform 0.1s ease;
}

.pad button:active { background: #e4e4e4; transform: scale(0.96); }
.pad .pad__fn { border: 1px solid var(--line); background: var(--paper); }
.pad .pad__ok { background: var(--ink); color: var(--paper); }
.pad .pad__ok:active { background: #2a2a2a; }

.done { padding: var(--s2) 0 var(--s1); text-align: center; }
.done__label { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }

.done__sum {
  margin: var(--s1) 0 var(--s4);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.btn-primary {
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: var(--r);
  background: var(--ink);
  color: var(--paper);
  font-size: 16px;
  font-weight: 650;
}

.btn-primary:active { background: #2a2a2a; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

@media (min-width: 520px) {
  .problem { padding-top: var(--s4); }
  .problem__top { padding: 0 var(--s5) 0 var(--s6); }
  .problem__scroll { padding: 0 var(--s6) var(--s5); }
}

/* Wide screens: the dock becomes a card under the problem instead of a bar at the screen edge. */
@media (min-width: 720px) {
  .dock { margin-bottom: var(--s6); border-top: 0; background: transparent; box-shadow: none; }
  .dock__in {
    padding: var(--s4) var(--s6) var(--s5);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--paper);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
    overflow: hidden;
  }
  .dock { padding: var(--s1) var(--gutter) 0; }
  .dock__in { max-width: calc(var(--max) - 2 * var(--gutter)); }
  .progress { top: 0; }
}

/* Desktop: Kira uses the whole width. The problem fills the left, and the
   step panel and keypad sit in a column on the right. */
@media (min-width: 1024px) {
  :root { --wide: 1200px; }

  .bar__in,
  .foot__in { max-width: var(--wide); padding-left: var(--s8); padding-right: var(--s8); }

  .card { min-height: 280px; padding: var(--s6); }

  .page-kira {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 400px);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .page-kira .bar { grid-column: 1 / -1; }
  .page-kira .bar__in { max-width: none; }

  .page-kira .kira {
    grid-column: 1;
    grid-row: 2;
    max-width: none;
    padding: var(--s6) var(--s3) var(--s6) var(--s8);
  }

  .page-kira .pick { gap: var(--s3); }
  .page-kira .chips { margin: 0; padding: 0; }
  .page-kira .chip { height: 38px; font-size: 15px; }
  .page-kira .problem { margin-top: var(--s5); }
  .page-kira .problem__sum { font-size: 28px; }

  .page-kira .dock {
    display: flex;
    grid-column: 2;
    grid-row: 2;
    min-height: 0;
    margin: 0;
    padding: var(--s6) var(--s8) var(--s6) var(--s3);
  }

  .page-kira .dock__in {
    display: flex;
    flex: 1;
    flex-direction: column;
    max-width: none;
    margin: 0;
    min-height: 0;
    padding: var(--s6);
    overflow: hidden;
  }

  .page-kira .step__top { align-items: flex-start; }
  .page-kira .step__toggle { align-items: flex-start; padding-top: 7px; }
  .page-kira .step__head { white-space: normal; line-height: 1.4; }
  .page-kira .step__head.is-expr { line-height: 1.2; }
  .page-kira .step__count,
  .page-kira .switch { margin-top: 2px; }
  .page-kira .step__say { min-height: 44px; font-size: 16px; }

  .page-kira .dock__in > .working {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: var(--s4);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .page-kira .step__work { flex-wrap: wrap; row-gap: var(--s2); }

  /* A calculator-style 3 x 4 keypad, pinned to the bottom of the column. */
  .page-kira .pad {
    flex: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: auto;
    padding-top: var(--s5);
  }

  .page-kira .pad button { height: 64px; font-size: 26px; }
  .page-kira .pad [data-key="del"] { order: 10; }
  .page-kira .pad [data-key="0"] { order: 11; }
  .page-kira .pad [data-key="ok"] { order: 12; }
  .page-kira .done { margin: auto 0; }
}

@media (max-height: 700px) {
  .pad button { height: 46px; }
  .step__say { min-height: 0; }
}

@media (max-width: 349px) {
  :root { --gutter: 12px; }
  .pad { gap: 6px; }
}

/* Phones held sideways: ask for portrait instead of squeezing the layout. */
.rotate { display: none; }

@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  .rotate {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--s2);
    padding: var(--s6);
    background: var(--paper);
    text-align: center;
  }

  .rotate__icon { margin-bottom: var(--s2); animation: tilt 2.4s ease-in-out infinite; }
  .rotate__h { font-size: 20px; font-weight: 700; }
  .rotate__p { color: var(--muted); font-size: 15px; }
  body { overflow: hidden; }
}

@keyframes tilt {
  0%, 30% { transform: rotate(-90deg); }
  60%, 100% { transform: rotate(0deg); }
}

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