/* 포스텔러 만세력 스타일 — FortellerTheme 포팅 */
:root {
  --bg: #FCFBF9;
  --text: #2E2A26;
  --text-gray: #524C46;
  --text-muted: #756E67;
  --border: #968F88;
  --border-soft: #EDE9E4;
  --panel-border: #E8E4DF;
  --solar: #E60012;
  --lunar: #0066FF;
  --wood: #009944;
  --fire: #E60012;
  --earth: #F39800;
  --metal: #7A7A7A;
  --water: #111111;
  --marker-green: #00A651;
  --marker-red: #E60012;
  --marker-yellow: #FFC400;
  --marker-white: #FFFFFF;
  --marker-grey: #9E9E9E;
  --marker-black: #000000;
  --line: #D9D0C3;
  --appbar-h: 52px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  letter-spacing: -0.02em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.hidden { display: none !important; }

/* ── 앱바 (일반과 동일: 높이·패딩·하단 라인·타이틀 크기) ── */
.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--appbar-h);
  padding: 0 max(10px, env(safe-area-inset-right, 0px)) 0 max(10px, env(safe-area-inset-left, 0px));
  background: rgba(252, 251, 249, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.appbar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  /* 양옆 버튼 폭과 무관하게 항상 정중앙 */
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  z-index: 0;
  pointer-events: none;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  font-size: 20px;
  color: var(--text);
  cursor: pointer;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:hover { background: #f1ede8; }

.menu-btn {
  flex-shrink: 0;
  color: #2E2A26;
  width: 52px;
  height: 52px;
}
.menu-btn .menu-icon {
  display: block;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.appbar-spacer {
  width: 44px;
  flex-shrink: 0;
}

.appbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 44px;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.2;
  border: 1px solid transparent;
}
.plan-badge.plan-free {
  background: #F1EEEA;
  color: #6B655E;
  border-color: #DDD7CF;
}
.plan-badge.plan-plus {
  background: #E8F0FF;
  color: #1F4B99;
  border-color: #B9CEF2;
}
.plan-badge.plan-admin {
  background: #F4E8FF;
  color: #6B2FA0;
  border-color: #D7B8F0;
}

.upgrade-btn {
  border: 1px solid #1F4B99;
  background: #1F4B99;
  color: #fff;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.upgrade-btn:hover { background: #173A78; }
.export-btn {
  border: 1px solid var(--panel-border);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 8px;
  cursor: pointer;
}
.export-btn:hover { background: #F4F1ED; }
.export-btn:disabled { opacity: 0.55; cursor: wait; }

.drawer-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.drawer-upgrade {
  width: 100%;
  margin-bottom: 8px;
}

/* ── 드로어 ── */
#drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 30;
}

#drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 300px;
  max-height: 100vh;
  max-height: 100dvh;
  background: #2E2A26;
  color: #f5f3f0;
  z-index: 31;
  display: flex;
  flex-direction: column;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  overflow: hidden;
  box-sizing: border-box;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.drawer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.drawer-title,
.drawer-title:link,
.drawer-title:visited,
.drawer-title:hover,
.drawer-title:active,
.drawer-title:focus {
  font-size: 18px;
  font-weight: 800;
  color: #f5f3f0;
  text-decoration: none;
}

.drawer-badge {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(226, 197, 106, 0.18);
  color: #E2C56A;
  border: 1px solid rgba(226, 197, 106, 0.35);
}

#drawer .icon-btn { color: #f5f3f0; font-size: 24px; }
#drawer .icon-btn:hover { background: rgba(255,255,255,0.08); }

.drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 12px 14px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #E8E4DF;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-label {
  flex: 1;
  min-width: 0;
}

.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
  opacity: 1;
}

.drawer-footer {
  font-size: 13px;
  color: #B6B0A9;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.12);
  flex-shrink: 0;
}
.drawer-footer .btn-link {
  background: none; border: none; color: #E8E4DF; cursor: pointer;
  font-size: 13px; padding: 0; text-decoration: underline;
}
.drawer-user-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px 14px;
  margin-top: 10px;
}

/* ── 레이아웃 ── */
#main { padding: 20px 28px 32px; }

.center-panel { display: flex; justify-content: center; }

.input-home-panel {
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.panel {
  background: #fff;
  border: 1px solid var(--panel-border);
  border-radius: 0;
  padding: 18px;
  box-shadow: 0 4px 12px rgba(82, 76, 70, 0.04);
  margin-bottom: 16px;
}

.input-panel { width: 100%; max-width: 540px; padding: 24px; overflow: hidden; margin-bottom: 0; }
#saju-form { min-width: 0; }

/* 홈: 저장명식 미리보기 */
.home-saved-wrap {
  width: 100%;
  max-width: 540px;
}
.home-box {
  background: #fff;
  border: 1px solid var(--panel-border);
  padding: 16px 16px 10px;
  box-shadow: 0 4px 12px rgba(82, 76, 70, 0.04);
}
.home-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.home-box-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.home-more {
  border: 0;
  background: transparent;
  color: var(--text-gray);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 2px;
  white-space: nowrap;
}
.home-more:hover { text-decoration: underline; }
.home-saved-list .saved-item {
  padding: 12px 2px;
}
.home-saved-list .saved-item:hover {
  margin: 0 -8px;
  padding-left: 10px;
  padding-right: 10px;
}
.home-saved-list .hint {
  text-align: left;
  padding: 8px 2px 12px;
  font-size: 13px;
}

/* ── 만세력 결과: 왼쪽 고정 + 오른쪽 스크롤 (720px+) ── */
.result-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
}

.result-left,
.result-right {
  min-width: 0;
  width: 100%;
}

.result-right .panel:last-child {
  margin-bottom: 0;
}

@media (min-width: 720px) {
  body.result-mode {
    overflow: hidden;
  }

  body.result-mode #main {
    padding: 20px 28px 16px;
    height: calc(100vh - var(--appbar-h));
    overflow: hidden;
    box-sizing: border-box;
  }

  body.result-mode #panel-result,
  body.result-mode #panel-compat,
  body.result-mode #panel-compat #compat-view {
    height: 100%;
    overflow: hidden;
  }

  .result-grid {
    flex-direction: row;
    align-items: stretch;
    height: 100%;
    overflow: hidden;
  }

  .result-left {
    flex: 4 1 0;
    min-height: 0;
    overflow: visible;
  }

  .result-left.compat-left {
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
  }

  .result-right {
    flex: 6 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
  }

  .result-right::-webkit-scrollbar,
  .result-left.compat-left::-webkit-scrollbar {
    width: 8px;
  }

  .result-right::-webkit-scrollbar-thumb,
  .result-left.compat-left::-webkit-scrollbar-thumb {
    background: #D8D3CD;
    border-radius: 0;
  }
}

