.message-read-along-container { position: relative; }
.reading-along { -webkit-text-fill-color: transparent !important; text-shadow: none !important; }
.message-read-along {
  box-sizing: border-box;
  position: absolute;
  z-index: 1;
  margin: 0;
  border: 1px solid transparent;
  color: var(--text, #17363e);
  pointer-events: none;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  unicode-bidi: plaintext;
}
.contrast .message-read-along { color: #fff; }
.message-read-along.reading-whole-message { box-shadow: inset 0 0 0 var(--read-along-thickness) var(--read-along-colour); }
.read-along-word {
  color: inherit;
  background: transparent;
  text-decoration: underline;
  text-decoration-thickness: var(--read-along-thickness);
  text-decoration-color: var(--read-along-colour);
  text-underline-offset: .13em;
  text-decoration-skip-ink: none;
}
.read-along-square .read-along-word { background: var(--read-along-square); color: #171717; border-radius: 0; }
.read-along-options { display: grid; gap: 6px; }
.read-along-options select { width: 100%; }
.read-along-options fieldset { min-width: 0; margin: 0; }
.read-along-options fieldset[disabled] { opacity: .68; }
.read-along-preview { padding: 8px; margin: 4px 0; }

#panelaaceverywhere .quick-speech-custom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-block: 6px;
}
#panelaaceverywhere .quick-speech-custom-row label {
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}

#showBottomBar {
  flex: 0 0 auto;
  align-self: flex-end;
  min-height: var(--bottom-bar-touch-size);
  margin-inline: 8px;
  padding: 5px 10px;
  font-size: var(--bottom-bar-label-size);
}
#showBottomBar[hidden] { display: none; }
body.bottom-bar-collapsed #showBottomBar {
  margin-bottom: max(4px, env(safe-area-inset-bottom));
}
body.bottom-bar-collapsed main {
  padding-bottom: 0;
  scroll-padding-bottom: 0;
}
body.bottom-bar-collapsed #grid > .aac-colour-row:last-child,
body.bottom-bar-collapsed #grid > .board-section:last-child .board-row {
  padding-bottom: 0;
}
body.bottom-bar-collapsed #grid > .board-section:last-child {
  margin-bottom: 0;
}
body.bottom-bar-collapsed #pictures { margin-bottom: 0; }
body.bottom-bar-collapsed #composer,
body.bottom-bar-collapsed #composer ~ #status { display: none !important; }

body.picture-box-only:not(.settings-open) #composer:not([hidden]) {
  display: flex;
  flex-direction: column;
}
body.picture-box-only #composer :is(#messageInputRow,#pictureSentence,.composer-extra-actions,#callAudioShortcut),
body.picture-box-only #farEdgeMessage,
body.picture-box-only #composerActions > :not(#bottomControls) { display: none !important; }
body.picture-box-only #composer #composerActions { order: -1; display: block; margin-bottom: 4px; }
body.picture-box-only #composer #composerActions > #bottomControls { display: grid; }
#pictureBoxPanel { margin: 0; min-width: 0; }
#pictureBoxTiles { position: relative; display: flex; align-items: stretch; gap: 6px; overflow-x: auto; padding: 3px; }
.picture-box-tile {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  min-width: 52px;
  max-width: 144px;
  min-height: 56px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow-wrap: anywhere;
}
.picture-box-tile :is(.symbol,.picture-box-emoji) { font-size: 32px; line-height: 1; }
.picture-box-tile img { width: 40px; height: 40px; object-fit: contain; }
.picture-box-speaking { outline: var(--read-along-thickness, 3px) solid var(--read-along-colour, var(--accent)); outline-offset: -2px; }
.read-along-square .picture-box-speaking { background: var(--read-along-square); color: #171717; }
#pictureBoxEmpty { margin: 4px 0; font-size: 15px; }
.picture-box-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin-top: 4px; }
.board-arrange-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; }
.board-arrange-bar p { margin: 0; font-size: 14px; }
body.arranging-board #grid [data-drag-board] { touch-action: none; user-select: none; cursor: grab; }
body.arranging-board #grid .arrange-picked { outline: 3px dashed var(--accent); outline-offset: -4px; cursor: grabbing; }
body.arranging-board #grid .arrange-target { outline: 3px solid var(--accent); outline-offset: -4px; }

