/* ==========================================================================
   색소폰 사이트 공통 스타일
   설계 기준: 주 사용자가 40~50대. 아래 3가지는 임의로 바꾸지 말 것.
   1) 라이트 모드가 기본이다. 노안은 밝은 배경 + 진한 글씨의 대비가 읽기 쉽다.
      (다크는 토글로만 제공 — 어두운 연습실용)
   2) 본문 18px 이상. 16px는 40대 후반부터 읽기 힘들어진다.
   3) 누를 수 있는 것은 최소 48px. 아이콘만 두지 말고 항상 글자 라벨을 붙인다.
   ========================================================================== */

:root {
  --bg:        #fdfcfa;
  --bg-sub:    #f4f1ec;
  --card:      #ffffff;
  --border:    #e0dcd4;
  --text:      #1e2329;
  --text-dim:  #5c636d;
  --accent:    #a86a11;   /* 황동색. 흰 배경 대비 5.4:1 */
  --accent-bg: #fdf3e2;
  --ok:        #1f7a4d;
  --warn:      #b2401a;
  --shadow:    0 1px 3px rgba(30, 35, 41, .08), 0 4px 16px rgba(30, 35, 41, .05);
  --radius:    14px;
}

[data-theme="dark"] {
  --bg:        #16181c;
  --bg-sub:    #1d2025;
  --card:      #212429;
  --border:    #33383f;
  --text:      #f1efec;
  --text-dim:  #a2a9b3;
  --accent:    #e8a94a;
  --accent-bg: #2c2519;
  --ok:        #4dc98a;
  --warn:      #f08a5f;
  --shadow:    none;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
               "Pretendard", "Malgun Gothic", "맑은 고딕", sans-serif;
  font-size: 18px;
  line-height: 1.7;
  word-break: keep-all;      /* 한글이 단어 중간에서 안 끊기게 */
  overflow-wrap: break-word;
  /* 하단 탭바 + iOS 홈 인디케이터 만큼 여백 */
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}

/* 본문 링크. 이걸 안 잡아두면 브라우저 기본 파란색이 나와서
   다크 모드에서 거의 안 보인다. */
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

/* ---------- 헤더 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
}
.site-header__inner {
  max-width: 900px;
  margin: 0 auto;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.site-logo {
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.site-logo span { color: var(--accent); }

.theme-toggle {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

/* ---------- 레이아웃 ---------- */
.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}
.page-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -.03em;
  margin: 8px 0 6px;
  line-height: 1.3;
}
.page-lead {
  font-size: 18px;
  color: var(--text-dim);
  margin: 0 0 28px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px;
  margin-bottom: 20px;
}
.card h2 {
  font-size: 21px;
  font-weight: 700;
  margin: 0 0 14px;
  letter-spacing: -.02em;
}

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 24px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  /* <a>에 .btn을 쓰는 곳이 있다. 그때 밑줄이 나오면 버튼처럼 안 보인다 */
  text-decoration: none;
}
a.btn { color: var(--text); }
a.btn--primary { color: #fff; }
[data-theme="dark"] a.btn--primary { color: #1a1509; }
.btn:active { transform: scale(.98); }
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
[data-theme="dark"] .btn--primary { color: #1a1509; }
.btn--big { width: 100%; min-height: 68px; font-size: 22px; }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- 큰 숫자 조절기 (BPM 등) ---------- */
.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.stepper__btn {
  width: 64px;
  height: 64px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.stepper__value {
  font-size: 60px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 3.2ch;
  text-align: center;
  letter-spacing: -.04em;
}
.stepper__unit { font-size: 17px; color: var(--text-dim); font-weight: 600; }

/* 슬라이더도 두껍게 — 손가락으로 잡기 쉽게 */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 40px;
  background: transparent;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 5px;
  background: var(--bg-sub);
  border: 1px solid var(--border);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 38px; height: 38px;
  margin-top: -15px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--card);
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  cursor: pointer;
}
input[type="range"]::-moz-range-track {
  height: 10px; border-radius: 5px;
  background: var(--bg-sub); border: 1px solid var(--border);
}
input[type="range"]::-moz-range-thumb {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--card); cursor: pointer;
}

/* ---------- 선택 버튼 그룹 ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  min-height: 52px;
  padding: 0 18px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
}

.field-label {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dim);
  margin: 0 0 10px;
}

/* ---------- 안내 문구 ---------- */
.note {
  background: var(--bg-sub);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 16.5px;
  color: var(--text-dim);
  margin: 16px 0 0;
}
.note strong { color: var(--text); }

/* 용어 옆 괄호 설명 — 전문 용어를 그냥 두지 않는다 */
.term-sub { font-size: .82em; font-weight: 500; color: var(--text-dim); }

/* ---------- 홈 카드 ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 620px) {
  .tool-grid { grid-template-columns: 1fr 1fr; }
}
.tool-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px;
}
.tool-card__icon { font-size: 34px; line-height: 1; }
.tool-card__title {
  font-size: 22px; font-weight: 800; margin: 10px 0 4px; letter-spacing: -.02em;
}
.tool-card__desc { font-size: 16.5px; color: var(--text-dim); margin: 0; }

/* ---------- 하단 탭바 ----------
   40~50대가 가장 못 찾는 UI가 햄버거 메뉴(☰)다. 항상 보이는 탭바로 간다. */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 66px;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
}
.tabbar__item[aria-current="page"] { color: var(--accent); }
.tabbar__icon { font-size: 23px; line-height: 1; }

