/* === TrustStat global theme tokens === */
:root,
[data-theme="light"]{
  --bg:#ffffff;
  --surface:#ffffff;
  --surface-2:#f8fafc;
  --text:#111827;
  --muted:#6b7280;
  --border:#e5e7eb;
  --primary:#3b82f6;

  color-scheme:light;
}
[data-theme="dark"]{
  --bg:#0b0f14;
  --surface:#13151a;
  --surface-2:#151c23;
  --text:#e7ebef;
  --muted:#9aa1ab;
  --border:#2a2f36;
  --primary:#60a5fa;

  color-scheme:dark;
}

html,
body{
  background:var(--bg);
  color:var(--text);
}
.site-header,
.zip-header,
.zip-nav,
.nav{
  background:var(--surface);
  color:var(--text);
}

/* 기본 카드/버튼/배지 */
.card{
  background:var(--surface);
  color:var(--text);
}
.muted{
  color:var(--muted);
}

.btn{
  background:var(--surface);
  color:var(--text);
  border-radius:10px;
  padding:8px 12px;
}
.btn.primary{
  background:var(--primary);
  color:#fff;
  border:none;
}

.badge{
  display:inline-block;
  padding:2px 10px;
  font-size:12px;
  text-decoration:none;
  line-height:20px;
  border:1px solid var(--border);
  border-radius:999px;
}
.badge:hover{
  background:var(--surface-2);
}

/* KPI 안의 점수 배지는 숫자만 크게 */
.kpi-value .badge{
  background:none;
  color:#333;
  font-size:26px;
  line-height:35px;
  border:none;
}

/* ===================================================================
   Domain detail base layout + overflow guard
   =================================================================== */

.analysis-shell{
  width:100%;
}
.analysis-main{
  margin:0 auto;
  padding:16px;
}
@media (max-width:768px){
  .analysis-main{
    max-width:100%;
    padding:12px;
  }
}

/* 도메인 상세 페이지 공통 */
body.domain-page{
  overflow-x:hidden;
}

/* 도메인 상세 레이아웃 통일 (PC 960px, 모바일 100%) */
body.domain-page .analysis-shell{
  display:block;
  width:100%;
  max-width:100%;
}
body.domain-page .analysis-main{
  box-sizing:border-box;
  width:100%;
  max-width:1100px;
  margin:0 auto;
}

/* 카드 공통 & 그리드 강제 1열 (기본) */
body.domain-page .card.section{
  margin:10px 0;

}
body.domain-page .kpi,
body.domain-page .grid-2,
body.domain-page .grid.cols-2,
body.domain-page .grid.cols-3{
  display:grid;
  grid-template-columns:1fr !important;
  gap:12px;
}

/* KPI 2/4열은 breakpoint 기준으로 */
@media (min-width:640px){
  body.domain-page .kpi{
    grid-template-columns:repeat(2,minmax(0,1fr)) !important;
  }
}
@media (min-width:1024px){
  body.domain-page .kpi{
    grid-template-columns:repeat(4,minmax(0,1fr)) !important;
  }
}

/* 모바일 fallback (container query 미지원 브라우저용) */
@media (max-width:900px){
  body.domain-page .analysis-shell{
    grid-template-columns:1fr !important;
  }
  body.domain-page .grid-2,
  body.domain-page .grid.cols-2,
  body.domain-page .grid.cols-3{
    grid-template-columns:1fr !important;
  }
  body.domain-page .kpi{
    grid-template-columns:repeat(2,minmax(0,1fr)) !important;
  }
}
@media (max-width:540px){
  body.domain-page .kpi{
    grid-template-columns:1fr !important;
  }
}

/* 가로 오버플로우 방지: 카드/텍스트/코드/metric */
.analysis-main,
.card{
  min-width:0;
}
.card p,
.card .muted,
.kpi .kpi-value,
.kpi .kpi-label,
.list-pills li,
.chip span{
  overflow-wrap:anywhere;
  word-break:break-word;
}
.card pre{
  max-width:100%;
  overflow:auto;
}

/* 긴 코드/DMARC/TXT 등의 한 줄 문자열 */
body.domain-page .card code{
  font-family:var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace);
  font-size:0.95em;
  overflow-wrap:anywhere;
  word-break:break-all;
}
/* pre 는 카드 안에서만 가로 스크롤 */
body.domain-page .card pre{
  max-width:100%;
  overflow-x:auto;
  white-space:pre-wrap;
  word-break:break-word;
}

