/* ─────────────────────────────────────────────
   English Play — Supabase 톤 정렬 (DESIGN.md 기반)
   ‣ 클래스명은 app.js / activities.js와 계약이므로 변경하지 않음(리스타일만).
   ‣ 화이트 캔버스 + 단일 에메랄드 액센트. 에메랄드 버튼 위 텍스트는 니어블랙(브랜드 고유의 "lit green").
   ‣ 각진 반경(버튼 6px·카드 12px), 플랫 필, hairline 보더. 대기 그라디언트 없음.
   ‣ 라이트 우선. dark-preference 기기에는 canvas-night 다크 폴백 제공.
   ───────────────────────────────────────────── */
:root {
  /* 표면 (canvas / canvas-soft) */
  --bg: #fafafa;            /* 페이지 = 배럴리-틴티드 오프화이트 */
  --bg-tint: #f2f2f2;
  --card: #ffffff;          /* 카드 = 순백 캔버스 */
  --card-soft: #fafafa;

  /* 텍스트 (ink 계열 — 니어블랙, 순흑 아님) */
  --ink: #171717;
  --ink-soft: #404040;
  --muted: #707070;

  /* 브랜드 / 상태 — 단일 에메랄드가 유일한 색채 이벤트 */
  --brand: #3ecf8e;
  --brand-strong: #24b47e;  /* pressed / deep */
  --brand-soft: #e7f7ef;    /* 소프트 에메랄드 틴트 */
  --brand-ink: #171717;     /* 에메랄드 필 위 텍스트 = 니어블랙 */
  --accent: #24b47e;        /* purple 폐기 → 에메랄드-deep로 통일 */
  --ok: #24b47e;
  --ok-soft: #e7f7ef;
  --no: #dc2626;            /* 오답 = 표준 에러 레드(의미색) */
  --no-soft: #fdecec;

  /* 선 / 그림자 (hairline ladder + elevation) */
  --line: #ededed;
  --line-strong: #dfdfdf;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06);
  --shadow: 0 8px 24px rgba(0, 0, 0, .08);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .12);

  /* 형태 (square-ish radii) */
  --radius: 12px;
  --radius-sm: 6px;
  --radius-pill: 9999px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1c;          /* canvas-night */
    --bg-tint: #202020;
    --card: #202020;        /* canvas-night-soft */
    --card-soft: #262626;
    --ink: #ededed;
    --ink-soft: #c7c7c7;
    --muted: #9a9a9a;
    --brand: #3ecf8e;
    --brand-strong: #4ade80;
    --brand-soft: #14312a;
    --accent: #4ade80;
    --ok: #3ecf8e;
    --ok-soft: #14312a;
    --no-soft: #2a1514;
    --line: #2e2e2e;
    --line-strong: #3a3a3a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow: 0 8px 24px rgba(0, 0, 0, .5);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, .6);
    /* --brand-ink는 유지: 에메랄드 위 텍스트는 라이트/다크 모두 니어블랙 */
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Inter", "Pretendard", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg);   /* 순수 캔버스 — 대기 그라디언트 없음 */
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv05", "cv11";
}
::selection { background: color-mix(in srgb, var(--brand) 22%, transparent); }

/* ── 상단바 ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px clamp(16px, 4vw, 28px);
  background: color-mix(in srgb, var(--card) 80%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 700; font-size: 19px; color: var(--ink);
  text-decoration: none; letter-spacing: -0.03em;
  display: inline-flex; align-items: center; gap: 2px;
}
.brand:hover { color: var(--brand-strong); }
.topnav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topnav .who { color: var(--muted); font-size: 13px; font-weight: 500; }
.app { flex: 1; width: 100%; max-width: 920px; margin: 0 auto; padding: clamp(20px, 4vw, 36px) 16px 56px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; border-top: 1px solid var(--line); }

/* ── 공통 ── */
h1 { font-size: clamp(22px, 4vw, 28px); font-weight: 600; line-height: 1.2; margin: 4px 0 2px; letter-spacing: -0.03em; }
h2 { font-size: 18px; font-weight: 600; margin: 26px 0 10px; letter-spacing: -0.02em; }
.sub { color: var(--muted); font-size: 15px; margin: 0 0 22px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* 버튼 */
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line-strong);
  background: var(--card); color: var(--ink);
  border-radius: var(--radius-sm); padding: 10px 16px;
  transition: transform .08s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease, color .15s ease;
}
button:hover, .btn:hover { border-color: var(--brand); color: var(--ink); background: color-mix(in srgb, var(--brand) 7%, var(--card)); box-shadow: var(--shadow-sm); }
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
button:disabled:hover { border-color: var(--line-strong); color: var(--ink); background: var(--card); }
button.primary, .btn.primary {
  background: var(--brand);                 /* 플랫 에메랄드 필 */
  color: var(--brand-ink);                  /* 니어블랙 텍스트 — "lit green" */
  border-color: transparent; font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .10);
}
button.primary:hover, .btn.primary:hover {
  background: var(--brand-strong);          /* pressed-deep로 리프트 */
  color: var(--brand-ink); filter: none;
  box-shadow: var(--shadow-sm);
}
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--brand-strong); box-shadow: none; }
.rowbtns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }

