:root{--bg:#f6f7fb;--card:var(--surface);--line:#e8ebf2;--line-strong:#d6dbe8;--text:var(--text-main);--primary:var(--point-dark);--primary-dark:#c81e2a;--primary-soft:#fff1f3;--shadow:0 10px 30px rgba(15,23,42,.06)}

a{color:var(--blue);text-decoration:none;}

button, input{font:inherit;}

.page-shell{
  max-width:1100px;
  margin:0 auto;
  padding:28px 16px 60px;
}

.preview-card, .syllable-block{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:24px;
  box-shadow:var(--shadow);
}

.hero-card h1{
  margin:0 0 10px;
  font-size:clamp(1.9rem,3vw,2.6rem);
  line-height:1.2;
}

.hero-card p{margin:0;color:var(--text-sub);}

.section-card p, .section-card li, .tool-panel p{color:var(--text-sub);}

#hanja_controls{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:16px;
}

#nameInput{
  flex:1 1 280px;
  min-width:0;
  height:52px;
  border:1px solid var(--line-strong);
  border-radius:14px;
  background:var(--surface);
  padding:0 16px;
  color:var(--text);
  outline:none;
}

#nameInput:focus{
  border-color:#f3a7b0;
  box-shadow:0 0 0 4px rgba(231,51,64,.08);
}

.surname-chip{
  border:0;
  cursor:pointer;
  transition:.18s ease;
}

.btn-main:hover{background:var(--primary-dark);}

.btn-main:disabled{
  opacity:.55;
  cursor:not-allowed;
}

.db-status{
  display:flex;
  align-items:center;
  gap:10px;
  margin-top:14px;
  padding:12px 14px;
  border-radius:14px;
  font-size:.95rem;
}

.db-status.loading{
  background:#f8fafc;
  border:1px solid #e5e7eb;
  color:#475569;
}

.db-status.ready{
  background:#f0fdf4;
  border:1px solid #bbf7d0;
  color:#166534;
}

.db-status.error{
  background:#fef2f2;
  border:1px solid #fecaca;
  color:#b91c1c;
}

.spinner, .ai-spinner{
  width:16px;
  height:16px;
  border-radius:50%;
  border:2px solid rgba(0,0,0,.12);
  border-top-color:currentColor;
  animation:spin .8s linear infinite;
  display:inline-block;
  vertical-align:-2px;
}

@keyframes spin{to{transform:rotate(360deg);}}

.surname-wrap{margin-top:16px;}

.surname-title{
  font-size:.96rem;
  font-weight:700;
  margin:0 0 10px;
}

.surname-chips{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.surname-chip{
  height:38px;
  padding:0 14px;
  border-radius:999px;
  background:var(--surface);
  border:1px solid var(--line-strong);
  color:var(--text);
}

.surname-chip:hover{
  background:var(--primary-soft);
  border-color:#f3b6bd;
  color:var(--primary-dark);
}

.result-wrap{margin-top:18px;}

.empty-msg{
  padding:24px;
  text-align:center;
  color:var(--text-sub);
  background:#fafbfc;
  border:1px dashed var(--line-strong);
  border-radius:18px;
}

.syllable-block{
  margin-top:14px;
  padding:18px;
}

.syllable-label{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  margin-bottom:14px;
}

.syl-ko{
  width:54px;
  height:54px;
  border-radius:16px;
  background:var(--primary-soft);
  color:var(--primary-dark);
  font-size:1.4rem;
  font-weight:800;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
}

.syl-info{
  flex:1;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
}

.syl-role{font-weight:800;}

.syl-count{
  color:var(--text-sub);
  font-size:.93rem;
}

.hanja-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(120px,1fr));
  gap:12px;
}

.hanja-card{
  position:relative;
  background:var(--surface);
  border:1px solid var(--line-strong);
  border-radius:18px;
  min-height:128px;
  padding:14px 12px 12px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  cursor:pointer;
  transition:.18s ease;
}

