/* Salita – calm, high-contrast, big touch targets */
:root {
  --primary: #1E40AF;
  --on-primary: #FFFFFF;
  --bg: #F5F7FB;
  --card: #FFFFFF;
  --text: #13203B;
  --muted: #475569;
  --border: #CBD5E1;
  --ring: #F59E0B;
  --radius: 18px;
  --tile-min: 150px;
  --img: 76px;

  /* Category colors (AAC color-coding: soft fill + strong edge) */
  --pink-bg: #FDE7F0;   --pink-edge: #BE185D;
  --green-bg: #E3F5E8;  --green-edge: #15803D;
  --blue-bg: #E3EEFD;   --blue-edge: #1D4ED8;
  --orange-bg: #FDEEDC; --orange-edge: #C2410C;
  --yellow-bg: #FEF6D3; --yellow-edge: #A16207;
  --purple-bg: #F1E8FD; --purple-edge: #7E22CE;
  --teal-bg: #DDF4F1;   --teal-edge: #0F766E;
  --red-bg: #FDE5E5;    --red-edge: #B91C1C;
  --slate-bg: #E9EDF3;  --slate-edge: #475569;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}
body.big { --tile-min: 200px; --img: 108px; }

button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 4px solid var(--ring); outline-offset: 3px; }
a { color: var(--primary); }

.skip {
  position: absolute; left: -999px; top: 8px;
  background: var(--primary); color: var(--on-primary); padding: 8px 14px; border-radius: 10px; z-index: 50;
}
.skip:focus { left: 8px; }

/* Top bar */
.topbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--border);
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand h1 { margin: 0; font-size: 1.5rem; line-height: 1.1; color: var(--primary); }
.tagline { margin: 0; color: var(--muted); font-size: 0.95rem; }
.top-actions { display: flex; gap: 10px; align-items: center; }

.lang-switch { display: flex; border: 2px solid var(--primary); border-radius: 999px; overflow: hidden; }
.lang-btn {
  min-height: 44px; padding: 0 16px; border: 0; background: transparent; font-weight: 600; color: var(--primary);
}
.lang-btn[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }

.icon-btn {
  min-height: 44px; min-width: 44px; padding: 0 14px; border-radius: 999px;
  border: 2px solid var(--border); background: var(--card); display: inline-flex; gap: 6px; align-items: center; font-weight: 600;
}

/* Sentence strip */
.strip {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 10px 16px; background: #EAF0FB; border-bottom: 1px solid var(--border);
}
.strip.off { display: none; }
.strip-items { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 260px; min-height: 52px; align-items: center; }
.strip-items li {
  display: flex; align-items: center; gap: 6px; padding: 4px 12px 4px 6px;
  background: var(--card); border: 2px solid var(--border); border-radius: 12px; font-weight: 600;
}
.strip-items:empty { display: none; }
.strip-items img { width: 36px; height: 36px; }
.strip-empty { margin: 0; color: var(--muted); flex: 1 1 260px; }
.strip-empty[hidden] { display: none; }
.strip-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.act {
  min-height: 48px; padding: 0 16px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--card); font-weight: 700; display: inline-flex; gap: 6px; align-items: center;
}
.act-speak { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.act:disabled { opacity: 0.45; cursor: default; }

/* Categories */
.cats { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 16px 4px; }
.cat {
  min-height: 48px; padding: 0 18px; border-radius: 999px; font-weight: 700;
  border: 2px solid var(--border); background: var(--card);
}
.cat[aria-pressed="true"] { outline: 3px solid var(--text); outline-offset: 1px; }
.cat.pink { background: var(--pink-bg); border-color: var(--pink-edge); }
.cat.green { background: var(--green-bg); border-color: var(--green-edge); }
.cat.blue { background: var(--blue-bg); border-color: var(--blue-edge); }
.cat.orange { background: var(--orange-bg); border-color: var(--orange-edge); }
.cat.yellow { background: var(--yellow-bg); border-color: var(--yellow-edge); }
.cat.slate { background: var(--slate-bg); border-color: var(--slate-edge); }
.cat.red { background: var(--red-bg); border-color: var(--red-edge); }
.cat.teal { background: var(--teal-bg); border-color: var(--teal-edge); }
.cat.purple { background: var(--purple-bg); border-color: var(--purple-edge); }

/* Board */
.board {
  display: grid; gap: 14px; padding: 14px 16px 24px;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-min), 1fr));
}
.board:focus { outline: none; }
.section-title { grid-column: 1 / -1; margin: 10px 0 0; font-size: 1.15rem; }