/* 배지 / 칩 */
.badge { display: inline-block; background: var(--line); color: var(--muted); border-radius: var(--radius-pill); padding: 3px 11px; font-size: 12px; font-weight: 600; }
.badge.elementary { background: #e6f7ef; color: #177a4e; }
.badge.middle { background: #eef0f2; color: #52525b; }
.badge.high { background: #f5ece3; color: #92561f; }
@media (prefers-color-scheme: dark) {
  .badge.elementary { background: #12362a; color: #5fe0a6; }
  .badge.middle { background: #2a2d33; color: #c7ccd4; }
  .badge.high { background: #332217; color: #e0a878; }
}
.chip {
  display: inline-block; background: var(--brand-soft); color: var(--brand-strong);
  border: 1px solid color-mix(in srgb, var(--brand) 20%, transparent);
  border-radius: var(--radius-pill); padding: 4px 11px; font-size: 12.5px; font-weight: 500;
  margin: 0 6px 6px 0;
}
.notice {
  padding: 18px 20px; border-radius: var(--radius);
  background: var(--card); border: 1px dashed var(--line-strong);
  color: var(--muted); box-shadow: var(--shadow-sm);
}
.notice p { margin: 0 0 12px; }
.err { color: var(--no); font-size: 13px; min-height: 18px; margin: 6px 0; font-weight: 500; }

/* ── 학년 그룹 / 카드 ── */
.group-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 30px 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }

/* ── 이미지 우선 레벨 카드 ── */
.level-card {
  padding: 0; overflow: hidden; text-align: left; display: flex; flex-direction: column;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.level-card:hover {
  transform: translateY(-4px); border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  box-shadow: var(--shadow-lg); color: var(--ink);
}
.level-card .lc-media {
  width: 100%; aspect-ratio: 4 / 3; background: var(--brand-soft);
  display: grid; place-items: center; overflow: hidden; font-size: 68px; line-height: 1;  /* 폴백 이모지 크기 */
}
.level-card .lc-media .lc-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.level-card:hover .lc-media .lc-img { transform: scale(1.04); }
.level-card .lc-media .lc-img { transition: transform .35s ease; }
.level-card .lc-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.level-card .lc-name { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.level-card .lc-meta { color: var(--muted); font-size: 13px; font-weight: 500; }
.progress-mini { height: 8px; background: var(--line); border-radius: var(--radius-pill); overflow: hidden; margin-top: 4px; }
.progress-mini > i { display: block; height: 100%; background: var(--brand); width: 0; border-radius: inherit; transition: width .45s ease; }

/* ── 이미지 우선 단원 카드 ── */
.unit-grid { margin-top: 8px; }
.unit-card {
  padding: 0; overflow: hidden; text-align: left; display: flex; flex-direction: column;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.unit-card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); box-shadow: var(--shadow-lg); color: var(--ink); }
.unit-card .uc-media { position: relative; width: 100%; aspect-ratio: 4 / 3; background: var(--brand-soft); overflow: hidden; }
.unit-card .uc-media .uc-img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s ease; }
.unit-card:hover .uc-media .uc-img { transform: scale(1.04); }
.unit-card .uc-badge {
  position: absolute; top: 10px; left: 10px; min-width: 28px; height: 28px; padding: 0 9px;
  border-radius: var(--radius-pill); background: rgba(0, 0, 0, .55); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.unit-card .uc-check {
  position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--ok); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}
.unit-card .uc-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; }
.unit-card .uc-title { font-weight: 700; letter-spacing: -0.01em; }
.unit-card .uc-meta { color: var(--muted); font-size: 12.5px; }
.unit-card .uc-status { margin-top: 4px; font-size: 13px; color: var(--brand-strong); font-weight: 600; }
.unit-card .uc-status .done { color: var(--ok); font-weight: 700; }

/* ── 수업 히어로(단원 삽화) ── */
.lesson-hero { position: relative; width: 100%; height: 190px; border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; box-shadow: var(--shadow-sm); background: var(--brand-soft); }
.lesson-hero-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lesson-hero-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 28px 18px 14px; color: #fff; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; background: linear-gradient(to top, rgba(0, 0, 0, .62), rgba(0, 0, 0, 0)); }

/* ── 내 진도: 완료 단원 행 ── */
.done-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin: 10px 0; }
.done-row .done-check { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-weight: 800; }
.done-row .done-main { flex: 1; min-width: 0; }
.done-row .done-t { font-weight: 700; letter-spacing: -0.01em; }
.done-row .done-s { color: var(--muted); font-size: 13px; }
.done-row .done-score { flex: 0 0 auto; font-size: 13px; color: var(--ok); font-weight: 700; }

/* ── 랜딩 / 히어로 (SEO 정적 콘텐츠 + 홈 인트로) ── */
.seo-landing { max-width: 860px; margin: 0 auto; }
.hero { text-align: center; padding: 24px 0 8px; }
.hero-badge { display: inline-block; background: var(--brand-soft); color: var(--brand-strong); border-radius: var(--radius-pill); padding: 5px 14px; font-size: 13px; font-weight: 700; letter-spacing: -0.01em; }
.hero h1 { font-size: clamp(26px, 5vw, 40px); line-height: 1.18; letter-spacing: -0.03em; margin: 16px 0 12px; font-weight: 800; }
.hero h1 .accent { color: var(--brand-strong); }
.hero-sub { color: var(--ink-soft); font-size: clamp(15px, 2.4vw, 18px); line-height: 1.6; max-width: 620px; margin: 0 auto 20px; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 20px 0 8px; }
.hero-stats .hs { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px; min-width: 100px; box-shadow: var(--shadow-sm); }
.hero-stats .hs b { display: block; font-size: 24px; font-weight: 800; color: var(--brand-strong); letter-spacing: -0.02em; }
.hero-stats .hs span { font-size: 12px; color: var(--muted); }
.seo-landing h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; margin: 34px 0 12px; }
.curr-list, .feat-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.curr-list li, .feat-list li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 14px; font-size: 14px; color: var(--ink-soft); }
.curr-list li b, .feat-list li b { color: var(--ink); }
.faq details { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 2px 14px; margin: 8px 0; }
.faq summary { cursor: pointer; font-weight: 600; padding: 11px 0; letter-spacing: -0.01em; }
.faq details p { color: var(--ink-soft); font-size: 14px; line-height: 1.6; margin: 0 0 12px; }
.seo-cta { text-align: center; margin: 30px 0 10px; }

/* 홈 컴팩트 히어로(JS 렌더) */
.home-hero { text-align: center; padding: 6px 0 4px; margin-bottom: 10px; }
.home-hero .hero-badge { margin-bottom: 12px; }
.home-hero h1 { font-size: clamp(22px, 4vw, 32px); line-height: 1.2; letter-spacing: -0.03em; font-weight: 800; margin: 0 0 8px; }
.home-hero p { color: var(--ink-soft); font-size: 15px; max-width: 560px; margin: 0 auto; }

/* ── 수업 플레이어 ── */
.player-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.player-head .pt { font-weight: 600; letter-spacing: -0.01em; }
.bar { height: 10px; background: var(--line); border-radius: var(--radius-pill); overflow: hidden; margin: 12px 0 4px; }
.bar > i { display: block; height: 100%; background: var(--brand); width: 0; border-radius: inherit; transition: width .4s ease; }
.progress-label { color: var(--muted); font-size: 12px; margin-bottom: 16px; }
.activity-card { padding: 24px; margin: 14px 0; box-shadow: var(--shadow); }
.atype { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-strong); }
.atitle { font-weight: 600; font-size: 18px; margin: 4px 0 4px; letter-spacing: -0.01em; }
.meta { font-size: 12.5px; color: var(--muted); margin: 2px 0; }
.instr { font-size: 15px; margin: 10px 0 14px; color: var(--ink-soft); }
.instr-sub { font-size: 13px; color: var(--muted); margin: 6px 0; }
.question { font-size: 16px; font-weight: 600; margin: 12px 0; }
.template { font-size: 21px; font-weight: 600; margin: 12px 0; letter-spacing: .01em; }
.model { font-size: 23px; font-weight: 600; text-align: center; margin: 12px 0; letter-spacing: -0.01em; }
.big { font-size: 48px; text-align: center; margin: 10px 0; }
.big-img { display: block; margin: 4px auto; width: auto; height: auto; max-width: min(240px, 72%); max-height: 220px; object-fit: contain; border-radius: 14px; box-shadow: var(--shadow-sm); }
.wordlabel { font-size: 23px; font-weight: 700; text-align: center; margin: 6px 0; letter-spacing: -0.02em; }
.imagehint { font-size: 14px; color: var(--muted); margin: 4px 0; }
.scene { text-align: center; margin: 12px 0; }
.scene .scene-img { display: block; margin: 0 auto 8px; width: auto; height: auto; max-width: min(380px, 92%); max-height: 300px; object-fit: contain; border-radius: 14px; box-shadow: var(--shadow-sm); }
.scene .scene-cap { color: var(--muted); font-size: 13px; }
.turn { font-size: 15px; }
.play {
  background: var(--brand-soft); color: var(--brand-strong); border-color: transparent; font-weight: 600;
}
.play:hover { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand-strong); border-color: transparent; }

