/* 디자인 토큰. 색은 라이트 기본값이고 다크모드는 아래 미디어쿼리에서 덮어씀 */
:root {
  color-scheme: light;
  --background: #f7f8fa;
  --surface: #fff;
  --text: #172136;
  --muted: #5c667a;
  --line: #e1e6ee;
  --input-border: #aab3c2;
  --accent: #315bdf;
  --accent-hover: #2448bb;
  --accent-soft: #e9eefc;
  --on-accent: #fff;
  --danger: #c23b3b;
  --result-bg: #f0f3f9;
  --shadow-focus: 0 0 0 3px var(--accent);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --radius-s: 8px;
  --radius-l: 12px;

  --text-xs: 12px;
  --text-s: 14px;
  --text-m: 16px;
  --text-l: 18px;
  --text-xl: 22px;

  --tap: 44px;

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
  color: var(--text);
  background: var(--background);
  scroll-behavior: smooth;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --background: #0f1420;
    --surface: #171d2b;
    --text: #e8ecf4;
    --muted: #a3adc2;
    --line: #2a3345;
    --input-border: #5c6a85;
    --accent: #8aa4ff;
    --accent-hover: #a6baff;
    --accent-soft: #1e2a4a;
    --on-accent: #0f1420;
    --danger: #ff8a8a;
    --result-bg: #1c2436;
  }
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; }
a:focus-visible { outline: 3px solid var(--accent); outline-offset: 5px; }
.wrap { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }

/* 헤더 */
.site-header { display: flex; align-items: center; justify-content: space-between; min-height: 72px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-size: 20px; font-weight: 750; letter-spacing: -0.04em; }
.nav-link { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 0 0 var(--space-3); font-size: var(--text-s); color: var(--muted); text-decoration: none; }
.nav-link:hover { color: var(--accent); }
.skip-link { position: absolute; z-index: 1; top: -100px; left: 20px; padding: var(--space-3); border-radius: var(--radius-s); background: var(--surface); }
.skip-link:focus { top: 12px; }

/* 홈 */
.hero { padding-block: var(--space-7) var(--space-5); }
.eyebrow { display: inline-block; margin: 0; color: var(--accent); font-size: 13px; font-weight: 650; letter-spacing: 0.03em; }
h1 { margin: var(--space-3) 0; font-size: clamp(28px, 4vw, 42px); font-weight: 760; letter-spacing: -0.05em; line-height: 1.25; word-break: keep-all; }
.hero-description { margin: 0; color: var(--muted); font-size: var(--text-m); line-height: 1.8; word-break: keep-all; }
.topics { padding-bottom: var(--space-7); scroll-margin-top: 28px; }
h2 { margin: 10px 0 0; font-size: 24px; letter-spacing: -0.04em; }
.tool-group { margin-top: var(--space-5); }
.tool-group h3 { margin: 0 0 var(--space-3); font-size: var(--text-s); font-weight: 650; color: var(--muted); letter-spacing: 0.02em; }
.tool-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.tool-list li { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4) 20px; border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); }
.tool-list a { color: var(--accent); font-size: 17px; font-weight: 650; letter-spacing: -0.02em; text-decoration: none; }
.tool-list a:hover { text-decoration: underline; }
.tool-list span { color: var(--muted); font-size: var(--text-s); word-break: keep-all; }
.not-found { padding-block: 110px 150px; }
.not-found h1 { font-size: clamp(30px, 4vw, 48px); }

/* 푸터 */
.site-footer { display: grid; gap: var(--space-4); padding-block: var(--space-5) var(--space-6); border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.site-footer p { margin: 0; }
.footer-tools, .footer-nav { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); }
.footer-tools a, .footer-nav a { display: inline-flex; align-items: center; min-height: 36px; color: var(--muted); text-decoration: none; }
.footer-tools a:hover, .footer-nav a:hover { color: var(--accent); text-decoration: underline; }
.footer-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-5); }

/* 도구 페이지 공통 */
.tool-page { padding-block: var(--space-5) var(--space-7); }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: 13px; }
.breadcrumb li + li::before { content: "›"; margin-right: var(--space-2); }
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
.tool-page h1 { margin: var(--space-3) 0 var(--space-2); font-size: clamp(26px, 4vw, 38px); }
.tool-summary { margin: 0 0 var(--space-4); font-size: var(--text-m); line-height: 1.7; word-break: keep-all; }
.tool-lead { margin: var(--space-6) 0 0; color: var(--muted); font-size: 15px; line-height: 1.8; word-break: keep-all; }
.tool-lead + .tool-lead { margin-top: var(--space-3); }

/* 계산 종류 탭 */
.mode-tabs { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-3); }
.mode-tabs [role="tab"] { flex: 0 0 auto; min-height: var(--tap); padding: 0 var(--space-4); border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; font-size: var(--text-s); font-weight: 600; cursor: pointer; white-space: nowrap; }
.mode-tabs [role="tab"][aria-selected="true"] { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.mode-tabs [role="tab"]:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.tool-section { margin-bottom: var(--space-5); padding: var(--space-5); border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); }
.tool-section[hidden] { display: none; }
.tool-section h2 { margin: 0 0 var(--space-1); font-size: var(--text-l); }
.tool-hint { margin: 0 0 var(--space-4); color: var(--muted); font-size: var(--text-s); line-height: 1.7; word-break: keep-all; }