.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: calc(var(--img) + 84px); padding: 12px 8px;
  border-radius: var(--radius); border: 3px solid var(--border); background: var(--card);
  text-align: center; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation;
  transition: transform 120ms ease-out, box-shadow 120ms ease-out;
}
.tile img { width: var(--img); height: var(--img); pointer-events: none; }
.tile img.photo, .strip-items img.photo { object-fit: cover; border-radius: 12px; border: 2px solid #fff; }
.tile .main { font-size: 1.2rem; font-weight: 800; line-height: 1.2; }
.tile .second { font-size: 0.95rem; color: var(--muted); line-height: 1.2; }
body.no-second .tile .second { display: none; }
.tile:hover { box-shadow: 0 4px 0 rgba(19, 32, 59, 0.12); }
.tile:active, .tile.speaking { transform: scale(0.97); }
.tile.speaking { box-shadow: 0 0 0 5px var(--ring); }

.tile.pink { background: var(--pink-bg); border-color: var(--pink-edge); }
.tile.green { background: var(--green-bg); border-color: var(--green-edge); }
.tile.blue { background: var(--blue-bg); border-color: var(--blue-edge); }
.tile.orange { background: var(--orange-bg); border-color: var(--orange-edge); }
.tile.yellow { background: var(--yellow-bg); border-color: var(--yellow-edge); }
.tile.slate { background: var(--slate-bg); border-color: var(--slate-edge); }
.tile.red { background: var(--red-bg); border-color: var(--red-edge); }
.tile.teal { background: var(--teal-bg); border-color: var(--teal-edge); }
.tile.purple { background: var(--purple-bg); border-color: var(--purple-edge); }

/* Footer */
.footer { padding: 18px 16px 28px; border-top: 1px solid var(--border); background: var(--card); text-align: center; color: var(--muted); }
.footer p { margin: 6px 0; }
.footer .free { color: var(--text); font-weight: 700; }
.footer a { font-weight: 600; }
.coffee {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 18px; border-radius: 999px;
  background: #FFDD00; color: #13203B; text-decoration: none; font-weight: 800;
}
.credits { font-size: 0.9rem; }

/* Settings dialog */
dialog { border: 0; border-radius: 20px; padding: 0; max-width: min(560px, 92vw); color: var(--text); }
dialog::backdrop { background: rgba(19, 32, 59, 0.45); }
.about-inner { padding: 22px; }
.about-inner h2 { margin-top: 0; color: var(--primary); }
.about-inner h3 { margin-bottom: 4px; }
.toggle { display: flex; gap: 12px; align-items: center; min-height: 48px; font-weight: 600; cursor: pointer; }
.toggle input { width: 26px; height: 26px; accent-color: var(--primary); flex: none; }
.muted { color: var(--muted); font-size: 0.95rem; }
.close-btn { margin-top: 10px; width: 100%; justify-content: center; }

@media (max-width: 480px) {
  :root { --tile-min: 128px; --img: 64px; }
  body.big { --tile-min: 160px; --img: 88px; }
  .icon-btn-label { display: none; }
  .strip-actions { flex-wrap: nowrap; width: 100%; }
  .act-speak { flex: 1; justify-content: center; }
  .act .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .act { min-width: 52px; justify-content: center; }
  .tile .main { font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .tile:active, .tile.speaking { transform: none; }
}
.help-ask { display: block; margin: 14px 0 6px; color: var(--text); font-weight: 700; }
.noscript { padding: 16px; color: var(--muted); }

/* Install bar + guide */
.install-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: #FEF6D3; border-bottom: 1px solid #E9D98A;
}
.install-bar[hidden] { display: none; }
.install-text { flex: 1 1 220px; font-weight: 700; }
.install-note { display: block; font-weight: 400; color: var(--muted); }
.steps { padding-left: 1.4em; }
.steps li { margin: 10px 0; line-height: 1.5; }
.key { display: inline-block; padding: 0 8px; border: 2px solid var(--border); border-radius: 8px; background: var(--bg); font-weight: 700; }
.url-box { display: block; margin: 8px 0; padding: 10px; border-radius: 10px; background: var(--bg); font-weight: 700; word-break: break-all; }
.install-bar .act { white-space: nowrap; }
@media (max-width: 480px) {
  .install-bar .act { flex: 1 1 100%; justify-content: center; }
}
