/* Subtwine styles — the learn step's writing area inside the player column:
   the segments the reference punctuation splits it into, the answer directly
   under them, the translation hint, and the three states of a sentence row.
   Loaded from index.html in the order web_manifest.py declares. */
.dictation-screen {
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:14px;
  padding:18px 18px 14px;
  display:grid;
  gap:14px;
}
.dictation-screen[hidden] {
  display:none;
}
.dictation-screen header,
.dictation-actions {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
}
.dictation-screen h2 {
  font-size:19px;
  font-weight:500;
  margin:0;
}
.dictation-screen small,
.dictation-count {
  color:var(--muted);
  font-size:11.5px;
  font-variant-numeric:tabular-nums;
}

/* ---- the segments ---- */
/* One line of writing: the segments flow like words, and the area takes the
   height they need instead of scrolling. */
.dictation-input {
  /* One size for every hint inside the area: the placeholder rule below and
     the measurement in app-dictation.js both read it. */
  --segment-hint:12px;
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  row-gap:6px;
  padding:10px 12px;
  border:1.5px solid var(--line-strong);
  border-radius:10px;
  background:var(--surface);
  cursor:text;
  overflow:hidden;
  transition:border-color .12s,box-shadow .12s;
}
.dictation-input:focus-within {
  border-color:var(--accent);
  box-shadow:0 0 0 4px color-mix(in srgb,var(--accent) 16%,transparent);
}
.dictation-part {
  display:inline-flex;
  /* A segment that wrapped is taller than its separator, and the separator
     belongs beside its last line. */
  align-items:flex-end;
  /* Segments are measured, so the line may not squeeze them on its own. */
  flex:none;
}
/* The control and its mirror share one box, so the mirror can take the box
   whole (`inset:0`) instead of being measured against the control. */
.dictation-box {
  position:relative;
  display:inline-flex;
  max-width:100%;
}
/* A segment is a textarea: what does not fit the line wraps and the segment
   grows taller at the same type size. app-dictation.js keeps its width and its
   height at what its own writing needs. It is positioned so it paints over the
   mirror: the caret, the selection and the input method stay in the control. */
.dictation-segment {
  display:block;
  position:relative;
  z-index:1;
  min-height:28px;
  min-width:46px;
  border:0;
  border-bottom:1.5px dashed var(--line-strong);
  border-radius:0;
  padding:0 2px;
  background:none;
  font-size:16px;
  line-height:28px;
  color:var(--ink);
  caret-color:var(--accent);
  resize:none;
  overflow:hidden;
  overflow-wrap:break-word;
}
/* The mirror is the reader's own writing again, invisible, laid out in the
   same box with the same metrics so a mark lands under the word it belongs to.
   Every declaration here either matches the control above or keeps the layer
   out of the reader's way; changing one without the other moves the marks.
   The control paints its own dashed underline, so the mirror only reserves the
   line that border takes, which keeps the two content boxes the same height. */
.dictation-mirror {
  position:absolute;
  inset:0;
  border-bottom:1.5px solid transparent;
  padding:0 2px;
  font-size:16px;
  line-height:28px;
  color:transparent;
  white-space:pre-wrap;
  overflow-wrap:break-word;
  overflow:hidden;
  pointer-events:none;
  -webkit-user-select:none;
  user-select:none;
  z-index:0;
}
.dictation-segment.filled {
  border-bottom-color:transparent;
}
.dictation-segment:focus,
.dictation-segment.filled:focus {
  border-bottom:1.5px solid var(--accent);
}
.dictation-segment::placeholder {
  color:var(--faint);
  font-size:var(--segment-hint);
}
.dictation-mark {
  color:var(--muted);
  font-size:16px;
  line-height:28px;
  font-weight:600;
  margin:0 9px 0 2px;
}

/* ---- the answer, directly under the writing area ---- */
.dictation-answer {
  display:grid;
  gap:3px;
  line-height:1.7;
}
.dictation-answer[hidden] {
  display:none;
}
.answer-reference {
  font-size:16px;
  color:var(--ink);
}
.dictation-answer small {
  font-size:12.5px;
  color:var(--muted);
  line-height:1.5;
}
/* One neutral colour for both sides of a comparison: a wavy line under what
   was written, the matching background on the reference. Neither is a score. */
