/* First Words — calm by design. No effects, no motion beyond the one functional
   enlargement, nothing that competes with the photo and the word. */

:root {
  --paper: #FBF9F5;
  --surface: #F2EFE7;
  --surface-2: #ECE8DD;
  --ink: #262319;
  --muted: #6E6656;
  --accent: #33695E;
  --accent-ink: #2A574E;
  --accent-soft: #E2EDE8;
  --amber: #A97A20;
  --rust: #A5533B;
  --line: #E2DDD0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* screens set their own display; hidden must still win */

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Nunito Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

.screen {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* ---------- Start screen (adult-facing) ---------- */

#screen-start {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  touch-action: manipulation;
}
.start-inner { padding: 24px; max-width: 480px; }
.start-inner h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 700;
  margin: 0 0 6px;
}
.adult-line { color: var(--muted); font-size: 15px; margin: 28px 0 0; }
.big-btn {
  font: inherit;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 18px 64px;
  cursor: pointer;
}
.big-btn:disabled { background: var(--surface-2); color: var(--muted); cursor: default; }
.big-btn:focus-visible, .btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.start-msg { color: var(--rust); margin: 18px 0 0; }
.start-topic { color: var(--muted); margin: 0 0 30px; font-size: 18px; }
.start-inner h1 + .big-btn { margin-top: 30px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 44px; }

/* ---------- Child session ---------- */

#screen-session {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.pair {
  position: absolute;
  /* generous dead margins on every edge — resting palms land on nothing */
  inset: 7vh 6vw;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10vw;
}
.card {
  width: min(38vw, 62vh);
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  overflow: hidden;
  background: var(--surface);
  transition: transform 0.45s ease, opacity 0.4s ease;
  will-change: transform, opacity;
}
.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.card.focus { z-index: 2; }
.card.away { opacity: 0; }

@media (orientation: portrait) {
  .pair { flex-direction: column; inset: 6vh 8vw; gap: 6vh; }
  .card { width: min(70vw, 34vh); }
}

/* Swipe mode: one photo, moved by his finger. The whole screen takes the swipe;
   only the photo itself takes a tap. */
#screen-session[data-mode="swipe"] .pair { display: none; }
#screen-session[data-mode="pair"] .stage { display: none; }
.stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.slide {
  position: absolute;
  width: min(76vw, 76vh);
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  overflow: hidden;
  background: var(--surface);
  will-change: transform;
}
.slide[hidden] { display: none; }
.slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .card { transition-duration: 0.01s; }
}

/* ---------- End screen ---------- */

#screen-end {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.end-inner { text-align: center; color: var(--muted); }
.end-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.5;
  margin: 0 auto 16px;
}
.end-inner p { font-family: Georgia, serif; font-size: 18px; margin: 0; }
.end-home { margin-top: 28px; }
.parent-head h2 .ver { font-family: inherit; font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 8px; }

/* ---------- Parent area ---------- */

.parent-screen {
  overflow-y: auto;
  touch-action: pan-y;
  background: var(--paper);
}
.parent-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}
.parent-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--paper);
  padding: 10px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.parent-head h2 {
  font-family: Georgia, serif;
  font-size: 28px;
  margin: 0;
}
.parent-note {
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 16px 0 0;
}

.p-block {
  margin-top: 30px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}
.settings-grid { display: flex; flex-wrap: wrap; gap: 20px 32px; }
.settings-grid > div { min-width: 220px; }
details.sub { margin-top: 16px; }
details.sub summary { font-weight: 600; font-size: 15px; color: var(--muted); }
.p-block h3 { font-size: 19px; margin: 0 0 12px; }
details.p-block > summary { font-size: 19px; padding: 0; }
details.p-block > ul { margin-top: 12px; }
details.p-block .settings-grid { margin-top: 14px; }
.p-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.count { color: var(--muted); font-weight: 400; font-size: 15px; }

.btn {
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 18px;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--rust); }
.btn:disabled { opacity: 0.5; cursor: default; }