body {
  --bottom-bar-text-offset: 0px;
  --bottom-bar-icon-offset: 0px;
  --bottom-bar-height-offset: 0px;
  --settings-footer-height: 48px;
  --full-screen-button-share: .90;
  --full-screen-height-share: 24dvh;
  --bottom-bar-label-size: calc((clamp(13px, 3.5vw, 18px) + var(--bottom-bar-text-offset)) * var(--reading-scale, 1));
  --bottom-bar-icon-size: calc(clamp(22px, 5.6vw, 28px) + var(--bottom-bar-icon-offset));
  --bottom-bar-touch-size: 48px;
  --full-screen-button-limit: 128px;
}
body[data-bottom-bar-size="small"] {
  --bottom-bar-text-offset: -2px;
  --bottom-bar-icon-offset: -4px;
  --bottom-bar-touch-size: 44px;
  --bottom-bar-height-offset: -16px;
  --settings-footer-height: 44px;
  --full-screen-button-share: .76;
  --full-screen-height-share: 18dvh;
  --full-screen-button-limit: 96px;
}
body[data-bottom-bar-size="large"] {
  --bottom-bar-text-offset: 2px;
  --bottom-bar-icon-offset: 4px;
  --bottom-bar-touch-size: 64px;
  --bottom-bar-height-offset: 20px;
  --settings-footer-height: 68px;
  --full-screen-button-share: 1;
  --full-screen-height-share: 30dvh;
  --full-screen-button-limit: 152px;
}
#composer {
  --action-gap: 4px;
  --action-height: max(48px, calc(2.25 * var(--bottom-bar-label-size) + var(--bottom-bar-icon-size) + 8px), calc(68px + var(--bottom-bar-height-offset)));
}
body.settings-open #bottomControls :is(#backToBoard,#closeSettingsPage,#layout,#openSettings) {
  min-height: var(--settings-footer-height);
  font-size: var(--bottom-bar-label-size);
}
body.settings-open #bottomControls #openSettings .composer-button-icon { font-size: var(--bottom-bar-icon-size); }
#composer #composerActions {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--action-gap);
}
#composer #composerActions > #bottomControls {
  grid-column: span 3;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--action-gap);
}
#composer #composerActions #boardSelector { height: 100%; }
#composer .composer-extra-actions {
  display: flex;
  justify-content: center;
  gap: var(--action-gap);
}
#composer .composer-extra-actions > button {
  flex: 0 0 calc((100% - 6 * var(--action-gap)) / 7);
}
#composer #composerActions > button,
#composer #composerActions > #bottomControls button,
#composer .composer-extra-actions > button {
  height: var(--action-height);
  min-height: var(--action-height);
  padding-inline: 2px;
  font-size: var(--bottom-bar-label-size);
}
#composer #composerActions > #bottomControls button { max-width: none; }

#composer :is(#composerActions, .composer-extra-actions) .composer-button-label { line-height: 1.1; }
body.phone-device[data-composer-button-style=icons] #composer {
  --action-height: max(var(--bottom-bar-touch-size), calc(50px + var(--bottom-bar-height-offset)));
}
#composer :is(#composerActions, .composer-extra-actions) .composer-button-icon,
body[data-composer-button-style=icons] #composer :is(#composerActions, .composer-extra-actions) .composer-button-icon {
  font-size: var(--bottom-bar-icon-size);
}
#status {
  flex: 0 0 auto;
  min-height: 1.6em;
  margin: 0;
  padding: 1px 10px max(3px, env(safe-area-inset-bottom));
  color: var(--text);
  background: var(--surface);
  overflow-wrap: anywhere;
}
#composer[hidden] ~ #status { display: none; }