[data-diff-side=input] [data-diff-kind=changed] {
  text-decoration:underline wavy var(--diff);
  text-decoration-thickness:1.5px;
  text-underline-offset:4px;
  /* The wave reads as one line under the whole word, so a descender may not
     cut it into pieces. */
  text-decoration-skip-ink:none;
}
/* Inside a segment the wave shares the line with the control's own underline,
   so it sits closer to the letters than it does in a list row. */
.dictation-mirror [data-diff-kind=changed] {
  text-underline-offset:3px;
}
[data-diff-side=reference] [data-diff-kind=changed] {
  background:var(--diff-bg);
  border-radius:3px;
  padding:0 3px;
  font-weight:600;
}

/* ---- the actions row ---- */
.dictation-actions {
  justify-content:flex-start;
}
/* The prompt stands directly under the writing area and stays there for every
   sentence: it is the one thing allowed between the writing and the answer.
   `justify-self` keeps it as wide as its own words while its left edge stays
   on the writing area's. */
.dictation-hint {
  justify-self:start;
  /* The grid gap is set for the cards; the prompt belongs closer to the
     writing it explains. */
  margin:-4px 0 0;
  padding:1px 6px;
  border-radius:5px;
  font-size:11.5px;
  line-height:1.5;
  color:var(--faint);
  /* Chinese and Japanese have no spaces to break at, so a prompt that has to
     wrap wraps between its clauses instead of through a word. */
  word-break:keep-all;
  transition:background .12s,color .12s;
}
/* One Enter is waiting for the second: the emphasis changes, the words do not,
   so there is nothing for a screen reader to read again. */
.dictation-hint[data-armed=true] {
  background:var(--accent-soft);
  color:var(--accent-ink);
  font-weight:600;
}
/* The reveal reads as an eye that closes once it is on. */
.dictation-actions .dictation-reveal {
  display:inline-flex;
  align-items:center;
  gap:6px;
  height:28px;
  padding:0 10px;
  border:1px solid var(--line-strong);
  border-radius:7px;
  background:var(--surface);
  color:var(--ink);
  font-size:11.5px;
  white-space:nowrap;
}
.dictation-actions .dictation-reveal[aria-pressed=true] {
  border-color:transparent;
  background:var(--accent-soft);
  color:var(--accent-ink);
}
/* Comparing everything already shows this answer, so the control says so by
   being out of reach rather than by disappearing. */
.dictation-actions .dictation-reveal:disabled {
  opacity:.5;
  cursor:default;
}
/* Comparing the reference belongs to the dictation state only. Outside it the
   control takes no line at all, so the head is the one row it has always been.
   Each state keeps its short label and says its full name through `title` and
   `aria-label`, which is what a shared line can always hold. */
.panel-head .compare-state {
  display:none;
}
.mode-dictation .panel-head .compare-state {
  display:flex;
}

/* ---- the sentence rows while writing ---- */
/* The eye is a per-row control rather than a hover extra, so it stays visible
   at low emphasis; the star keeps the A2 habit of appearing on hover. */
.row-eye {
  opacity:.5;
}
.row-eye.revealed {
  color:var(--accent);
  opacity:1;
}
.sentence-bars em {
  font-style:normal;
  font-size:13px;
  color:var(--faint);
  margin:0 2px 0 -2px;
}
.sentence-skipped {
  margin-top:3px;
}
.sentence-skipped span {
  display:inline-block;
  padding:1px 6px;
  border-radius:5px;
  background:var(--surface-2);
  color:var(--muted);
  font-size:10.5px;
}

/* Watch and learn are two steps of the one workspace: the columns and the
   list stay, only the tools change. Learning shows no caption, no display
   switch and no subtitle settings. */
.mode-dictation #display-mode,
.mode-dictation #translation-select,
.mode-dictation .cap-set-wrap,
.mode-dictation #study-tools {
  display:none!important;
}
.hint-switch {
  display:inline-flex;
  align-items:center;
  gap:8px;
  font-size:12.5px;
  color:var(--ink-2);
  cursor:pointer;
}
.hint-switch input {
  appearance:none;
  -webkit-appearance:none;
  position:relative;
  width:34px;
  height:20px;
  margin:0;
  border-radius:99px;
  background:var(--line-strong);
  cursor:pointer;
  transition:background .15s;
}
.hint-switch input::after {
  content:"";
  position:absolute;
  left:2px;
  top:2px;
  width:16px;
  height:16px;
  border-radius:50%;
  background:#fff;
  box-shadow:0 1px 2px rgba(0,0,0,.2);
  transition:transform .15s;
}
.hint-switch input:checked {
  background:var(--accent);
}
.hint-switch input:checked::after {
  transform:translateX(14px);
}
.hint-switch input:disabled {
  opacity:.45;
  cursor:not-allowed;
}
.dx-hint-line {
  margin:-4px 0 0;
  padding:8px 12px;
  border-radius:9px;
  background:var(--sidebar);
  border:1px solid var(--line-soft);
  color:var(--ink-2);
  font-size:13.5px;
}
#dictation-reference-note {
  margin:0;
  color:var(--diff);
  background:var(--diff-bg);
  border-radius:7px;
  padding:9px 12px;
  font-size:11px;
}
#dictation-reference-note[hidden] {
  display:none;
}