/* 선택지 */
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; margin: 8px 0; font-size: 16px; font-weight: 500;
  border-color: var(--line-strong);
}
.opt .opt-main { font-size: 22px; line-height: 1; }
.opt .opt-label { color: var(--muted); font-size: 14px; font-weight: 600; }
.opt:hover .opt-label { color: var(--ink); }
.opt:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--ink); }
.opt.ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ink); }
.opt.no { border-color: var(--no); background: var(--no-soft); color: var(--ink); }

/* 단어 배열 */
.slot { display: flex; flex-wrap: wrap; gap: 8px; min-height: 52px; padding: 10px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius-sm); margin-bottom: 10px; width: 100%; background: var(--card-soft); }
.pool { display: flex; flex-wrap: wrap; gap: 8px; }
.tok {
  background: var(--ink); color: var(--card); border: none;   /* button-on-dark 칩 — 초록 절약 */
  padding: 9px 14px; border-radius: var(--radius-sm); font-size: 16px; font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.tok:hover { background: var(--ink); color: var(--card); border: none; filter: brightness(1.14); box-shadow: var(--shadow); }

/* 피드백 */
.fb { font-size: 14px; margin-top: 12px; min-height: 20px; font-weight: 600; }
.fb.ok { color: var(--ok); }
.fb.no { color: var(--no); }

/* 플래시카드 */
.card3d {
  text-align: center; padding: 30px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  cursor: pointer; user-select: none; background: var(--card-soft);
  transition: transform .16s ease, box-shadow .16s ease;
}
.card3d:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.cardhint { color: var(--muted); font-size: 13px; margin-top: 8px; }

/* 쓰기 입력 */
.writebox { min-height: 58px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); margin: 6px 0; font-size: 16px; background: var(--card-soft); transition: border-color .15s, box-shadow .15s; }
.writebox:empty::before { content: attr(data-ph); color: var(--muted); }
.writebox:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
ul.ck { margin: 10px 0 0; padding-left: 20px; font-size: 14px; color: var(--muted); }
ul.ck li { margin: 3px 0; }
.player-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; }

