/* =====================================================
   앱 셸 — 목업의 고정 프레임(340x700 / 1112x660)을 실제 뷰포트에 맞게 확장.
   폰(<720px) = 앱 레이아웃 · 태블릿/PC(>=720px) = 태블릿 가로/관리자페이지.
   ===================================================== */

html, body { height: 100%; }
body {
  padding: 0;
  background: var(--paper-dim);
  overscroll-behavior-y: none;
}
#app { height: 100dvh; display: flex; flex-direction: column; }

/* =====================================================
   화면 전환 — 흰 깜빡임 없애기

   새 화면은 모듈 로드 + API 응답을 기다리는 동안 아무것도 그리지 못한다.
   그 사이 이전 화면을 그대로 남겨 두어 빈 프레임이 한 장도 나가지 않게 한다.
   (js/router.js 의 beginTransition/endTransition)
   ===================================================== */
.screen-out, #app.screen-in {
  position: fixed; inset: 0; height: 100dvh;
}
/* 떠나는 화면이 «위에» 불투명하게 남는다. 새 화면을 투명하게 깔았다가 밝히면
   이전 화면이 사라진 직후 한 프레임이 비어 흰 깜빡임이 그대로 다시 생긴다. */
.screen-out { z-index: 2; pointer-events: none; }
#app.screen-in { z-index: 1; }

/* 전환이 길어지면(220ms+) 상단에 얇은 진행 표시 — '멈춘 것' 처럼 보이지 않게 */
body.nav-busy::after {
  content: ''; position: fixed; left: 0; right: 0; z-index: 950;
  top: env(safe-area-inset-top); height: 2px;
  background: linear-gradient(90deg, transparent, var(--lime-deep), transparent);
  animation: nav-sweep .9s linear infinite;
}
@keyframes nav-sweep {
  0% { transform: translateX(-100%) }
  100% { transform: translateX(100%) }
}

/* 오버스크롤로 문서 밖이 드러나도 흰 바탕이 보이지 않게 */
html { background: var(--paper-dim); }

/* 실제 앱에서는 프레임이 뷰포트를 채운다 */
.frame.phone, .frame.desktop, .frame.tablet {
  width: 100%; height: 100%;
  border: none; border-radius: 0; box-shadow: none;
  max-width: none;
}
.frame { background: var(--paper); }
.scroll { -webkit-overflow-scrolling: touch; }

/* 넓은 화면에서 앱 표면(폰 레이아웃)은 중앙 정렬 컬럼으로 */
.surface-app .frame.phone {
  max-width: 480px; margin: 0 auto;
  border-left: 1px solid var(--line); border-right: 1px solid var(--line);
}
.surface-admin .frame.desktop { zoom: 1; }

/* 안전영역 */
.m-appbar { padding-top: calc(20px + env(safe-area-inset-top)); }
.m-nav { padding-bottom: calc(6px + env(safe-area-inset-bottom)); height: auto; min-height: 62px; }

/* ---------- 토스트 (목업 .toast 확장) ---------- */
.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 700;
  padding: 11px 18px; border-radius: var(--r-pill); opacity: 0;
  transition: opacity .18s, transform .18s; pointer-events: none; z-index: 900;
  max-width: min(560px, calc(100vw - 32px)); text-align: center; line-height: 1.5;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 시트 / 다이얼로그 ---------- */
.scrim {
  position: fixed; inset: 0; background: rgba(17,18,16,.42); z-index: 800;
  opacity: 0; transition: opacity .2s; backdrop-filter: blur(2px);
}
.scrim.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 810;
  background: #fff; border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .25s cubic-bezier(.2,.8,.3,1);
  max-height: 86dvh; overflow-y: auto; max-width: 640px; margin: 0 auto;
}
.sheet.show { transform: translateY(0); }
.sheet .sheet-grab { width: 38px; height: 4px; border-radius: 99px; background: var(--ink-25); margin: 4px auto 14px; }
.sheet-title { font-size: 15px; font-weight: 800; margin-bottom: 4px; }
.sheet-desc { font-size: 12px; color: var(--ink-45); font-weight: 600; line-height: 1.7; }
.dialog {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%,-48%) scale(.97);
  z-index: 810; background: #fff; border-radius: var(--r-xl); padding: 24px 22px 18px;
  width: min(360px, calc(100vw - 40px)); opacity: 0; transition: all .2s;
}
.dialog.show { transform: translate(-50%,-50%) scale(1); opacity: 1; }
.dialog-t { font-size: 16px; font-weight: 800; }
.dialog-d { font-size: 12.5px; color: var(--ink-45); font-weight: 600; line-height: 1.75; margin-top: 8px; }
.dialog-btns { display: flex; gap: 8px; margin-top: 20px; }
.dialog-btns button { flex: 1; height: 44px; border-radius: var(--r-md); font-size: 13px; font-weight: 800; }
.btn-ghost { background: var(--paper-dim); color: var(--ink-70); }
.btn-ghost:hover { background: var(--paper-sub); }