/* Fit more of the communication board on Fire tablets with limited height. */
body.fire-tablet-landscape #composer {
  --action-height: max(var(--bottom-bar-touch-size), calc(2.25 * var(--bottom-bar-label-size) + 6px));
  padding: 5px 8px max(4px, env(safe-area-inset-bottom));
}
body.fire-tablet-landscape #messageInputRow { margin-bottom: 4px; }
body.fire-tablet-landscape #composer #composerActions button,
body.fire-tablet-landscape #composer .composer-extra-actions > button,
body.fire-tablet-landscape #messageInputRow > button {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 3px 6px;
}
body.fire-tablet-landscape #messageInputRow > button { max-width: none; }
body.fire-tablet-landscape:not(.settings-open) #composer #composerActions #bottomControls :is(#openBoardDialog,#layout,#openSettings) {
  flex-direction: row;
  gap: clamp(3px, .65vw, 8px);
}
body.fire-tablet-landscape:not(.settings-open,[data-composer-button-style=words]) #composer #bottomControls
  :is(#openBoardDialog,#layout,#openSettings) > .composer-button-icon {
  display: block;
}
body.fire-tablet-landscape:not(.settings-open) #composer #bottomControls
  :is(#openBoardDialog,#layout,#openSettings) > .composer-button-label {
  display: block;
}
body.fire-tablet-landscape #currentBoard[data-aac-board] { font-size: calc(26px * var(--reading-scale, 1)); }
body.fire-tablet-landscape:is([data-layout=lines],.browse-boards) #grid {
  --landscape-board-font: clamp(17px, 2vw, 22px);
  --landscape-board-picture: clamp(38px, 4.3vw, 56px);
  --landscape-section-tile: clamp(132px, 15vw, 178px);
}
body.fire-tablet-landscape:is([data-layout=lines],.browse-boards) #grid .tile {
  font-size: calc(var(--landscape-board-font) * var(--reading-scale, 1));
}
body.fire-tablet-landscape:is([data-layout=lines],.browse-boards) #grid .symbol {
  min-height: var(--landscape-board-picture);
  font-size: var(--landscape-board-picture);
}
body.fire-tablet-landscape:is([data-layout=lines],.browse-boards)[data-icon-style=drawings] #grid .symbol {
  width: var(--landscape-board-picture);
  height: var(--landscape-board-picture);
}
body.fire-tablet-landscape:is([data-layout=lines],.browse-boards)[data-icon-style=drawings] #grid .symbol.semantic-composite {
  width: calc(var(--landscape-board-picture) * 1.6);
}
body.fire-tablet-landscape.browse-boards #grid :is(.tile,.board-load-more) {
  flex-basis: var(--landscape-section-tile);
  min-width: var(--landscape-section-tile);
}
body.fire-tablet-landscape.browse-boards.large #grid .tile {
  flex-basis: calc(var(--landscape-section-tile) * 1.15);
  min-width: calc(var(--landscape-section-tile) * 1.15);
}

/* Give every communication tile one common size for the current layout. */
body[data-theme][data-layout] #boardPage #grid .tile {
  box-sizing: border-box;
  min-height: var(--standard-board-tile-height);
  height: var(--standard-board-tile-height);
  max-height: var(--standard-board-tile-height);
  --standard-board-tile-height: var(--tile-height, 112px);
  overflow: hidden;
}
body[data-layout=lines] #boardPage #grid .tile {
  --standard-board-tile-height: calc(80px * var(--reading-scale, 1));
}
body.browse-boards #boardPage #grid .tile {
  --standard-board-tile-height: calc(132px * var(--reading-scale, 1));
}
body.large[data-layout=lines] #boardPage #grid .tile {
  --standard-board-tile-height: calc(104px * var(--reading-scale, 1));
}
body.large.browse-boards #boardPage #grid .tile {
  --standard-board-tile-height: calc(154px * var(--reading-scale, 1));
}
#boardPage #grid .tile .tile-caption {
  min-height: 0;
  overflow: hidden;
}
#boardPage #grid .tile .tile-caption:not(.bilingual-label),
#boardPage #grid .tile .bilingual-label :is(.english-label,.translation-label) {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

@media (max-width: 360px) {
  #composer { --action-gap: 2px; }
}

@media (max-width: 400px) {
  #composer { --action-height: max(calc(97px + var(--bottom-bar-height-offset)), calc(4.4 * var(--bottom-bar-label-size) + var(--bottom-bar-icon-size) + 8px)); }
}

/* AAC Board colours supplement the words and pictures. */
.aac-colour-column {
  display: grid;
  align-self: start;
  gap: var(--tile-grid-gap, 8px);
  min-width: 0;
}
.aac-colour-row {
  grid-column: 1 / -1;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--tile-card-width, 132px);
  justify-content: start;
  gap: var(--tile-grid-gap, 8px);
  min-width: 0;
  padding-block-end: 4px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
}
.aac-colour-row > :is(.tile,.aac-colour-column) { scroll-snap-align: start; }