/* Latest sites carousel */
#latest-sites .latest-row{
  display:flex;
  gap:8px;
  flex-wrap:nowrap;
  overflow:auto;
  padding-bottom:4px;
  -webkit-overflow-scrolling:touch;
}
#latest-sites .chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:6px 10px;
  border-radius:999px;
  white-space:nowrap;
  text-decoration:none;
  color:inherit;
  background:var(--surface);
}
#latest-sites .chip .favicon{
  border-radius:4px;
  flex:0 0 auto;
}
#latest-sites .latest-row::-webkit-scrollbar{
  height:8px;
}
#latest-sites .latest-row::-webkit-scrollbar-thumb{
  background:rgba(0,0,0,.15);
  border-radius:8px;
}
/* 도메인 상세에서 캐러셀 폭 제한 */
body.domain-page #latest-sites .latest-row{
  max-width:100%;
}

/* ========== Threat insight / Deep scan ========== */
#threat-insight .insight{
  border-radius:12px;
  padding:12px;
}
#threat-insight .verdict{
  font-size:18px;
}
#threat-insight .ok{
  color:#166534;
}
#threat-insight .warn{
  color:#92400e;
}
#threat-insight .bad{
  color:#7f1d1d;
}
#deep-scan .insight .ok{
  color:#166534;
}
#deep-scan .insight .warn{
  color:#92400e;
}
#deep-scan .insight .bad{
  color:#7f1d1d;
}
#deep-scan .insight .na{
  color:#6b7280;
}

/* === Domain detail: 모바일-friendly overrides === */
@media (max-width:768px){

  body.domain-page .analysis-shell{
    display:block;
  }
  body.domain-page .analysis-main{
    max-width:100%;
    padding:12px 12px 20px;
    margin:0;
  }
  body.domain-page .card.section{
    margin:10px 0;

  }
  /* 모든 그리드는 모바일에서 1열 */
  body.domain-page .kpi,
  body.domain-page .grid-2,
  body.domain-page .grid.cols-2,
  body.domain-page .grid.cols-3{
    grid-template-columns:1fr !important;
  }
}

/* ===================================================================
   Score cards (요약 서브 도넛 3개)
   =================================================================== */

#score-cards .grid-2{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr)) !important;
  gap:12px;
  justify-items:center;           /* 각 도넛 카드가 그리드 안에서 가운데 정렬 */
}
@media (max-width:820px){
  #score-cards .grid-2{
    grid-template-columns:1fr;
  }
}

/* 각 도넛 카드 */
.donut-card{
  width:100%;
  max-width:220px;                /* 데스크톱에서 너무 커지지 않게 */
  margin-inline:auto;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
}
.donut-caption{
  font-weight:600;
}

/* 도넛 SVG 크기 조정 – 여기 때문에 튀어나오던 거 줄임 */
.donut-svg{
  width:100%;
  max-width:160px;                /* PC 기준 최대 160px */
  aspect-ratio:1 / 1;
  height:auto;
  overflow:visible;
  display:block;
}
@media (max-width:480px){
  .donut-svg{
    max-width:140px;              /* 아주 좁은 모바일에서 더 줄이기 */
  }
}
.donut-svg .bg{
  stroke:var(--border);
  stroke-width:12;
  fill:none;
}
.donut-svg .fg{
  stroke:currentColor;
  stroke-width:12;
  fill:none;
  stroke-linecap:round;
}
.donut-svg text.value{
  font-size:22px;
  font-weight:700;
  text-anchor:middle;
  dominant-baseline:middle;
  fill:var(--text);
  pointer-events:none;
}
#donut-security .fg{ stroke:#16a34a; }
#donut-reputation .fg{ stroke:#0ea5e9; }
#donut-scam .fg{ stroke:#ef4444; }

/* ===================================================================
   Summary meter (메인 요약 원형 차트)
   =================================================================== */

.meter{
  --p:72;
  --track:var(--border);
  --size:min(160px, 60vw);      /* 화면 폭 기준으로도 제한 */
  --thick:10px;

  position:relative;
  width:var(--size);
  height:var(--size);
  max-width:100%;
  border-radius:50%;
  background:conic-gradient(
    var(--brand-1, var(--primary)) calc(var(--p) * 1%),
    var(--track) 0
  );
}
.meter::before{
  content:"";
  position:absolute;
  inset:var(--thick);
  border-radius:50%;
  background:var(--surface);
}
.meter .val{
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  font-weight:800;
  font-size:clamp(18px, 2.6vw, 24px);
}
.meter .val small{
  font-size:.6em;
  margin-left:2px;
  opacity:.8;
}
.meter.lg{
  --size:min(180px, 70vw);
  --thick:12px;
}

/* Summary 카드 컨테이너는 중앙 정렬 */
.summary-card{
  display:grid;
  gap:12px;
  place-items:center;
}
.summary-list{
  width:100%;
  display:grid;
  gap:8px;
}
.summary-list li{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.summary-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:center;
}

/* ===================================================================
   History sparkline
   =================================================================== */

