/* Korean Pathway — bright, refined, friendly. Tokens from docs/BUILD_BRIEF.md (2026-09-15). Mobile first, 320–430px. */

:root {
  color-scheme: light;
  --bg: #F4F6FC;
  --surface: #FFFFFF;
  --text: #151E35;
  --muted: #5B6680;
  --primary: #4054DD;
  --primary-dark: #3143B5;
  --primary-soft: #EEF1FF;
  --primary-line: #C9D2F7;
  --line: #DCE3F1;
  --ok: #12724F;
  --ok-soft: #E4F5EE;
  --err: #B23F31;
  --err-soft: #FDEDEA;
  --glow: rgba(64, 84, 221, .16);
  --radius-lg: 24px;
  --radius: 18px;
  --radius-sm: 14px;
  --shadow: 0 8px 24px rgba(21, 30, 53, .06);
  --shadow-sm: 0 2px 8px rgba(21, 30, 53, .06);
  --font: "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans", system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--bg); font-size: 17px; line-height: 1.55; overflow-x: hidden; overflow-wrap: anywhere; }
img, svg { display: block; max-width: 100%; }
button, a { font: inherit; }
button { color: inherit; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; border-radius: 10px; }
.btn--primary:focus-visible, .listen--normal:focus-visible { outline-color: var(--text); }
[tabindex="-1"]:focus-visible { outline: 2px solid var(--primary-line); outline-offset: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Soft light only at the top edge; never behind body text. */
.glow { position: fixed; left: 50%; top: -220px; width: 720px; height: 420px; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(closest-side, rgba(255, 255, 255, .95), var(--glow) 55%, rgba(244, 246, 252, 0)); pointer-events: none; z-index: 0; }

/* Shell */
.shell { position: relative; z-index: 1; width: min(100%, 480px); margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: max(12px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom)); }
.app { flex: 1; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 8px 0 12px; }
.brand { font-size: 12px; letter-spacing: .18em; font-weight: 800; color: var(--primary); white-space: nowrap; }
.episode { margin-left: auto; width: 34px; height: 34px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 50%; font-weight: 800; font-size: 13px; color: var(--muted); }
.progress { flex: 1; display: flex; gap: 5px; height: 6px; }
.progress__seg { flex: 1; border-radius: 99px; background: var(--line); transition: background .2s var(--ease); }
.progress__seg.is-done { background: var(--primary); }
.progress__seg.is-current { background: var(--primary-line); box-shadow: inset 0 0 0 1px var(--primary); }
.foot { padding: 24px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.loading { color: var(--muted); text-align: center; padding: 40px 0; }
.noscript { padding: 20px; text-align: center; }

/* Screens: short, low-amplitude entrances; text is readable from the first frame. */
.screen { animation: rise .2s var(--ease) both; }
.chat > *, .delay-1, .delay-2, .delay-3 { animation: rise .18s var(--ease) both; }
.delay-1 { animation-delay: .06s; }
.delay-2 { animation-delay: .12s; }
.delay-3 { animation-delay: .18s; }
@keyframes rise { from { opacity: .7; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.kicker { display: flex; gap: 8px; align-items: baseline; margin: 4px 0 12px; font-size: 13px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--primary); }
.kicker__sep { color: var(--line); }
.kicker__step { color: var(--muted); letter-spacing: .04em; text-transform: none; font-weight: 600; }

/* Start */
.hero { padding: 6px 0 8px; display: flex; flex-direction: column; }
.hero__greeting { display: flex; justify-content: center; padding: 0 12px; }
.bubble--hero { position: relative; align-items: center; text-align: center; padding: 14px 22px 12px; border-bottom-left-radius: var(--radius); }
.bubble--hero::after { content: ""; position: absolute; left: 30%; bottom: -9px; width: 18px; height: 18px; background: var(--surface); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); transform: rotate(45deg); }
.bubble--hero .bubble__ko { font-size: 32px; }
.duo { display: flex; justify-content: center; align-items: flex-end; gap: 6px; margin: 14px 0 6px; padding: 0 8px; }
.duo__friend { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.duo__name { font-size: 14px; font-weight: 700; color: var(--muted); }
.hero__title { font-size: clamp(30px, 8vw, 38px); line-height: 1.15; letter-spacing: -.02em; margin: 14px 0 6px; text-align: center; }
.hero__intro { margin: 0 0 14px; font-size: 17px; color: var(--muted); text-align: center; }
.hero__note { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); font-size: 16px; line-height: 1.5; box-shadow: var(--shadow-sm); }
.hero__note .icon { flex: none; margin-top: 3px; color: var(--primary); }
.hero__meta { margin: 0 0 16px; font-size: 15px; color: var(--muted); font-weight: 600; text-align: center; }

/* Portraits (webtoon PNG with SVG fallback) */
.portrait { display: inline-flex; flex: none; position: relative; }
.portrait__frame { display: block; width: 100%; height: 100%; overflow: hidden; border-radius: 22px 22px 8px 8px; }
.portrait__img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; }
.portrait__svg { width: 100%; height: 100%; border-radius: 50%; }
.portrait--lg { width: 128px; height: 148px; }
.portrait--md { width: 108px; height: 124px; }
.portrait--result { width: 92px; height: 106px; }
.portrait--sm { width: 44px; height: 44px; }
.portrait--sm .portrait__frame { border-radius: 50%; background: var(--primary-soft); border: 1px solid var(--line); }
.portrait--sm .portrait__img { object-fit: cover; object-position: center 12%; transform: scale(1.15); transform-origin: center 20%; }
.portrait--fallback.portrait--lg .portrait__frame, .portrait--fallback.portrait--md .portrait__frame, .portrait--fallback.portrait--result .portrait__frame { border-radius: 50%; width: 100px; height: 100px; margin: auto; border: 2px solid var(--line); }
/* Speaking ring is tied to the real audio player state. */
.portrait::after { content: ""; position: absolute; inset: -4px; border-radius: 26px; border: 3px solid transparent; pointer-events: none; transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
.portrait--sm::after { border-radius: 50%; }
.portrait.is-speaking::after { border-color: var(--primary); box-shadow: 0 0 0 6px rgba(64, 84, 221, .14); animation: speak 1.2s ease-in-out infinite; }
.portrait.is-happy::after { border-color: var(--ok); box-shadow: 0 0 0 6px rgba(23, 138, 98, .12); }
.portrait.is-encouraging::after { border-color: var(--primary-line); }
.portrait.is-happy .portrait__frame { animation: cheer .22s var(--ease); }
@keyframes speak { 0%, 100% { box-shadow: 0 0 0 4px rgba(64, 84, 221, .12); } 50% { box-shadow: 0 0 0 9px rgba(64, 84, 221, .18); } }
@keyframes cheer { 0% { transform: translateY(0); } 50% { transform: translateY(-5px); } 100% { transform: none; } }

/* Speaker panel */
.speaker { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.speaker__stage { position: relative; height: 150px; padding: 12px 16px 0; display: flex; align-items: flex-end; gap: 12px; background: linear-gradient(180deg, #FBFCFF, var(--primary-soft)); overflow: hidden; }
.backdrop { position: absolute; inset: 0; pointer-events: none; }
.backdrop__svg { width: 100%; height: 100%; }
.speaker__stage .portrait { position: relative; z-index: 1; }
.speaker__stage .portrait--md { width: 118px; height: 138px; }
.speaker__stage .portrait__frame { border-radius: 0; }
.speaker__name { position: relative; z-index: 1; align-self: flex-end; margin-bottom: 12px; padding: 5px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; font-weight: 700; color: var(--text); box-shadow: var(--shadow-sm); }
.bubble--speaker { position: relative; border: 0; border-radius: 0; box-shadow: none; padding: 18px 18px 16px; }
.bubble--speaker::before { content: ""; position: absolute; left: 56px; top: -8px; width: 16px; height: 16px; background: var(--surface); transform: rotate(45deg); border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
.bubble--speaker .bubble__ko { font-size: clamp(32px, 9vw, 38px); }
.situation { margin: 0; padding: 16px 18px 18px; font-size: 19px; font-weight: 800; line-height: 1.4; border-top: 1px solid var(--line); }

/* Conversation */
.chat { display: flex; flex-direction: column; gap: 14px; padding-bottom: 24px; }
.narration { margin: 0; padding: 0 6px; font-size: 16px; color: var(--muted); text-align: center; }
.msg { display: flex; gap: 10px; align-items: flex-end; }
.msg--you { flex-direction: row-reverse; }
.msg__body { display: flex; flex-direction: column; gap: 4px; max-width: 88%; min-width: 0; }
.msg--you .msg__body { align-items: flex-end; }
.msg__name { font-size: 13px; font-weight: 700; color: var(--muted); padding: 0 6px; }
.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.avatar__svg { width: 100%; height: 100%; }
.bubble { position: relative; padding: 14px 16px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 6px; }
.bubble--friend { border-bottom-left-radius: 6px; }
.bubble--you { border-bottom-right-radius: 6px; background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: none; }
.bubble__ko { font-size: 26px; font-weight: 800; line-height: 1.25; letter-spacing: -.01em; }
.bubble__mn { font-size: 16px; color: var(--muted); line-height: 1.45; }
.bubble--you .bubble__ko { font-size: 24px; }
.tag { align-self: flex-start; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); background: var(--primary-soft); padding: 4px 10px; border-radius: 99px; margin-bottom: 2px; }

.teach { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--primary); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 6px; }
.teach__intro { margin: 0; font-size: 16px; color: var(--muted); }

/* Listen controls: normal = filled play, slow = light turtle. Names stay visible. */
.listen-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.listen { display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 8px 16px 8px 12px; border-radius: 13px; border: 1.5px solid var(--primary); background: var(--primary); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer; transition: transform .12s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease); }
.listen:active { transform: scale(.97); }
.listen__icon { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: rgba(255, 255, 255, .22); }
.listen--slow { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary-dark); }
.listen--slow .listen__icon { background: var(--surface); }
.listen:hover { box-shadow: var(--shadow-sm); }
.listen.is-playing { box-shadow: 0 0 0 3px rgba(64, 84, 221, .22); animation: speak 1.2s ease-in-out infinite; }
.listen--normal.is-playing { background: var(--primary-dark); }
.listen-group--sm .listen { min-height: 44px; padding: 6px 14px 6px 10px; font-size: 14px; }
.listen-group--sm .listen__icon { width: 24px; height: 24px; }
.listen-off { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; margin: 6px 0 0; padding: 4px 10px 4px 8px; border-radius: 10px; border: 1.5px dashed var(--line); color: var(--muted); font-size: 15px; font-weight: 600; }
.listen-status { flex-basis: 100%; margin: 0; font-size: 15px; color: var(--err); font-weight: 600; }
.icon { width: 20px; height: 20px; flex: none; }

/* Prompt + options */
.prompt { margin: 6px 0 0; font-size: 19px; font-weight: 800; line-height: 1.4; }
.options { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.option-card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.option { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 66px; width: 100%; padding: 14px 16px; text-align: left; background: transparent; border: 0; border-radius: var(--radius); cursor: pointer; transition: background .15s var(--ease), transform .12s var(--ease); }
.option:hover:not([disabled]) { background: var(--primary-soft); }
.option:active:not([disabled]) { transform: scale(.985); }
.option:focus-visible { outline-offset: -4px; }
.option[disabled] { cursor: default; }
.option[disabled]:not(.is-correct):not(.is-wrong) { opacity: .5; }
.option-card:has(.option:hover:not([disabled])) { border-color: var(--primary-line); }
.option-card:has(.is-correct) { border-color: var(--ok); }
.option-card:has(.is-wrong) { border-color: var(--err); }
.option.is-correct { background: var(--ok-soft); }
.option.is-wrong { background: var(--err-soft); }
.option__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.option__ko { font-size: 26px; font-weight: 800; line-height: 1.25; }
.option__mn { font-size: 16px; color: var(--muted); line-height: 1.4; }
.option__mark { display: inline-flex; align-items: center; gap: 4px; flex: none; font-size: 13px; font-weight: 800; }
.option.is-correct .option__mark { color: var(--ok); }
.option.is-wrong .option__mark { color: var(--err); }
.option__mark .icon { width: 22px; height: 22px; }
.option__listen { padding: 0 14px 12px; border-top: 1px dashed var(--line); margin-top: -2px; padding-top: 10px; }
.option__listen .listen-group { margin-top: 0; }

/* Feedback (sits directly under the options) */
.feedback { border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; border: 1.5px solid; }
.feedback--ok { background: var(--ok-soft); border-color: rgba(23, 138, 98, .35); }
.feedback--no { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-sm); }
.feedback__head { display: flex; align-items: center; gap: 10px; }
.feedback__icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; }
.feedback--ok .feedback__icon { background: var(--ok); }
.feedback--no .feedback__icon { background: var(--err); }
.feedback__title { margin: 0; font-weight: 800; font-size: 18px; }
.feedback__body { margin: 0; font-size: 16px; line-height: 1.55; }
.feedback__answer { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 10px 12px; background: var(--primary-soft); border-radius: var(--radius-sm); }
.feedback__answer-label { font-size: 15px; font-weight: 700; color: var(--muted); }
.feedback__answer-ko { font-size: 22px; font-weight: 800; }
.feedback__answer-mn { font-size: 16px; color: var(--muted); }
.feedback__answer .listen-group { flex-basis: 100%; margin-top: 2px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 54px; padding: 12px 18px; border-radius: 16px; border: 1.5px solid transparent; font-weight: 800; font-size: 17px; cursor: pointer; text-decoration: none; transition: transform .12s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease); }
.btn:active { transform: scale(.985); }
.btn--primary { background: var(--primary); color: #fff; box-shadow: 0 6px 18px rgba(64, 84, 221, .25); }
.btn--primary:hover { background: var(--primary-dark); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn--secondary:hover { border-color: var(--primary-line); }
.btn--outline { background: transparent; color: var(--primary-dark); border-color: var(--primary-line); }
.btn--outline:hover { background: var(--primary-soft); }
.btn--ghost { background: transparent; color: var(--primary-dark); border-color: transparent; width: auto; min-height: 44px; padding: 8px 12px; text-decoration: underline; text-underline-offset: 4px; }
.btn[disabled] { opacity: .6; cursor: default; }
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.actions--hint { align-items: center; margin-top: 0; }
.actions--stack { margin-top: 26px; }
.note { margin: 0; font-size: 16px; color: var(--muted); display: flex; gap: 6px; align-items: center; justify-content: center; text-align: center; }
.note .icon { width: 18px; height: 18px; }

/* Check intro */
.intro-card { margin-top: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 28px 22px; box-shadow: var(--shadow); text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.intro-card__icon { width: 56px; height: 56px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.intro-card__icon .icon { width: 28px; height: 28px; }
.intro-card__title { margin: 0; font-size: 26px; line-height: 1.25; }
.intro-card__body { margin: 0; color: var(--muted); }
.intro-card .actions { width: 100%; margin-top: 8px; }

/* Result */
.reward { text-align: center; padding: 6px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.reward__duo { display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.reward__badge { width: 96px; height: 96px; margin: 0 -10px 10px; position: relative; z-index: 1; }
.reward__title { margin: 6px 0 0; font-size: clamp(26px, 7vw, 32px); line-height: 1.2; }
.reward__body { margin: 0; color: var(--muted); }
.panel { margin-top: 22px; }
.panel__title { margin: 0 0 10px; font-size: 13px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--primary); }
.phrase-list, .check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.phrase-item { display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm); }
.phrase-item__head { display: flex; align-items: center; gap: 12px; }
.phrase-item__num, .check-item__num { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; font-size: 14px; display: grid; place-items: center; }
.phrase-item__text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.phrase-item__ko { font-size: 24px; font-weight: 800; line-height: 1.25; }
.phrase-item__mn { font-size: 16px; color: var(--muted); }
.phrase-item__use { font-size: 14px; color: var(--primary-dark); font-weight: 700; margin-top: 2px; }
.phrase-item .listen-group { margin-top: 0; }
.check-item { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.check-item__num { background: var(--text); }
.check-item__ko { font-size: 20px; font-weight: 800; }

/* Keep Hangul counters open at small sizes and use the same glyphs on every device. */
[lang="ko"] {
  font-family: "Korean Pathway Korean", "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-weight: 700;
  font-synthesis: none;
  letter-spacing: normal;
  line-height: 1.4;
}
.check-item__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 99px; font-size: 13px; font-weight: 700; }
.pill .icon { width: 16px; height: 16px; }
.pill--first-try { background: var(--ok-soft); color: var(--ok); }
.pill--hint, .pill--retry { background: var(--primary-soft); color: var(--primary-dark); }
.card-status { margin: 8px 0 0; font-size: 16px; color: var(--muted); text-align: center; min-height: 1em; }
.card-preview { margin-top: 12px; }
.card-preview__img { width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.panel--guide { padding: 20px 16px; border: 1px solid var(--primary-line); border-radius: var(--radius-lg); background: linear-gradient(145deg, #fff, var(--primary-soft)); }
.guide__meta { margin: 0 0 8px; color: var(--primary-dark); font-size: 13px; font-weight: 800; }
.guide__title { margin: 0 0 10px; font-size: 23px; line-height: 1.3; }
.guide__body { margin: 0 0 16px; font-size: 16px; line-height: 1.6; }
.guide__note { margin: 12px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* Error */
.error__title { font-size: 22px; line-height: 1.4; margin: 40px 0 8px; }

@media (min-width: 400px) {
  .speaker__stage { height: 160px; }
  .speaker__stage .portrait--md { width: 128px; height: 148px; }
  .portrait--lg { width: 140px; height: 160px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
