/* ─────────────────────────────────────────
   Design System & Tokens (Premium Sidebar)
───────────────────────────────────────── */
:root {
  --primary: #2c3e50;
  --accent: #d4af37; /* Gold/Brass */
  --bg-app: #f4f7f6;
  --bg-panel: rgba(255, 255, 255, 0.85);
  --text-main: #333;
  --text-muted: #666;
  --border-color: #ddd;
  --paper-bg: #fdfcf7;
  --paper-border: #d4c4b7;
  --shadow: 0 10px 30px rgba(0,0,0,0.08);
  --glass-blur: 12px;
  --accent-color: #b14b3c; /* For original results */
}

*{box-sizing:border-box;margin:0;padding:0}

body {
  font-family: 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Premium Header ── */
.hdr {
  background: var(--bg-panel);
  backdrop-filter: blur(var(--glass-blur));
  padding: 1.5rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}
.hdr h1 {
  font-size: 1.6rem;
  color: var(--primary);
  letter-spacing: 2px;
  font-weight: 700;
  margin-bottom: 0.2rem;
}
.hdr p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.wrap {
  display: flex;
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
}

/* ── Premium Input Panel (Sidebar) ── */
.inp {
  width: 380px;
  min-width: 320px;
  background: var(--bg-panel);
  backdrop-filter: blur(var(--glass-blur));
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 85px);
  position: sticky;
  top: 85px;
  z-index: 50;
  box-shadow: 10px 0 30px rgba(0,0,0,0.02);
}
.inp-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.inp-footer {
  padding: 16px 24px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -5px 15px rgba(0,0,0,0.03);
}

.stit {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
  margin: 1.8rem 0 0.8rem;
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 4px solid var(--accent);
  padding-left: 10px;
  border-top: none; /* Removed original dotted border */
}
.stit:first-child { margin-top: 0; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  margin: 14px 0 6px;
}

.sub-info {
  font-size: 0.75rem;
  color: #e74c3c;
  margin-bottom: 8px;
  display: block;
  font-style: italic;
}

