:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6ea;
  --text: #1a1d21;
  --text-soft: #5b626b;
  --text-faint: #8b929b;
  --accent: #2f6df6;
  --accent-hover: #2257d0;
  --accent-soft: #e8f0fe;
  --danger: #d93b3b;
  --success: #17915b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);

  /* 차트 전용 색. 버튼용 --accent 와 분리해 둔다.
     기준: OKLCH 밝기 대역과 표면 대비를 통과한 값만 쓴다. (라이트 표면 #ffffff) */
  --chart-1: #2f6df6;
  --chart-grid: #e8ebef;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* 다크는 라이트 색을 뒤집지 않고 다크 표면(#1c2027)에 맞춰 따로 고른 값이다. */
    --chart-1: #5c90f0;
    --chart-grid: #2c323b;
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c;
    --surface: #1c2027;
    --surface-2: #242932;
    --border: #2f353f;
    --text: #e9ecf1;
    --text-soft: #a8b0bb;
    --text-faint: #767e8a;
    --accent: #6f9bff;
    --accent-hover: #89aeff;
    --accent-soft: #1e2a44;
    --danger: #ff7b7b;
    --success: #4fc98d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.wrap-wide { max-width: 900px; margin: 0 auto; padding: 0 16px; }

/* ===== 헤더 ===== */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.site-header .wrap-wide {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
}
.logo { font-size: 18px; font-weight: 800; color: var(--text); letter-spacing: -.02em; }
.logo:hover { text-decoration: none; }
.site-nav { display: flex; gap: 18px; font-size: 14px; }
.site-nav a { color: var(--text-soft); }

/* ===== 히어로 / 폼 ===== */
.hero { text-align: center; padding: 48px 0 28px; }
.hero h1 { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.3; }
.hero p { margin-top: 10px; color: var(--text-soft); font-size: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.shorten-row { display: flex; gap: 8px; }

input[type="url"], input[type="text"], select, textarea {
  width: 100%;
  padding: 13px 14px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--text-faint); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 20px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 10px;
  cursor: pointer;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: progress; }

.btn-sub {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
  font-size: 14px;
  padding: 10px 14px;
}
.btn-sub:hover { background: var(--border); border-color: var(--border); }

/* 커스텀 주소 접기/펼치기 */
.alias-toggle {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}
.alias-toggle::marker { color: var(--text-faint); }
.alias-body { margin-top: 12px; }
.alias-input-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--text-soft);
}
.alias-input-row .host { white-space: nowrap; }
.hint { margin-top: 8px; font-size: 13px; color: var(--text-faint); }

.form-error {
  margin-top: 12px; padding: 11px 14px;
  font-size: 14px; color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border-radius: 10px;
}

/* ===== 결과 ===== */
.result { margin-top: 16px; }
.result-label { font-size: 13px; font-weight: 700; color: var(--text-faint); letter-spacing: .04em; }
.result-url {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
}
.result-url input {
  font-size: 16px; font-weight: 700; color: var(--accent);
  background: var(--surface-2);
}
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.result-origin {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-faint); word-break: break-all;
}
.qr-box { margin-top: 16px; text-align: center; }
.qr-box canvas, .qr-box img {
  background: #fff; padding: 12px; border-radius: 10px; border: 1px solid var(--border);
}

/* ===== 광고 ===== */
.ad-slot {
  margin: 24px auto;
  text-align: center;
  min-height: 0;
  overflow: hidden;
}
.ad-disclosure {
  margin: 10px auto 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-faint);
  text-align: center;
}

/* ===== 본문 섹션 ===== */
.section { margin: 44px 0; }
.section h2 {
  font-size: 20px; font-weight: 800; letter-spacing: -.02em;
  padding-bottom: 10px; border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.section h3 { font-size: 16px; font-weight: 700; margin: 20px 0 6px; }
.section p { color: var(--text-soft); margin-bottom: 10px; }
.section ul, .section ol { color: var(--text-soft); padding-left: 20px; }
.section li { margin-bottom: 6px; }

.steps { list-style: none; padding: 0; counter-reset: step; }
.steps li {
  position: relative; padding-left: 38px; margin-bottom: 14px; counter-increment: step;
}
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 1px;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  color: var(--accent); background: var(--accent-soft);
}

.faq-item { border-bottom: 1px solid var(--border); padding: 14px 0; }
.faq-item:last-child { border-bottom: none; }
.faq-item summary {
  font-weight: 700; cursor: pointer; list-style: none;
  display: flex; justify-content: space-between; gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; color: var(--text-faint); font-weight: 400; }