body[data-aac-board-colour-strength=medium] { --aac-board-surface-share: 72%; }
body[data-aac-board-colour-strength=strong] { --aac-board-surface-share: 55%; }
[data-everyday-group="pronouns"] { --aac-word-colour: #c46b31; }
[data-everyday-group="actions"] { --aac-word-colour: #c44788; }
[data-everyday-group="responses"] { --aac-word-colour: #377eb8; }
[data-everyday-group="social"] { --aac-word-colour: #318777; }
[data-everyday-group="questions"] { --aac-word-colour: #777984; }
[data-everyday-group="linking"] { --aac-word-colour: #8b5ab5; }
[data-everyday-group="timePlace"] { --aac-word-colour: #45883f; }
[data-everyday-group="describing"] { --aac-word-colour: #a17a20; }
[data-everyday-group="nouns"] { --aac-word-colour: #996444; }
body:not(.contrast,.colourblind,.colour-buttons) #grid .tile[data-everyday-group] {
  background: color-mix(in srgb, var(--surface) var(--aac-board-surface-share,87%), var(--aac-word-colour)) !important;
  border-color: var(--aac-word-colour);
}

/* Position feedback uses a label and arrow as well as colour; no flashing. */
.board-arrange-bar{flex-wrap:wrap}.board-arrange-bar p{flex:1 1 200px}.board-arrange-bar button{min-height:44px}
#grid .tile.arrange-moved{position:relative;outline:5px solid #075985!important;outline-offset:-5px;box-shadow:inset 0 0 0 8px #fde047!important}
#grid .arrange-move-badge{position:absolute;inset-block-start:4px;inset-inline-start:4px;z-index:2;background:#075985;color:#fff;border:2px solid #fde047;border-radius:5px;padding:2px 5px;font-size:clamp(10px,1.4vw,14px);font-weight:700;line-height:1.2;pointer-events:none}
@media (forced-colors:active){#grid .tile.arrange-moved{outline-color:Highlight!important}#grid .arrange-move-badge{background:Highlight;color:HighlightText;border-color:HighlightText}}

@supports not (background:color-mix(in srgb,white,black)){
 body[data-aac-board-colour-strength=strong] #grid [data-everyday-group="pronouns"]{--aac-strong-fill:#e4bca2}
 body[data-aac-board-colour-strength=strong] #grid [data-everyday-group="actions"]{--aac-strong-fill:#e4acc9}
 body[data-aac-board-colour-strength=strong] #grid [data-everyday-group="responses"]{--aac-strong-fill:#a5c5df}
 body[data-aac-board-colour-strength=strong] #grid [data-everyday-group="social"]{--aac-strong-fill:#a2c9c2}
 body[data-aac-board-colour-strength=strong] #grid [data-everyday-group="questions"]{--aac-strong-fill:#c2c3c8}
 body[data-aac-board-colour-strength=strong] #grid [data-everyday-group="linking"]{--aac-strong-fill:#cbb5de}
 body[data-aac-board-colour-strength=strong] #grid [data-everyday-group="timePlace"]{--aac-strong-fill:#abc9a9}
 body[data-aac-board-colour-strength=strong] #grid [data-everyday-group="describing"]{--aac-strong-fill:#d5c39b}
 body[data-aac-board-colour-strength=strong] #grid [data-everyday-group="nouns"]{--aac-strong-fill:#d1b9ab}
 body[data-aac-board-colour-strength=strong]:not(.contrast,.colourblind,.colour-buttons) #grid .tile[data-everyday-group]{background:var(--aac-strong-fill,var(--surface))!important;color:#14223a}
}

/* Action colours supplement labels; a white icon surface stays readable on any theme. */
.composer-button-icon[data-action-icon]{color:var(--action-icon-colour);background:#fff;border-radius:6px;padding:3px;box-sizing:content-box;line-height:1}
.composer-button-icon[data-action-icon] svg{display:block;width:1em;height:1em;min-width:1em}
[data-action-icon=speak]{--action-icon-colour:#087443}[data-action-icon=stop]{--action-icon-colour:#ba1b2a}[data-action-icon=undo]{--action-icon-colour:#966000}[data-action-icon=clear]{--action-icon-colour:#8e1735}[data-action-icon=openBoardDialog]{--action-icon-colour:#175bb5}[data-action-icon=layout]{--action-icon-colour:#7238a1}[data-action-icon=openSettings]{--action-icon-colour:#48566b}
body:is(.contrast,.colourblind) .composer-button-icon[data-action-icon]{color:inherit;background:transparent}
/* Keep live feedback available to assistive technology without a redundant footer row. */
body #status{position:absolute!important;width:1px!important;height:1px!important;min-height:0!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;clip-path:inset(50%)!important;white-space:nowrap!important;border:0!important;flex:none!important}
#pictureSentence{display:none!important}
