/* First-encounter */
.fe-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fe-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0 12px;
  border-bottom: 1px dashed rgba(58, 42, 26, 0.15);
  margin-bottom: 4px;
}

.fe-topbar-btn {
  background: transparent;
  border: 1px solid var(--fg-soft);
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.fe-topbar-btn:hover:not(:disabled) { background: rgba(58, 42, 26, 0.05); }
.fe-topbar-btn:disabled { opacity: 0.35; cursor: default; }

.fe-topbar-progress {
  font-size: 14px;
  color: var(--fg-soft);
  font-weight: 600;
}

.fe-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.fe-progress {
  font-size: 14px;
  color: var(--fg-soft);
  align-self: flex-end;
}

.fe-image {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
}

.fe-hint {
  font-size: 20px;
  color: var(--fg-soft);
  text-align: center;
}

.fe-sentence {
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-button);
  width: 100%;
}

.fe-translation {
  font-size: 18px;
  color: var(--fg-soft);
  text-align: center;
  padding: 8px 16px;
  width: 100%;
}

.fe-word-progress {
  font-size: 14px;
  color: var(--fg-soft);
}

.fe-word {
  font-size: 56px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.fe-word-tr {
  font-size: 24px;
  color: var(--fg-soft);
}

.fe-choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.fe-choice {
  width: 100%;
  padding: 18px 20px;
  font-size: 18px;
  font-family: inherit;
  background: #fff;
  border: 2px solid transparent;
  border-radius: var(--radius-button);
  box-shadow: var(--card-shadow);
  color: var(--fg);
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s, border-color 0.2s;
}
.fe-choice:active { transform: scale(0.98); }
.fe-choice:hover  { border-color: var(--accent); }
.fe-choice:disabled { cursor: default; }
.fe-choice--correct { border-color: #2d8a4e; background: #e3f5e8; }
.fe-choice--wrong   { border-color: #c44a4a; background: #fbe6e6; }

.fe-feedback {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
}
.fe-feedback.ok { color: #2d8a4e; }
.fe-feedback.no { color: #c44a4a; }

/* Skeleton template slot chips (step6) */
.fe-slot-chip {
  display: inline-block;
  padding: 2px 12px;
  margin: 0 2px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Replay row — fixed position right below image / main media */
.fe-replay-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: -8px;
  margin-bottom: 4px;
}
.fe-replay-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #fff;
  border: 2px solid var(--accent);
  color: var(--accent);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border-radius: 14px;
  cursor: pointer;
}
.fe-replay-btn:hover:not(:disabled) { background: rgba(255, 138, 76, 0.08); }
.fe-replay-btn:disabled { opacity: 0.5; cursor: default; }
.listen-progress {
  display: inline-flex;
  align-items: center;
  align-self: center;
  min-height: 28px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 183, 77, 0.16);
  color: var(--fg-soft);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.listen-progress--capped {
  background: rgba(107, 114, 128, 0.12);
  opacity: 0.62;
}
.listen-progress--rewarded {
  background: rgba(255, 183, 77, 0.3);
  color: var(--accent);
  opacity: 1;
}
.fe-stt-score {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 183, 77, 0.16);
  color: var(--fg);
  font-size: 14px;
  font-weight: 700;
}
.fe-stt-score span { color: var(--fg-soft); font-size: 12px; }
.fe-stt-retry { width: 100%; margin-top: 8px; font-size: 13px; }

/* Teacher note (main axis explanation, shown by default) */
.fe-teacher-note {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255, 138, 76, 0.08);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  font-size: 15px;
  color: var(--fg);
  line-height: 1.5;
}
.fe-teacher-note__label {
  display: block;
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

/* Enrichment expansion layer (passive, opt-in) */
.fe-expand {
  width: 100%;
}
.fe-expand__toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px dashed var(--fg-soft);
  color: var(--fg-soft);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.fe-expand__toggle:hover { background: rgba(58, 42, 26, 0.04); }
.fe-expand__body {
  margin-top: 8px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 10px;
  font-size: 14px;
  color: var(--fg-soft);
  line-height: 1.6;
  text-align: left;
}
.fe-expand__body ul {
  margin: 0;
  padding-left: 18px;
}
.fe-expand__body li {
  margin: 4px 0;
}

/* Chunks visualization (step4 expand) */
.fe-chunks-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.fe-chunks-chip {
  display: inline-block;
  padding: 6px 12px;
  background: rgba(184, 224, 210, 0.4);
  border-radius: 10px;
  font-size: 15px;
  color: var(--fg);
}
.fe-chunks-chip--tw {
  background: rgba(255, 224, 198, 0.55);
}

/* Bilingual chunks alignment (step4 expand, when chunk_translations provided) */
.fe-chunks-paired {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px 10px;
  align-items: center;
  width: 100%;
}
.fe-chunks-paired .fe-chunks-chip {
  text-align: center;
}
.fe-chunks-paired__arrow {
  color: var(--fg-soft);
  font-size: 16px;
  text-align: center;
}

/* Chunks ordering (first-encounter step 5) — tap-to-select, no drag */
.fe-ordering-step { gap: 12px; }
.fe-ordering-zone,
.fe-ordering-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  min-height: 56px;
  padding: 10px 12px;
  border-radius: 14px;
}
.fe-ordering-zone {
  background: rgba(255, 224, 198, 0.45);
  border: 2px dashed var(--accent);
}
.fe-ordering-bank {
  background: rgba(184, 224, 210, 0.35);
}
.fe-ordering-arrow {
  font-size: 13px;
  color: var(--fg-soft);
  text-align: center;
  margin: -2px 0;
}
.fe-ordering-empty {
  font-size: 14px;
  color: var(--fg-soft);
  padding: 8px 4px;
}
.fe-chunk-tap {
  display: inline-block;
  padding: 10px 14px;
  background: #fff;
  border: 2px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  font-size: 18px;
  color: var(--fg);
  cursor: pointer;
  transition: transform 0.08s, border-color 0.12s, background 0.12s;
  -webkit-user-select: none;
  user-select: none;
}
.fe-chunk-tap:hover {
  border-color: var(--accent);
}
.fe-chunk-tap:active {
  transform: scale(0.97);
}
.fe-chunk-tap.selected {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.fe-ordering-verdict {
  text-align: center;
  font-size: 17px;
  padding: 8px 10px;
  border-radius: 10px;
}
.fe-ordering-verdict.correct {
  background: rgba(118, 200, 158, 0.22);
  color: #2e7d4f;
}
.fe-ordering-verdict.wrong {
  background: rgba(231, 111, 81, 0.18);
  color: #b34a30;
}

/* Tier 4 review self-evaluation (step10 standalone) */
.fe-self-eval {
  margin-top: 12px;
  padding: 14px 12px;
  background: rgba(255, 224, 198, 0.45);
  border-radius: 14px;
  border: 2px solid var(--accent);
  text-align: center;
}
.fe-self-eval__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 10px;
}
.fe-self-eval__row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.fe-self-eval__row .btn {
  flex: 1 1 160px;
}

/* Variant mini quiz (review step 8): listen → pick emoji icon */
.fe-variant-icons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 12px 0;
}
.fe-variant-icon {
  flex: 1 1 100px;
  min-width: 100px;
  max-width: 140px;
  padding: 14px 8px;
  background: #fff;
  border: 3px solid rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.08s, border-color 0.12s, background 0.12s;
  -webkit-user-select: none;
  user-select: none;
}
.fe-variant-icon:hover {
  border-color: var(--accent);
}
.fe-variant-icon:active {
  transform: scale(0.96);
}
.fe-variant-icon.correct {
  border-color: #2e7d4f;
  background: rgba(118, 200, 158, 0.22);
}
.fe-variant-icon.wrong {
  border-color: #b34a30;
  background: rgba(231, 111, 81, 0.18);
}
.fe-variant-icon__emoji {
  font-size: 44px;
  line-height: 1;
}
.fe-variant-icon__tr {
  font-size: 14px;
  color: var(--fg-soft);
  margin-top: 6px;
}

/* Word family related (step7 expand) */
.fe-related {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fe-related__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 8px;
}
.fe-related__main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.fe-related__word {
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
}
.fe-related__pos {
  font-size: 11px;
  color: var(--fg-soft);
  letter-spacing: 0.05em;
}
.fe-related__tr {
  font-size: 13px;
  color: var(--fg-soft);
}
.fe-related__play {
  background: transparent;
  border: 1px solid var(--fg-soft);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 14px;
}
.fe-related__play:hover { background: rgba(58, 42, 26, 0.05); }

/* Recording UI (step3 / step9) */
.fe-record {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.fe-record__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  background: #fff;
  border: 2px solid var(--accent);
  color: var(--accent);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  border-radius: 16px;
  cursor: pointer;
}
.fe-record__btn--recording {
  background: #ffe6dc;
  animation: fe-pulse 1.2s ease-in-out infinite;
}
@keyframes fe-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}
.fe-record__playback {
  width: 100%;
  max-width: 360px;
}
.fe-record__hint {
  font-size: 13px;
  color: var(--fg-soft);
}