/* 입력 */
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-4); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: var(--text-s); }
.field-label { font-weight: 600; }
.field-example { margin-left: 2px; color: var(--muted); font-size: 13px; font-weight: 400; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.field input, .field select, .field textarea { width: 100%; min-height: var(--tap); padding: 10px 14px; border: 1px solid var(--input-border); border-radius: var(--radius-s); font: inherit; font-size: var(--text-m); color: var(--text); background: var(--surface); }
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .tool-form button:focus-visible, .result:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.field [aria-invalid="true"] { border-color: var(--danger); }
.input-wrap { position: relative; display: block; }
.input-wrap[data-unit]::after { content: attr(data-unit); position: absolute; top: 50%; right: 14px; transform: translateY(-50%); color: var(--muted); font-size: var(--text-s); pointer-events: none; }
.input-wrap[data-unit] input { padding-right: 56px; }
.input-wrap-action { display: flex; gap: var(--space-2); }
.input-wrap-action input { flex: 1 1 auto; min-width: 0; }
.input-wrap-action button { flex: 0 0 auto; white-space: nowrap; }

/* 버튼 */
.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
.tool-form button { min-height: var(--tap); padding: 0 var(--space-4); border: 1px solid var(--accent); border-radius: var(--radius-s); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.button-primary { color: var(--on-accent); background: var(--accent); }
.button-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button-secondary { color: var(--accent); background: var(--surface); }
.button-secondary:hover { background: var(--accent-soft); }
.tool-form .button-ghost { color: var(--muted); border-color: var(--line); background: var(--surface); }
.tool-form .button-ghost:hover { color: var(--text); border-color: var(--muted); }
.tool-form .button-small { min-height: 40px; padding: 0 var(--space-3); font-size: var(--text-s); }
.button { display: inline-flex; justify-content: center; align-items: center; gap: var(--space-3); min-height: var(--tap); margin-top: var(--space-4); padding: 0 20px; border-radius: var(--radius-s); background: var(--accent); color: var(--on-accent); text-decoration: none; font-size: 15px; font-weight: 600; }
.button:hover { background: var(--accent-hover); }

/* 오류와 결과 */
.form-error { margin: var(--space-3) 0 0; color: var(--danger); font-size: var(--text-s); }
.form-error:empty, .copy-status:empty { display: none; }
.result { display: grid; gap: var(--space-1); margin-top: var(--space-4); padding: var(--space-4) 20px; border-radius: var(--radius-l); background: var(--result-bg); overflow-wrap: anywhere; }
.result[hidden], .result-actions[hidden] { display: none; }
.result-value { font-size: clamp(24px, 6vw, 32px); font-weight: 750; letter-spacing: -0.03em; line-height: 1.3; }
.result-detail { color: var(--muted); font-size: 15px; font-weight: 500; line-height: 1.6; }
.result-detail[hidden] { display: none; }
.result-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.copy-status { margin: var(--space-2) 0 0; color: var(--muted); font-size: 13px; }

/* 설명과 FAQ */
.tool-notes { margin-top: var(--space-6); }
.tool-notes h2 { margin: 0 0 var(--space-3); font-size: var(--text-l); }
.tool-notes ul { margin: 0; padding-left: 20px; color: var(--muted); font-size: var(--text-s); line-height: 1.9; word-break: keep-all; }
.tool-notes li { margin-bottom: var(--space-1); }
.tool-notes p { color: var(--muted); font-size: var(--text-s); line-height: 1.8; word-break: keep-all; }
.tool-notes a { color: var(--accent); }
.tool-notes table { width: 100%; margin: var(--space-3) 0; border-collapse: collapse; font-size: var(--text-s); }
.tool-notes caption { margin-bottom: var(--space-2); color: var(--muted); text-align: left; }
.tool-notes th, .tool-notes td { padding: 10px var(--space-3); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tool-notes th { font-weight: 600; }
.tool-faq h3 { margin: var(--space-4) 0 var(--space-1); font-size: var(--text-m); letter-spacing: -0.02em; }
.tool-faq p { margin: 0; }
.related-tools { margin-top: var(--space-6); }
.related-tools h2 { margin: 0 0 var(--space-3); font-size: var(--text-l); }

/* 안내 페이지: 소개, 개인정보처리방침, 문의 */
.text-page section { margin-top: var(--space-6); }
.text-page h2 { margin: 0 0 10px; font-size: var(--text-l); }
.text-page p, .text-page li { color: var(--muted); font-size: 15px; line-height: 1.9; word-break: keep-all; }
.text-page p { margin: 0 0 var(--space-3); }
.text-page .tool-lead { margin: 0; font-size: var(--text-m); }
.text-page ul { margin: 0; padding-left: 20px; }
.text-page li { margin-bottom: var(--space-1); }
.text-page a { color: var(--accent); }
.contact-email { display: inline-block; margin: 2px 0 var(--space-3); font-size: 20px; font-weight: 650; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.text-page .page-date { margin: var(--space-6) 0 0; font-size: 13px; }

@media (max-width: 760px) {
  .wrap { width: calc(100% - 32px); }
  .site-header { min-height: 64px; }
  .hero { padding-block: var(--space-6) var(--space-4); }
  .tool-page { padding-block: var(--space-4) var(--space-7); }
  .tool-section { padding: var(--space-4); }
  .tool-list { grid-template-columns: 1fr; }
  .topics { padding-bottom: var(--space-7); }
  .not-found { padding-block: 80px 110px; }
}

@media (prefers-reduced-motion: reduce) {
  :root { scroll-behavior: auto; }
}
