/* 네이버 SEO 체크 — 스타일 (모바일 · 태블릿 우선) */

:root {
  --green: #03c75a;
  --green-strong: #00b351;
  --green-soft: rgba(3, 199, 90, 0.1);
  --green-ink: #04803c;
  --bg: #eef2f0;
  --bg-grad: radial-gradient(120% 90% at 50% -10%, #dff5e8 0%, #eef2f0 55%, #eef2f0 100%);
  --card: #ffffff;
  --text: #15191a;
  --text-soft: #4b5563;
  --muted: #7b8794;
  --line: #e3e8e5;
  --warn: #d99400;
  --warn-soft: rgba(224, 165, 0, 0.12);
  --fail: #d5372f;
  --fail-soft: rgba(213, 55, 47, 0.1);
  --pass-soft: rgba(3, 199, 90, 0.12);
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 32, 0.04), 0 10px 30px -18px rgba(16, 24, 32, 0.25);
  --shadow-strong: 0 18px 40px -24px rgba(3, 120, 60, 0.5);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --font: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic",
    "맑은 고딕", "Noto Sans KR", system-ui, Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101413;
    --bg-grad: radial-gradient(120% 90% at 50% -10%, #0d2b1b 0%, #101413 60%);
    --card: #181d1c;
    --text: #f2f5f3;
    --text-soft: #b6c0ba;
    --muted: #8b968f;
    --line: #262e2b;
    --green-soft: rgba(3, 199, 90, 0.16);
    --green-ink: #4bdd8c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 28px -20px rgba(0, 0, 0, 0.8);
    --shadow-strong: 0 18px 40px -26px rgba(0, 0, 0, 0.9);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
p,
ol,
ul {
  margin: 0;
}

ul,
ol {
  padding: 0;
}

a {
  color: var(--green-ink);
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--green-soft);
  padding: 0.1em 0.35em;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 50;
  padding: 10px 16px;
  background: var(--card);
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus {
  left: 0;
}

/* ------------------------------ 헤더 ------------------------------ */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 18px 10px;
  background: var(--card);
  background: color-mix(in srgb, var(--card) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  box-shadow: 0 4px 10px -6px rgba(3, 120, 60, 0.7);
  flex: none;
}

.brand-text h1 {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-text p {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------ 레이아웃 ------------------------------ */

.app-main {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card-title {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* ------------------------------ 검색 ------------------------------ */

.field-label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-soft);
}

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

#urlInput {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 14px;
  font-family: var(--font);
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#urlInput::placeholder {
  color: var(--muted);
}

#urlInput:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}

.primary-btn {
  flex: none;
  min-width: 96px;
  height: 52px;
  padding: 0 18px;
  font-family: var(--font);
  font-size: 0.98rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #05d763 0%, var(--green) 60%, var(--green-strong) 100%);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-strong);
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.primary-btn:hover {
  transform: translateY(-1px);
}
.primary-btn:active {
  transform: translateY(0) scale(0.99);
}
.primary-btn[disabled] {
  opacity: 0.6;
  cursor: progress;
  transform: none;
}

.field-help {
  margin-top: 8px;
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.chips-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  margin-right: 2px;
}

.chip {
  padding: 7px 12px;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--green-ink);
  background: var(--green-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.chip:hover {
  border-color: color-mix(in srgb, var(--green) 45%, transparent);
}

.ghost-btn {
  padding: 9px 14px;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--green-ink);
  background: var(--green-soft);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.ghost-btn:hover {
  border-color: color-mix(in srgb, var(--green) 40%, transparent);
}

.ghost-btn.small {
  padding: 6px 10px;
  font-size: 0.78rem;
}

:where(button, a, input):focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* ------------------------------ 로딩 ------------------------------ */

.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 26px 18px;
}

.spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid var(--green-soft);
  border-top-color: var(--green);
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-soft);
}

.steps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 10px;
  list-style: none;
  font-size: 0.74rem;
  color: var(--muted);
}

.steps li::before {
  content: "○ ";
}

.steps li.is-done {
  color: var(--green-ink);
}
.steps li.is-done::before {
  content: "● ";
}

/* ------------------------------ 오류 ------------------------------ */

.error-card {
  border-color: color-mix(in srgb, var(--fail) 30%, var(--line));
  background: linear-gradient(180deg, var(--fail-soft), transparent 70%), var(--card);
}

.error-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--fail);
}

.error-message {
  margin-top: 6px;
  font-size: 0.9rem;
  color: var(--text);
}

.error-detail {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.error-card .ghost-btn {
  margin-top: 12px;
}

/* ------------------------------ 결과 ------------------------------ */

.result {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.notice {
  padding: 13px 15px;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-soft);
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: var(--radius);
}

.score-card {
  padding: 20px 18px 16px;
}

.score-top {
  display: flex;
  align-items: center;
  gap: 18px;
}

.gauge {
  position: relative;
  width: 116px;
  height: 116px;
  flex: none;
}

.gauge-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-track {
  fill: none;
  stroke: var(--green-soft);
  stroke-width: 10;
}

.gauge-bar {
  fill: none;
  stroke: var(--green);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke 0.3s ease;
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.gauge-score {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.gauge-max {
  margin-top: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
}

.score-summary {
  min-width: 0;
  flex: 1;
}

.score-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
  background: var(--green);
  border-radius: 9px;
}

.score-title {
  font-size: 1rem;
  font-weight: 700;
}

.score-url {
  margin-top: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-soft);
  word-break: break-all;
}

.score-counts {
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--muted);
}

.score-time {
  margin-top: 2px;
  font-size: 0.72rem;
  color: var(--muted);
}