/* Pos badge (small label on word cards / variation cards) */
.fe-pos {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  background: rgba(58, 42, 26, 0.1);
  color: var(--fg-soft);
  border-radius: 6px;
  letter-spacing: 0.05em;
}

/* Dev-only time travel corner (Phase E pilot; remove before release) */
.dev-corner {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px dashed rgba(58, 42, 26, 0.3);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  opacity: 0.55;
}
.dev-corner__label {
  width: 100%;
  text-align: center;
  font-size: 11px;
  color: var(--fg-soft);
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}
.dev-btn {
  font-size: 12px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--fg-soft);
  border-radius: 8px;
  color: var(--fg-soft);
  font-family: inherit;
  cursor: pointer;
}
.dev-btn:hover { opacity: 1; background: rgba(58, 42, 26, 0.05); }

/* ============================================================
   Writing ladder (first-encounter step 10+)
   Spec: spec/v2/first-encounter.md §3
   ============================================================ */

.fe-subtitle {
  font-size: 15px;
  color: var(--fg-soft);
  letter-spacing: 0.04em;
  text-align: center;
  font-weight: 600;
}

.fe-writing-step { gap: 14px; }

.fe-writing-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 8px;
  font-size: 22px;
  line-height: 1.8;
  width: 100%;
  padding: 14px 12px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-button);
}