.sparkline{
  width:100%;
  height:120px;
}
.sparkline .line{
  fill:none;
  stroke:currentColor;
  stroke-width:2;
  stroke-linecap:round;
}
.sparkline .area{
  opacity:.18;
}
.sparkline.positive{
  color:#16a34a;
}
.sparkline.negative{
  color:#ef4444;
}

/* ===================================================================
   Loader / Modal (공통)
   =================================================================== */

.ts-fullloader{
  position:fixed;
  inset:0;
  background:rgba(10,10,15,.75);
  backdrop-filter:blur(8px);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:9999;
}
.ts-hidden{
  display:none;
}

.ts-panel{
  width:min(560px,92vw);
  background:var(--surface);
  color:var(--text);
  border-radius:14px;
  padding:20px;
}
.ts-spinner{
  width:42px;
  height:42px;
  border:4px solid rgba(0,0,0,.15);
  border-top-color:var(--primary);
  border-radius:50%;
  animation:ts-spin 1s linear infinite;
  margin:0 auto;
}
@keyframes ts-spin{
  to{ transform:rotate(360deg); }
}

.ts-steps{
  max-height:32vh;
  overflow:auto;
  margin:10px 0;
  padding-left:20px;
}
.ts-steps li{
  margin:4px 0;
}
.ts-steps li.active{
  font-weight:700;
  list-style:'⏳ ';
}
.ts-steps li.done{
  opacity:.6;
  list-style:'✅ ';
}
.ts-progress{
  height:8px;
  background:rgba(0,0,0,.08);
  border-radius:999px;
  overflow:hidden;
  margin-top:8px;
}
.ts-bar{
  height:100%;
  width:0;
  background:var(--primary);
  transition:width .25s;
}
#ts-elapsed{
  font-size:13px;
  opacity:.85;
}

/* Modal */
.ts-modal{
  position:fixed;
  inset:0;
  background:rgba(10,10,15,.55);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:10000;
}
.ts-modal.ts-hidden{
  display:none;
}
.ts-modal-panel{
  width:min(560px,92vw);
  background:var(--surface);
  color:var(--text);
  border-radius:12px;
  padding:16px;
}

/* ===================================================================
   Domain 타입스케일 & spacing
   =================================================================== */

body.domain-page{
  font-size:14px; /* rem 기준점 */
}
body.domain-page .analysis-toolbar .title-domain{
  font-size:14px;
  line-height:1.2;
}
body.domain-page .section h2{
  font-size:18px;
}
body.domain-page .section h3{
  font-size:16px;
}

/* 헤더를 일반 flow로 (도메인 상세는 sticky 헤더 없음) */
body.domain-page{
  --header-h:0px;
  padding-top:0 !important;
}
body.domain-page .zip-header{
  position:static !important;
  top:auto !important;
  transform:none !important;
  margin:0 !important;
}
html.body-domain-page,
body.domain-page{
  scroll-padding-top:var(--header-h, 0px);
}

/* 도메인 상세에서 툴바는 사용 안 함 */
body.domain-page .analysis-toolbar{
  display:none !important;
}

/* 13px type lock (요청했던 세밀한 타입 고정) */
body.domain-page h1,
body.domain-page h2,
body.domain-page h3,
body.domain-page h4,
body.domain-page h5,
body.domain-page h6,
body.domain-page p,
body.domain-page li,
body.domain-page small,
body.domain-page .badge,
body.domain-page .btn,
body.domain-page .meta,
body.domain-page code,
body.domain-page pre{
  font-size:14px;
  line-height:1.5;
}
body.domain-page .analysis-toolbar .title-domain{
  font-size:1rem;
  line-height:1.4;
}
.badge-score {
  font-size:30px !important;
}
/* 기본 본문 폰트 */
#main li,
#main p,
#main div{
  font-size:14px;
}
#main .row{
  margin:20px 0 !important;
}

/* Design tokens & spacing scale */
:root{
  --sp-0:0;
  --sp-1:4px;
  --sp-2:8px;
  --sp-3:0px;
  --sp-4:16px;
  --sp-6:24px;
  --sp-8:32px;
  --radius-1:4px;
  --radius-2:8px;
  --toolbar-h:0px; /* 툴바 제거 */
}

/* 분석 기본 레이아웃은 theme.css가 관리 */
.analysis-shell{
  display:grid;
  gap:var(--sp-4);
}
.section{
  margin-block:var(--sp-6);
}
.card{
  border-radius:var(--radius-2);
}
@supports not (container-type:inline-size){
  @media (min-width:1200px){
    .analysis-shell{
      grid-template-columns:1fr !important;
    }
  }
}
.analysis-main{
  min-width:0;
}
.analysis-aside{
  display:none !important;
}