.score-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.category-bars {
  display: grid;
  gap: 9px;
  margin-top: 18px;
  list-style: none;
}

.category-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  font-size: 0.78rem;
}

.category-bar span:first-child {
  color: var(--text-soft);
  font-weight: 600;
}

.category-bar .category-value {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.category-track {
  grid-column: 1 / -1;
  height: 7px;
  overflow: hidden;
  background: var(--green-soft);
  border-radius: 999px;
}

.category-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--green), #4bdd8c);
  border-radius: inherit;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ------------------------------ 필터 ------------------------------ */

.filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter {
  flex: none;
  padding: 9px 14px;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.filter.is-active {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 6px 14px -10px rgba(3, 120, 60, 0.9);
}

.filter .filter-count {
  margin-left: 5px;
  font-size: 0.72rem;
  opacity: 0.75;
}

/* ------------------------------ 항목 카드 ------------------------------ */

.items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.item[hidden] {
  display: none;
}

.item-head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  width: 100%;
  padding: 13px 16px;
  font-family: var(--font);
  text-align: left;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.head-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  flex: none;
  padding: 3px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 999px;
  letter-spacing: -0.01em;
}

.status-pass {
  color: var(--green-ink);
  background: var(--pass-soft);
}
.status-warn {
  color: #8a5f00;
  background: var(--warn-soft);
}
.status-fail {
  color: var(--fail);
  background: var(--fail-soft);
}

@media (prefers-color-scheme: dark) {
  .status-warn {
    color: #f0be4d;
  }
}

.item-title {
  flex: 1;
  min-width: 0;
  font-size: 0.93rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.item-score {
  flex: none;
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
}

.item-score .item-score-max {
  font-weight: 500;
  color: var(--muted);
}

.chev {
  flex: none;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.2s ease;
}

.item-head[aria-expanded="true"] .chev {
  transform: rotate(-135deg) translateY(-2px);
}

.item-summary {
  display: block;
  padding: 0 0 0 2px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-soft);
}

.item-body {
  padding: 0 16px 16px;
  border-top: 1px dashed var(--line);
  margin-top: 0;
  display: grid;
  gap: 10px;
}

.item-body[hidden] {
  display: none;
}

.item-body h4 {
  margin-top: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.item-body h4:first-child {
  margin-top: 14px;
}

.pre-block {
  margin: 0;
  padding: 11px 12px;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text);
  background: color-mix(in srgb, var(--bg) 70%, var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.guide-text {
  font-size: 0.83rem;
  line-height: 1.62;
  color: var(--text-soft);
}

.snippet {
  margin-top: 4px;
  border: 1px solid color-mix(in srgb, var(--green) 30%, var(--line));
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.snippet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  background: var(--green-soft);
}

.snippet-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--green-ink);
}

.copy-btn {
  padding: 5px 11px;
  font-family: var(--font);
  font-size: 0.74rem;
  font-weight: 700;
  color: #fff;
  background: var(--green);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.copy-btn:active {
  transform: scale(0.97);
}

.copy-btn.is-copied {
  background: var(--green-ink);
}

.snippet pre {
  margin: 0;
  padding: 11px 12px;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: var(--text);
}

/* ------------------------------ 다음 단계 ------------------------------ */

.next-card {
  background: linear-gradient(180deg, var(--green-soft), transparent 65%), var(--card);
}

.next-list {
  margin-top: 10px;
  padding-left: 18px;
  display: grid;
  gap: 7px;
  font-size: 0.83rem;
  line-height: 1.55;
  color: var(--text-soft);
}

/* ------------------------------ 최근 기록 ------------------------------ */

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-empty {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

.history-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  list-style: none;
}

.history-list:empty {
  display: none;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font);
  text-align: left;
  color: inherit;
  background: color-mix(in srgb, var(--bg) 55%, var(--card));
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.history-row:hover {
  border-color: var(--line);
}

.history-grade {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  font-size: 0.76rem;
  font-weight: 800;
  color: #fff;
  border-radius: 8px;
}

.history-main {
  flex: 1;
  min-width: 0;
}

.history-url {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta {
  display: block;
  margin-top: 1px;
  font-size: 0.72rem;
  color: var(--muted);
}

.history-score {
  flex: none;
  font-size: 0.9rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
}

/* ------------------------------ 푸터 · 토스트 ------------------------------ */

.app-footer {
  max-width: 860px;
  margin: 0 auto;
  padding: 4px 20px calc(26px + env(safe-area-inset-bottom));
}

.app-footer p {
  font-size: 0.72rem;
  line-height: 1.6;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 40;
  transform: translate(-50%, 12px);
  padding: 11px 18px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #fff;
  background: rgba(18, 24, 21, 0.92);
  border-radius: 999px;
  box-shadow: 0 12px 30px -14px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------ 태블릿 · 데스크톱 ------------------------------ */

@media (min-width: 720px) {
  body {
    font-size: 16.5px;
  }

  .app-main {
    padding: 22px 22px 10px;
    gap: 16px;
  }

  .app-header {
    padding: 14px 26px;
  }

  .card {
    padding: 22px;
  }

  .score-card {
    padding: 24px 24px 20px;
  }

  .gauge {
    width: 136px;
    height: 136px;
  }

  .gauge-score {
    font-size: 2.5rem;
  }

  .search-card form {
    display: block;
  }

  .items {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  #items {
    grid-template-columns: 1fr;
  }

  .score-top {
    gap: 24px;
  }
}

@media (min-width: 1000px) {
  .app-main {
    padding-top: 28px;
  }

  .score-card {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    align-items: center;
    gap: 8px 28px;
  }

  .category-bars {
    margin-top: 0;
    padding-left: 24px;
    border-left: 1px solid var(--line);
  }
}

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