.fe-writing-word {
  font-weight: 600;
}

.fe-writing-hole {
  border: none;
  border-bottom: 3px solid var(--accent);
  background: rgba(255, 255, 255, 0.9);
  padding: 4px 8px;
  font-family: inherit;
  font-size: 20px;
  font-weight: 600;
  color: var(--fg);
  text-align: center;
  border-radius: 6px 6px 0 0;
  outline: none;
  transition: background 0.2s, border-color 0.2s;
}
.fe-writing-hole::placeholder {
  color: rgba(107, 90, 74, 0.5);
  letter-spacing: 0.1em;
  font-weight: 400;
}
.fe-writing-hole:focus {
  background: #fff;
  border-bottom-color: #ff6a1f;
}

.fe-writing-final {
  width: 100%;
  min-height: 80px;
  padding: 14px 16px;
  border: 2px solid var(--accent);
  border-radius: var(--radius-button);
  background: #fff;
  font-family: inherit;
  font-size: 20px;
  line-height: 1.5;
  color: var(--fg);
  resize: vertical;
  outline: none;
}
.fe-writing-final:focus { border-color: #ff6a1f; }
.fe-writing-final::placeholder {
  color: rgba(107, 90, 74, 0.5);
}

.fe-writing-diff {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-button);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 20px;
  line-height: 1.6;
  text-align: center;
  word-break: break-word;
  border: 2px solid transparent;
}
.fe-writing-diff.correct {
  border-color: #4caf50;
  background: rgba(76, 175, 80, 0.08);
}
.fe-writing-diff.wrong {
  border-color: #ef6c6c;
  background: rgba(239, 108, 108, 0.06);
}
.fe-writing-char-correct {
  color: #1f7fd4;
  font-weight: 600;
}
.fe-writing-char-wrong {
  color: #d04545;
  font-weight: 700;
  background: rgba(208, 69, 69, 0.12);
  border-radius: 2px;
}
.fe-writing-verdict {
  margin-top: 8px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
}

.fe-writing-solution {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255, 217, 163, 0.4);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  font-size: 16px;
  color: var(--fg);
}
.fe-writing-solution strong {
  font-size: 18px;
  display: inline-block;
  margin-top: 4px;
}

.fe-writing-hint-btn {
  align-self: center;
  padding: 8px 16px;
  background: transparent;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-button);
  color: var(--accent);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.fe-writing-hint-btn:hover { background: rgba(255, 138, 76, 0.08); }

.fe-writing-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  width: 100%;
  flex-wrap: wrap;
}

.fe-writing-tip {
  font-size: 14px;
  color: var(--fg-soft);
  text-align: center;
  font-style: italic;
}

/* Word-card spelling exercise (step 5 枝葉) */
.fe-word-input {
  display: block;
  margin: 0 auto;
  border: none;
  border-bottom: 4px solid var(--accent);
  background: rgba(255, 255, 255, 0.9);
  padding: 4px 12px;
  font-family: inherit;
  font-size: 42px;
  font-weight: 700;
  color: var(--fg);
  text-align: center;
  border-radius: 8px 8px 0 0;
  outline: none;
  min-width: 6ch;
  letter-spacing: 0.05em;
  transition: background 0.2s, border-color 0.2s;
}
.fe-word-input::placeholder {
  color: rgba(107, 90, 74, 0.4);
  font-weight: 400;
  letter-spacing: 0.15em;
}
.fe-word-input:focus {
  background: #fff;
  border-bottom-color: #ff6a1f;
}

/* btn variants used by step-writing */
.btn-secondary {
  display: inline-block;
  padding: 12px 22px;
  background: transparent;
  color: var(--fg);
  border: 2px solid var(--fg-soft);
  border-radius: var(--radius-button);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-secondary:hover { background: rgba(58, 42, 26, 0.05); }
.btn-secondary:active { transform: scale(0.97); }

.btn-strong {
  box-shadow: 0 0 0 4px rgba(255, 138, 76, 0.3);
  animation: btn-pulse 1.4s ease-in-out infinite;
}
@keyframes btn-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255, 138, 76, 0.3); }
  50%      { box-shadow: 0 0 0 8px rgba(255, 138, 76, 0.15); }
}

