/* Lecture — app.css. A well-made printed book with large, calm controls in fixed places.
   Every colour pair used for text is ≥ 7:1 (WCAG 1.4.6); see the token comments. No inline styles anywhere:
   the scripts only set custom properties (--size, --fit, --level, --progress). */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/AtkinsonHyperlegibleNext.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/AtkinsonHyperlegibleNext-Italic.woff2") format("woff2");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Lecture Serif";            /* Source Serif 4 (Adobe, OFL), subset + renamed: static/fonts/FONTS.txt */
  src: url("/fonts/LectureSerif.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Lecture Serif";
  src: url("/fonts/LectureSerif-Italic.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}
/* Atkinson draws a slashed zero (« 2Ø26 », « 16 h Ø2 ») with no plain alternate: its digits come from Source Sans 3
   (same cap height, 660 vs 668). Declared after Atkinson, so this face wins for U+0030–0039 (CSS Fonts §4.5). */
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/LectureDigits.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0030-0039;
}

/* ---------------------------------------------------------------------------------------------- tokens */

:root,
[data-theme="clair"] {
  --paper: #FBF7EF;
  --ink: #1B1A17;          /* 16.6:1 on paper */
  --ink-soft: #4A453D;     /* 8.9:1 on paper, 8.0:1 on surface */
  --rule: #DAD1BF;         /* hairlines and borders, never text */
  --surface: #F2EBDD;      /* buttons */
  --surface-press: #E7DDCA;
  --raise: #FFFDF8;        /* cards */
  --accent: #1E4D8C;       /* 7.9:1 on paper */
  --accent-press: #173E72;
  --on-accent: #FFFFFF;    /* 8.4:1 on accent */
  --mark: #FFD54A;         /* the sentence being read */
  --on-mark: #1B1A17;      /* 12.3:1 */
  --focus: #1E4D8C;
  --shade: 46 36 18;
  color-scheme: light;
}

[data-theme="sepia"] {
  --paper: #F3EAD7;
  --ink: #3A2E1F;          /* 11.0:1 */
  --ink-soft: #4E402B;     /* 8.4:1 on paper, 7.6:1 on surface */
  --rule: #D5C5A6;
  --surface: #EADFC7;
  --surface-press: #DFD1B4;
  --raise: #F9F2E3;
  --accent: #1E4D8C;       /* 7.0:1 on paper */
  --accent-press: #173E72;
  --on-accent: #FFFFFF;
  --mark: #FFD54A;
  --on-mark: #3A2E1F;      /* 9.3:1 */
  --focus: #1E4D8C;
  --shade: 58 46 31;
  color-scheme: light;
}

[data-theme="sombre"] {
  --paper: #1B1A18;
  --ink: #EDE6D6;          /* 14.0:1 */
  --ink-soft: #C2B9A7;     /* 8.9:1 on paper, 8.0:1 on surface */
  --rule: #3D3A33;
  --surface: #26241F;
  --surface-press: #312E28;
  --raise: #23211D;
  --accent: #8FB4E8;       /* 8.2:1 on paper */
  --accent-press: #A6C4EE;
  --on-accent: #10161F;    /* 8.5:1 on accent */
  --mark: #5C4A16;
  --on-mark: #FFF6E0;      /* 8.0:1 */
  --focus: #8FB4E8;
  --shade: 0 0 0;
  color-scheme: dark;
}

:root {
  --size: 32px;
  --font-ui: "Atkinson Hyperlegible Next", -apple-system, system-ui, "Segoe UI", sans-serif;
  --font-read: var(--font-ui);
  --read-axes: normal;
  --gutter: 28px;
  --gap: 16px;
  --radius: 16px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --t-turn: 240ms;
  --t-mark: 200ms;
  --t-rise: 240ms;
}

[data-font="serif"] {
  /* « Classique »: Lecture Serif (Source Serif 4) with its optical size held near 16, so strokes stay sturdy when large */
  --font-read: "Lecture Serif", Georgia, "Times New Roman", serif;
  --read-axes: "opsz" 16;
}

/* ---------------------------------------------------------------------------------------------- base */

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

html,
body {
  margin: 0;
  height: 100%;
}

html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 24px;
  line-height: 1.4;
  font-kerning: normal;
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

input,
textarea {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

button {
  font: inherit;
  color: inherit;
}

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--paper);
}