/* 코드 입력 오류 셰이크 (CM-02) */
.code-boxes.shake { animation: shake .38s; }
@keyframes shake {
  0%, 100% { transform: translateX(0) }
  20% { transform: translateX(-7px) }
  40% { transform: translateX(6px) }
  60% { transform: translateX(-4px) }
  80% { transform: translateX(3px) }
}

/* ---------- 공통 유틸 ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--ink-45); }
.empty .ico { font-size: 30px; color: var(--ink-25); }
.empty .t { font-size: 13px; font-weight: 800; color: var(--ink-70); margin-top: 12px; }
.empty .s { font-size: 11.5px; font-weight: 600; margin-top: 6px; line-height: 1.7; }
.empty .cta { margin-top: 16px; display: inline-flex; padding: 11px 20px; font-size: 12px; }
/* 연결 실패 — 화면 전체를 쓰므로 .empty 와 달리 세로도 중앙에 둔다 */
.net-err {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 32px 28px; color: var(--ink-45);
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
}
.net-err .ico { font-size: 38px; color: var(--ink-25); line-height: 1; }
.net-err .t { font-size: 15px; font-weight: 800; color: var(--ink); margin-top: 18px; }
.net-err .s { font-size: 12.5px; font-weight: 600; margin-top: 10px; line-height: 1.7; }
.net-err .cta { margin-top: 24px; display: inline-flex; padding: 13px 26px; font-size: 12.5px; }
.net-err .hint { font-size: 11.5px; font-weight: 600; color: var(--ink-25); margin-top: 14px; }