/* ---- the learn step's layout: the picture, its panel, the writing area ----
   The picture keeps the material's own proportions at one fixed height, the
   panel takes the rest of that row, and the writing area runs the whole width
   below. The sentence list stays in the right-hand column. Under 900px the
   panel moves below the picture. */
.mode-dictation .study-column {
  grid-template-columns:auto minmax(0,1fr);
  grid-template-areas:"video panel" "write write";
  column-gap:16px;
  row-gap:12px;
  align-items:start;
}
/* Every rule about the picture is scoped to the column: the export dialog
   borrows the player card's class and the stage itself while it is open. */
.mode-dictation .study-column > .player-card {
  grid-area:video;
  /* The width the panel keeps, whatever the picture asks for. */
  --lp-reserve:296px;
  --learn-h:clamp(190px, 36vh, 340px);
  --ar-ratio:var(--ar-n, 1.7778);
  /* `--learn-col` is this column's own width, kept by app-workbench.js. */
  --learn-h-fit:min(var(--learn-h), calc((var(--learn-col, 840px) - var(--lp-reserve)) / var(--ar-ratio)));
  /* The card hugs the picture; it only grows to what the transport needs. */
  width:max(min(var(--learn-col, 840px), 160px), calc(var(--learn-h-fit) * var(--ar-ratio)));
  max-width:100%;
  background:var(--player);
}
.mode-dictation .study-column .stage {
  max-height:none;
  height:var(--learn-h-fit);
  width:calc(var(--learn-h-fit) * var(--ar-ratio));
  margin-inline:auto;
}
.mode-dictation .study-column .stage.expanded {
  height:100vh;
  width:100vw;
  margin:0;
}
/* The picture can be narrower than the transport, so the progress bar takes its
   own line, and the speed is the panel's. */
.mode-dictation .study-column .controls {
  flex-wrap:wrap;
  background:var(--surface);
}
.mode-dictation .study-column .controls .seek {
  order:10;
  flex-basis:100%;
}
.mode-dictation .study-column #speed {
  display:none;
}
.mode-dictation .learn-panel {
  grid-area:panel;
  align-self:stretch;
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:12px;
  padding:14px 16px;
  border:1px solid var(--line);
  border-radius:14px;
  background:var(--surface);
}
.mode-dictation .learn-panel[hidden] {
  display:none;
}
.mode-dictation .dictation-screen {
  grid-area:write;
}
.lp-position {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  min-height:32px;
}
.lp-sentence {
  font-size:15px;
  color:var(--ink-2);
  font-variant-numeric:tabular-nums;
  min-width:0;
}
.lp-sentence b {
  font-weight:650;
  color:var(--ink);
  white-space:nowrap;
}
.lp-star.starred {
  color:var(--star);
}
.lp-tools {
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}
.lp-tools .tool {
  border-color:var(--line);
}
.lp-row {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  font-size:12.5px;
  color:var(--ink-2);
  min-height:30px;
}
.lp-row .mini-sel {
  min-width:0;
}
.lp-nav {
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  margin-top:auto;
}
.lp-nav button {
  flex:1 1 auto;
  min-width:0;
  min-height:36px;
  padding:6px 10px;
  border-radius:8px;
  background:var(--accent-soft);
  color:var(--accent-ink);
  font-size:12.5px;
}
.lp-nav button:disabled {
  opacity:.5;
  cursor:default;
}
@media (max-width:900px) {
  .mode-dictation .study-column {
    grid-template-columns:minmax(0,1fr);
    grid-template-areas:"video" "panel" "write";
  }
  .mode-dictation .study-column > .player-card {
    --lp-reserve:0px;
    --learn-h:clamp(160px, 34vh, 300px);
    justify-self:center;
  }
}