/* ── 완료 화면 ── */
.complete { text-align: center; padding: 40px 24px; box-shadow: var(--shadow-lg); }
.complete .trophy { font-size: 60px; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .15)); }
.complete .score {
  font-size: 44px; font-weight: 700; margin: 8px 0; letter-spacing: -0.03em;
  color: var(--brand-strong);
}
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; margin: 22px 0; }
.stat { padding: 18px 14px; text-align: center; background: var(--card-soft); }
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; color: var(--brand-strong); }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── 대시보드 ── */
.dash-hero {
  padding: 28px; text-align: center; box-shadow: var(--shadow);
  background: var(--card);   /* 화이트 카드 · 대기 그라디언트 없음 */
}
.vocab-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ── 인증 폼 ── */
.auth-wrap { max-width: 420px; margin: 36px auto; padding: 32px; box-shadow: var(--shadow-lg); }
.field { display: block; margin: 14px 0; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 13px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--card-soft); color: var(--ink); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.auth-switch { text-align: center; font-size: 14px; margin-top: 18px; color: var(--muted); }
.auth-switch a { color: var(--brand-strong); text-decoration: none; font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }

/* ── 진입 애니메이션 ── */
@media (prefers-reduced-motion: no-preference) {
  .app > * { animation: rise .32s ease both; }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}