/* ---------- 광고 자리 ----------
   광고는 홈·글 페이지에만. 튜너/메트로놈 화면 안에는 넣지 않는다.
   연습 중 광고는 곧바로 이탈로 이어진다. */
.ad-slot {
  margin: 28px auto;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 26px 16px 10px;
  text-align: center;
  color: var(--text-dim);
  font-size: 15px;
}

/* ---------- 되돌아가기 ----------
   40~50대는 브라우저 뒤로가기 버튼을 잘 안 쓴다. 화면 안에 명시적으로 둔다. */
.backlink {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.backlink:hover { color: var(--accent); }

/* ---------- 글 ---------- */
.article h2 { font-size: 24px; margin-top: 0; letter-spacing: -.02em; }
.article h3 { font-size: 19px; margin: 24px 0 8px; }
.article p  { margin: 0 0 14px; }
.article ol, .article ul { margin: 0 0 14px; padding-left: 22px; }
.article li { margin-bottom: 8px; }
.article table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 16.5px; }
.article th, .article td { border: 1px solid var(--border); padding: 10px 12px; text-align: left; }
.article th { background: var(--bg-sub); font-weight: 700; }
/* 표가 좁은 화면을 밀어내지 않게 — 표만 따로 가로 스크롤 */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.article-meta { font-size: 15px; color: var(--text-dim); margin: 0 0 20px; }

.article-list { list-style: none; padding: 0; margin: 0; }
.article-list li { border-bottom: 1px solid var(--border); }
.article-list li:last-child { border-bottom: 0; }
.article-list a {
  display: block; padding: 18px 4px; text-decoration: none; color: inherit;
}
.article-list a:hover { background: var(--bg-sub); }
.article-list__title { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.article-list__desc  { font-size: 16px; color: var(--text-dim); margin-top: 4px; }

/* 다음에 읽을 글 — 체류시간(=광고 노출)을 늘리는 가장 확실한 장치 */
.next-reads { display: grid; gap: 10px; }
.next-reads a {
  display: block; padding: 16px 18px; border: 1px solid var(--border);
  border-radius: 12px; text-decoration: none; color: inherit; background: var(--card);
  font-weight: 700; font-size: 17px;
}
.next-reads a:hover { border-color: var(--accent); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   인쇄 ----------------------------------------------------------------------
   사용자는 음악 강사고, 결과물이 종이로 나가는 경우가 많다.
   화면용 요소(탭바·헤더·광고·버튼)는 전부 빼고 A4에 맞춘다.
   ========================================================================== */
@media print {
  @page { size: A4 portrait; margin: 14mm; }

  html, body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt;
    line-height: 1.5;
    padding-bottom: 0;
  }
  /* 인쇄에서는 다크 모드를 강제로 끈다 — 안 그러면 잉크를 다 쓴다 */
  [data-theme="dark"] {
    --bg: #fff; --bg-sub: #f2f2f2; --card: #fff;
    --border: #999; --text: #000; --text-dim: #444; --accent: #000;
  }

  .site-header, .tabbar, .site-footer, .ad-slot,
  .theme-toggle, .backlink, .no-print, .btn {
    display: none !important;
  }

  .wrap { max-width: none; padding: 0; }
  .card {
    border: 1px solid #999; box-shadow: none; break-inside: avoid;
    page-break-inside: avoid; margin-bottom: 8mm; padding: 6mm;
  }
  .page-title { font-size: 18pt; margin: 0 0 2mm; }
  .page-lead  { font-size: 10pt; margin-bottom: 5mm; }
  h2 { break-after: avoid; page-break-after: avoid; }
  a { color: #000; text-decoration: none; }

  .print-break { break-before: page; page-break-before: always; }
}
