/* ── 디자인 토큰 (design/mockup.html 시안에서 이식) ── */
:root {
  --ink: #241C1A; --sub: #6B5D57; --muted: #A0938D;
  --cream: #FFF7F0; --paper: #fff; --line: #F0E4DA;
  --coral: #FF6B5B; --coral-d: #E85445; --peach: #FFE3D5;
  --lilac: #B9A9FF; --lilac-s: #EFEAFF; --lilac-d: #5A46C4;
  --mint: #7FD8B0; --mint-s: #E3F7EE; --mint-d: #1D8A5F;
  --r-card: 26px; --r-btn: 18px;
  --sh: 0 8px 24px rgba(120,80,64,.10);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* display:flex 등이 hidden 속성을 덮어쓰지 않게 */
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--cream);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.app { max-width: 480px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── 헤더 (마스코트 + 인사) ── */
.topbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px 6px; }
.mascot { width: 44px; height: 44px; flex: 0 0 auto; }
.mascot.sm { width: 34px; height: 34px; }
.topbar h1 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.topbar h1 small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 3px; letter-spacing: 0; }


/* ── 검색창 ── */
.io { padding: 8px 16px 0; }
.search {
  background: var(--paper); border-radius: 18px; padding: 12px 14px;
  box-shadow: var(--sh); display: flex; align-items: center; gap: 8px;
}
#input {
  flex: 1; min-width: 0; border: none; outline: none; background: none;
  /* ⚠️ 16px 미만이면 iOS 사파리가 포커스 순간 화면을 **확대**하고 다시 안 줄여준다.
     JS 로 되돌릴 방법이 없으므로 애초에 확대가 안 일어나게 16px 를 지킨다(15px 였다). */
  font-family: inherit; font-size: 16px; font-weight: 600; color: var(--ink);
}
#input::placeholder { color: var(--muted); font-weight: 500; }
#input::-webkit-search-cancel-button { -webkit-appearance: none; }

.btn-primary {
  padding: 13px; font-size: 14px; font-weight: 800; font-family: inherit; color: #fff;
  background: var(--coral); border: none; border-radius: var(--r-btn); cursor: pointer;
  box-shadow: 0 6px 14px rgba(255,107,91,.35); letter-spacing: -.01em; width: 100%;
}
.btn-primary:active { background: var(--coral-d); }
.btn-primary.sm { padding: 9px; font-size: 12px; }
.btn-primary:disabled { background: var(--coral); opacity: .55; box-shadow: none; cursor: default; }

/* ── 결과 ── */
.result { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px 4px; display: flex; flex-direction: column; gap: 10px; }
.hint { color: var(--muted); text-align: center; padding: 28px 16px; font-size: 13.5px; line-height: 1.7; }

