:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #e2e0da;
  --accent: #0f766e;
  --danger: #c62828;
  --warn-bg: #fff4e5;
  --warn-ink: #8a4b00;

  /* departure = cool colours, destination = warm colours */
  --f1: #1d4ed8; --f1-bg: #dbe6ff;
  --f2: #0e7490; --f2-bg: #cdf1f7;
  --f3: #6d28d9; --f3-bg: #e9ddff;
  --f4: #c2410c; --f4-bg: #ffe2cc;
  --f5: #be123c; --f5-bg: #ffd6df;
  --f6: #a16207; --f6-bg: #fdefb2;
}

* { box-sizing: border-box; }
html { font-size: 19px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Naskh Arabic", "Cairo", "Segoe UI", Tahoma, sans-serif;
  line-height: 1.7;
}
button, input, select, textarea { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; background: var(--accent); color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.save-status { font-size: .85rem; opacity: .95; }
.save-status.err { background: #fff; color: var(--danger); padding: 0 8px; border-radius: 6px; }

main { max-width: 780px; margin: 0 auto; padding: 12px 16px 110px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; margin-bottom: 14px;
}
.home-card h2 { margin: 0 0 6px; font-size: 1.35rem; }
.progress { height: 12px; background: #ebe9e3; border-radius: 6px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--accent); }
.big-num { font-size: 1.15rem; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 6px 18px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600;
  text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ok.on { background: #15803d; border-color: #15803d; color: #fff; }
.btn.discard.on { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sel { outline: 3px solid var(--accent); outline-offset: 1px; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar .pos { font-weight: 600; }
.toolbar select { min-height: 40px; border-radius: 8px; border: 1px solid var(--line); padding: 0 8px; background: #fff; }
.spacer { flex: 1; }

details.help { background: #eef7f5; border: 1px solid #c6e3dd; border-radius: 12px; padding: 8px 14px; margin-bottom: 12px; }
details.help summary { cursor: pointer; font-weight: 700; }
details.help ol { margin: 6px 0 2px; padding-inline-start: 0; list-style: none; font-size: .95rem; }

.problem { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; white-space: pre-line; font-size: .95rem; }

.sentence { display: flex; flex-wrap: wrap; gap: 8px; font-size: 1.6rem; line-height: 1.5; padding: 6px 0 2px; }
.chip {
  position: relative; border: 2px solid var(--line); background: #fafaf8;
  border-radius: 10px; padding: 2px 12px 4px; cursor: pointer; user-select: none;
}
.chip.selected { border-color: #111; box-shadow: 0 0 0 3px #11111133; background: #fff; }
.chip .tags { position: absolute; top: -10px; left: -6px; display: flex; gap: 2px; }
.chip .tag { font-size: .6rem; line-height: 1; color: #fff; border-radius: 8px; padding: 3px 5px; font-family: sans-serif; }
.hint { color: var(--muted); font-size: .85rem; }

.assign-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.assign-grid .btn { color: #fff; border: none; font-size: .9rem; line-height: 1.3; padding: 6px 8px; min-height: 56px; }
.assign-grid .group-label { grid-column: 1 / -1; font-size: .85rem; color: var(--muted); margin-top: 2px; }

.field { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.field .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.field label { flex: none; width: 11.5em; font-size: .9rem; }
.field input { flex: 1; min-width: 0; min-height: 44px; border: 2px solid var(--line); border-radius: 8px; padding: 2px 10px; background: #fff; }
.field input.bad { border-color: var(--danger); background: #fff5f5; }
.field .x { flex: none; width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 1.3rem; cursor: pointer; }
.field-warn { color: var(--danger); font-size: .85rem; margin: -4px 0 6px; padding-inline-start: 22px; }
.warn-box { color: var(--danger); background: #fff0f0; border: 1px solid #f3c2c2; border-radius: 10px; padding: 8px 12px; margin: 8px 0; font-size: .95rem; }

.orig { color: var(--muted); font-size: .8rem; line-height: 1.6; margin-top: 8px; }

.row-flex { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; min-height: 48px; }
.switch input { width: 26px; height: 26px; }
textarea { width: 100%; min-height: 70px; border: 2px solid var(--line); border-radius: 8px; padding: 6px 10px; background: #fff; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  background: #fffffff2; border-top: 1px solid var(--line);
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
}
.bottom-nav .inner { max-width: 780px; margin: 0 auto; display: flex; gap: 10px; }
.bottom-nav .btn { flex: 1; }
.bottom-nav .btn.primary { flex: 2; }
.shortcuts { color: var(--muted); font-size: .8rem; text-align: center; margin-top: 4px; }

.spoken-big { font-size: 2rem; font-weight: 700; margin: 0; }
.example { font-size: 1.3rem; }
mark { background: #ffe066; border-radius: 4px; padding: 0 3px; }
.meta { color: var(--muted); font-size: .9rem; }
.guess { font-size: 1.15rem; }
.choice-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.answer-now { font-weight: 700; color: #15803d; }

.search-input { width: 100%; min-height: 50px; border: 2px solid var(--accent); border-radius: 10px; padding: 4px 12px; font-size: 1.15rem; background: #fff; }
.suggest { list-style: none; margin: 8px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.suggest li { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; background: #fff; }
.suggest li:last-child { border-bottom: none; }
.suggest li:active, .suggest li:hover { background: #eef7f5; }
.suggest .alias { color: var(--muted); font-size: .8rem; }

@media (max-width: 560px) {
  html { font-size: 17px; }
  .field { flex-wrap: wrap; }
  .field label { width: calc(100% - 26px); }
  .sentence { font-size: 1.45rem; }
}