@media (max-width: 719px) {
  #main { padding: 8px 16px 32px; }

  .result-grid {
    flex-direction: column;
  }
}

.section-title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.panel-title-row .section-title { margin: 0; }

/* ── 입력 폼 ── */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; flex: 1 1 0; min-width: 0; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-gray); }

.field input, .field textarea, .field select {
  width: 100%;
  max-width: 100%;
  padding: 14px;
  font-size: 16px;
  border: 1px solid #D8D3CD;
  border-radius: 0;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

.field select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23988E82' stroke-width='1.6' d='M1 1.5 6 6l5-4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--text); border-color: transparent; }

.field input:disabled, .field select:disabled { background: #F4F1ED; color: var(--text-muted); }

.field-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 0;
  min-width: 0;
}

.date-row {
  display: grid;
  grid-template-columns: 3fr 2fr 2fr;
  gap: 8px;
  margin-bottom: 14px;
}

.date-row .field { margin-bottom: 0; }

.time-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: end;
  gap: 8px;
  margin-bottom: 14px;
}

.time-row .time-field { margin-bottom: 0; }

.time-row .colon {
  padding-bottom: 14px;
  align-self: end;
  font-weight: 600;
  line-height: 1;
}

.time-row .time-check {
  margin-bottom: 0;
  padding-bottom: 14px;
  white-space: nowrap;
  align-self: end;
}

@media (max-width: 420px) {
  .time-row {
    grid-template-columns: 1fr auto 1fr;
  }
  .time-row .time-check {
    grid-column: 1 / -1;
    padding-bottom: 0;
    margin-top: 2px;
  }
}

.segmented {
  display: flex;
  border: 1px solid #D8D3CD;
  border-radius: 0;
  overflow: hidden;
  margin-bottom: 14px;
}

.segmented button {
  flex: 1;
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  background: #fff;
  color: var(--text-gray);
  cursor: pointer;
  font-family: inherit;
}

.segmented button.on { background: var(--text); color: #fff; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 14px;
  cursor: pointer;
}

.check input { width: 17px; height: 17px; accent-color: var(--text); }