/* Add/edit form */
#word-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  margin: 16px 0;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.f-label { display: block; font-weight: 800; font-size: 14px; margin: 0 0 6px; }
.f-label.gap { margin-top: 18px; }
.mode-opts { display: flex; flex-direction: column; gap: 10px; }
.mode-opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 15px;
  cursor: pointer;
  max-width: 560px;
}
.mode-opt input { width: 18px; height: 18px; margin-top: 3px; flex-shrink: 0; accent-color: var(--accent); }
#word-form input[type="text"], #f-taps, #f-topic-session, .import-row input[type="text"] {
  font: inherit;
  width: 100%;
  max-width: 260px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}
#word-form input[type="file"] { font: inherit; font-size: 14px; max-width: 100%; }
.photo-preview { margin-top: 10px; }
.photo-preview img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.tip { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.coach { margin-bottom: 10px; }
.rec-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rec-time { color: var(--rust); font-weight: 700; min-width: 46px; }
.form-msg { color: var(--rust); margin: 14px 0 0; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }

/* Topics, packs, file import */
.topic-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 -2px;
  padding: 0 2px;
}
.topic-head:first-child { margin-top: 0; }
.topic-head strong { font-size: 16px; }
.pack-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  flex-wrap: wrap;
}
.import-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.import-row input[type="text"] { max-width: 220px; }
.import-row input[type="file"] { font: inherit; font-size: 14px; max-width: 100%; }

/* Word list */
.word-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.word-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  flex-wrap: wrap;
}
.word-row .thumb {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
}
.w-main { flex: 1; min-width: 120px; }
.w-main strong { font-size: 17px; display: block; }
.w-meta { color: var(--muted); font-size: 13px; }
.chk {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.chk input { width: 18px; height: 18px; accent-color: var(--accent); }
.row-actions { display: flex; gap: 8px; }

/* Help */
details { margin-bottom: 10px; }
summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
details ul { margin: 8px 0 12px; padding-left: 22px; }
details li { margin-bottom: 6px; }
details em { font-style: normal; font-weight: 700; }

/* ---------- Parent area: topics, word cards, guided recording ---------- */

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 0 4px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.tab.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.tab.add { background: transparent; border-style: dashed; color: var(--muted); }
.tab.add.on { background: var(--ink); border-style: solid; color: var(--paper); }
.tab:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.topic-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.topic-summary { margin: 0; color: var(--muted); font-size: 15px; }
.legend { margin-top: 12px; }

.wgrid {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.wcard {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid transparent;
}
.wcard.practising { border-color: var(--accent); }
.wcard.says { opacity: 0.7; }
.wphoto {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  background: var(--surface-2);
  cursor: pointer;
}
.wphoto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wcard.needs-voice .wphoto img { opacity: 0.55; }
.wphoto:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.wmark {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  line-height: 26px;
  text-align: center;
}
.wmark:empty { display: none; }
.wcard.says .wmark { background: var(--muted); }
.wbody {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 10px 2px;
}
.wname { font-weight: 800; font-size: 16px; }
.chip {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.chip.practising { background: var(--accent-soft); color: var(--accent-ink); }
.chip.needs-voice { background: #F3E7CC; color: var(--amber); }
.chip.resting, .chip.says { background: var(--surface-2); color: var(--muted); }
.wacts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 10px 12px;
  margin-top: auto;
}
.btn.small { font-size: 13px; padding: 5px 10px; }
.btn.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn.on { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent-ink); }

.rec-panel {
  margin-top: 16px;
  background: var(--surface);
  border-radius: 16px;
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.rec-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}
.rec-photo {
  width: min(60vw, 300px);
  max-width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 14px;
  background: var(--surface-2);
}
.rec-word { font-family: Georgia, serif; font-size: 30px; margin: 0; }
.rec-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.rec-panel .big-btn { padding: 14px 40px; font-size: 20px; }
.rec-panel .tip { margin: 0; }

#add-view h3 { font-size: 19px; margin: 18px 0 10px; }
.add-more { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.latest-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.latest-row .tip { margin: 0; }
.hint .app-version { opacity: 0.7; }
#word-form h3 { font-size: 19px; margin: 0 0 14px; }