.skeleton { background: linear-gradient(90deg, var(--paper-dim) 25%, var(--paper-sub) 37%, var(--paper-dim) 63%); background-size: 400% 100%; animation: sk 1.2s infinite; border-radius: var(--r-md); }
@keyframes sk { 0% { background-position: 100% 0 } 100% { background-position: 0 0 } }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.banner-warn {
  display: flex; gap: 9px; align-items: flex-start; background: #FFF7E6; border: 1px solid #F0D9A0;
  border-radius: var(--r-md); padding: 11px 13px; font-size: 11px; font-weight: 700; color: #7A5C10; line-height: 1.6;
}
.banner-err {
  display: flex; gap: 9px; align-items: center; background: #FDECEC; border: 1px solid #F4C3C4;
  border-radius: var(--r-md); padding: 11px 13px; font-size: 11px; font-weight: 700; color: #A5282C;
}
.banner-err button, .banner-warn button { margin-left: auto; font-size: 11px; font-weight: 800; text-decoration: underline; flex-shrink: 0; }
.pill-tag { font-size: 9.5px; font-weight: 800; border-radius: var(--r-pill); padding: 4px 9px; background: var(--paper-dim); color: var(--ink-70); }
.pill-tag.lime { background: var(--lime); color: var(--ink); }
.pill-tag.red { background: #FDECEC; color: var(--red); }

/* ---------- 스플래시 (CM-01) ---------- */
.splash {
  position: fixed; inset: 0; background: #000; color: #fff; z-index: 1000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  transition: opacity .3s;
}
.splash.out { opacity: 0; pointer-events: none; }
.splash .wm { font-size: 30px; font-weight: 800; letter-spacing: -.05em; opacity: 0; animation: fadeUp .7s ease forwards; }
.splash .tag { font-size: 12.5px; font-weight: 600; color: rgba(255,255,255,.55); opacity: 0; animation: fadeUp .7s .12s ease forwards; }
.splash .load { margin-top: 22px; width: 24px; height: 2px; background: rgba(255,255,255,.25); border-radius: 99px; overflow: hidden; opacity: 0; transition: opacity .3s; }
.splash .load.on { opacity: 1; }
.splash .load i { display: block; height: 100%; width: 40%; background: var(--lime); animation: slide 1s infinite; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }
@keyframes slide { 0% { transform: translateX(-100%) } 100% { transform: translateX(350%) } }

/* ---------- 웹 관리자페이지(태블릿=PC) ---------- */
.surface-admin { background: var(--paper-dim); }
.surface-admin .d-body { height: 100%; }
.admin-only-note { display: none; }

/* 폰 폭에서 관리자페이지 진입 시 안내 */
@media (max-width: 719px) {
  .surface-admin .d-nav { overflow-x: auto; scrollbar-width: none; }
  .surface-admin .d-cols { grid-template-columns: 1fr !important; }
  .admin-only-note { display: block; }
}

/* 태블릿 가로 뷰어(ST-07)는 720px 이상에서만 */
@media (max-width: 719px) {
  .t3 { display: none !important; }
}

/* 접근성 */
:focus-visible { outline: 2px solid var(--lime-deep); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* 달력 보조 — 선택일 강조 · 자녀별 점 색 (PA-03) */
.cal-d.sel:not(.today) { box-shadow: inset 0 0 0 1.5px var(--ink); }
.cal-d .dt { background: var(--ink); }
.cal-d .dt.a { background: var(--lime-deep); }
.cal-d.today .dt { background: var(--lime); }

/* 상담방 목록 배지 위치 보정 (PA-02 / DR-02) */
.chl-row .mn-badge { position: static; }

/* 청구 상태 pill 확장 (PA-06 / AD-08) */
.pay-st.done { background: var(--lime); color: var(--ink); }
.pay-st.late { background: var(--red); color: #fff; }

/* 채점 시트 정답 마크 (ST-03) — 목업의 .xmark 와 짝을 이룬다 */
.okmark { width: 20px; height: 20px; border-radius: 6px; transform: rotate(45deg);
  background: var(--lime); border: 1.5px solid var(--ink); display: flex; align-items: center; justify-content: center; }
.okmark i { transform: rotate(-45deg); font-size: 11px; color: var(--ink); }

/* 단어시험 정오 피드백 (ST-04) */
.wt-c.ok { border-color: var(--lime-deep); background: var(--lime); }
.wt-c.no { border-color: var(--red); color: var(--red); }

/* 전자칠판 — Esc 컨트롤 숨김(미러링 화면에 교재만 남긴다) */
.bb-top.hidden, .bb-strip.hidden { display: none; }
.pdf-ans.revealed { filter: none !important; }
.bb-page { position: relative; }

/* =====================================================
   관리자페이지 보조 툴바
   목업의 .d-top-right 는 상단바 안에서 '우측으로 밀어내는' 용도(margin-left:auto)라
   화면 전체 폭 툴바로 재사용하면 폭이 콘텐츠만큼 줄고 오른쪽에 붙어 버린다.
   전용 클래스로 분리한다.
   ===================================================== */
.d-subbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 28px; border-bottom: 1px solid var(--line);
  flex-shrink: 0; justify-content: space-between; flex-wrap: wrap;
}
.d-subbar.end { justify-content: flex-end; }
.d-subbar .lg-btn { width: auto; margin: 0; }

/* 큰 모니터에서 본문이 과하게 늘어지지 않도록 — 목업 캔버스(1112px) 기준 */
.surface-admin .d-body > * { max-width: 1400px; }
.surface-admin .d-body { display: flex; flex-direction: column; align-items: stretch; }
@media (min-width: 1500px) {
  .surface-admin .d-body { padding-left: max(28px, calc((100% - 1400px) / 2)); padding-right: max(28px, calc((100% - 1400px) / 2)); }
}

/* 이모지를 아이콘 자리에 쓸 때 — 플랫폼마다 글리프가 커서 컨테이너를 넘긴다.
   컨테이너가 정한 크기를 넘지 않도록 고정한다. */
.mi2, .cc-av, .care-av, .chl-av, .rp-ico, .nt-ico, .bk-ico, .ma-ico, .d-avatar {
  line-height: 1; overflow: hidden;
}
.mi2, .cc-av, .care-av, .chl-av { font-variant-emoji: text; }

/* 앱 표면 — 목업은 340px 폰 기준이라 큰 폰에서 여백이 과해지지 않게 상한을 둔다 */
.surface-app .frame.phone { max-width: 520px; }

/* 버튼 최소 터치 타깃 (모바일 접근성) */
@media (pointer: coarse) {
  .m-nav .mn-item, .ab-ico, .bk-go, .care-act, .sheet-btn { min-height: 40px; }
}

/* =====================================================
   관리자 상단바 — 항목이 늘어나도 글자가 접히지 않게
   flex 자식은 기본적으로 콘텐츠보다 작게 줄어든다. 그래서 GNB 항목이 13개가 되자
   버튼마다 텍스트가 두 줄로 접히고 로고까지 '오늘의 스/터디'로 쪼개졌다.
   ===================================================== */
.d-topbar { gap: 16px; }
.d-topbar .logo,
.d-topbar .d-top-right { flex-shrink: 0; white-space: nowrap; }
.d-nav {
  flex: 1 1 auto; min-width: 0;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -ms-overflow-style: none;
}
.d-nav::-webkit-scrollbar { display: none; }
.dn-item { flex-shrink: 0; white-space: nowrap; }
.d-acad, .d-quick { white-space: nowrap; flex-shrink: 0; }
.d-acad { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }

/* 폭이 빠듯하면 GNB 를 먼저 좁힌다 */
@media (max-width: 1279px) {
  .d-topbar { padding: 0 16px; gap: 12px; }
  .d-nav { gap: 2px; }
  .dn-item { padding-left: 8px; padding-right: 8px; }
  .d-acad { display: none; }
}

/* 관리자 서브툴바도 같은 규칙 */
.d-subbar > * { flex-shrink: 0; }
.d-subbar .lg-btn, .d-subbar .d-quick { white-space: nowrap; }

/* 목록 항목 제목은 잘라내지 말고 CSS 로 말줄임 */
.pg-item { min-width: 0; }
.pg-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* =====================================================
   브랜드 마크 — logo.png (배경 투명)
   mask 로 얹어 currentColor 를 따르게 한다.
   흰 배경 앱바에서는 검정, 블랙 히어로/스플래시에서는 흰색,
   CM-02 대상 확인 카드에서는 라임으로 같은 파일 하나가 쓰인다.
   원본 비율 512:370 ≈ 1.384 : 1
   ===================================================== */
.sym, .sym-big, .brand-mark {
  display: inline-block; flex-shrink: 0;
  background: currentColor;
  -webkit-mask: url('../logo.png') center/contain no-repeat;
  mask: url('../logo.png') center/contain no-repeat;
}
.logo .sym { width: 22px; height: 16px; }
.d-topbar .logo .sym { width: 17px; height: 12px; }
.sym-big { width: 84px; height: 61px; }
.brand-mark { width: 20px; height: 14px; }

/* 스플래시 — 워드마크 위에 마크를 얹는다 */
.splash .mark { width: 92px; height: 66px; background: #fff; margin-bottom: 20px;
  -webkit-mask: url('logo.png') center/contain no-repeat; mask: url('logo.png') center/contain no-repeat;
  opacity: 0; animation: fadeUp .7s ease forwards; }

/* =====================================================
   flex 컨테이너 안의 폼 요소
   목업은 입력칸이 <div> 라 문제가 없었지만 실제 입력을 받으려면 <input> 이어야 한다.
   input 은 기본 min-width 가 콘텐츠 기준(size 속성)이라 flex 로 줄어들지 않고
   옆의 전송 버튼을 화면 밖으로 밀어낸다. 게다가 그 상태에서 포커스가 가면
   overflow:hidden 인 .frame 이 가로로 스크롤돼 화면 전체가 밀린다.
   ===================================================== */
input.ci-field, textarea.ci-field,
.ch-input input, .ch-input textarea,
.d-subbar input, .d-subbar select { min-width: 0; }
input.ci-field { width: 100%; border: none; outline: none; font: inherit; color: var(--ink); }
input.ci-field::placeholder { color: var(--ink-25); font-weight: 600; }

/* 프레임은 세로로만 스크롤한다 — 포커스·앵커 이동이 가로로 밀지 못하게 */
.frame { overflow-x: clip; }

/* 세그먼트 버튼도 글자가 접히지 않게 */
.seg button { white-space: nowrap; }

/* 앱바 안에 들어간 세그먼트는 폭이 좁으니 버튼 간 여백을 준다 */
.m-appbar .seg { padding: 3px; gap: 2px; }
.m-appbar .seg button { padding: 7px 10px; }

/* =====================================================
   알림 패널 (js/notify.js)

   같은 목록을 맥락에 따라 다르게 내놓는다.
     .as-window  앱 셸 — 아래에서 올라오는 «새 창». 화면을 다 덮고, 닫으면 창이 닫힌다.
     .as-modal   브라우저 — 페이지 위에 뜨는 중앙 모달.
   브라우저에는 주소창·탭이 «웹을 보고 있다»는 맥락을 주지만 앱에는 없기 때문이다.
   ===================================================== */
.np {
  position: fixed; z-index: 820; background: var(--paper);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transition: opacity .2s, transform .26s cubic-bezier(.2,.8,.3,1);
}
.np.show { opacity: 1; }

/* ── 앱: 새 창 ── */
.np.as-window {
  inset: 0; border-radius: 0; transform: translateY(100%);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.np.as-window.show { transform: translateY(0); }

/* ── 웹: 중앙 모달 ── */
.np.as-modal {
  left: 50%; top: 50%; transform: translate(-50%, -48%) scale(.98);
  width: min(460px, calc(100vw - 32px)); max-height: min(680px, 82dvh);
  border-radius: var(--r-xl); box-shadow: 0 24px 64px rgba(17,18,16,.22);
}
.np.as-modal.show { transform: translate(-50%, -50%) scale(1); }
/* 넓은 화면에서는 벨 근처(우상단)에 붙는 것이 더 자연스럽다 */
@media (min-width: 900px) {
  .np.as-modal {
    left: auto; top: 64px; right: 24px;
    transform: translateY(-8px) scale(.98); transform-origin: top right;
  }
  .np.as-modal.show { transform: translateY(0) scale(1); }
}

/* ── 머리 ── */
.np-head {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  padding: 16px 18px 12px;
}
.np-title { font-size: 19px; font-weight: 800; letter-spacing: -.03em; display: flex; align-items: center; gap: 7px; }
.np-n {
  font-family: var(--font-num); font-size: 10.5px; font-weight: 800;
  background: var(--lime); color: var(--ink); border-radius: var(--r-pill);
  padding: 2px 7px; min-width: 18px; text-align: center;
}
.np-read {
  margin-left: auto; font-size: 11.5px; font-weight: 700; color: var(--ink-45);
}
.np-read:disabled { opacity: .35; }
.np-read:not(:disabled):hover { color: var(--ink); }
.np-x {
  width: 34px; height: 34px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--ink-70); background: var(--paper-dim);
}
.np-x:hover { background: var(--paper-sub); color: var(--ink); }

/* ── 필터 칩 ── */
.np-filters {
  display: flex; gap: 6px; flex-shrink: 0;
  padding: 0 18px 12px; overflow-x: auto; scrollbar-width: none;
}
.np-filters::-webkit-scrollbar { display: none; }
.np-chip {
  flex-shrink: 0; font-size: 11.5px; font-weight: 700; white-space: nowrap;
  padding: 7px 13px; border-radius: var(--r-pill);
  background: var(--paper-dim); color: var(--ink-70);
}
.np-chip.on { background: var(--ink); color: #fff; }

/* ── 목록 ── */
.np-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 6px; }
.np-day {
  position: sticky; top: 0; z-index: 1;
  background: var(--paper); padding: 8px 8px 6px;
  font-size: 10.5px; font-weight: 800; color: var(--ink-45);
}
.np-item {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 12px;
  align-items: start; width: 100%; text-align: left;
  padding: 12px 8px; border-radius: 14px;
  transition: background .12s;
}
.np-item:hover { background: var(--paper-dim); }
/* 안읽음은 배경 틴트로 알린다 — 점 하나보다 목록에서 훨씬 빨리 읽힌다 */
.np-item.unread { background: rgba(198,245,0,.10); }
.np-item.unread:hover { background: rgba(198,245,0,.18); }
.np-item.unread .np-t::after {
  content: ''; display: inline-block; vertical-align: .12em; margin-left: 6px;
  width: 6px; height: 6px; border-radius: 1px; transform: rotate(45deg);
  background: var(--lime-deep);
}
.np-ico {
  width: 40px; height: 40px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}
.np-ico.lime { background: var(--lime); color: var(--ink); }
.np-ico.ink { background: var(--ink); color: var(--lime); }
.np-ico.plain { background: var(--paper-sub); color: var(--ink-70); }
.np-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.np-t { font-size: 13px; font-weight: 700; line-height: 1.45; color: var(--ink); }
.np-item.unread .np-t { font-weight: 800; }
.np-s {
  font-size: 11.5px; font-weight: 600; color: var(--ink-45); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.np-m { font-size: 10px; font-weight: 700; color: var(--ink-25); }
.np-time {
  font-family: var(--font-num); font-size: 10px; font-weight: 600;
  color: var(--ink-25); white-space: nowrap; padding-top: 3px;
}

.np-empty { padding: 56px 24px; text-align: center; color: var(--ink-45); }
.np-empty i { font-size: 32px; color: var(--ink-25); }
.np-empty .t { font-size: 13.5px; font-weight: 800; color: var(--ink-70); margin-top: 14px; }
.np-empty .s { font-size: 11.5px; font-weight: 600; margin-top: 6px; line-height: 1.7; }
.np-empty .cta { margin-top: 18px; display: inline-flex; padding: 11px 20px; font-size: 12px; }
.np-foot {
  flex-shrink: 0; text-align: center; font-size: 9.5px; font-weight: 600;
  color: var(--ink-25); padding: 10px 18px calc(14px + env(safe-area-inset-bottom));
}
.np.as-modal .np-foot { padding-bottom: 14px; }