.form-error { color: #C0494A; font-size: 13px; margin: 4px 0; }

.submit-btn {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: var(--text);
  border: none;
  border-radius: 0;
  cursor: pointer;
  font-family: inherit;
}

.submit-btn:hover { background: #45403A; }

/* ── 빈 상태 ── */
.empty-state { text-align: center; padding: 80px 0; }
.logo-mark { font-size: 64px; color: var(--text-gray); }
.tagline { font-size: 14px; font-weight: 600; color: var(--text-gray); margin: 16px 0 6px; }
.hint { font-size: 13px; color: var(--text-muted); margin: 0; }

/* ── 인물 카드 ── */
#person-card { position: relative; }
#pillar-board { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--panel-border); }
.person-head { display: flex; justify-content: space-between; align-items: flex-start; }
.person-name { font-size: 20px; font-weight: 700; }
.person-name .sub { font-size: 14px; font-weight: 500; color: var(--text-gray); }

.edit-fab {
  position: static;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #D8D3CD;
  border-radius: 50%;
  background: #fff;
  color: var(--text-gray);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.edit-fab:hover { background: var(--text); color: #fff; border-color: var(--text); }
.card-fabs {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 6px;
}
.memo-fab.has-memo {
  color: var(--lunar);
  border-color: #A9C2E8;
  background: #F3F7FD;
}
.memo-fab.has-memo:hover {
  background: var(--lunar);
  color: #fff;
  border-color: var(--lunar);
}
.print-memo-panel { display: none; }

/* ── 메모 모달 ── */
.memo-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.memo-modal.hidden { display: none; }
.memo-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}
.memo-modal-sheet {
  position: relative;
  width: min(520px, 100%);
  max-height: min(88vh, 720px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--panel-border);
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.memo-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.memo-modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}
.memo-modal-sub {
  margin: 0;
  font-size: 13px;
  color: var(--text-gray);
}
.memo-textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 1px solid var(--panel-border);
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: #FCFBF9;
}
.memo-textarea:focus {
  outline: 2px solid #C9D8EF;
  outline-offset: 0;
  border-color: #8FA9D4;
}
.memo-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.memo-modal-actions .submit-btn {
  width: auto;
  min-width: 96px;
  padding: 10px 16px;
}
.edit-modal-sheet {
  width: min(480px, 100%);
}
.edit-form {
  margin: 0;
}
.edit-form .submit-btn {
  margin-top: 0;
}
.edit-form .memo-modal-actions {
  margin-top: 4px;
}

.junghwa-chip {
  padding: 5px 10px;
  border-radius: 0;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid;
}

.date-line { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.date-tag {
  padding: 2px 6px;
  border-radius: 0;
  font-size: 11px;
  font-weight: 700;
}
.date-tag.solar { color: var(--solar); background: rgba(230,0,18,0.10); }
.date-tag.lunar { color: var(--lunar); background: rgba(0,102,255,0.10); }
.date-text { font-size: 13px; font-weight: 600; color: var(--text-gray); }

/* ── 사주 그리드 ── */
.pb-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.pb-table td { text-align: center; vertical-align: middle; padding: 0; }
.pb-label { font-size: 14px; font-weight: 600; color: var(--text); height: 32px; width: 11%; }
.pb-header { font-size: 14px; font-weight: 700; height: 40px; }
.pb-header .sub { display: block; font-size: 12px; font-weight: 600; color: var(--text-gray); }
.pb-divider { width: 1px; background: var(--border-soft); padding: 0 !important; }

.pb-ganji {
  margin: 2px;
  min-height: 56px;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 5px 0;
}
.pb-ganji .hanja { font-size: 24px; font-weight: 800; line-height: 1; }
.pb-ganji .kor { font-size: 14px; font-weight: 700; }

.pb-text { font-size: 13px; font-weight: 600; padding: 4px 1px; min-height: 32px; display: flex; align-items: center; justify-content: center; line-height: 1.25; }
.pb-empty { color: var(--text-muted); }

/* 오행 색상 (배경 + 오행색 테두리) */
.oh-0 { color: var(--wood); } .oh-bg-0 { background: rgba(0,153,68,0.12); border: 1px solid rgba(0,153,68,0.45); }
.oh-1 { color: var(--fire); } .oh-bg-1 { background: rgba(230,0,18,0.10); border: 1px solid rgba(230,0,18,0.45); }
.oh-2 { color: var(--earth); } .oh-bg-2 { background: rgba(243,152,0,0.14); border: 1px solid rgba(243,152,0,0.5); }
.oh-3 { color: var(--metal); } .oh-bg-3 { background: rgba(122,122,122,0.12); border: 1px solid rgba(122,122,122,0.5); }
.oh-4 { color: var(--water); } .oh-bg-4 { background: rgba(17,17,17,0.10); border: 1px solid rgba(17,17,17,0.45); }

/* ── 합충 마커 ── */
.marker-row { height: 18px; display: flex; justify-content: center; align-items: center; gap: 3px; }
.mk { display: inline-block; cursor: default; }
.mk-circle { width: 13px; height: 13px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.mk-tri, .mk-sq, .mk-x { width: 13px; height: 13px; display: inline-flex; background: transparent !important; box-shadow: none !important; }
.mk-tri svg, .mk-sq svg, .mk-x svg { width: 100%; height: 100%; display: block; }
.mk-x .x-line { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.mk-tri .tri-body { fill: currentColor; }
.mk-tri .tri-plus { fill: none; stroke: #fff; stroke-width: 1.6; stroke-linecap: round; }
.mk-tri .tri-line { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.mk-tri .tri-plus-line { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.mk-sq .sq-body { fill: currentColor; }
.mk-sq .sq-plus { fill: none; stroke: #fff; stroke-width: 1.6; stroke-linecap: round; }
/* 금(白): 흰 배경에서 보이도록 외곽선/진한 + */
.mk-tri.tone-white, .mk-sq.tone-white { color: #fff; }
.mk-tri.tone-white .tri-body { stroke: var(--text); stroke-width: 1; }
.mk-tri.tone-white .tri-plus { stroke: var(--text); }
.mk-tri.tone-white .tri-line { stroke: var(--border); }
.mk-tri.tone-white .tri-plus-line { stroke: var(--border); }
.mk-sq.tone-white .sq-body { stroke: var(--text); stroke-width: 1; }
.mk-sq.tone-white .sq-plus { stroke: var(--text); }
.mk-star { width: 13px; height: 13px; display: inline-flex; align-items: center; justify-content: center; }
.mk-star svg { width: 100%; height: 100%; display: block; }
.mk-star svg path { fill: currentColor; }
.tone-green { color: var(--marker-green); background-color: var(--marker-green); border-bottom-color: var(--marker-green); }
.tone-red { color: var(--marker-red); background-color: var(--marker-red); border-bottom-color: var(--marker-red); }
.tone-yellow { color: var(--marker-yellow); background-color: var(--marker-yellow); border-bottom-color: var(--marker-yellow); }
.tone-white { color: var(--border); background-color: var(--marker-white); border-bottom-color: var(--marker-white); box-shadow: 0 0 0 1px var(--border); }
.tone-grey { color: var(--marker-grey); background-color: var(--marker-grey); border-bottom-color: var(--marker-grey); }
.tone-black { color: var(--marker-black); background-color: var(--marker-black); border-bottom-color: var(--marker-black); }
/* 번개(충)는 배경 없이 currentColor 로만 채색 */
.mk-star { background: transparent !important; box-shadow: none !important; }
.mk-star.tone-green { color: var(--marker-green); }
.mk-star.tone-red { color: var(--marker-red); }
.mk-star.tone-yellow { color: var(--marker-yellow); }
.mk-star.tone-grey { color: var(--marker-grey); }
.mk-star.tone-black { color: var(--marker-black); }
/* 금(白) 번개: 흰 배경에서 보이도록 흰색 채움 + 진한 외곽선 (회색과 구분) */
.mk-star.tone-white { color: #fff; }
.mk-star.tone-white svg path { stroke: var(--text); stroke-width: 1.1; }
/* 합(원): 색 배경 위에 흰 '+' (흰색 금 원에는 진한 +) */
.mk-circle { color: #fff; font-size: 10px; font-weight: 900; line-height: 1; }
.mk-circle.tone-white { color: var(--text); }

/* ── 운세 행 (대운·세운·월운) ── */
.unse-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 14px; }
.unse-head .title { font-size: 16px; font-weight: 700; }
.unse-head .su { font-size: 14px; font-weight: 700; color: var(--text-gray); }

.unse-row-label { font-size: 15px; font-weight: 700; margin: 14px 0 10px; }

.unse-scroll {
  display: flex;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.unse-cell {
  flex: 0 0 auto;
  width: 56px;
  margin-right: 8px;
  padding: 7px 5px;
  border-radius: 0;
  border: 1.5px solid transparent;
  text-align: center;
  cursor: pointer;
  background: transparent;
  font-family: inherit;
}

.unse-cell.hl { background: #F7F5F2; border-color: var(--text); }
.unse-cell .lbl { font-size: 14px; font-weight: 700; color: var(--text-gray); }
.unse-cell.hl .lbl { color: var(--text); font-weight: 800; }
.unse-cell .sub { font-size: 11px; color: var(--text-muted); }
.unse-cell .sip { font-size: 12px; font-weight: 600; color: var(--text-gray); margin: 3px 0; }
.unse-cell .uns { font-size: 12px; font-weight: 600; color: var(--text); margin-top: 3px; }

.unse-ganji {
  width: 44px;
  height: 44px;
  margin: 3px auto;
  border-radius: 0;
  position: relative;
  border: 1px solid;
  display: flex;
  align-items: center;
  justify-content: center;
}
.unse-ganji .hj { font-size: 19px; font-weight: 800; line-height: 1; }
.unse-ganji .kr { position: absolute; right: 4px; bottom: 3px; font-size: 9px; font-weight: 700; opacity: 0.85; }
.oh-bd-0 { border-color: rgba(0,153,68,0.45); background: rgba(0,153,68,0.12); }
.oh-bd-1 { border-color: rgba(230,0,18,0.45); background: rgba(230,0,18,0.10); }
.oh-bd-2 { border-color: rgba(243,152,0,0.5); background: rgba(243,152,0,0.14); }
.oh-bd-3 { border-color: rgba(122,122,122,0.5); background: rgba(122,122,122,0.12); }
.oh-bd-4 { border-color: rgba(17,17,17,0.45); background: rgba(17,17,17,0.10); }

/* ── 신살 보드 ── */
.grid-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.grid-table td { text-align: center; vertical-align: middle; padding: 2px; }
.gt-label { font-size: 13px; font-weight: 600; width: 15%; }
.gt-header { font-size: 13px; font-weight: 600; height: 34px; }

.gt-ganji {
  min-height: 56px;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.gt-ganji .hanja { font-size: 24px; font-weight: 800; line-height: 1.05; }
.gt-ganji .kor { font-size: 12px; font-weight: 700; }

.gt-text { font-size: 13px; font-weight: 600; line-height: 1.5; white-space: pre-line; padding: 6px 2px; }

/* ── 사주풀이 ── */
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.filter-chip {
  padding: 7px 12px;
  border-radius: 0;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-gray);
  cursor: pointer;
  font-family: inherit;
}
.filter-chip.on { background: #524C46; border-color: #524C46; color: #fff; }

.detail-ganji {
  margin: 3px;
  min-height: 68px;
  border-radius: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.detail-ganji .hanja { font-size: 28px; font-weight: 800; }
.detail-ganji .kor { font-size: 15px; font-weight: 600; }
.detail-ganji .badge {
  position: absolute;
  right: 6px;
  bottom: 5px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  text-align: right;
  white-space: pre-line;
}

.detail-header { font-size: 13px; font-weight: 700; padding: 6px 4px; }
.detail-header .h2 { display: block; font-size: 11px; font-weight: 600; color: var(--text-gray); }
.detail-header .h3 { display: block; font-size: 11px; font-weight: 400; color: var(--text-muted); }

.empty-relation {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #F7F5F2;
  border: 1px solid var(--panel-border);
  border-radius: 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

/* ── 오행·십성 도넛 ── */
.option-row { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; margin-bottom: 6px; cursor: pointer; }
.option-row input { width: 17px; height: 17px; accent-color: var(--text); }

.donut-wrap { display: flex; justify-content: space-around; margin-top: 16px; flex-wrap: wrap; gap: 16px; }
.donut-wrap > div { flex: 1 1 160px; display: flex; flex-direction: column; align-items: center; }
.donut-box { position: relative; width: 132px; height: 132px; }
.donut-box svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.donut-center .top { font-size: 24px; font-weight: 800; }
.donut-center .sub { font-size: 13px; font-weight: 600; }

.donut-legend { display: flex; justify-content: center; gap: 10px; margin-top: 8px; font-size: 11px; color: var(--text-gray); flex-wrap: wrap; }
.donut-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 3px; }

/* ── 용신 ── */
.yongsin-box {
  padding: 14px 16px;
  border: 1px solid #D8D3CD;
  border-radius: 0;
  font-size: 15px;
  font-weight: 600;
}
.yongsin-sub { font-size: 12px; color: var(--text-muted); margin-top: 8px; line-height: 1.6; }

/* ── 운세 달력 ── */
.cal-head { display: flex; justify-content: center; align-items: center; gap: 8px; margin-bottom: 4px; }
.cal-head .nav { border: none; background: transparent; font-size: 20px; cursor: pointer; color: var(--text-gray); padding: 2px 8px; }
.cal-head .ym { font-size: 15px; font-weight: 700; }
.cal-jie { text-align: center; font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }
.cal-segments { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.cal-seg {
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  background: #F7F5F2;
  border: 1px solid var(--panel-border);
  border-radius: 0;
}

.cal-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal-table th { font-size: 11px; font-weight: 600; color: var(--text-gray); padding: 4px 0; }
.cal-table th.sun { color: var(--solar); }
.cal-table th.sat { color: var(--lunar); }

.cal-cell {
  height: 58px;
  text-align: center;
  vertical-align: middle;
  border-radius: 0;
  cursor: pointer;
}
.cal-cell:hover { background: #F7F5F2; }
.cal-cell.sel { background: #F7F5F2; box-shadow: inset 0 0 0 1.2px var(--text); }
.cal-cell .num { font-size: 13px; font-weight: 600; width: 24px; height: 24px; line-height: 24px; border-radius: 50%; margin: 0 auto; }
.cal-cell .num.sun { color: var(--solar); } .cal-cell .num.sat { color: var(--lunar); }
.cal-cell .num.today { background: var(--text); color: #fff; font-weight: 800; }
.cal-chips { display: flex; justify-content: center; gap: 2px; margin-top: 3px; }
.cal-chip {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800;
  border-radius: 0;
  border: 1px solid;
  color: var(--text);
}

.cal-info { margin-top: 12px; padding: 12px 14px; background: #F7F5F2; border-radius: 0; }
.cal-info .date { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.cal-info .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cal-info .chip {
  padding: 4px 10px;
  background: #fff;
  border: 1px solid var(--panel-border);
  border-radius: 0;
  font-size: 11px;
  font-weight: 600;
}
.today-btn { border: none; background: none; font-size: 12px; color: var(--text-gray); cursor: pointer; text-decoration: underline; }

/* ── 합충파 도형 범례 ── */
.marker-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--panel-border);
}
.marker-legend-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--panel-border);
}
.marker-legend-item:last-child { border-bottom: none; }
.marker-legend-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #F7F5F2;
  border: 1px solid var(--panel-border);
}
.marker-legend-icon .mk { transform: scale(1.15); }
.marker-legend-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.marker-legend-text strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.marker-legend-text span {
  font-size: 13px;
  color: var(--text-gray);
  line-height: 1.45;
}
.marker-legend-note { margin-top: 10px; }

/* ── 12운성표 ── */
.unsung-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1.5px solid #555;
  -webkit-overflow-scrolling: touch;
}
.unsung-table {
  width: 100%;
  min-width: 410px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
  text-align: center;
}
.unsung-table th,
.unsung-table td {
  height: 34px;
  padding: 5px 2px;
  border-right: 1px solid #8A8A8A;
  border-bottom: 1px solid #8A8A8A;
  white-space: nowrap;
}
.unsung-table tr > :last-child { border-right: none; }
.unsung-table tbody tr:last-child > * { border-bottom: none; }
.unsung-table thead th,
.unsung-table tbody th {
  background: #E7F1F8;
  color: var(--text);
  font-family: "Noto Serif KR", serif;
  font-size: 14px;
  font-weight: 800;
}
.unsung-table thead th:first-child,
.unsung-table tbody th { width: 9%; }
.unsung-table td { color: #2F3337; font-weight: 600; }
.unsung-birth { background: #FAE7DF; }
.unsung-power { background: #E8E8E8; }
.unsung-growth { background: #E2EEF6; }
.unsung-rest { background: #FFF4CF; }
.unsung-cut { background: #DDEECD; }
.unsung-neutral { background: #FFFFFF; }
.unsung-table-note { margin-top: 10px; }

/* ── 저장 목록 ── */
.list-screen {
  width: 100%;
}

.list-panel {
  width: 100%;
  max-width: 640px;
  padding: 20px 20px 8px;
  margin: 0 auto;
}

/* 저장명식·궁합명식: 검색·하단 버튼 고정, 목록만 스크롤 */
#panel-list.saved-screen,
#compat-picker.compat-screen {
  display: flex;
  justify-content: center;
  align-items: stretch;
  height: calc(100dvh - var(--appbar-h));
  min-height: 0;
  margin: -20px -28px -32px;
  padding: 12px 28px 16px;
  overflow: hidden;
  box-sizing: border-box;
}
.saved-panel,
.compat-panel {
  flex: 1;
  min-width: 0;
  min-height: 0;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 0;
  overflow: hidden;
}
.saved-head,
.compat-head {
  flex-shrink: 0;
}
.saved-head .saved-search-wrap,
.compat-head .saved-search-wrap { margin-bottom: 10px; }
.saved-head .saved-meta-row,
.compat-head .saved-meta-row { margin-bottom: 8px; }
.compat-pick-hint {
  margin: 0 0 12px;
  text-align: left;
  padding: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
}
.saved-scroll,
.compat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.saved-footer,
.compat-footer {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  margin: 0 -16px 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-soft);
  background: rgba(252, 251, 249, 0.96);
  backdrop-filter: blur(6px);
}
.saved-footer .submit-btn,
.saved-footer .btn-ghost,
.compat-footer .submit-btn,
.compat-footer .btn-ghost {
  flex: 1;
  margin: 0;
  min-height: 44px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-sizing: border-box;
}
.saved-footer .btn-ghost,
.compat-footer .btn-ghost {
  border: 1px solid #D8D3CD;
  background: #fff;
  color: var(--text-gray);
}
.saved-footer .btn-ghost:hover,
.compat-footer .btn-ghost:hover { background: #F4F1ED; }
.saved-footer .btn-ghost:disabled,
.saved-footer .submit-btn:disabled,
.compat-footer .btn-ghost:disabled,
.compat-footer .submit-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.saved-import-guide {
  margin: 0 0 16px;
  padding-left: 1.2em;
  color: var(--text-gray);
  font-size: 13px;
  line-height: 1.65;
}
.saved-import-guide li { margin-bottom: 4px; }
.saved-import-actions .btn-ghost,
.saved-import-actions .submit-btn {
  flex: 1;
  margin: 0;
}

@media (max-width: 720px) {
  #panel-list.saved-screen,
  #compat-picker.compat-screen {
    margin: -8px -16px -32px;
    padding: 0;
    width: auto;
    justify-content: stretch;
  }
  #panel-list .saved-panel.list-panel,
  #compat-picker .compat-panel.list-panel {
    width: 100%;
    max-width: none;
    margin: 0;
    border-left: none;
    border-right: none;
    border-radius: 0;
    padding: 12px 12px 0;
    box-shadow: none;
  }
  #panel-list .saved-footer,
  #compat-picker .compat-footer {
    margin: 0 -12px 0;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 479px) {
  #panel-list.saved-screen,
  #compat-picker.compat-screen {
    margin: -16px -12px -24px;
    padding: 0;
  }
}

/* 구독·1:1 문의·문의관리·이용안내 — 이용안내와 동일 가로폭 */
#panel-subscribe .panel,
#panel-inquiry .panel,
#panel-inquiry-admin .panel,
#panel-guide .panel {
  width: 100%;
  max-width: 720px;
}

.saved-search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 44px;
  background: #F7F5F2;
  border: 1px solid var(--border-soft);
  border-radius: 0;
  margin-bottom: 14px;
}

.saved-search-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.saved-search-wrap input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
}

.saved-search-wrap input::placeholder {
  color: var(--text-muted);
}

.saved-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  padding: 0 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.saved-meta-row #saved-count {
  font-weight: 600;
  color: var(--text-gray);
}

.saved-shown {
  font-size: 12px;
}

.saved-list {
  width: 100%;
}

.saved-list .hint {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.saved-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 0.12s ease;
}

.saved-item:last-child {
  border-bottom: none;
}

.saved-item:hover {
  background: #FAF8F5;
  margin: 0 -8px;
  padding-left: 10px;
  padding-right: 10px;
  border-radius: 0;
  border-bottom-color: transparent;
}

.saved-body {
  flex: 1;
  min-width: 0;
}

.saved-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-detail {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-gray);
  line-height: 1.4;
}

.cal-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 0;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
}

.cal-chip.solar {
  color: var(--solar);
  background: rgba(230, 0, 18, 0.10);
}

.cal-chip.lunar {
  color: var(--lunar);
  background: rgba(0, 102, 255, 0.10);
}

.saved-birth {
  font-weight: 500;
  color: var(--text-gray);
}

.saved-del {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: #C0494A;
  cursor: pointer;
  border-radius: 0;
  padding: 0;
  opacity: 0.75;
  transition: opacity 0.12s ease, background 0.12s ease;
}

.saved-del:hover {
  opacity: 1;
  background: #FDF0F0;
}

@media (min-width: 640px) {
  .list-panel {
    max-width: 720px;
    padding: 24px 28px 12px;
  }

  #panel-subscribe .panel,
  #panel-inquiry .panel,
  #panel-inquiry-admin .panel,
  #panel-guide .panel {
    max-width: 720px;
  }

  .saved-name {
    font-size: 16px;
  }

  .saved-detail {
    font-size: 14px;
  }
}

@media (max-width: 479px) {
  #main { padding: 16px 12px 24px; }

  .list-panel {
    padding: 16px 14px 6px;
  }

  .saved-item {
    padding: 12px 0;
  }

  .saved-detail {
    font-size: 12px;
    gap: 6px;
  }
}

/* ── 문의 ── */
.inq-item { padding: 14px 4px; border-bottom: 1px solid var(--border-soft); }
.inquiry-search-wrap { margin-top: 0; margin-bottom: 0; flex: 1; min-width: 0; }
.inquiry-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.inq-status-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.inq-filter {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-gray);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.inq-filter input {
  width: 16px;
  height: 16px;
  accent-color: var(--text);
  cursor: pointer;
}
.inq-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.inq-uid {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-gray);
  font-variant-numeric: tabular-nums;
}
.inq-del {
  width: 30px;
  height: 30px;
  margin-left: auto;
  padding: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.inq-del:hover {
  color: var(--fire);
  border-color: rgba(230, 0, 18, 0.28);
  background: rgba(230, 0, 18, 0.06);
}
.inq-del svg { width: 17px; height: 17px; }
.inq-item .ti { font-size: 14px; font-weight: 700; }
.inq-item .st {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid;
}
.inq-item .st.pending {
  color: #A5432A;
  border-color: #F0CBB2;
  background: #FFF3EC;
}
.inq-item .st.answered {
  color: #1F6B3A;
  border-color: #B7DEC5;
  background: #EAF7EF;
}
.inq-item .ct { font-size: 13px; color: var(--text-gray); margin: 4px 0; white-space: pre-line; }
.inq-item .ans { background: #F7F5F2; padding: 8px 10px; border-radius: 0; font-size: 13px; margin-top: 6px; }
.inq-item textarea { width: 100%; margin-top: 6px; padding: 8px; border: 1px solid #D8D3CD; border-radius: 0; font-family: inherit; font-size: 13px; }
.inq-item .ans-btn { margin-top: 6px; padding: 6px 14px; border: none; border-radius: 0; background: var(--text); color: #fff; font-size: 13px; cursor: pointer; }
.inq-more { margin: 12px 0 4px; text-align: center; }
.nav-item.admin-only.hidden { display: none !important; }
.inq-admin-ta {
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid #D8D3CD;
  border-radius: 0;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}
#panel-inquiry-admin .inquiry-toolbar { margin-top: 0; }
#panel-subscribe .sub-lead:first-child,
#panel-guide .guide-lead:first-child,
#panel-inquiry form:first-child,
#panel-compat .compat-pick-hint:first-child {
  margin-top: 0;
}

/* ── 이용안내 ── */
.guide-panel { padding-bottom: 28px; }
.guide-body { font-size: 14px; line-height: 1.7; color: var(--text-gray); }
.guide-lead {
  margin: 0 0 20px;
  padding: 12px 14px;
  background: #F7F5F2;
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-weight: 600;
}
.guide-body h3 {
  margin: 22px 0 8px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}
.guide-body ul {
  margin: 0 0 4px;
  padding-left: 1.15rem;
}
.guide-body li { margin-bottom: 6px; }
.guide-body strong { color: var(--text); font-weight: 700; }

.inq-spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 16px 0 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}
.inq-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-soft);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: inq-spin 0.7s linear infinite;
}
@keyframes inq-spin {
  to { transform: rotate(360deg); }
}

/* ── 토스트 ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 0;
  font-size: 14px;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

/* 로그인 안내 배너 */
.login-banner {
  max-width: 540px;
  margin: 0 auto 16px;
  padding: 10px 14px;
  background: #FFF8EC;
  border: 1px solid #EAD9B0;
  border-radius: 0;
  font-size: 13px;
  color: var(--text-gray);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.login-banner a { color: var(--text); font-weight: 700; }

/* ── 플랜 / 결제 ── */
.sub-lead {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-gray);
}
.sub-guide-title {
  margin: 18px 0 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.sub-table-wrap {
  overflow-x: auto;
  margin: 0 0 12px;
  border: 1px solid var(--border, #E5E0DA);
  background: #fff;
}
.sub-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.sub-table th,
.sub-table td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border, #E5E0DA);
  white-space: nowrap;
}
.sub-table th {
  background: #F7F4F0;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.sub-table tr:last-child td { border-bottom: 0; }
.sub-guide-list {
  margin: 0 0 8px;
  padding-left: 1.15em;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-gray);
}
.sub-guide-list li { margin-bottom: 4px; }
.sub-status { margin-bottom: 14px; }
.sub-badge {
  display: inline-block; padding: 4px 12px; border-radius: 0;
  font-size: 13px; font-weight: 700; background: #EDE9E4; color: var(--text-gray);
}
.sub-badge.active { background: #E8F0FF; color: #1F4B99; }
.sub-line { margin-top: 8px; font-size: 14px; color: var(--text-gray); }
.sub-line.warn { color: #B4462F; font-weight: 600; }
.sub-usage { margin-top: 6px; font-size: 13px; color: var(--text-muted); line-height: 1.55; }
.sub-locked-n { color: #B4462F; }
.sub-price { font-size: 26px; font-weight: 800; color: var(--text); margin: 8px 0 14px; }
.sub-price span { font-size: 15px; font-weight: 600; color: var(--text-muted); }
.sub-form .field-row { display: flex; gap: 10px; }
.sub-note { margin-top: 10px; text-align: center; }
.sub-cancel {
  padding: 12px 18px; border: 1px solid #D8D3CD; border-radius: 0;
  background: #fff; color: var(--text-gray); font-family: inherit;
  font-size: 15px; font-weight: 600; cursor: pointer;
  width: 100%;
  margin-top: 12px;
}
.sub-cancel:hover { background: #F4F1ED; }

#sub-pay-btn { border-radius: 8px; }

.plan-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 4px 0 16px;
}
.plan-card {
  border: 1px solid var(--panel-border);
  background: #fff;
  padding: 14px 12px;
}
.plan-card.current { border-color: #8A8A8A; box-shadow: inset 0 0 0 1px #8A8A8A; }
.plan-card.plus { border-color: #9BB6E8; background: #F7FAFF; }
.plan-card.plus.current { border-color: #1F4B99; box-shadow: inset 0 0 0 1px #1F4B99; }
.plan-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}
.plan-card-head strong { font-size: 16px; font-weight: 800; }
.plan-chip {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  background: #EDE9E4;
  color: #6B655E;
}
.plan-chip.plus { background: #1F4B99; color: #fff; }
.plan-card-price {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 10px;
}
.plan-card-price span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.plan-card-list {
  margin: 0;
  padding-left: 1.05rem;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-gray);
}
.plan-card-list li { margin-bottom: 3px; }

.plus-period {
  display: flex;
  gap: 6px;
  margin: 0 0 10px;
}
.plus-period-btn {
  flex: 1;
  border: 1px solid #C5D4EF;
  background: #fff;
  color: #1F4B99;
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.plus-period-btn.on {
  background: #1F4B99;
  border-color: #1F4B99;
  color: #fff;
}
.plus-card-meta {
  margin: -4px 0 10px;
  font-size: 12px;
  color: #6B7280;
}
.plus-card-list {
  margin-left: 6px;
  font-size: 12px;
  color: #8A8A8A;
  text-decoration: line-through;
}

.plus-pkg-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}
.plus-pkg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  padding: 12px;
  border: 1px solid var(--panel-border, #E5E0DA);
  background: #fff;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.plus-pkg.on {
  border-color: #1F4B99;
  box-shadow: inset 0 0 0 1px #1F4B99;
  background: #F7FAFF;
}
.plus-pkg-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.plus-pkg-top strong { font-size: 15px; font-weight: 800; }
.plus-pkg-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: #1F4B99;
  background: rgba(31, 75, 153, 0.1);
  padding: 2px 6px;
}
.plus-pkg-price {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.plus-pkg-list {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-gray);
  text-decoration: line-through;
}
.plus-pkg-meta {
  font-size: 12px;
  color: var(--text-gray);
}

@media (max-width: 520px) {
  .plan-cards { grid-template-columns: 1fr; }
  .plus-pkg-grid { grid-template-columns: 1fr; }
  .upgrade-btn { font-size: 10px; padding: 5px 6px; }
  .export-btn { font-size: 10px; padding: 5px 6px; }
}

/* ── PDF 내보내기 (브라우저 인쇄) ── */
@media print {
  body.print-result *,
  body.print-compat * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body.print-result .appbar,
  body.print-result #drawer,
  body.print-result #drawer-overlay,
  body.print-result .site-footer,
  body.print-result #toast,
  body.print-result .edit-fab,
  body.print-result .card-fabs,
  body.print-result #memo-modal,
  body.print-result #edit-modal,
  body.print-result #saved-import-modal,
  body.print-result .today-btn,
  body.print-result #unse-panel,
  body.print-result #calendar-panel,
  body.print-result #marker-legend-panel,
  body.print-result #unsung-table-panel,
  body.print-compat .appbar,
  body.print-compat #drawer,
  body.print-compat #drawer-overlay,
  body.print-compat .site-footer,
  body.print-compat #toast,
  body.print-compat .edit-fab,
  body.print-compat .card-fabs,
  body.print-compat #memo-modal,
  body.print-compat #edit-modal,
  body.print-compat #saved-import-modal,
  body.print-compat .today-btn,
  body.print-compat #compat-unse-panel,
  body.print-compat #compat-calendar-panel,
  body.print-compat #compat-marker-legend-panel,
  body.print-compat #compat-unsung-table-panel,
  body.print-compat .compat-back-btn,
  body.print-compat .compat-link-bar {
    display: none !important;
  }
  body.print-result .print-memo-panel:not(:empty),
  body.print-compat .print-memo-panel:not(:empty) {
    display: block;
    margin-top: 14px;
    border: 1px solid #8A8A8A;
    background: #FAF8F5;
    font-size: 12px;
    line-height: 1.55;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  body.print-result .print-memo-item,
  body.print-compat .print-memo-item {
    padding: 10px 12px;
    border-top: 1px solid #D8D3CD;
  }
  body.print-result .print-memo-item:first-of-type,
  body.print-compat .print-memo-item:first-of-type {
    border-top: none;
  }
  body.print-result .print-memo-panel .section-title,
  body.print-compat .print-memo-panel .section-title {
    margin: 0;
    padding: 10px 12px;
  }
  body.print-result .print-memo-item strong,
  body.print-compat .print-memo-item strong {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
  }
  body.print-result .print-memo-item div,
  body.print-compat .print-memo-item div {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
  body.print-result,
  body.print-compat {
    background: #fff !important;
  }
  body.print-result #main,
  body.print-compat #main {
    padding: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }
  body.print-compat .compat-grid {
    display: none !important;
  }
  body.print-compat .compat-print-stack {
    display: block !important;
  }
  .compat-print-stack {
    display: none;
  }
  body.print-compat .compat-print-person {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  body.print-compat .compat-print-person + .compat-print-person {
    break-before: page;
    page-break-before: always;
    margin-top: 0;
  }
  body.print-compat .compat-print-title {
    margin: 0 0 12px;
    font-size: 18px;
    font-weight: 700;
  }
  body.print-compat .compat-print-card .person-head {
    margin-bottom: 10px;
  }
  body.print-result .result-grid {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    max-width: none !important;
  }
  body.print-result .result-left,
  body.print-result .result-right {
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    flex: none !important;
  }
  body.print-result .panel,
  body.print-compat .panel {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 12px;
    box-shadow: none !important;
  }
}

/* 잠금(마스킹) 저장 항목 */
.saved-banner {
  width: 100%; text-align: left; margin: 0 0 12px; padding: 12px 14px;
  background: #FFF3EC; border: 1px solid #F0CBB2; border-radius: 0;
  color: #A5432A; font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit; line-height: 1.4;
}
.saved-banner:hover { background: #FDE8DC; }
.saved-item.locked { cursor: pointer; background: #FAF8F5; }
.saved-lock-row {
  display: flex; align-items: center; gap: 6px;
  color: #A5432A; font-size: 14px; font-weight: 700;
}
.saved-detail.masked { color: var(--text-muted); letter-spacing: 1px; margin-top: 4px; }
.saved-lock-cta {
  align-self: center; padding: 5px 12px; border-radius: 0;
  background: #A5432A; color: #fff; font-size: 12px; font-weight: 700;
}

/* ── 궁합 비교 ── */
.compat-pick-item { gap: 10px; }
.compat-pick-item.picked {
  background: color-mix(in srgb, var(--lunar) 10%, white);
  margin: 0 -8px;
  padding-left: 10px;
  padding-right: 10px;
  border-bottom-color: transparent;
  box-shadow: inset 3px 0 0 var(--lunar);
}
.compat-check {
  width: 28px;
  height: 28px;
  border: 2px solid #D8D3CD;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  background: #fff;
}
.compat-check.on {
  background: var(--lunar);
  border-color: var(--lunar);
}
.compat-check.locked {
  border: none;
  background: transparent;
  font-size: 16px;
}

#compat-view { position: relative; }
.compat-back-btn {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 18;
  padding: 10px 14px;
  border: 1px solid var(--panel-border);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(46, 42, 38, 0.12);
}
.compat-back-btn:hover { background: #FAF8F5; }

.compat-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.compat-card {
  position: relative;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  border: 2px solid var(--panel-border);
  outline: none;
}
.compat-card:hover {
  border-color: color-mix(in srgb, var(--lunar) 55%, #D8D3CD);
  background: #FAFCFF;
}
.compat-card:focus-visible {
  border-color: var(--lunar);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--lunar) 25%, transparent);
}
.compat-card.active {
  border-color: var(--lunar);
  background: color-mix(in srgb, var(--lunar) 7%, white);
  box-shadow: 0 0 0 1px var(--lunar), 0 6px 16px rgba(46, 42, 38, 0.08);
}
.compat-card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #E8E4DF;
  color: var(--text-gray);
  font-size: 12px;
  font-weight: 800;
  z-index: 1;
}
.compat-card.active .compat-card-badge {
  background: var(--lunar);
  color: #fff;
}
.compat-person { position: relative; padding-top: 8px; }
.compat-pillar {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--panel-border);
}

.compat-right {
  border-left: 3px solid transparent;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.compat-right[data-active="0"],
.compat-right[data-active="1"] {
  border-left-color: var(--lunar);
  background: color-mix(in srgb, var(--lunar) 4%, transparent);
}
.compat-link-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--lunar) 12%, white);
  border: 1px solid color-mix(in srgb, var(--lunar) 40%, #D8D3CD);
}
.compat-link-bar::before {
  content: "";
  width: 10px;
  height: 10px;
  background: var(--lunar);
  flex-shrink: 0;
}
.compat-link-label {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

@media (max-width: 719px) {
  .compat-back-btn { left: 12px; bottom: 12px; }
  .compat-right {
    border-left: none;
    border-top: 3px solid var(--lunar);
    padding-top: 4px;
  }
}

/* ── 사이트 풋터 ── */
.site-footer {
  width: 100%;
  max-width: 1400px;
  margin: 8px auto 0;
  padding: 20px 16px 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.7;
  border-top: 1px solid var(--border-soft);
}
.site-footer a {
  color: var(--text-gray);
  text-decoration: none;
  font-weight: 600;
}
.site-footer a:hover { color: var(--text); text-decoration: underline; }
.site-footer .divider { margin: 0 0.35rem; opacity: 0.45; }
.site-footer .footer-links { margin-bottom: 10px; }
.site-footer .footer-info p { margin: 2px 0; }
.site-footer .footer-info a { font-weight: 500; }
body.result-mode .site-footer { display: none; }
@media (max-width: 479px) {
  .site-footer .br-m { display: block; }
  .site-footer .divider-m { display: none; }
}

/* ── 로그인 게이트 (/pro 인라인, Basic과 동일 패턴) ── */
#screen-login {
  --auth-ink: #F5F0E8;
  --auth-ink-soft: #C9C2B6;
  --auth-muted: #8A847C;
  --auth-line: rgba(255,255,255,0.14);
  --auth-accent: #C9A227;
  --auth-accent-hover: #B8921F;
  --auth-accent-soft: rgba(201, 162, 39, 0.18);
  --auth-card: rgba(255,255,255,0.05);
  --auth-danger: #E8A09A;
  --auth-display: "Gowun Batang", "궁서", serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px 48px;
  background:
    radial-gradient(900px 520px at 50% -8%, rgba(201, 162, 39, 0.22) 0%, transparent 55%),
    radial-gradient(700px 400px at 100% 100%, rgba(201, 162, 39, 0.08) 0%, transparent 45%),
    linear-gradient(165deg, #0C0A08 0%, #17140F 55%, #100E0C 100%);
  color: var(--auth-ink);
  box-sizing: border-box;
}
#screen-login.hidden { display: none !important; }
#screen-login .auth-wrap { width: min(100%, 380px); }
#screen-login .auth-hero {
  text-align: center;
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  column-gap: 10px;
  row-gap: 0;
}
#screen-login .auth-brand {
  margin: 0;
  font-family: var(--auth-display);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
#screen-login .auth-brand a { color: inherit; text-decoration: none; }
#screen-login .auth-brand a:hover { color: var(--auth-accent); }
#screen-login .auth-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--auth-accent-soft);
  color: #E2C56A;
}
#screen-login .auth-title {
  width: 100%;
  margin: 14px 0 8px;
  font-size: 22px;
  font-weight: 700;
}
#screen-login .auth-sub {
  width: 100%;
  margin: 0 0 10px;
  color: var(--auth-ink-soft);
  font-size: 14px;
  line-height: 1.55;
}
#screen-login .auth-sync {
  width: 100%;
  margin: 0 0 20px;
  color: var(--auth-ink);
  font-size: 13.5px;
  line-height: 1.55;
  font-weight: 500;
}
#screen-login .auth-card {
  background: var(--auth-card);
  border: 1px solid var(--auth-line);
  border-radius: 18px;
  padding: 18px;
  backdrop-filter: blur(8px);
}
#screen-login .auth-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
#screen-login .auth-field:last-of-type { margin-bottom: 14px; }
#screen-login .auth-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--auth-muted);
}
#screen-login .auth-field input {
  width: 100%;
  border: 1px solid var(--auth-line);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  background: rgba(0,0,0,0.35);
  color: var(--auth-ink);
  box-sizing: border-box;
}
#screen-login .auth-field input:focus {
  outline: 2px solid rgba(201, 162, 39, 0.35);
  border-color: var(--auth-accent);
}
#screen-login .auth-field input::placeholder { color: #6E6860; }
#screen-login .auth-submit {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 14px;
  background: var(--auth-accent);
  color: #1C1915;
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}
#screen-login .auth-submit:hover { background: var(--auth-accent-hover); }
#screen-login .auth-submit:disabled { opacity: 0.55; cursor: wait; }
#screen-login .auth-or {
  position: relative;
  margin: 18px 0 6px;
  text-align: center;
}
#screen-login .auth-or::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  border-top: 1px solid var(--auth-line);
}
#screen-login .auth-or span {
  position: relative;
  display: inline-block;
  padding: 0 10px;
  background: #12100E;
  color: var(--auth-muted);
  font-size: 12px;
}
#screen-login .auth-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 12px;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.18);
  background: #fff;
  color: #1C1915;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  box-sizing: border-box;
}
#screen-login .auth-google:hover { background: #F7F3EC; }
#screen-login .auth-links {
  margin: 18px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--auth-muted);
}
#screen-login .auth-links a {
  color: var(--auth-ink-soft);
  font-weight: 600;
  text-decoration: none;
}
#screen-login .auth-links a:hover { color: var(--auth-accent); }
#screen-login .auth-error {
  color: var(--auth-danger);
  font-size: 13px;
  margin: 0 0 10px;
  text-align: center;
}
body:has(#screen-login:not(.hidden)) {
  background: #0C0A08;
}