.faq-item[open] summary::after { content: "−"; }
.faq-item p { margin-top: 10px; margin-bottom: 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; border: 1px solid var(--border); text-align: left; }
th { background: var(--surface-2); font-weight: 700; }

/* ===== 링크 목록 / 통계 ===== */
.link-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.link-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.link-item-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.link-item-short { font-weight: 700; color: var(--accent); }
.link-item-origin { font-size: 13px; color: var(--text-faint); word-break: break-all; margin-top: 4px; }
.link-item-meta { font-size: 12px; color: var(--text-faint); margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; }
.link-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn {
  padding: 6px 10px; font-size: 12px; font-weight: 600;
  color: var(--text-soft); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.icon-btn:hover { background: var(--border); }

.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.stat-tile {
  flex: 1 1 140px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.stat-tile .k { font-size: 12px; color: var(--text-faint); font-weight: 600; }
.stat-tile .v { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }

.empty {
  text-align: center; padding: 48px 16px; color: var(--text-faint);
  border: 1px dashed var(--border); border-radius: var(--radius);
}

/* ===== 차트 ===== */
.chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.chart-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.chart-title { font-size: 15px; font-weight: 700; }
.chart-sub { font-size: 12px; color: var(--text-faint); }

/* 축 라벨이 들어갈 높이까지 포함해 컨테이너를 잡는다. 안 그러면 카드 안에 스크롤이 생긴다. */
.chart-plot { position: relative; width: 100%; }
.chart-plot svg { display: block; width: 100%; height: auto; }

.chart-grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart-bar { fill: var(--chart-1); }
.chart-hit { fill: transparent; cursor: pointer; }
.chart-hit:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chart-axis-text {
  fill: var(--text-faint); font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.chart-peak-text { fill: var(--text-soft); font-size: 11px; font-weight: 700; }

.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  padding: 7px 10px; border-radius: 8px;
  background: var(--text); color: var(--bg);
  font-size: 12px; line-height: 1.5; white-space: nowrap;
  transform: translate(-50%, -100%);
  opacity: 0; transition: opacity .12s ease;
}
.chart-tip.show { opacity: 1; }
.chart-tip b { font-size: 13px; }

.table-toggle {
  margin-top: 14px; display: flex; justify-content: flex-end;
}
.data-table { margin-top: 12px; }
.data-table td:last-child, .data-table th:last-child {
  text-align: right; font-variant-numeric: tabular-nums;
}

/* 유입 경로: 가로 막대 목록 */
.bar-list { list-style: none; padding: 0; margin: 0; }
.bar-list li { padding: 9px 0; border-bottom: 1px solid var(--border); }
.bar-list li:last-child { border-bottom: none; }
.bar-list .row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  font-size: 14px; margin-bottom: 6px;
}
.bar-list .host { color: var(--text); word-break: break-all; }
.bar-list .n { color: var(--text-soft); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.bar-list .track { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar-list .fill { height: 100%; border-radius: 3px; background: var(--chart-1); }

/* ===== 알림 페이지 (404 등) ===== */
.notice { text-align: center; padding: 90px 16px; }
.notice-code { font-size: 13px; font-weight: 700; color: var(--text-faint); letter-spacing: .1em; }
.notice h1 { font-size: 24px; font-weight: 800; margin: 8px 0 10px; }
.notice-msg { color: var(--text-soft); margin-bottom: 24px; }

/* ===== 토스트 ===== */
.toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(90px);
  padding: 12px 22px; border-radius: 10px;
  background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; z-index: 100;
  transition: opacity .25s ease, transform .25s ease;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); color: #fff; }

/* ===== 푸터 ===== */
.site-footer {
  margin-top: 60px; padding: 28px 0 40px;
  border-top: 1px solid var(--border); background: var(--surface);
}
.footer-nav {
  display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center;
  font-size: 14px; margin-bottom: 14px;
}
.footer-nav a { color: var(--text-soft); }
.footer-biz {
  text-align: center; font-size: 12px; line-height: 1.8; color: var(--text-faint);
}
.footer-biz span { margin: 0 6px; }

@media (max-width: 600px) {
  .hero { padding: 32px 0 20px; }
  .hero h1 { font-size: 24px; }
  .shorten-row { flex-direction: column; }
  .site-nav { gap: 12px; font-size: 13px; }
  .result-url { flex-direction: column; align-items: stretch; }
}
