/* Talkapic AAC — calm, high-contrast, big touch targets, no flashing. */
:root {
  --bg: #eef4f8;
  --card: #ffffff;
  --text: #2b3a45;
  --accent: #5b9bd5;
  --accent-soft: #dceaf6;
  --go: #7cc47f;
  --go-dark: #5da861;
  --folder: #f3e6c4;
  --line: #cfe0ee;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Comic Sans MS", "Segoe UI", system-ui, sans-serif;
  padding-bottom: 24px;
}

/* ---- Top message bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  padding: 10px;
  background: var(--card);
  border-bottom: 3px solid var(--line);
}
.msg-bar {
  flex: 1 1 auto;
  min-height: 76px;
  background: var(--accent-soft);
  border-radius: 16px;
  padding: 8px 10px;
  overflow-x: auto;
  cursor: pointer;
}
.msg-chips { display: flex; gap: 8px; align-items: center; min-height: 60px; }
.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: #fff;
  border-radius: 12px;
  padding: 6px 8px;
  font-size: 0.95rem;
  white-space: nowrap;
}
.chip-pic { width: 40px; height: 40px; object-fit: contain; }
.msg-actions { display: flex; flex-direction: column; gap: 6px; }
.act {
  font-size: 1.4rem;
  font-family: inherit;
  border: none;
  border-radius: 14px;
  width: 58px;
  height: 35px;
  background: #fff;
  border: 2px solid var(--line);
  cursor: pointer;
}
.act-speak { background: var(--go); color: #fff; border-color: var(--go-dark); height: 41px; }
.act:active { transform: translateY(2px); }

/* ---- App body ---- */
.app { padding: 12px; max-width: 1000px; margin: 0 auto; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.core-grid { margin-bottom: 14px; }

.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 4px 10px;
}
.board-title { font-size: 1.3rem; font-weight: bold; color: var(--accent); }
.board-tools { display: flex; gap: 8px; }
.chip-btn {
  font-size: 1.1rem;
  font-family: inherit;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
}
.chip-btn:active { transform: translateY(2px); }

/* ---- Cells ---- */
.cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 18px;
  padding: 10px 4px;
  min-height: 110px;
  cursor: pointer;
  font-family: inherit;
}
.cell:active { transform: translateY(2px); background: var(--accent-soft); }
.cell-pic { width: 64px; height: 64px; object-fit: contain; }
.cell-pic.pic-emoji, .pic-emoji { font-size: 3rem; line-height: 1; }
.cell-label { font-size: 1.05rem; color: var(--text); text-align: center; }
.cell.folder { background: var(--folder); border-color: #e3d099; }
.cell.back { background: var(--accent); border-color: var(--accent); }
.cell.back .cell-label { color: #fff; }

/* ---- Settings modal ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(43, 58, 69, 0.45);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px;
  z-index: 20;
  overflow-y: auto;
}
.sheet {
  background: #fff;
  width: 100%;
  max-width: 540px;
  border-radius: 22px;
  padding: 18px 20px 24px;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet h2 { color: var(--accent); margin: 6px 0 12px; }
fieldset { border: 2px solid var(--line); border-radius: 14px; margin: 14px 0; padding: 12px 14px; }
legend { font-weight: bold; color: var(--accent); padding: 0 6px; }
.sheet label { display: block; margin: 10px 0; font-size: 1.05rem; }
.sheet label.row { display: flex; align-items: center; gap: 8px; }
.sheet input[type="text"], .sheet select, .sheet input[type="range"] {
  width: 100%;
  font-size: 1.05rem;
  font-family: inherit;
  padding: 8px;
  border: 2px solid var(--line);
  border-radius: 10px;
  margin-top: 4px;
}
.sheet input[type="checkbox"] { width: 22px; height: 22px; }
.rec-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.rec-state { font-size: 0.95rem; color: #6b7c88; }
.save-btn {
  width: 100%;
  font-size: 1.2rem;
  font-family: inherit;
  font-weight: bold;
  color: #fff;
  background: var(--go);
  border: none;
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--go-dark);
}
.save-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--go-dark); }
.custom-list { display: flex; flex-direction: column; gap: 8px; }
.custom-row { display: flex; align-items: center; gap: 10px; }
.custom-pic { width: 40px; height: 40px; object-fit: contain; }
.custom-pic.pic-emoji { font-size: 1.8rem; }
.custom-name { flex: 1 1 auto; }
.credit { font-size: 0.8rem; color: #9aa9b4; text-align: center; margin-top: 14px; }
.credit a { color: inherit; }
.hidden { display: none; }