/* Mobile-first 카드 패딩 */
@media (max-width:768px){
  .analysis-shell{
    grid-template-columns:1fr;
  }
  .analysis-aside{
    position:static;
    top:auto;
  }
  .card{
    padding:var(--sp-3);
  }
}

/* 이미지/테이블 반응형 */
img{
  max-width:100%;
  height:auto;
}
.table-wrap{
  overflow:auto;
  -webkit-overflow-scrolling:touch;
}
table{
  border-collapse:collapse;
  width:100%;
}
th,
td{
  padding:var(--sp-2) var(--sp-3);
}

/* 공통 버튼 유틸 */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:var(--sp-2);
    padding: 0 10px;
  height:32px;
  border-radius:var(--radius-1);
  border:1px solid var(--btn-bd, #D0D5DD);
  background:var(--btn-bg, #fff);
  color:var(--btn-fg, #111);
}
.btn:hover{
  filter:brightness(0.98);
}
.btn:active{
  filter:brightness(0.96);
}
.btn[disabled]{
  opacity:.5;
  pointer-events:none;
}
.btn-primary{
  --btn-bg:#111;
  --btn-fg:#fff;
  --btn-bd:#111;
}
.btn-ghost{
  --btn-bg:transparent;
  --btn-fg:#111;
  --btn-bd:#D0D5DD;
}

/* Utility spacing helpers */
.mb-0{ margin-bottom:0 !important; }
.mt-0{ margin-top:0 !important; }
.mb-2{ margin-bottom:var(--sp-2) !important; }
.mt-2{ margin-top:var(--sp-2) !important; }
.mb-3{ margin-bottom:var(--sp-3) !important; }
.mt-3{ margin-top:var(--sp-3) !important; }
.mb-4{ margin-bottom:var(--sp-4) !important; }
.mt-4{ margin-top:var(--sp-4) !important; }



/* 도메인 리포트 카드 전체: 밖으로 안 튀어나가게 */
.analysis-main,
.analysis-shell {
  overflow-x: hidden;
}

/* 카드 안의 코드/프리 포맷은 줄바꿈 + 내부 스크롤 허용 */
.card.section pre,
.card.section code {
  max-width: 100%;
  white-space: pre-wrap;     /* 너무 길면 줄 바꿈 */
  word-break: break-all;     /* 긴 토큰(도메인, URL)도 강제로 잘라줌 */
}

/* deep-scan / fix 섹션처럼 코드가 많은 곳은 살짝 더 여유 */
#deep-scan code,
.fix-list pre {
  display: block;
  overflow-x: auto;          /* 안에서만 가로 스크롤 생기게 */
}


#latest-sites .latest-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#latest-sites .chip {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* =========================================================
   Domain page overflow hardening
   (칩 / metric / tooltip 가로 튀어나옴 방지)
   ========================================================= */

/* 1) metric 그리드: 첫 컬럼이 부모 폭을 밀어내지 않도록 */
body.domain-page .metric{
  grid-template-columns:minmax(0, 1fr) auto auto;
}
body.domain-page .metric > *{
  min-width:0;
}

/* 2) list-pills 칩들이 한 줄로만 늘어나지 않게 */
body.domain-page .list-pills{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}
body.domain-page .list-pills > li{
  display:flex;
  align-items:center;
  max-width:100%;
  height:auto;                 /* 28px 고정 높이 해제 */
  white-space:normal;          /* 여러 줄 허용 */
  overflow-wrap:anywhere;
  word-break:break-word;
}

/* 3) KPI / 그리드 안 카드들이 그리드 밖으로 안 튀어나가게 */
body.domain-page .kpi-item,
body.domain-page .grid-2 > *,
body.domain-page .grid.cols-2 > *,
body.domain-page .grid.cols-3 > *{
  min-width:0;
}

.page-title {
  font-size:21px !important;
}
  .ico{ width:16px; height:16px; vertical-align:-2px; margin-right:6px }
  .btn-icon{
    width:32px;
    padding:0;
    justify-content:center;
  }
  .btn-icon .ico{
    margin-right:0;
  }
/* 모바일에서 상단 공유/분석 버튼 2줄로 정렬 */
@media (max-width: 640px){
  body.domain-page .top-actions{
    flex-direction: column;      /* 위아래로 쌓기 */
    align-items: stretch;
    gap: 6px;
  }
  body.domain-page .top-actions > .row{
    width: 100%;
    justify-content: flex-start; /* 양쪽 벌어지지 않게 */
    flex-wrap: wrap;             /* 아이콘이 많으면 그 안에서 줄 바꿈 */
    gap: 6px;
  }
  body.domain-page .top-actions .btn{
    flex: 0 0 auto;              /* 버튼이 한 줄 꽉 채우려 하지 않게 */
  }
  body.domain-page .top-actions .btn-icon{
    width: 32px;
  }
}