.app__screen,
.screen {
  position: absolute;
  inset: 0;
}

.app__overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.app__overlay > * {
  pointer-events: auto;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  display: block;
  flex: none;
  width: 1.1em;
  height: 1.1em;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 8px 18px;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 600;
  line-height: 1.12;
  text-align: center;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  transition: transform 120ms var(--ease), background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.btn__label {
  min-width: 0;
  overflow-wrap: break-word;
}

.btn--main {
  min-height: 88px;
  font-size: 26px;
}

.btn--main .icon {
  width: 30px;
  height: 30px;
}

.btn--aux {
  min-height: 72px;
  font-size: 23px;
  border-radius: 14px;
}

.btn--aux .icon {
  width: 26px;
  height: 26px;
}

.btn--small {
  min-height: 44px;
  padding: 6px 16px;
  font-size: 17px;
  border-radius: 10px;
  gap: 8px;
}

.btn--small .icon {
  width: 20px;
  height: 20px;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 1px 0 rgb(var(--shade) / 0.12), 0 10px 22px -14px rgb(var(--shade) / 0.7);
}

.btn--plain {
  background: var(--surface);
  border-color: var(--rule);
  color: var(--ink);
}

.btn--quiet {
  background: transparent;
  border-color: var(--rule);
  color: var(--ink-soft);
}

.btn:active {
  transform: scale(0.97);
}

.btn--plain:active,
.btn--quiet:active {
  background: var(--surface-press);
}

.btn--primary:active {
  background: var(--accent-press);
  border-color: var(--accent-press);
}

.btn:disabled {
  opacity: 0.38;
  cursor: default;
  transform: none;
  box-shadow: none;
}

@media (hover: hover) {
  .btn--plain:hover:not(:disabled),
  .btn--quiet:hover:not(:disabled) {
    background: var(--surface-press);
  }
  .btn--primary:hover:not(:disabled) {
    background: var(--accent-press);
    border-color: var(--accent-press);
  }
  .w:hover {
    text-decoration: underline dotted;
    text-decoration-thickness: 0.06em;
    text-underline-offset: 0.2em;
    cursor: pointer;
  }
  .book:hover .cover,
  .continue:hover {
    border-color: var(--ink-soft);
  }
}

/* ---------------------------------------------------------------------------------------------- top & bar */

.top {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
  min-height: calc(96px + env(safe-area-inset-top));
  padding: calc(12px + env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 12px max(24px, env(safe-area-inset-left));
}

.top__back {
  flex: none;
  padding-right: 22px;
}

.top__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top__book {
  font-style: italic;
  color: var(--ink);
}

.bar {
  padding: 16px max(24px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  border-top: 1px solid var(--rule);
  background: var(--paper);
}

.bar__row {
  display: grid;
  gap: var(--gap);
  max-width: 1040px;
  margin: 0 auto;
}

.bar__row + .bar__row {
  margin-top: var(--gap);
}

.bar__row--main {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.32fr) minmax(0, 1fr);
}

.bar__row--aux {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.bar__row > .btn,
.bar__slot > .btn {
  width: 100%;
}

.bar__slot {
  display: flex;
  min-width: 0;
}

.bar__play {
  font-size: 30px;
  gap: 14px;
}

.bar__play .icon {
  width: 34px;
  height: 34px;
}

/* a paragraph is being prepared (the first request for it can take a few seconds): a slow, quiet breath */
.bar__play.is-starting .icon {
  animation: breathe 1.6s ease-in-out infinite;
}

/* ---------------------------------------------------------------------------------------------- reader */

.screen--reader {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
}

.frame {
  position: relative;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}

.page {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  max-width: calc(var(--size) * 24 + 2 * var(--gutter));
  padding: 4px var(--gutter) 14px;
  font-family: var(--font-read);
  font-variation-settings: var(--read-axes);
  font-optical-sizing: none;
  font-size: calc(var(--size) * var(--fit, 1));
  font-weight: 400;
  line-height: 1.55;
  text-align: left;
  -webkit-hyphens: none;
  hyphens: none;
  overflow-wrap: break-word;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.page--measure {
  visibility: hidden;
  pointer-events: none;
  z-index: -1;
}

.page--note {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 28px;
}

.note {
  margin: 0;
  color: var(--ink-soft);
  max-width: 22em;
}

.note__actions {
  margin-top: 28px;
}

.b {
  margin: 0 0 0.6em;
}

.b:last-child {
  margin-bottom: 0;
}

.b--h {
  margin: 0.15em 0 0.95em;
  font-size: 1.12em;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.002em;
}

.b--v {
  white-space: pre-line;
  padding-left: 0.6em;
}

.b--i {
  margin-left: 1.2em;
}

.b--sep {
  height: 1.2em;
  margin: 0.3em auto 0.9em;
  width: 3.2em;
  background-image: radial-gradient(circle, var(--ink-soft) 0.075em, transparent 0.09em);
  background-size: 1.07em 100%;
  background-position: center;
  background-repeat: space no-repeat;
}

/* the sentence being read: padding and negative margins cancel out, so the highlight never moves a line */
.seg,
.part {
  padding: 0.07em 0.14em;
  margin: 0 -0.14em;
  border-radius: 0.2em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-color var(--t-mark) ease, color var(--t-mark) ease;
}

.seg.is-reading,
.part.is-reading {
  background-color: var(--mark);
  color: var(--on-mark);
}

.w.is-asked {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 0.09em;
  text-underline-offset: 0.2em;
}

.page.turn-fwd {
  animation: turn-fwd var(--t-turn) var(--ease) both;
}

.page.turn-back {
  animation: turn-back var(--t-turn) var(--ease) both;
}

@keyframes turn-fwd {
  from {
    opacity: 0;
    transform: translateX(3%);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes turn-back {
  from {
    opacity: 0;
    transform: translateX(-3%);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------------------------------------------------------------------------------------------- sheets */

.sheet {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  background: var(--paper);
  animation: rise var(--t-rise) var(--ease) both;
}

.sheet__body {
  min-height: 0;
  overflow-y: auto;
  scroll-padding: 24px 0 33%;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 0 max(28px, env(safe-area-inset-right)) 28px max(28px, env(safe-area-inset-left));
}

.recall {
  max-width: calc(var(--size) * 24 + 8px);
  margin: 0 auto;
  padding-top: 4px;
}

.recall__lead {
  margin: 0 0 28px;
  font-size: 30px;
  line-height: 1.3;
  color: var(--ink-soft);
}

.recall__title {
  font-style: italic;
  color: var(--ink);
}

.recall__quote {
  margin: 0 0 32px;
  padding: 2px 0 2px 26px;
  border-left: 4px solid var(--rule);
  font-family: var(--font-read);
  font-variation-settings: var(--read-axes);
  font-optical-sizing: none;
  font-size: var(--size);
  line-height: 1.55;
  color: var(--ink);
}

.recall__para {
  margin: 0;
}

.recall__para + .recall__para {
  margin-top: 0.6em;
}

.recall__recap {
  margin: 0;
  font-family: var(--font-read);
  font-variation-settings: var(--read-axes);
  font-optical-sizing: none;
  font-size: var(--size);
  line-height: 1.55;
}

/* question */

.ask {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  min-height: 100%;
  padding: 8px 0 12px;
  text-align: center;
}

.ask__mic {
  position: relative;
  display: grid;
  place-items: center;
  width: 176px;
  height: 176px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--rule);
  color: var(--accent);
}

.ask__mic .icon {
  width: 72px;
  height: 72px;
}

.ask__ring {
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  border: 6px solid var(--accent);
  opacity: 0;
  transform: scale(calc(1 + var(--level, 0) * 0.28));
}

.ask--listening .ask__ring {
  opacity: 0.45;
}

.ask--thinking .ask__mic {
  animation: breathe 2.4s ease-in-out infinite;
}

.ask--answer .ask__mic,
.ask--message .ask__mic {
  display: none;
}

@keyframes breathe {
  50% {
    opacity: 0.45;
  }
}

.ask__status {
  margin: 0;
  font-size: 40px;
  font-weight: 700;
  line-height: 1.2;
}

.ask__status:empty {
  display: none;
}

.ask__hint {
  margin: 0;
  max-width: 24em;
  font-size: 28px;
  line-height: 1.35;
  color: var(--ink-soft);
}

.ask__hint:empty {
  display: none;
}

.ask__qa {
  width: 100%;
  max-width: calc(var(--size) * 24 + 8px);
  text-align: left;
}

.ask--answer {
  justify-content: flex-start;
}

.ask__asked {
  margin: 0 0 6px;
  font-size: 24px;
  color: var(--ink-soft);
}

.ask__asked:empty,
.ask__question:empty {
  display: none;
}

.ask__question {
  margin: 0 0 28px;
  font-size: 30px;
  line-height: 1.35;
  font-style: italic;
}

.ask__answer {
  margin: 0;
  font-family: var(--font-read);
  font-variation-settings: var(--read-axes);
  font-optical-sizing: none;
  font-size: var(--size);
  line-height: 1.55;
}

/* explanation card: the half of the screen away from the word */

.explain {
  position: absolute;
  inset: 0;
}

.explain__card {
  position: absolute;
  left: max(24px, env(safe-area-inset-left));
  right: max(24px, env(safe-area-inset-right));
  max-height: calc(50% - 32px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 26px 32px 24px;
  overflow-y: auto;
  border: 1.5px solid var(--rule);
  border-radius: 22px;
  background: var(--raise);
  box-shadow: 0 2px 0 rgb(var(--shade) / 0.05), 0 28px 60px -26px rgb(var(--shade) / 0.65);
  animation: rise var(--t-rise) var(--ease) both;
}

.explain__card--bottom {
  bottom: calc(20px + env(safe-area-inset-bottom));
}

.explain__card--top {
  top: calc(20px + env(safe-area-inset-top));
}

.explain__word,
.explain__text {
  width: 100%;
  max-width: calc(var(--size) * 26);
  margin-left: auto;
  margin-right: auto;
}

.explain__word {
  margin-top: 0;
  margin-bottom: 0;
  font-family: var(--font-read);
  font-variation-settings: var(--read-axes);
  font-size: calc(var(--size) * 1.12);
  font-weight: 700;
  line-height: 1.2;
}

.explain__text {
  margin-top: 0;
  margin-bottom: 0;
  font-family: var(--font-read);
  font-variation-settings: var(--read-axes);
  font-optical-sizing: none;
  font-size: var(--size);
  line-height: 1.5;
}

.explain__wait {
  color: var(--ink-soft);
}

.explain__actions {
  display: flex;
  justify-content: center;
  margin-top: auto;
  padding-top: 6px;
}

.explain__actions .btn {
  width: min(380px, 100%);
}

/* ---------------------------------------------------------------------------------------------- home */

.screen--home,
.screen--family,
.screen--pair {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.home__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: calc(44px + env(safe-area-inset-top)) max(36px, env(safe-area-inset-right)) calc(56px + env(safe-area-inset-bottom)) max(36px, env(safe-area-inset-left));
}

.home__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.home__greet {
  margin: 0;
  font-size: 52px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.008em;
}

.home__date {
  margin: 10px 0 0;
  font-size: 32px;
  line-height: 1.25;
  color: var(--ink-soft);
}

.home__family {
  flex: none;
}

.home__empty {
  margin: 40px 0 0;
  font-size: 28px;
  color: var(--ink-soft);
}

.continue {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 32px;
  width: 100%;
  min-height: 248px;
  margin: 40px 0 0;
  padding: 24px 32px 24px 24px;
  border: 1.5px solid var(--rule);
  border-radius: 22px;
  background: var(--raise);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 0 rgb(var(--shade) / 0.05), 0 18px 40px -28px rgb(var(--shade) / 0.6);
  transition: transform 120ms var(--ease), border-color 160ms ease;
}

.continue:active {
  transform: scale(0.985);
}

.continue__cover {
  width: 133px;
  height: 200px;
}

.continue__text {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.continue__label {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
}

.continue__title {
  font-size: 38px;
  line-height: 1.15;
  font-weight: 700;
  overflow-wrap: break-word;
}

.continue__author {
  font-size: 24px;
  color: var(--ink-soft);
}

.continue__chev {
  width: 44px;
  height: 44px;
  color: var(--accent);
}

.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, 160px);
  justify-content: start;
  gap: 36px 32px;
  margin: 44px 0 0;
  padding: 0;
  list-style: none;
}

.shelf__item {
  margin: 0;
}

.book {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 160px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.book__title {
  font-size: 21px;
  line-height: 1.25;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cover {
  display: block;
  flex: none;
  width: 160px;
  height: 240px;
  object-fit: cover;
  border: 1px solid var(--rule);
  border-radius: 4px 7px 7px 4px;
  background: var(--surface);
  box-shadow: inset 4px 0 0 rgb(var(--shade) / 0.06), 0 1px 2px rgb(var(--shade) / 0.18), 0 14px 26px -16px rgb(var(--shade) / 0.65);
  transition: transform 120ms var(--ease), border-color 160ms ease;
}

.book:active .cover {
  transform: scale(0.97);
}

.cover--plain {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px 16px 18px;
  background: var(--surface);
  outline: 1px solid var(--rule);
  outline-offset: -9px;
  font-family: "Lecture Serif", Georgia, serif;
  font-variation-settings: "opsz" 20;
  color: var(--ink);
  overflow: hidden;
}

.cover__title {
  font-size: 21px;
  line-height: 1.2;
  font-weight: 650;
  overflow-wrap: break-word;
}

.cover__author {
  font-size: 16px;
  line-height: 1.25;
  color: var(--ink-soft);
}

.continue__cover.cover--plain .cover__title {
  font-size: 18px;
}

.book--add .book__title {
  color: var(--ink-soft);
}

.book__cover--add {
  display: grid;
  place-items: center;
  width: 160px;
  height: 240px;
  border: 2px dashed var(--rule);
  border-radius: 8px;
  color: var(--accent);
  transition: transform 120ms var(--ease);
}

.book__cover--add .icon {
  width: 52px;
  height: 52px;
}

.book--add:active .book__cover--add {
  transform: scale(0.97);
}

.upload {
  margin-top: 32px;
}

.upload__text {
  margin: 0;
  max-width: 34em;
  font-size: 24px;
  line-height: 1.35;
}

.upload__text:empty {
  display: none;
}

.upload[data-kind="refused"] .upload__text {
  padding-left: 18px;
  border-left: 4px solid var(--accent);
}

.upload__bar {
  display: block;
  max-width: 520px;
  height: 6px;
  margin-top: 14px;
  border-radius: 3px;
  background: var(--surface-press);
  overflow: hidden;
}

.upload__fill {
  display: block;
  height: 100%;
  width: calc(var(--progress, 0) * 100%);
  border-radius: 3px;
  background: var(--accent);
  transition: width 240ms linear;
}

/* ---------------------------------------------------------------------------------------------- pairing */

.screen--pair {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: calc(9vh + env(safe-area-inset-top)) 24px 24px;
}

.pair {
  width: min(660px, 100%);
  padding: 40px 44px 36px;
  border: 1.5px solid var(--rule);
  border-radius: 26px;
  background: var(--raise);
  text-align: center;
  box-shadow: 0 1px 0 rgb(var(--shade) / 0.05), 0 22px 50px -32px rgb(var(--shade) / 0.6);
}

.pair__mark {
  display: flex;
  justify-content: center;
  color: var(--accent);
}

.pair__mark .icon {
  width: 60px;
  height: 60px;
}

.pair__prompt {
  margin: 18px 0 30px;
  font-size: 30px;
  line-height: 1.35;
}

.pair__form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.pair__code {
  width: 6.9em;
  max-width: 100%;
  margin: 0;
  padding: 10px 0 10px 0.3em;
  border: 2px solid var(--rule);
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 56px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3em;
  text-align: center;
  caret-color: var(--accent);
}

.pair__code:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

.pair__form .btn {
  min-width: min(340px, 100%);
}

.pair__msg {
  min-height: 1.35em;
  margin: 22px 0 0;
  font-size: 24px;
  line-height: 1.35;
}

/* « Choisissez votre code »: a title above the sentence, then a check once it is kept */
.pair__prompt--title {
  margin-bottom: 0;
  font-size: 36px;
  font-weight: 700;
}

.pair__prompt--title + .pair__prompt {
  margin-top: 10px;
}

.pair__done {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 8px 0 0;
  font-size: 32px;
  font-weight: 700;
  animation: fade var(--t-rise) var(--ease) both;
}

.pair__done .icon {
  width: 44px;
  height: 44px;
  color: var(--accent);
}

/* ---------------------------------------------------------------------------------------------- crash */

.screen--crash {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.crash {
  text-align: center;
}

.crash__title {
  margin: 0 0 14px;
  font-size: 40px;
  font-weight: 700;
}

.crash__hint {
  margin: 0;
  font-size: 26px;
  color: var(--ink-soft);
}

.crash .btn {
  margin-top: 26px;
  min-width: 320px;
}

/* ---------------------------------------------------------------------------------------------- family (18 px) */

.family {
  font-size: 18px;
  line-height: 1.5;
}

.family__inner {
  max-width: 860px;
  margin: 0 auto;
  padding: calc(28px + env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) calc(56px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.family__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.family__title {
  margin: 0;
  font-size: 32px;
  line-height: 1.2;
}

.family__error {
  margin: 24px 0 0;
}

.banner {
  margin: 24px 0 0;
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--mark);
  color: var(--on-mark);
  font-weight: 600;
}

.fsection {
  margin-top: 44px;
}

.fsection__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.fsection__title {
  margin: 0 0 14px;
  font-size: 22px;
  line-height: 1.3;
}

.fsection__state {
  margin: 8px 0 0;
  color: var(--ink-soft);
}

.fsection__state:empty {
  display: none;
}

.fsection__actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.fbooks,
.fdevices {
  margin: 0;
  padding: 0;
  list-style: none;
  border-bottom: 1px solid var(--rule);
}

.fbook {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 18px;
  padding: 18px 0;
  border-top: 1px solid var(--rule);
}

.fbook--none {
  display: block;
  color: var(--ink-soft);
}

.fbook__cover {
  width: 64px;
  height: 96px;
  border-radius: 3px 5px 5px 3px;
}

.fbook__cover.cover--plain {
  padding: 8px 6px;
  outline-offset: -4px;
}

.fbook__cover .cover__title {
  font-size: 10px;
}

.fbook__cover .cover__author {
  display: none;
}

.fbook__title {
  margin: 0;
  font-weight: 700;
  font-size: 19px;
  line-height: 1.3;
}

.fbook__author,
.fbook__meta {
  margin: 2px 0 0;
  color: var(--ink-soft);
}

.fbook__lines {
  margin-top: 10px;
}

.fbook__caption {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.fbook__para {
  margin: 0;
}

.fbook__para + .fbook__para {
  margin-top: 0.4em;
}

.fbook__quote {
  margin: 0;
  padding-left: 14px;
  border-left: 3px solid var(--rule);
  font-family: var(--font-read);
  font-variation-settings: var(--read-axes);
  font-size: 19px;
  line-height: 1.5;
}

.fbook__actions {
  margin-top: 10px;
}

.confirm {
  margin-top: 10px;
  padding: 14px 16px;
  border: 1.5px solid var(--rule);
  border-radius: 12px;
  background: var(--raise);
}

.confirm__q {
  margin: 0 0 12px;
  font-weight: 600;
}

.confirm__actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.fset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.fset__legend {
  padding: 0;
  margin: 0 0 8px;
  font-weight: 600;
}

.choice {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice__item {
  position: relative;
  display: inline-flex;
}

.choice__input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.choice__label {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 16px;
  border: 1.5px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
}

.choice__input:checked + .choice__label {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.choice__input:focus-visible + .choice__label {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
}

.field {
  display: grid;
  gap: 6px;
}

.field__label {
  font-weight: 600;
}

.field__input {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 8px 12px;
  border: 1.5px solid var(--rule);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

.field__input:focus {
  border-color: var(--accent);
  outline: 4px solid var(--focus);
  outline-offset: 2px;
}

.field__hint {
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
}

.fdevice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--rule);
}

.fdevice__label {
  margin: 0;
  font-weight: 700;
}

.fdevice__meta {
  margin: 0;
  color: var(--ink-soft);
}

.fdevice .confirm {
  flex-basis: 100%;
}

.adddev {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.adddev:empty {
  display: none;
}

.adddev__intro,
.adddev__until {
  margin: 0;
}

.adddev__until {
  color: var(--ink-soft);
}

.adddev__code {
  margin: 0;
  font-size: 60px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.adddev__row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.adddev__row .field__input {
  flex: 1;
}

/* ---------------------------------------------------------------------------------------------- narrow screens */

@media (max-width: 900px) {
  .btn--main {
    font-size: 24px;
    gap: 10px;
    padding: 8px 14px;
  }
  .bar__play {
    font-size: 28px;
  }
  .btn--aux {
    font-size: 22px;
  }
}

@media (max-width: 640px) {
  :root {
    --gutter: 18px;
  }
  .btn--main {
    font-size: 20px;
    flex-direction: column;
    gap: 4px;
  }
  .btn--aux {
    font-size: 19px;
  }
  .bar__play {
    font-size: 24px;
  }
  .home__greet {
    font-size: 44px;
  }
  .home__date {
    font-size: 28px;
  }
  .continue {
    gap: 18px;
    padding: 18px;
  }
  .continue__cover {
    width: 100px;
    height: 150px;
  }
  .continue__title {
    font-size: 28px;
  }
}

/* ---------------------------------------------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  .page.turn-fwd,
  .page.turn-back,
  .sheet,
  .explain__card {
    animation: fade 120ms ease-out both;
  }
  .btn,
  .continue,
  .cover,
  .book__cover--add {
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
  }
  .btn:active,
  .continue:active,
  .book:active .cover,
  .book--add:active .book__cover--add {
    transform: none;
  }
  .seg,
  .part {
    transition-duration: 120ms;
  }
  .ask__ring {
    transform: none;
  }
  .ask--listening .ask__ring {
    opacity: calc(0.2 + var(--level, 0) * 0.8);
  }
  .ask--thinking .ask__mic,
  .bar__play.is-starting .icon {
    animation: none;
  }
  .upload__fill {
    transition: none;
  }
}

/* ---------------------------------------------------------------------------------------------- settings */

/* « Réglages », top right of the reader and of Accueil */
.top__settings {
  flex: none;
  margin-left: auto;
}

.home__actions {
  display: flex;
  flex: none;
  gap: 12px;
}

/* the chosen option: same surface as the others, a thick accent edge — never a second blue button */
.btn--chosen {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
  color: var(--ink);
}

.btn--chosen .icon {
  color: var(--accent);
}

.btn--chosen:active {
  background: var(--surface-press);
}

/* « Réglages »: a compact window over a dimmed screen (Taha 10-21: « réglages window is too big ») */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);   /* a sized row, so the window's max-height: 100% holds */
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background: rgb(20 18 14 / 0.45);
  animation: fade var(--t-rise) var(--ease) both;
}

.dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(720px, 100%);
  max-height: 100%;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 24px 60px -20px rgb(0 0 0 / 0.45);
  animation: rise var(--t-rise) var(--ease) both;
}

.dialog__head {
  padding: 22px 28px 6px;
}

.dialog__title {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.dialog__body {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 0 28px;
}

.dialog__foot {
  display: flex;
  justify-content: flex-end;
  padding: 14px 28px 22px;
  border-top: 1px solid var(--rule);
}

.set__group {
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
}

.set__group:last-child {
  border-bottom: 0;
}

.set__label {
  margin: 0 0 4px;
  font-size: 22px;
}

.set__hint {
  margin: 0 0 10px;
  font-size: 18px;
  color: var(--ink-soft);
}

.set__row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 10px;
}

.set__opt {
  position: relative;
  font-size: 20px;
  padding-left: 10px;
  padding-right: 10px;
}

/* the check of the chosen option sits in its corner: the label keeps the whole width and never breaks inside a word */
.set__opt .icon {
  position: absolute;
  top: 7px;
  left: 8px;
  width: 18px;
  height: 18px;
}

.set__opt .btn__label {
  overflow-wrap: normal;
}

/* each colour choice is shown in its own colours, each font choice in its own font */
.set__opt--theme[data-value="clair"] { background: #FBF7EF; color: #1B1A17; }
.set__opt--theme[data-value="sepia"] { background: #F3EAD7; color: #3A2E1F; }
.set__opt--theme[data-value="sombre"] { background: #1B1A18; color: #EDE6D6; }
.set__opt--font[data-value="atkinson"] { font-family: "Atkinson Hyperlegible Next", system-ui, sans-serif; }
.set__opt--font[data-value="serif"] { font-family: "Lecture Serif", Georgia, serif; font-weight: 600; }
.set__opt--theme.btn--chosen .icon { color: currentColor; }

/* wide screens (the computer, the iPad held flat): two columns, so every choice shows without scrolling — the speed
   and its example on the left, size, colours and font on the right */
@media (min-width: 1000px) {
  .dialog--settings {
    width: min(1040px, 100%);
  }
  .set {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    column-gap: 36px;
    align-items: start;
  }
  .set__group--rate {
    grid-column: 1;
    grid-row: 1 / span 3;
    border-bottom: 0;
  }
  .set__group--size,
  .set__group--theme,
  .set__group--font {
    grid-column: 2;
  }
}

/* the example: at his size, font and colours; the sentence being read is highlighted */
.set__example {
  margin: 14px 0 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface);
  font-family: var(--font-read);
  font-variation-settings: var(--read-axes);   /* « Classique » as on the page: optical size held near 16 */
  font-optical-sizing: none;
  font-size: var(--size);
  line-height: 1.5;
}

.set__example:empty {
  display: none;
}

.set__example .part {
  border-radius: 6px;
  transition: background-color 200ms var(--ease);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.set__example .part.is-reading {
  background: var(--mark);
}

.fsection__hint {
  margin: 0 0 12px;
  color: var(--ink-soft);
}