.hanja-card:hover{
  transform:translateY(-2px);
  border-color:#f0a9b1;
  box-shadow:0 10px 20px rgba(231,51,64,.08);
}

.hanja-card.selected{
  border-color:var(--primary);
  background:#fff7f8;
  box-shadow:0 0 0 3px rgba(231,51,64,.08);
}

.check-badge{
  position:absolute;
  top:10px;
  right:10px;
  width:22px;
  height:22px;
  border-radius:50%;
  background:var(--primary);
  color:var(--surface);
  font-size:.82rem;
  font-weight:700;
  display:none;
  align-items:center;
  justify-content:center;
}

.hanja-card.selected .check-badge{display:flex;}

.hanja-char{
  font-size:2rem;
  font-weight:800;
  line-height:1;
}

.hanja-reading{
  margin-top:8px;
  font-size:.94rem;
  font-weight:700;
}

.hanja-meaning{
  margin-top:4px;
  font-size:.83rem;
  color:var(--text-sub);
  display:-webkit-box;
  -webkit-line-clamp:3;
  -webkit-box-orient:vertical;
  overflow:hidden;
  line-height:1.4;
  text-align:center;
  word-break:keep-all;
}

.preview-card{
  margin-top:18px;
  padding:22px;
  background:linear-gradient(180deg,var(--surface) 0%,#fffafb 100%);
  border-color:#ffe0e5;
}

.preview-name{
  font-size:clamp(2.1rem,4vw,3rem);
  font-weight:800;
  line-height:1.15;
  text-align:center;
  letter-spacing:.03em;
}
/* 경기바탕 한자 서브셋에 없는 글자가 섞이면 이름 전체를 한 서체로(글자별 섞임 방지 — JS가 토글) */
.preview-name.hj-uniform-fb{font-family:'Noto Serif KR','Nanum Myeongjo',AppleMyungjo,Batang,serif;}

.preview-reading{
  text-align:center;
  color:var(--text-sub);
  margin-top:8px;
}

.preview-actions{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  margin-top:18px;
}

.preview-actions-left, .preview-actions-right{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

/* 뜻풀이 섹션 - "이름 : 한자(뜻) 한자(뜻)" 한 줄 형태 */
.meaning-section{
  margin-top:18px;
  padding-top:18px;
  border-top:1px solid #f1d8dc;
}

.meaning-section-title{
  font-weight:800;
  margin-bottom:12px;
  font-size:1rem;
}

.meaning-inline{
  display:flex;
  align-items:baseline;
  flex-wrap:wrap;
  gap:6px;
  font-size:1rem;
  line-height:1.8;
}

.meaning-name-label{
  font-weight:800;
  color:var(--text);
  margin-right:4px;
}

.meaning-colon{
  color:var(--text-sub);
  margin-right:8px;
}

.meaning-item{
  display:inline-flex;
  align-items:baseline;
  gap:3px;
  background:#faf5f6;
  border:1px solid #f2d8dc;
  border-radius:8px;
  padding:3px 10px;
}

.meaning-item-hanja{
  font-size:1.15rem;
  font-weight:800;
  color:var(--primary-dark);
}

.meaning-item-text{
  font-size:.87rem;
  color:var(--text-sub);
}

.ai-box{
  margin-top:18px;
  border:1px solid #f5c8cf;
  background:#fff5f7;
  border-radius:18px;
  padding:16px;
}

.ai-box-title{
  font-weight:800;
  margin-bottom:8px;
}

.ai-box-body{
  color:#5b2130;
  white-space:pre-line;
  line-height:1.75;
}

/* FAQ */

.faq-list p{margin:.6em 0 0;color:var(--text-sub);}

@media (max-width:640px){
  .preview-card, .syllable-block{
    padding:18px;
    border-radius:20px;
  }
  .preview-actions{
    flex-direction:column;
    align-items:stretch;
  }
  .preview-actions-left, .preview-actions-right{
    width:100%;
    flex-direction:column;
    align-items:stretch;
  }
  .preview-actions .btn-main, .preview-actions .btn-sub{
    width:100%;
  }
  .syllable-label{
    align-items:flex-start;
  }
  .syl-info{
    flex-direction:column;
    align-items:flex-start;
  }
  .meaning-inline{
    flex-direction:column;
    align-items:flex-start;
  }
}

/* AI 해석 후 노출되는 프로모 레이어 */

@keyframes hanjaPromoIn{from{transform:scale(0.88);opacity:0;}to{transform:scale(1);opacity:1;}}

/* 부모 테마가 .btn-main/.btn-sub 를 덮어쓰므로 색을 !important 로 고정 */

/* ══ 2026-10-01 사이트 전체 개선 — 한자 이름 변환기 (SD-10 · SD-12 · SD-15) ══ */

/* ── 「지금 이름」 막대(SD-10) ──
   🔴 고른 이름과 「이미지로 저장」이 후보 목록 맨 끝(모바일 10,991px)에만 있었다 → 결과 맨 위에 붙박이(sticky)로 둔다.
      후보 목록을 내려가는 동안 화면 위에 붙어 있다가, 결과 영역을 벗어나면 함께 사라진다(결과 상자 안에서만 붙는다). */
.hanja-now{position:sticky;top:0;z-index:5;display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;
  margin-top:14px;padding:10px 14px;background:var(--surface);border:1px solid #ffe0e5;border-radius:16px;
  box-shadow:0 8px 18px rgba(15,23,42,.08)}
.hanja-now-name{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap;min-width:0;font-size:.9rem;color:var(--text-sub)}
.hanja-now-lbl{font-size:.78rem;font-weight:700;color:var(--text-sub)}
.hanja-now-hj{font-size:1.45rem;font-weight:800;color:var(--text);letter-spacing:.03em}
.hanja-now-read{font-size:.88rem;color:var(--text-sub)}
.hanja-now-acts{display:flex;gap:8px}
.hanja-now-acts .btn-main,.hanja-now-acts .btn-sub{min-height:44px;min-width:0;padding:0 12px;font-size:.92rem;white-space:nowrap}
/* 「뜻풀이·AI 해석 ↓」로 내려가면 붙박이 막대가 카드 머리를 가리지 않게 숨 쉴 자리를 둔다. */
.preview-card{scroll-margin-top:140px}
.syllable-block{scroll-margin-top:12px}
.hanja-card:focus-visible{outline:3px solid rgba(var(--blue-rgb),.5);outline-offset:2px}

/* ── 후보 칸(SD-10) — 모바일에서 한 줄 세 칸(아주 좁으면 두 칸) ──
   🔴 120px 최소 폭 때문에 모바일은 두 칸뿐이라 「성」 하나에도 화면 여러 장을 내려야 했다. 글자·독음은 그대로 두고
      뜻풀이를 두 줄로 줄여 세 칸에 들어가게 한다. */
@media (max-width:640px){
  .hanja-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
  .hanja-card{min-height:104px;padding:12px 6px 10px;border-radius:14px}
  .hanja-char{font-size:1.7rem}
  .hanja-reading{margin-top:6px;font-size:.88rem}
  .hanja-meaning{-webkit-line-clamp:2;font-size:.78rem}
  .check-badge{top:6px;right:6px;width:18px;height:18px;font-size:.72rem}
  .hanja-now{padding:10px 12px}
  .hanja-now-acts{width:100%;display:grid;grid-template-columns:1fr 1fr}
}
@media (max-width:340px){.hanja-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}

/* ── 성씨 칩(SD-7 · SD-15) — 한 줄로 옆으로 민다(.ck-chip-row, 모바일). 누를 거리 40px. ── */
.surname-chip{height:40px}
