:root {
  --yellow: #ffd84d;
  --orange: #ff9f43;
  --pink: #ff6b9a;
  --sky: #4cc3ff;
  --green: #5fd38d;
  --purple: #a77bff;
  --ink: #3a2e5a;
  --panel: rgba(255, 255, 255, 0.92);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #e8f5fd; color: var(--ink);
  font-family: var(--app-font, "Apple SD Gothic Neo"), "Apple SD Gothic Neo", "Malgun Gothic", "Nanum Gothic", system-ui, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; background: none; }
input, select { font: inherit; -webkit-user-select: text; user-select: text; }
.hidden { display: none !important; }

/* ---------- 홈 ---------- */
.home { position: fixed; inset: 0; display: flex; flex-direction: column; }
.home-bg { position: absolute; inset: 0; background: #e8f5fd center bottom / cover no-repeat; }

.topbar { position: relative; z-index: 2; display: flex; justify-content: center; align-items: flex-start;
  padding: calc(16px + var(--safe-t)) calc(100px + var(--safe-r)) 4px calc(100px + var(--safe-l)); }
.main-menu { display: flex; gap: 30px; justify-content: center; }
.menu-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; transition: transform .12s; }
/* 참고 이미지처럼 배경 없는 알록달록 그림 아이콘 */
.menu-btn .ic { position: relative; display: block; width: 68px; height: 60px; font-style: normal; }
.menu-btn .ic svg { width: 68px; height: 60px; display: block; }
/* 글자 아이콘: 글자를 겹쳐 배치 (icon 폴더에 그림을 넣으면 그 그림으로 바뀜) */
.menu-btn .glyph span { position: absolute; line-height: 1; font-weight: 700; }
/* 글씨체는 앱의 다른 글자와 같게 (따로 받아오는 글꼴 없음) */
.menu-btn .glyph span { font-family: inherit; font-weight: 900; }
/* 가나다: 가(분홍) 왼쪽 위, 나(파랑) 오른쪽 위, 다(노랑) 왼쪽 아래 */
.glyph.ko .g1 { left: 2px; top: 4px; font-size: 32px; color: #ff5fa2; }
.glyph.ko .g2 { left: 34px; top: 0; font-size: 26px; color: #4a8dff; }
.glyph.ko .g3 { left: 10px; top: 30px; font-size: 29px; color: #ffbe1a; }
/* ABC: A(분홍) 왼쪽 크게, B(노랑) 위, C(파랑) 오른쪽 아래 */
.glyph.en .g1 { left: 0; top: 16px; font-size: 40px; color: #ff5f9e; }
.glyph.en .g2 { left: 23px; top: -2px; font-size: 30px; color: #ffbe1a; }
.glyph.en .g3 { left: 34px; top: 20px; font-size: 38px; color: #2f8cff; }
/* 123: 1(파랑) 위 가운데, 2(주황) 왼쪽 아래, 3(노랑) 오른쪽 아래 */
.glyph.num .g1 { left: 24px; top: -2px; font-size: 30px; color: #2f8cff; }
.glyph.num .g2 { left: 7px; top: 24px; font-size: 36px; color: #ff8a2a; }
.glyph.num .g3 { left: 35px; top: 24px; font-size: 36px; color: #ffbe1a; }.menu-btn b { position: relative; font-size: 17px; font-weight: 600; color: #555; padding-bottom: 5px; }
.menu-btn.active b { font-weight: 900; color: #111; }
/* 선택된 메뉴: 이름 아래 초록 밑줄 */
.menu-btn.active b::after { content: ""; position: absolute; left: -4px; right: -4px; bottom: 0; height: 4px; border-radius: 4px; background: #2ec263; }
.menu-btn.active .ic { transform: scale(1.08); }.menu-btn:active { transform: scale(.92); }

.settings-btn { position: absolute; top: calc(16px + var(--safe-t)); right: calc(22px + var(--safe-r));
  width: 66px; height: 66px; border-radius: 50%; background: #2ec263; display: grid; place-items: center;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.15), 0 4px 12px rgba(0,0,0,.18); }
.settings-btn svg { width: 38px; height: 38px; }
.settings-btn:active { transform: scale(.92); }

.sub-menu { position: relative; z-index: 2; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; padding: 12px 20px 6px; animation: drop .2s ease-out; }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } }
.pill { padding: 7px 24px; border-radius: 999px; font-size: 18px; font-weight: 600; color: #888; background: rgba(255,255,255,.9); border: 2.5px solid #b9b9b9; }
.pill.active { color: #22b85a; border-color: #22b85a; background: #fff; font-weight: 800; }
.empty-chip { padding: 10px 20px; border-radius: 16px; background: rgba(255,255,255,.9); font-size: 18px; }

/* 메뉴·탭은 고정, 목록만 아래로 스크롤 */
.content { position: relative; z-index: 1; flex: 1; min-height: 0; display: flex; flex-direction: column; animation: drop .2s ease-out; }
.c-head, .char-head { flex: none; padding-top: 4px; padding-bottom: 12px; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 8px calc(32px + var(--safe-r)) calc(96px + var(--safe-b)) calc(32px + var(--safe-l));
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14px); mask-image: linear-gradient(to bottom, transparent 0, #000 14px); }
.scroll.center { display: flex; flex-direction: column; justify-content: center; padding-bottom: calc(24px + var(--safe-b)); }
.empty { align-self: center; text-align: center; padding: 30px 40px; font-size: 22px; line-height: 1.6; color: #666;
  background: rgba(255,255,255,.85); border-radius: 24px; }

/* 가로로 넘기는 줄 (학습 카드) */
.hrow { display: flex; gap: 26px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
  padding: 16px 8px 18px; scrollbar-width: none; }
.hrow::-webkit-scrollbar { display: none; }
.hrow > * { flex: none; scroll-snap-align: start; }
.hrow > :first-child { margin-left: auto; }
.hrow > :last-child { margin-right: auto; }

/* 학습 카드 */
.tile { width: 190px; }
.tile-face { height: 210px; border-radius: 26px; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 12px; box-shadow: 0 6px 0 rgba(0,0,0,.08), 0 8px 18px rgba(0,0,0,.1); border: 5px solid #fff; }
.tile:active .tile-face { transform: scale(.95); }
.tile img { width: 100%; height: 120px; object-fit: contain; border-radius: 14px; }
.tile .emoji { font-size: 56px; line-height: 1.1; text-align: center; word-break: break-all; max-height: 124px; overflow: hidden; }
.tile-text { font-size: 30px; font-weight: 800; color: #333; }
.tile.text-only .tile-text { font-size: 84px; }
.learn-tile:nth-child(5n+1) .tile-face { background: #ffe9ee; } .learn-tile:nth-child(5n+2) .tile-face { background: #e3f5ff; }
.learn-tile:nth-child(5n+3) .tile-face { background: #e4f9ea; } .learn-tile:nth-child(5n+4) .tile-face { background: #fff4d6; }
.learn-tile:nth-child(5n) .tile-face { background: #f0e8ff; }

/* 캐릭터: 한 줄에 5개, 6번째부터 아랫줄 */
.char-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 28px 14px; max-width: 1400px; margin: 0 -10px; }
.char { display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: 0; }
.char-wrap { position: relative; width: 100%; }
.char-img { width: 100%; aspect-ratio: 1; border-radius: 50%; overflow: hidden; display: grid; place-items: center; font-size: 80px;
  background: #ffc928; box-shadow: 0 6px 16px rgba(0,0,0,.13); transition: transform .15s; }
.char-img.c1 { background: #2eb8f2; } .char-img.c2 { background: #38c766; }
.char-img.c3 { background: #ff6b6b; } .char-img.c4 { background: #b07cff; }
.char-img img { width: 100%; height: 100%; object-fit: cover; }
.char:active .char-img { transform: scale(.94); }
.char-wrap .heart { position: absolute; right: 4%; bottom: 4%; }
.char-name { font-size: 22px; font-weight: 700; color: #333; text-align: center; line-height: 1.25; text-shadow: 0 0 6px #fff, 0 0 3px #fff;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.char-head { display: flex; align-items: center; gap: 14px; padding-left: calc(32px + var(--safe-l)); padding-right: calc(32px + var(--safe-r)); }
.char-img.small { width: 72px; height: 72px; font-size: 36px; }
.char-title { font-size: 26px; font-weight: 800; color: #333; }
.char-head .tabs { margin-left: auto; }
.back-btn { width: 52px; height: 52px; border-radius: 50%; background: #ffb21e; display: grid; place-items: center; box-shadow: inset 0 -4px 0 rgba(0,0,0,.14); flex: none; }
.back-btn svg { width: 28px; height: 28px; }

.tabs { display: flex; gap: 10px; }
.tabs.center { justify-content: center; }

/* 영상 카드: 한 줄에 3개 */
.video-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px 24px; max-width: 1400px; margin: 0 auto; }
.vtile { text-align: left; min-width: 0; }
.vthumb { position: relative; aspect-ratio: 16/9; background: #222; border-radius: 20px; overflow: hidden; box-shadow: 0 6px 0 rgba(0,0,0,.1), 0 6px 16px rgba(0,0,0,.12); }
.vthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vtile:active .vthumb { transform: scale(.97); }
.badge { position: absolute; top: 0; right: 0; background: #1fb2f0; color: #fff; padding: 7px 14px; border-radius: 0 0 0 16px; font-size: 16px; font-weight: 700; }
.badge.song { background: #ff5f8f; }
.vtitle { padding: 10px 4px 0; font-size: 20px; font-weight: 700; color: #222; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vsub { padding: 2px 4px; font-size: 15px; color: #777; }
.file-thumb { width: 100%; height: 100%; display: grid; place-items: center; font-size: 56px; background: linear-gradient(135deg, #ffe0ec, #dff4ff); }
.file-thumb.sm { width: 96px; height: 54px; font-size: 26px; border-radius: 8px; flex: none; }
/* 전체 이어보기: 아래 가운데 떠 있는 버튼 */
.play-all-row { position: absolute; left: 0; right: 0; bottom: calc(18px + var(--safe-b)); display: flex; justify-content: center; pointer-events: none; z-index: 2; }
.play-all { pointer-events: auto; display: flex; align-items: center; gap: 8px; padding: 12px 28px; font-size: 19px; font-weight: 800; color: #333;
  background: #fff; border-radius: 999px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.play-all svg { width: 24px; height: 24px; }
.search-row { padding-left: calc(32px + var(--safe-l)); padding-right: calc(32px + var(--safe-r)); }
.search-row input { width: 100%; max-width: 640px; display: block; margin: 0 auto; padding: 14px 22px; font-size: 22px; border-radius: 999px; border: 3px solid #22b85a; outline: none; background: #fff; }

/* ---------- 오버레이 공통 ---------- */
.overlay { position: fixed; inset: 0; z-index: 10; background: rgba(30, 20, 50, .82); display: flex; align-items: center; justify-content: center;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l)); }
.round-btn { width: 54px; height: 54px; border-radius: 50%; background: #fff; color: #333; font-size: 24px; flex: none; display: grid; place-items: center; }
.round-btn svg { width: 26px; height: 26px; }
.round-btn.close { background: var(--pink); color: #fff; }

/* 플레이어 */
.player-box { width: 100%; max-width: 1100px; height: 100%; display: flex; flex-direction: column; gap: 10px; }
.player-top { display: flex; align-items: center; gap: 12px; color: #fff; }
.player-title { flex: 1; font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-stage { position: relative; flex: 1; min-height: 0; background: #000; border-radius: 18px; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; }
.player-stage iframe, #ytHost { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.file-video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }
.audio-art { width: min(50vh, 340px); aspect-ratio: 1; border-radius: 50%; overflow: hidden; display: grid; place-items: center; font-size: 120px;
  background: #fff; animation: spin 14s linear infinite; margin-bottom: 18px; }
.audio-art img { width: 100%; height: 100%; object-fit: cover; }
@keyframes spin { to { transform: rotate(360deg); } }
.file-audio { width: 80%; }
.player-ctrl { display: flex; align-items: center; gap: 12px; color: #fff; }
.loop-toggle { margin-left: auto; font-size: 17px; display: flex; gap: 6px; align-items: center; }
.player-list { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; flex: none; }
.pl-item { flex: none; width: 170px; display: flex; flex-direction: column; gap: 4px; color: #fff; text-align: left; opacity: .65; font-size: 14px; }
.pl-item .thumb-box { width: 170px; height: 96px; border-radius: 10px; }
.pl-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-item.active { opacity: 1; }
.pl-item.active .thumb-box { outline: 4px solid var(--yellow); }

/* 이어보기 질문 · 오류 안내 */
.resume-ask, .play-error { display: flex; flex-direction: column; align-items: center; gap: 22px; color: #fff; text-align: center; padding: 20px; }
.resume-msg, .err-msg { font-size: 28px; line-height: 1.5; }
.resume-msg b { color: var(--yellow); }
.resume-btns { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.resume-btn { padding: 16px 34px; border-radius: 999px; font-size: 24px; font-weight: 800; background: #fff; color: #333; }
.resume-btn.yes { background: #2ec263; color: #fff; }
.err-icon { font-size: 70px; }
.err-code { font-size: 16px; opacity: .7; }

/* 전체화면 */
#player.full { padding: 0; background: #000; }
#player.full .player-box { max-width: none; gap: 0; }
#player.full .player-top, #player.full .player-ctrl, #player.full .player-list { display: none; }
#player.full .player-stage { border-radius: 0; }

/* 학습 카드 크게 보기 */
.fixed-close { position: absolute; top: calc(18px + var(--safe-t)); right: calc(18px + var(--safe-r)); }
.card-stage { width: min(80vw, 640px); }
.big-card { position: relative; background: #fff; border-radius: 36px; padding: 30px; min-height: min(70vh, 560px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; box-shadow: 0 14px 0 rgba(0,0,0,.2); animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.big-face img { max-width: 100%; max-height: 40vh; border-radius: 20px; }
.big-face .emoji { font-size: 120px; text-align: center; line-height: 1.15; word-break: break-all; }
.big-text { font-size: 80px; text-align: center; }
.big-text.huge { font-size: 200px; line-height: 1; }
.speak-btn { position: absolute; right: 20px; bottom: 20px; width: 70px; height: 70px; border-radius: 50%; background: var(--yellow); font-size: 34px; }
.card-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 80px; height: 80px; border-radius: 50%; background: rgba(255,255,255,.9); font-size: 34px; }
.card-nav.left { left: calc(20px + var(--safe-l)); }
.card-nav.right { right: calc(20px + var(--safe-r)); }
.card-dots { position: absolute; bottom: calc(18px + var(--safe-b)); color: #fff; font-size: 20px; }

/* ---------- 설정 ---------- */
.settings-box { width: 100%; max-width: 980px; height: 100%; background: #fffdf6; border-radius: 26px; display: flex; flex-direction: column; overflow: hidden;
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif; -webkit-user-select: text; user-select: text; }
.settings-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 6px 24px; }
.settings-head h2 { margin: 0; font-size: 24px; }
.settings-tabs { display: flex; gap: 6px; padding: 6px 18px; overflow-x: auto; border-bottom: 1px solid #eee3c8; flex: none; }
.settings-tabs button { padding: 10px 18px; border-radius: 12px 12px 0 0; font-size: 17px; white-space: nowrap; color: #7a6f8f; }
.settings-tabs button.active { background: var(--yellow); color: var(--ink); font-weight: 700; }
.settings-body { flex: 1; overflow-y: auto; padding: 16px 22px 40px; -webkit-overflow-scrolling: touch; }
.set-sec { background: #fff; border: 1px solid #f0e6cc; border-radius: 16px; padding: 16px 18px; margin-bottom: 16px; }
.set-sec h3 { margin: 0 0 10px; font-size: 18px; }
.muted { color: #8b8199; font-size: 14px; margin: 4px 0 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.row.tight { margin: 4px 0 0; gap: 6px; }
.form { display: flex; flex-direction: column; gap: 8px; }
.set-sec input:not([type=radio]):not([type=checkbox]), .set-sec select { padding: 11px 12px; border: 1px solid #dcd2bb; border-radius: 10px; font-size: 16px; background: #fff; min-width: 0; }
.row input:not([type=radio]):not([type=checkbox]) { flex: 1; }
.btn { padding: 11px 18px; border-radius: 10px; background: #efe9da; font-size: 16px; }
.btn.primary { background: var(--orange); color: #fff; font-weight: 700; }
.btn.danger, .mini.danger { background: #ffe1e6; color: #d23a5a; }
.btn:disabled { opacity: .5; }
.radio { display: flex; gap: 6px; align-items: center; font-size: 16px; margin-right: 14px; }
.bg-preview { height: 220px; border-radius: 14px; background: #f3efe3 center/cover no-repeat; display: grid; place-items: center; color: #9a8f7a; margin-bottom: 8px; background-color: #222; }
.bg-preview:empty { background-color: #222; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 6px 6px 6px 14px; border-radius: 999px; background: #f3eee0; font-size: 16px; cursor: pointer; }
.chip.active { background: var(--yellow); font-weight: 700; }
.chip button { padding: 4px 7px; font-size: 13px; color: #7a6f8f; }
.item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid #f3ecd9; }
.item-thumb { width: 54px; height: 54px; flex: none; border-radius: 10px; background: #f6f2e6; display: grid; place-items: center; font-size: 26px; overflow: hidden; }
.item-thumb.round { border-radius: 50%; }
.item-thumb.wide { width: 96px; }
.item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item-main b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-main small { color: #8b8199; }
.item-main select { padding: 5px 8px !important; font-size: 14px !important; }
.mini { padding: 7px 10px; border-radius: 8px; background: #f1ecdf; font-size: 14px; flex: none; }
.list { margin-top: 10px; }

.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(30px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 12px 22px; border-radius: 14px; font-size: 18px; box-shadow: 0 6px 18px rgba(0,0,0,.3); }

/* ---------- 즐겨찾기 하트 ---------- */
.fav-btn { position: absolute; top: calc(16px + var(--safe-t)); left: calc(22px + var(--safe-l));
  width: 66px; height: 66px; border-radius: 50%; background: #ff5a5f; display: grid; place-items: center;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.15), 0 4px 12px rgba(0,0,0,.18); }
.fav-btn svg { width: 36px; height: 36px; }
.fav-btn:active { transform: scale(.92); }
.fav-btn.active { box-shadow: 0 0 0 5px #fff, 0 0 0 9px #ff5a5f; }
.heart { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: #fff; flex: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.18); cursor: pointer; transition: transform .15s; }
.heart svg { width: 26px; height: 26px; fill: #cfcfc4; transition: fill .15s; }
.heart.on svg { fill: #ff4d6d; }
.heart.pop { transform: scale(1.3); }
.heart.inline { width: 40px; height: 40px; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.heart.inline svg { width: 22px; height: 22px; }
.heart.big { width: 54px; height: 54px; }
.vinfo { display: flex; align-items: center; gap: 8px; }
.vtext { flex: 1; min-width: 0; }

/* ---------- 연동 상태 ---------- */
.sync-status { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; vertical-align: middle; margin-left: 6px; background: #eee; color: #777; }
.sync-status[data-s=ok] { background: #e1f7e8; color: #1a9b4b; }
.sync-status[data-s=busy] { background: #e3f1ff; color: #2276c9; }
.sync-status[data-s=err] { background: #ffe4e6; color: #d23a5a; }
.set-sec textarea { padding: 11px 12px; border: 1px solid #dcd2bb; border-radius: 10px; font: inherit; font-size: 16px; resize: vertical; -webkit-user-select: text; user-select: text; }
/* 썸네일 오른쪽 아래 영상 길이 */
.dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.72); color: #fff; padding: 4px 10px; border-radius: 8px; font-size: 15px; font-weight: 700; }

/* 속도·자막 버튼 */
.opt-btn { display: flex; align-items: center; gap: 6px; height: 48px; padding: 0 16px 0 8px; border-radius: 999px; background: rgba(255,255,255,.95); color: #333;
  font-size: 16px; font-weight: 800; flex: none; }
.opt-btn .oi { display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0 4px; border-radius: 999px; background: #eee; font-size: 15px; }
.opt-btn .oi.cc { font-size: 13px; font-weight: 900; border-radius: 6px; }
.opt-btn.on .oi { background: #2ec263; color: #fff; }
.opt-btn.dim { opacity: .45; }
/* 캐릭터 영상 소분류 줄 */
.vgroup + .vgroup { margin-top: 30px; }
.vgroup-title { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding-left: 4px; font-size: 24px; font-weight: 900; color: #333; text-shadow: 0 0 6px #fff, 0 0 3px #fff; }
.vgroup-title::before { content: ""; width: 7px; height: 24px; border-radius: 4px; background: #2ec263; }
.vgroup-title small { font-size: 15px; font-weight: 700; color: #fff; background: #2ec263; border-radius: 999px; padding: 2px 10px; }
.grp-input { width: 120px; padding: 5px 8px !important; font-size: 14px !important; }
/* icon 폴더 그림으로 바꾼 아이콘 */
.icon-img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.fav-btn.custom-icon, .settings-btn.custom-icon { background: none; box-shadow: none; padding: 0; }
/* 썸네일 상자: 그림을 못 불러오면 🎬/🎵 표시 */
.thumb-box { position: relative; width: 100%; height: 100%; overflow: hidden; background: linear-gradient(135deg, #ffe0ec, #dff4ff); }
.thumb-box::before { content: attr(data-emo); position: absolute; inset: 0; display: grid; place-items: center; font-size: 56px; }
.thumb-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.pl-item .thumb-box::before { font-size: 30px; }
.drive-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* 전체화면: 오른쪽 위에 속도 · 자막 · 전체화면 끝내기 */
.fs-bar { display: none; }
#player.full .fs-bar { display: flex; align-items: center; gap: 10px; position: absolute; z-index: 3;
  top: calc(14px + var(--safe-t)); right: calc(14px + var(--safe-r)); }
#player.full .fs-bar .opt-btn { background: rgba(255,255,255,.85); }
#player.full .fs-bar .full-exit { display: grid; background: rgba(255,255,255,.85); }
/* 설정: 글씨체 고르기 */
.font-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.font-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px 14px; border-radius: 12px; border: 2px solid #eee3c8; background: #fff; text-align: left; }
.font-opt .font-sample { font-size: 22px; color: #333; }
.font-opt small { color: #8b8199; font-size: 13px; }
.font-opt.active { border-color: #2ec263; background: #effbf3; }

/* 설정: 영상 목록 (캐릭터·소분류별, 끌어서 순서 바꾸기) */
.row.between { justify-content: space-between; }
.no-margin { margin: 0 !important; }
.chap-box summary { cursor: pointer; font-size: 15px; color: #5a4f72; padding: 4px 0; }
.chap-box textarea { width: 100%; margin-top: 6px; }
.vid-sec + .vid-sec { margin-top: 14px; }
.vid-sec-title { font-weight: 800; font-size: 15px; padding: 6px 10px; background: #f6f1e3; border-radius: 8px; }
.vid-sec-title small { color: #fff; background: #2ec263; border-radius: 999px; padding: 1px 8px; font-size: 12px; margin-left: 4px; }
.drag { flex: none; width: 36px; height: 44px; display: grid; place-items: center; font-size: 22px; color: #a99f8a; cursor: grab; touch-action: none; }
.vid-item.dragging { background: #fff7d6; box-shadow: 0 6px 18px rgba(0,0,0,.18); border-radius: 10px; position: relative; z-index: 2; }
.item-thumb .thumb-box::before { font-size: 24px; }
.sb-frame { position: absolute; inset: 0; background-repeat: no-repeat; }
/* 화면 끄기: 영상 위를 덮어서 썸네일만 보여줌 (영상·소리는 뒤에서 계속) */
.stage-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.screen-off { position: absolute; inset: 0; z-index: 2; border-radius: 18px; background: #0d0a24;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; color: #fff; padding: 20px; }
.screen-off-thumb { width: min(62%, 620px); }
.screen-off-thumb .thumb-box { aspect-ratio: 16 / 9; height: auto; border-radius: 22px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.screen-off-thumb .so-title { margin-top: 12px; text-align: center; font-size: 22px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.screen-off-msg { display: flex; align-items: center; gap: 10px; font-size: 18px; opacity: .85; }
.screen-on-btn { padding: 12px 28px; border-radius: 999px; background: #ffd84d; color: #333; font-size: 20px; font-weight: 800; }
/* 소리가 나오고 있다는 표시 (막대 3개) */
.eq { display: inline-flex; align-items: flex-end; gap: 3px; height: 18px; }
.eq i { width: 4px; background: #5fd38d; border-radius: 2px; animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: .2s; } .eq i:nth-child(3) { animation-delay: .4s; }
@keyframes eq { 0%, 100% { height: 5px; } 50% { height: 18px; } }
.screen-btn.on { background: #ffd84d; }
.opt-btn.screen-btn .oi svg { width: 18px; height: 18px; }
#player.full .screen-off { border-radius: 0; }
#player.full .fs-bar .screen-btn { background: rgba(255,255,255,.85); }
#player.full .fs-bar .screen-btn.on { background: #ffd84d; }

/* 캐릭터 화면: 마지막으로 본 영상 버튼 */
.last-slot { margin-left: auto; min-width: 0; }
.last-btn { display: flex; align-items: center; gap: 10px; max-width: 420px; padding: 6px 14px 6px 6px; border-radius: 16px; background: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,.12); text-align: left; }
.last-thumb { flex: none; width: 96px; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; }
.last-thumb .thumb-box::before { font-size: 22px; }
.last-text { display: flex; flex-direction: column; min-width: 0; }
.last-text small { font-size: 13px; color: #22b85a; font-weight: 800; }
.last-text b { font-size: 16px; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.last-play { flex: none; width: 36px; height: 36px; border-radius: 50%; background: #2ec263; color: #fff; display: grid; place-items: center; font-size: 15px; }
.last-btn:active { transform: scale(.97); }
/* 영상 메모 */
.vsub.memo { color: #5a4f72; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.memo-input { flex: 1; min-width: 140px; padding: 5px 8px !important; font-size: 14px !important; }
/* ---------- 작은 화면(휴대폰)에서 자동으로 줄이기 ----------
   --z: 메뉴·버튼·제목 등을 한꺼번에 줄이는 비율 (화면 폭/높이에 따라 자동) */
:root { --z: 1; }
@media (max-width: 1000px) { :root { --z: .9; } }
@media (max-width: 820px)  { :root { --z: .8; } }
@media (max-width: 640px)  { :root { --z: .7; } }
@media (max-width: 480px)  { :root { --z: .6; } }
@media (max-width: 380px)  { :root { --z: .54; } }
/* 휴대폰 가로 화면 (높이가 낮음) */
@media (max-height: 520px) { :root { --z: .62; } }

.topbar, .sub-menu, .c-head, .char-head, .play-all-row, .empty, .empty-chip,
.char-name, .char-wrap .heart, .vinfo, .vgroup-title, .badge, .dur, .hrow,
.player-top, .player-ctrl, .player-list, .fs-bar, .resume-ask, .play-error, .screen-off-msg, .screen-on-btn, .so-title,
.card-nav, .fixed-close, .card-dots, .big-card, .toast { zoom: var(--z); }
@media (max-width: 560px) { .last-text { display: none; } .last-btn { padding-right: 6px; } }

@media (max-width: 640px) {
  .scroll { padding-left: 14px; padding-right: 14px; }
  .char-grid { gap: 18px 10px; margin: 0; }
  .video-grid { gap: 16px 12px; }
  .opt-btn span:not(.oi) { display: none; }  /* 버튼은 아이콘만 */
  .opt-btn { padding: 0 7px; }
  .loop-toggle { font-size: 15px; }
  .item { flex-wrap: wrap; }
  .screen-off-thumb { width: 82%; }
}
/* 휴대폰 세로: 캐릭터 3개씩, 영상 2개씩 */
@media (max-width: 560px) {
  .char-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { padding-left: 84px; padding-right: 84px; }
  .main-menu { gap: 16px; }
  .player-box { gap: 6px; }
  .settings-head { padding-left: 16px; }
  .settings-body { padding: 12px 12px 30px; }
}
@media (max-width: 380px) {
  .video-grid { grid-template-columns: 1fr; }
}