/* 시안의 .res 2열 그리드. 한 토큰(= 한 단어/합성)이 .token-group 하나. */
.token-group { display: flex; flex-direction: column; gap: 9px; }
.token-group .cards { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.token-group .cards.one { grid-template-columns: 1fr; }

.card {
  background: var(--peach); border-radius: 18px; padding: 10px;
  box-shadow: 0 3px 10px rgba(120,80,64,.06); text-align: center;
}
.card .word { font-size: 12.5px; font-weight: 800; margin: 4px 0 1px; letter-spacing: -.01em; }
/* 사전 손그림은 흰 배경 위 실사진. multiply로 흰 배경을 죽여 카드 색이 비치게 한다. */
.card .frame {
  width: 100%; height: 74px; object-fit: contain; display: block;
  mix-blend-mode: multiply; filter: contrast(1.06);
}
/* 손모양 설명. 이제 <details> 라 기본은 접혀 있다 — 줄여 쓰면 다른 손짓이 되므로(⛔ 2번)
   글을 자르는 대신 감춘다. <p class="desc"> 인 '미지원' 카드도 같은 색·크기를 쓴다. */
.card .desc { color: #8A6A5C; font-size: 9px; line-height: 1.5; margin: 1px 0 0; text-align: center; }
.card details.desc > summary {
  cursor: pointer; list-style: none; font-weight: 700; color: var(--muted);
  padding: 3px 0; user-select: none;
}
.card details.desc > summary::-webkit-details-marker { display: none; }
.card details.desc > summary::after { content: " ⌄"; }
.card details.desc[open] > summary::after { content: " ⌃"; }
.card details.desc > p { margin: 2px 0 0; }
/* 국어사전 뜻. 단어 바로 아래 — 사용자가 확인하려는 건 "내가 친 말이 그 말이 맞나"라서
   손모양 설명보다 먼저 읽혀야 한다. 손모양 설명(.desc)보다 진하게 둬서 순서를 눈에 세운다. */
.card .mean { color: var(--sub); font-size: 9.5px; line-height: 1.45; margin: 2px 0 0; }
.cards.one .card .frame { height: 150px; }
.cards.one .card .word { font-size: 16px; }
.cards.one .card .mean { font-size: 12px; margin-top: 4px; }
.cards.one .card .desc { font-size: 11px; margin-top: 4px; }
.card.unsupported { background: var(--lilac-s); }
.card.unsupported .word { color: var(--lilac-d); }
.card.unsupported .desc { color: #5C5270; }
.card.text-sign { background: var(--cream); border: 1px dashed var(--line); }
.card.text-sign .desc { color: var(--sub); }
/* 수형이 못박히지 않은 부품 — 앱이 후보 중 첫 번째를 임의로 집은 카드다(⛔ 단정 금지). */
.card.unsure { background: var(--cream); border: 1px dashed var(--coral-d); }
.card.unsure .word::after {
  content: " (확인 안 됨)"; color: var(--coral-d); font-weight: 600; font-size: .82em;
}

.alts summary {
  cursor: pointer; color: var(--lilac-d); font-size: 11.5px; font-weight: 700;
  text-align: center; padding: 9px; background: var(--lilac-s); border-radius: 14px; list-style: none;
}
.alts summary::-webkit-details-marker { display: none; }
.alts[open] summary { margin-bottom: 9px; }
.alts .card { background: var(--cream); border: 1px solid var(--line); }
.alts .card .desc { color: var(--sub); }

/* 시안의 민트 안내 박스 */
.note {
  background: var(--mint-s); border-radius: 16px; padding: 11px 13px;
  font-size: 10.5px; line-height: 1.65; color: #356B57;
}
.note b { color: var(--mint-d); display: block; margin-bottom: 3px; font-size: 11.5px; }
.note b.inline { display: inline; margin: 0; font-size: inherit; }
.combo-src { margin: 2px 0 0; font-size: 10px; color: var(--muted); text-align: center; }
.combo-src a { color: var(--coral-d); }

.note.bad { background: var(--peach); color: #7A4A3D; }
.note.bad b { color: var(--coral-d); }

/* 시안의 라일락 점선 박스 */
.locked {
  border: 2px dashed var(--lilac); background: var(--lilac-s); border-radius: 20px;
  padding: 11px; text-align: center; margin: 4px 16px 8px;
}
.result .locked { margin: 4px 0 8px; }
.locked .t { font-size: 12px; font-weight: 900; color: var(--lilac-d); margin-bottom: 8px; }
.locked .s { font-size: 10px; color: #7A6BB8; margin: -4px 0 0; line-height: 1.55; }

/* ── 우리 단어장 ── */
.item {
  display: flex; align-items: center; gap: 11px; background: var(--paper);
  border-radius: 16px; padding: 6px 12px; box-shadow: 0 3px 10px rgba(120,80,64,.06);
}
.thumb {
  width: 40px; height: 40px; border-radius: 12px; background: var(--peach);
  flex: 0 0 auto; display: grid; place-items: center; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; mix-blend-mode: multiply; }
.item .t { font-size: 13px; font-weight: 800; letter-spacing: -.01em; }
.item .s { font-size: 9.5px; color: var(--muted); margin-top: 1px; }
.chk {
  margin-left: auto; background: none; border: none; color: var(--muted);
  font-size: 15px; cursor: pointer; padding: 6px 4px; font-family: inherit;
}
/* 합성 항목: 제목 줄(.item) 아래에 부품을 펼친다. 부품은 따로 담기지 않으므로 여기서만 보인다. */
.book-entry { display: flex; flex-direction: column; gap: 5px; }
.book-parts { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 12px; }
.book-part {
  display: flex; align-items: center; gap: 6px; background: var(--paper);
  border-radius: 12px; padding: 4px 9px 4px 4px; box-shadow: 0 2px 7px rgba(120,80,64,.05);
  font-size: 11px; font-weight: 700; color: var(--muted);
}
.book-part.unsure { color: var(--coral-d); }
.thumb.sm { width: 26px; height: 26px; border-radius: 8px; }

/* 연습에서 합성은 손짓을 나란히 보여준다. 하나뿐이면 종전처럼 한 장을 꽉 채운다. */
.quiz-frames { display: flex; gap: 8px; }
.quiz-frames > div { flex: 1; min-width: 0; position: relative; }
.quiz-frames > div > span {
  position: absolute; left: 6px; top: 4px; font-size: 12px; font-weight: 800; color: var(--muted);
}

/* ── 연습 ── */
.dots { display: flex; gap: 4px; justify-content: center; padding: 2px 0 4px; }
.dots i { width: 18px; height: 4px; border-radius: 99px; background: var(--line); }
.dots i.on { background: var(--coral); }
.card.quiz { padding: 14px; }
.quiz-lab { font-size: 11px; font-weight: 800; color: var(--coral-d); margin: 0 0 4px; }
.card.quiz .frame { height: 190px; }
.opt {
  background: var(--paper); border: 2px solid var(--line); border-radius: 16px;
  padding: 12px; font-size: 14px; font-weight: 700; font-family: inherit;
  text-align: center; cursor: pointer; color: var(--ink); width: 100%;
}
.opt.right { border-color: var(--mint); background: var(--mint-s); color: var(--mint-d); }
.opt.wrong { border-color: var(--coral); background: var(--peach); color: var(--coral-d); }

/* ── 첫 실행 안내문 ── */
.intro-backdrop {
  position: fixed; inset: 0; background: rgba(36,28,26,.45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.intro {
  background: var(--paper); width: 100%; max-width: 480px; max-height: 92vh;
  border-radius: 28px 28px 0 0; display: flex; flex-direction: column;
}
.intro-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 0; }
.intro-x {
  font-size: 20px; color: var(--muted); background: none; border: none;
  cursor: pointer; line-height: 1; padding: 4px 8px; font-family: inherit;
}
.intro-h { padding: 4px 18px 12px; }
.intro-h b { font-size: 19px; font-weight: 900; letter-spacing: -.03em; line-height: 1.35; display: block; }
.intro-h span { font-size: 11.5px; color: var(--muted); display: block; margin-top: 6px; line-height: 1.6; }
.intro-body { flex: 1; overflow-y: auto; padding: 0 18px; display: flex; flex-direction: column; gap: 8px; }
.rule { border-radius: 16px; padding: 12px 13px; }
.rule .t { font-size: 12.5px; font-weight: 900; letter-spacing: -.02em; }
.rule .d { font-size: 11px; line-height: 1.6; margin-top: 4px; }
.rule .eg { display: block; margin-top: 5px; font-weight: 800; color: var(--ink); font-size: 11px; }
.rule.a { background: var(--peach); } .rule.a .t { color: var(--coral-d); } .rule.a .d { color: #7A4A3D; }
.rule.b { background: var(--lilac-s); } .rule.b .t { color: var(--lilac-d); } .rule.b .d { color: #5C5270; }
.rule.c { background: var(--mint-s); } .rule.c .t { color: var(--mint-d); } .rule.c .d { color: #356B57; }
.rule.n { background: #F5EFE9; border: 1px solid var(--line); } .rule.n .t { color: var(--ink); } .rule.n .d { color: var(--sub); }
.intro-foot {
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px;
}
.btn-ghost {
  background: none; border: none; color: var(--muted); font-weight: 700;
  font-size: 12px; font-family: inherit; padding: 8px; cursor: pointer;
}
.btn-ghost.danger { color: var(--coral-d); }
/* 단어장 비우기. 공유 버튼 바로 아래 한 줄로 선다. */
#empty-btn { display: block; width: 100%; margin-top: 2px; }

/* 게이트는 **화면 전체**를 쓴다. 뒤가 반쯤 비치면 읽히려다 마는 글자가 방해만 된다.
   안내문 위에 뜨는 이유는 순서가 로그인 → 안내문 → 앱 이어야 해서다. */
.gate-backdrop { z-index: 60; background: var(--cream); align-items: stretch; }
.gate {
  padding: 22px 18px calc(8px + env(safe-area-inset-bottom, 0px));
  text-align: center; border-radius: 0; max-height: none; background: none;
  justify-content: center; gap: 6px;
}
.gate .mascot { width: 56px; height: 56px; margin: 0 auto; }
.gate .intro-h b { font-size: 22px; line-height: 1.45; }
.gate .intro-h span { font-size: 12.5px; margin-top: 10px; }
.gate .intro-foot { border-top: none; gap: 8px; padding: 18px 0 0; }

/* 헤더 아이콘 버튼(뒤로 ‹ / 설정 ⚙). 화면에 따라 JS 가 켜고 끈다. */
.icon-btn {
  flex: 0 0 auto; width: 40px; height: 40px; border: none; background: none;
  font-size: 22px; line-height: 1; color: var(--sub); cursor: pointer; font-family: inherit;
  border-radius: 999px;
}
.icon-btn.right { margin-left: auto; }
.icon-btn:active { background: var(--peach); }

/* 마이페이지 · 설정 */
#mypage, #settings { gap: 8px; }
#mypage .hint, #settings .hint { padding: 16px 8px 6px; }

/* 현재 플랜 — 마이 화면 맨 위. 제일 먼저 궁금한 게 "내가 뭘 쓸 수 있나"라서 위에 둔다. */
.plan {
  background: var(--ink); color: #fff; border-radius: var(--r-card); padding: 16px 18px;
}
.plan.pro { background: var(--lilac-d); }
.plan .k { font-size: 11px; font-weight: 800; opacity: .6; letter-spacing: .02em; }
.plan .n { font-size: 21px; font-weight: 900; letter-spacing: -.02em; margin-top: 3px; }
.plan .d { font-size: 11.5px; opacity: .7; margin-top: 5px; line-height: 1.5; }

/* 목록 — 설정 화면이 전부 이걸로 되어 있다. 카드 하나 안에 줄이 쌓인다. */
.list { background: var(--paper); border-radius: 18px; box-shadow: var(--sh); overflow: hidden; }
.list-row {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 15px 16px; border: none; background: none; font-family: inherit; cursor: pointer;
  border-top: 1px solid var(--line);
}
.list-row:first-child { border-top: none; }
.list-row:active { background: var(--cream); }
.list-row .l { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.list-row .v { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.list-row.danger .l { color: var(--coral-d); }
div.list-row { cursor: default; }   /* 누를 수 없는 줄(표시 전용) */

/* ── 친구 ────────────────────────────────────────────────────────────── */
/* 단어장 화면의 갈래(내 것 / 친구). 화면을 새로 만들지 않고 한 화면 안에서 가른다 —
   둘 다 "단어장"이라 하단 탭이 어디를 가리켜야 하는지가 애매해지기 때문. */
/* 바탕(--cream)과 같은 색을 쓰면 띠가 안 보인다 — 한 톤 진한 --line 으로 둔다. */
.segbar { display: flex; gap: 6px; background: var(--line); padding: 4px; border-radius: 14px; margin: 10px 16px 0; }
.seg {
  flex: 1; padding: 9px 8px; border: none; border-radius: 11px; background: none;
  font-family: inherit; font-size: 12.5px; font-weight: 700; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.seg.on { background: var(--paper); color: var(--ink); box-shadow: var(--sh); }
/* 받은 요청 표시. 푸시가 없는 동안 이게 유일한 알림이라 숫자 대신 눈에 띄는 점 하나로 둔다. */
.badge { width: 7px; height: 7px; border-radius: 999px; background: var(--coral-d); display: block; }

.list-head { font-size: 11.5px; font-weight: 800; color: var(--muted); padding: 12px 6px 6px; }
.list-row.friend .l small { font-weight: 600; color: var(--muted); font-size: 11.5px; }
.row-act { display: flex; gap: 6px; flex-shrink: 0; }
.chip {
  border: none; border-radius: 999px; padding: 7px 11px; font-family: inherit;
  font-size: 11.5px; font-weight: 700; cursor: pointer;
}
.chip.ok { background: var(--coral); color: #fff; }
.chip.no { background: var(--cream); color: var(--muted); }

/* 친구 단어장 팝업. <dialog> 라 포커스 가두기·Esc 닫기를 브라우저가 해준다.
   ⚠️ 배경색을 반드시 적는다 — 없는 토큰(var(--bg))을 적었더니 투명해져서 뒤 화면이 그대로 비쳤다. */
.sheet {
  border: none; border-radius: 22px; padding: 16px; width: min(92vw, 420px);
  background: var(--cream); color: var(--ink); box-shadow: 0 18px 50px rgba(60,30,20,.22);
}
.sheet::backdrop { background: rgba(40,20,14,.42); }
.sheet-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sheet-top b { font-size: 15px; font-weight: 800; flex: 1; }
/* .result 를 재활용하지 않는다 — 거기엔 flex:1 이 있어서 팝업 안에서 세로로 늘어난다. */
.sheet-body { display: flex; flex-direction: column; gap: 10px; max-height: 62vh; overflow-y: auto; }

/* 설정 맨 위 프로필. 별명은 여기서 바로 고친다. */
.profile { display: flex; align-items: center; gap: 12px; padding: 6px 2px 10px; }
.profile .mascot { width: 54px; height: 54px; background: var(--peach); border-radius: 999px; }
.profile-col { flex: 1; min-width: 0; }
.profile-sub { font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 5px 4px 0; }
.profile .name-field { padding: 9px 12px; }

/* 로그아웃은 목록 밖, 맨 아래. 되돌릴 수 있는 일이라 눈에 덜 띄게 둔다. */
.btn-ghost.logout { margin-top: 6px; padding: 14px; font-size: 13px; }

/* ⚠️ 16px 미만이면 iOS 가 포커스 순간 화면을 확대하고 안 돌려놓는다(함정 31). #input 과 같은 규칙. */
.name-field input {
  flex: 1; min-width: 0; border: none; outline: none; background: none;
  font-family: inherit; font-size: 16px; font-weight: 700; color: var(--ink);
}
.name-field input::placeholder { color: var(--muted); font-weight: 500; }


/* ── 로그인 ──
   카카오·네이버는 각 회사의 로그인 버튼 지침이 정한 색이다. 앱 토큰으로 바꾸면 안 된다. */
.login-kakao { background: #FEE500; color: #191600; box-shadow: none; }
.login-kakao:active { background: #F0D800; }
.login-naver { background: #03C75A; box-shadow: none; }
.login-naver:active { background: #02A94C; }
.login-google { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.login-google:active { background: var(--cream); }

/* ── 하단 탭 ── */
.tabs {
  display: flex; justify-content: space-around; background: var(--paper);
  border-top: 1px solid var(--line); position: sticky; bottom: 0;
  padding: 9px 4px calc(12px + env(safe-area-inset-bottom, 0px));
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 9.5px; font-weight: 700; color: var(--muted);
  background: none; border: none; font-family: inherit; cursor: pointer; padding: 2px 10px;
}
.tab i { font-style: normal; font-size: 18px; filter: grayscale(1); opacity: .45; }
.tab.on { color: var(--coral); } .tab.on i { filter: none; opacity: 1; }


.credit { text-align: center; color: var(--muted); font-size: 10.5px; line-height: 1.7; padding: 4px 16px 12px; }
.credit a { color: var(--sub); }

/* 벽에 닿았을 때는 담기 박스가 업그레이드 안내로 바뀐다 */
.locked.upsell { border-style: solid; border-color: var(--coral); background: var(--peach); }
.locked.upsell .t { color: var(--coral-d); }

/* 수형이 안 정해진 단어. 사전 화면의 .card.unsure 와 같은 뜻을 단어장에서도 보이게. */
.item .s.unsure { color: var(--coral-d); }