select, input[type=text], input[type=number], input[type=date] {
  width: 100%;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #ced4da;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}
select:focus, input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

.r2, .r3 { display: flex; gap: 10px; }
.r2 > div, .r3 > div { flex: 1; }

.date-quick { display: flex; gap: 8px; margin-top: 8px; }
.dqbtn {
  flex: 1;
  padding: 8px 5px;
  font-size: 0.8rem;
  background: #fff;
  border: 1px solid #ced4da;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
  text-align: center;
}
.dqbtn:hover { background: #f8f9fa; border-color: var(--accent); color: var(--accent); }
.dqbtn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.bp { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(44, 62, 80, 0.2); }
.bp:hover { background: #34495e; transform: translateY(-2px); }
.bp:active { transform: translateY(0); }

.bs { background: #f1f3f5; color: var(--text-main); font-size: 0.82rem; margin-top: 10px; border: 1px solid #dee2e6; }
.bs:hover { background: #e9ecef; }

/* ── Output Panel Area ── */
.out {
  flex: 1;
  padding: 40px;
  overflow-y: auto;
  height: calc(100vh - 85px);
  background: #ebedef;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tip {
  max-width: 800px;
  width: 100%;
  background: #fff;
  border-left: 5px solid var(--accent);
  padding: 20px 24px;
  border-radius: 12px;
  font-size: 0.9rem;
  color: #856404;
  line-height: 1.8;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  background-color: #fff3cd; /* Matching original tip color mood */
}

.toolrow {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  width: 100%;
  max-width: 794px;
  justify-content: center;
}

.graybtn {
  background: #fff;
  border: 1px solid #ced4da;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.graybtn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }


/* ── Restoration: Original Results View (STRICTLY MAINTAINED) ── */
#paperCapture {
  width: 794px;
  min-height: 1123px;
  margin: 0 auto;
  background: #fdfcf7;
  border: 1px solid #d4c4b7;
  border-radius: 4px;
  box-shadow: 0 8px 25px rgba(0,0,0,.08);
  padding: 15px 10px;
  position: relative;
  overflow: hidden;
}
#paperCapture::before {
  content: '';
  position: absolute;
  top: 9px;
  left: 9px;
  right: 9px;
  bottom: 9px;
  border: 1px solid #e6dace;
  pointer-events: none;
  z-index: 0;
}
.paper {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 1123px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}
.vbox {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 13.5px;
  direction: rtl;
  unicode-bidi: bidi-override;
  padding: 20px 100px 0 5px;
}
.vcol {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 430px;
  direction: ltr;
}
.c-wrap {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  margin-bottom: 3px;
  min-height: 27px;
}
.hj {
  font-family: 'cwTeXKai', 'Gungsuh', '궁서', serif;
  font-size: 3.2rem;
  color: #111;
  line-height: 1;
  width: 3.1rem;
  text-align: center;
  font-weight: 500;
}
.hg {
  font-family: 'Malgun Gothic', sans-serif;
  font-size: .7rem;
  color: #b14b3c;
  width: .8rem;
  text-align: left;
  margin-right: 2px;
  line-height: 1;
}
.sp {
  height: 27px;
  width: 100%;
}

/* ── Print Styles (Original Rules) ── */
@media print {
  @page { size: A4; margin: 0; }
  header, .hdr, .inp, .tip, .toolrow, .optrow, .phbox { display: none !important; }
  body { background: #fff; padding: 0; margin: 0; }
  .wrap { display: block; max-width: none; margin: 0; }
  .out { padding: 0; height: auto; overflow: visible; background: #fff; display: block; }
  
  #paperCapture {
    width: 210mm !important;
    height: 297mm !important;
    border: none;
    box-shadow: none;
    margin: 0 !important;
    padding: 10mm !important;
    background: white;
  }
  #paperCapture::before { top: 2.5mm; left: 2.5mm; right: 2.5mm; bottom: 2.5mm; border: .25mm solid #d9d0c7; }
  .vbox { gap: 3mm; padding: 0 1mm; }
  .vcol { min-height: 117.5mm; }
  .c-wrap { min-height: 6.75mm; margin-bottom: .4mm; }
  .hj { font-size: 13pt; width: 7mm; color: #000; }
  .hg { font-size: 3.25pt; width: 2mm; color: #000; margin-right: .4mm; }
  .sp { height: 6.75mm; }
}

/* ── Mobile Optimization (Localized to Sidebar/Layout) ── */
@media (max-width: 1024px) {
  .wrap { flex-direction: column; }
  .inp { 
    width: 100%; 
    height: auto; 
    position: static; 
    border-right: none; 
    border-bottom: 1px solid var(--border-color); 
  }
  .out { padding: 20px 10px; height: auto; }
  #paperCapture { 
    width: 100%; 
    max-width: 794px;
    height: auto; 
    aspect-ratio: 794/1123;
  }
}

/* ─────────────────────────────────────────
   도움말(?) 링크 / 모달 (기존 디자인 안 건드리는 선에서 최소 추가)
───────────────────────────────────────── */
.help-link{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:18px;
  height:18px;
  margin-left:6px;
  border-radius:50%;
  border:1px solid #888;
  color:#555;
  font-size:12px;
  line-height:1;
  font-weight:700;
  cursor:pointer;
  text-decoration:none;
  vertical-align:middle;
  background:#fff;
  user-select:none;
}
.help-link:hover{
  background:#f3f3f3;
  color:#222;
  border-color:#666;
}
.label-help{
  display:flex;
  align-items:center;
  gap:4px;
}
.stit-help{
  display:flex;
  align-items:center;
  gap:4px;
  flex-wrap:wrap;
}
.help-modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.55);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:9999;
  padding:18px;
}
.help-modal.show{
  display:flex;
}
.help-box{
  width:min(92vw,560px);
  max-height:85vh;
  overflow:auto;
  background:#fff;
  border-radius:16px;
  box-shadow:0 20px 60px rgba(0,0,0,.25);
  border:1px solid #ddd;
}
.help-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:16px 18px 12px;
  border-bottom:1px solid #eee;
}
.help-head h3{
  margin:0;
  font-size:1.05rem;
}
.help-close{
  border:none;
  background:#f2f2f2;
  width:34px;
  height:34px;
  border-radius:50%;
  font-size:18px;
  cursor:pointer;
}
.help-close:hover{
  background:#e7e7e7;
}
.help-body{
  padding:16px 18px 18px;
  font-size:.95rem;
  line-height:1.7;
  color:#222;
  white-space:pre-line;
}
.help-body .mini{
  display:block;
  margin-top:10px;
  color:#666;
  font-size:.88rem;
}

/* ─────────────────────────────────────────
   한글 발음 제외 체크 영역
───────────────────────────────────────── */
.optrow{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
  margin:10px 0 14px;
  font-size:.95rem;
}
.optrow label{
  display:flex;
  align-items:center;
  gap:7px;
  cursor:pointer;
  user-select:none;
}
.optrow input[type="checkbox"]{
  width:17px;
  height:17px;
  cursor:pointer;
}

@media (max-width: 768px){
  .help-box{
    width:95vw;
    max-height:88vh;
    border-radius:14px;
  }
}

/* ─────────────────────────────────────────
   성씨 검색 자동완성 드롭다운
───────────────────────────────────────── */
.surname-search-wrap {
  position: relative;
}
.surname-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ced4da;
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: 0 6px 16px rgba(0,0,0,.10);
}
.surname-dropdown.open {
  display: block;
}
.sd-item {
  padding: 8px 12px;
  font-size: .88rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #f0f0f0;
  transition: background .12s;
}
.sd-item:last-child { border-bottom: none; }
.sd-item:hover,
.sd-item.focused { background: #f8f4e8; }
.sd-hj {
  font-family: 'cwTeXKai','Gungsuh','궁서',serif;
  font-size: 1.1rem;
  color: #222;
  min-width: 1.4rem;
  text-align: center;
}
.sd-hg {
  color: #555;
  font-size: .82rem;
}
.sd-cnt {
  margin-left: auto;
  font-size: .75rem;
  color: #999;
}
.sd-empty {
  padding: 10px 12px;
  font-size: .85rem;
  color: #999;
  text-align: center;
}