/* TestMate 디자인 시스템(tm.css) — 단일 토큰·공용 컴포넌트.
 * 원칙: 페이지당 목적 1개 · 4상태(로딩/빈/에러/정상) · 네이티브 팝업 0 · 브랜드 1팔레트(#3457F5).
 * 페이지 고유 스타일은 각 페이지에, 여기는 전 페이지 공통만. */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');

:root {
  /* 브랜드 */
  --tm-primary: #3457F5;
  --tm-primary-d: #2746cc;          /* hover/pressed */
  --tm-primary-soft: #eef2ff;       /* 연한 배경 */
  --tm-grad: linear-gradient(135deg, #3457F5 0%, #7c3aed 100%);
  /* 잉크(텍스트) */
  --tm-ink: #0f172a;
  --tm-sub: #475569;
  --tm-mut: #94a3b8;
  /* 서피스 */
  --tm-bg: #f5f7fb;
  --tm-card: #ffffff;
  --tm-line: #e2e8f0;
  --tm-line-soft: #eef1f6;
  /* 판정 */
  --tm-pass: #16a34a;
  --tm-warn: #d97706;
  --tm-fail: #dc2626;
  --tm-na: #94a3b8;
  /* 형태 */
  --tm-radius: 12px;
  --tm-radius-lg: 16px;
  --tm-shadow: 0 2px 10px rgba(15, 23, 42, .06);
  --tm-shadow-lg: 0 12px 34px rgba(15, 23, 42, .12);
  --tm-font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', sans-serif;
}

/* ── 버튼 3종(primary/ghost/danger) — 이모지 단독 금지, 라벨 병기 ── */
.tm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 10px; padding: 9px 16px; font-size: 13.5px; font-weight: 700;
  font-family: var(--tm-font); cursor: pointer; border: 1px solid transparent;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .12s;
  text-decoration: none; line-height: 1.2; user-select: none;
}
.tm-btn:active { transform: translateY(1px); }
.tm-btn:disabled { opacity: .55; cursor: not-allowed; }
.tm-btn-primary { background: var(--tm-primary); color: #fff; box-shadow: 0 3px 10px rgba(52, 87, 245, .28); }
.tm-btn-primary:hover:not(:disabled) { background: var(--tm-primary-d); }
.tm-btn-ghost { background: var(--tm-card); color: var(--tm-sub); border-color: var(--tm-line); }
.tm-btn-ghost:hover:not(:disabled) { border-color: #c7d2e8; background: #fafbff; }
.tm-btn-danger { background: #fff; color: var(--tm-fail); border-color: #f3c2c2; }
.tm-btn-danger:hover:not(:disabled) { background: #fef3f2; }

/* ── 상태 알약(pill) — 판정·진행 상태 공통 ── */
.tm-pill {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 20px;
  padding: 3px 11px; font-size: 11.5px; font-weight: 800; border: 1px solid;
}
.tm-pill-ok   { background: #ecfdf3; color: #15803d; border-color: #abefc6; }
.tm-pill-warn { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.tm-pill-bad  { background: #fef3f2; color: #b42318; border-color: #fecdca; }
.tm-pill-na   { background: #f2f4f7; color: #475467; border-color: #e4e7ec; }
.tm-pill-brand{ background: var(--tm-primary-soft); color: var(--tm-primary); border-color: #c7d2fe; }

/* ── 카드 ── */
.tm-card-box {
  background: var(--tm-card); border: 1px solid var(--tm-line);
  border-radius: var(--tm-radius-lg); box-shadow: var(--tm-shadow);
}

/* ── 4상태: 스켈레톤(로딩) / 빈 / 에러 ── */
.tm-skel {
  position: relative; overflow: hidden; background: #edf1f7; border-radius: 8px; color: transparent !important;
}
.tm-skel::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .65), transparent);
  transform: translateX(-100%); animation: tmShimmer 1.4s infinite;
}
@keyframes tmShimmer { to { transform: translateX(100%); } }

.tm-empty {
  padding: 44px 20px; text-align: center; color: var(--tm-mut); font-size: 14px; line-height: 1.6;
}
.tm-empty b { color: var(--tm-sub); display: block; font-size: 15px; margin-bottom: 4px; }

.tm-error {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #fef3f2; border: 1px solid #fecdca; border-radius: var(--tm-radius);
  padding: 12px 16px; color: #b42318; font-size: 13.5px; font-weight: 600;
}
.tm-error .tm-btn { margin-left: auto; }

/* ── 입력 ── */
.tm-input {
  border: 1px solid var(--tm-line); border-radius: 10px; padding: 9px 12px;
  font-size: 13.5px; font-family: var(--tm-font); background: #fff; color: var(--tm-ink);
  transition: border-color .15s, box-shadow .15s; width: 100%; box-sizing: border-box;
}
.tm-input:focus { outline: none; border-color: var(--tm-primary); box-shadow: 0 0 0 3px rgba(52, 87, 245, .14); }
.tm-input::placeholder { color: var(--tm-mut); }

/* ── 인페이지 모달(네이티브 confirm/alert 대체) ── */
.tm-modal-bg {
  position: fixed; inset: 0; background: rgba(10, 14, 30, .5); z-index: 9999;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: tmFadeIn .18s ease-out;
}
.tm-modal {
  background: #fff; border-radius: var(--tm-radius-lg); max-width: 420px; width: 100%;
  padding: 22px 24px; box-shadow: 0 16px 60px rgba(0, 0, 0, .35);
  animation: tmPopIn .22s cubic-bezier(.2, .8, .3, 1.1);
}
.tm-modal h3 { margin: 0 0 8px; font-size: 16px; font-weight: 800; color: var(--tm-ink); }
.tm-modal p  { margin: 0 0 16px; font-size: 13.5px; color: var(--tm-sub); line-height: 1.6; }
.tm-modal .tm-modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
@keyframes tmFadeIn { from { opacity: 0; } }
@keyframes tmPopIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ── 포커스 링(접근성) ── */
:where(button, [role="button"], input, textarea, select, a[href], [tabindex]):focus-visible {
  outline: 2px solid var(--tm-primary) !important; outline-offset: 2px !important;
}
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 10000;
  transform: translateY(-160%);
  border-radius: 9px;
  background: #0b1437;
  color: #fff;
  padding: 10px 14px;
  font-weight: 800;
  text-decoration: none;
}
.skip-link:focus { transform: translateY(0); }

/* ── 모션 배려 ── */
@media (prefers-reduced-motion: reduce) {
  html:focus-within { scroll-behavior: auto; }
  .tm-skel::after { animation: none; }
  .tm-modal, .tm-modal-bg { animation: none; }
  .tm-btn, .tm-input, #__tw > * { transition: none !important; }
}

/* ── 다크모드 — 크롬(배경·사이드바·상단바·텍스트)은 다크, 리포트 콘텐츠 카드는 라이트 캔버스
   유지(Figma식: 캡처·판정 색 왜곡 방지). 적용: OS 설정 기본 + 인앱 토글(html[data-theme]) 우선. ── */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --tm-bg: #0f1420; --tm-card: #161d2e; --tm-line: #232b3f; --tm-ink: #e6eaf5; --tm-sub: #b9c1d4; --tm-mut: #7f89a1;
    --bg: #0f1420; --wash: #131a2a; --soft: #161d2e; --surface: #151c2c;
    --line: #232b3f; --line2: #1d2437;
    --ink: #e6eaf5; --ink2: #c3cad9; --mut: #8b94ab; --faint: #5f6981;
  }
  html:not([data-theme="light"]) body { background: var(--bg); }
  html:not([data-theme="light"]) .side { background: var(--surface); border-color: var(--line); }
  html:not([data-theme="light"]) .topbar { background: rgba(15, 20, 32, .9); border-color: var(--line); }
  html:not([data-theme="light"]) .gbtn { background: var(--surface); color: var(--ink2); border-color: var(--line); }
  html:not([data-theme="light"]) .mobile-links a { background: var(--surface); color: var(--ink2); border-color: var(--line); }
  html:not([data-theme="light"]) .tm-modal { background: var(--surface); }
  html:not([data-theme="light"]) .tm-modal h3 { color: var(--tm-ink); }
  html:not([data-theme="light"]) .tm-btn-ghost { background: var(--surface); color: var(--ink2); border-color: var(--line); }
  html:not([data-theme="light"]) .task-chip { background: #221b0d; border-color: #453612; }
  html:not([data-theme="light"]) .task-chip .task-main b { color: #ffd591; }
  html:not([data-theme="light"]) .task-chip .task-main small { color: #b5985c; }
  html:not([data-theme="light"]) .task-chip .task-action { background: var(--surface); color: var(--ink2); border-color: var(--line); }
  /* 흰 배경 컨테이너 → 다크 서피스(텍스트 변수와 대비 정합) */
  html:not([data-theme="light"]) :is(.ophome-card,.kpi,.panel,.gate,.drawer-card,.rep-shot-card,.summary-item,.dkpi,.wk-kpi,.wk-card,.mini-tag,.memo-input,.mobile-sec,.device-chip,.jobcard,.run-bar,.modal-card,.actionbox,.mock,.m-cancel,.clearbtn,.ghostbtn,.shot-modal-box,.pause-alert,.ophome-card.warn,.ophome-card.bad,.dkpi.warn,.summary-item.warn,.hero .label,.btn-ghost,.nav-logout,.hv-card,.card,.dual .box,.report-preview,.step,.price,.submit-card,.qa,.acard,.analysis-shell,.tabs,.coverage-panel,.rstat,.rcard,.verdict,.proofitem,.pcard,.usage-device-chip,.job-state,.job-action,.choice-card,.qa-release,.qa-release-count,.qa-release-item,.startbar-step,.gate-action) { background: var(--surface) !important; border-color: var(--line) !important; }
  html:not([data-theme="light"]) :is(.fld input,.fld select,.fld textarea,.searchbox input,.modal-card input,.actionrow input,.actionrow select,.field input,#shareUrl) { background: var(--soft) !important; border-color: var(--line) !important; color: var(--ink) !important; }
  html:not([data-theme="light"]) nav { background: rgba(15,20,32,.92); border-color: var(--line); }
  html:not([data-theme="light"]) :is(.mock-top,.hv-chrome,.hv-side,.hv-chart,.hv-rephead,.analysis-stage,.usage-grid,.analysis-pb,.startbar) { background: var(--soft) !important; border-color: var(--line) !important; }
  html:not([data-theme="light"]) :is(.btn-dark,.step .num) { background: #2b3650; color: #fff; }
  html:not([data-theme="light"]) .cta-band { background: #0b1437; }
  html:not([data-theme="light"]) .scorebox::after { background: var(--surface); }
  html:not([data-theme="light"]) #authGate { background: var(--surface) !important; border-color: var(--line) !important; color: var(--ink2) !important; }
  html:not([data-theme="light"]) :is(.ophome-card.warn,.dkpi.warn,.summary-item.warn) { background: #2b2110 !important; border-color: #6a4b16 !important; }
  html:not([data-theme="light"]) .ophome-card.bad { background: #2b171a !important; border-color: #71303a !important; }
  html:not([data-theme="light"]) .job-state.ready { background: var(--surface) !important; border-color: var(--line) !important; color: var(--ink2) !important; }
  html:not([data-theme="light"]) .job-state.paused { background: #2b2110 !important; border-color: #6a4b16 !important; color: #ffd08a !important; }
  html:not([data-theme="light"]) :is(.job-state.active,.job-state.done) { background: #10271c !important; border-color: #245b3d !important; color: #9fe3bb !important; }
  html:not([data-theme="light"]) .appmap-scroll { --ink:#0f172a;--ink2:#39425f;--mut:#626c84;--faint:#9aa3b8;--line:#dfe5f2; color-scheme:light; }
  html:not([data-theme="light"]) #sharePanel, html:not([data-theme="light"]) #ga4Panel { background: var(--surface) !important; border-color: var(--line) !important; }
  /* 리포트 캔버스는 라이트 섬 유지 — 내부 텍스트 변수만 라이트용으로 되돌림 */
  html:not([data-theme="light"]) #qaStory { --ink: #0f172a; --ink2: #39425f; --mut: #626c84; --faint: #9aa3b8; --line: #e6eaf4; background: #f0f2f8; }
}
html[data-theme="dark"] {
  --tm-bg: #0f1420; --tm-card: #161d2e; --tm-line: #232b3f; --tm-ink: #e6eaf5; --tm-sub: #b9c1d4; --tm-mut: #7f89a1;
  --bg: #0f1420; --wash: #131a2a; --soft: #161d2e; --surface: #151c2c;
  --line: #232b3f; --line2: #1d2437;
  --ink: #e6eaf5; --ink2: #c3cad9; --mut: #8b94ab; --faint: #5f6981;
}
html[data-theme="dark"] body { background: var(--bg); }
html[data-theme="dark"] .side { background: var(--surface); border-color: var(--line); }
html[data-theme="dark"] .topbar { background: rgba(15, 20, 32, .9); border-color: var(--line); }
html[data-theme="dark"] .gbtn { background: var(--surface); color: var(--ink2); border-color: var(--line); }
html[data-theme="dark"] .mobile-links a { background: var(--surface); color: var(--ink2); border-color: var(--line); }
html[data-theme="dark"] .tm-modal { background: var(--surface); }
html[data-theme="dark"] .tm-modal h3 { color: var(--tm-ink); }
html[data-theme="dark"] .tm-btn-ghost { background: var(--surface); color: var(--ink2); border-color: var(--line); }
html[data-theme="dark"] .task-chip { background: #221b0d; border-color: #453612; }
html[data-theme="dark"] .task-chip .task-main b { color: #ffd591; }
html[data-theme="dark"] .task-chip .task-main small { color: #b5985c; }
html[data-theme="dark"] .task-chip .task-action { background: var(--surface); color: var(--ink2); border-color: var(--line); }
html[data-theme="dark"] :is(.ophome-card,.kpi,.panel,.gate,.drawer-card,.rep-shot-card,.summary-item,.dkpi,.wk-kpi,.wk-card,.mini-tag,.memo-input,.mobile-sec,.device-chip,.jobcard,.run-bar,.modal-card,.actionbox,.mock,.m-cancel,.clearbtn,.ghostbtn,.shot-modal-box,.pause-alert,.ophome-card.warn,.ophome-card.bad,.dkpi.warn,.summary-item.warn,.hero .label,.btn-ghost,.nav-logout,.hv-card,.card,.dual .box,.report-preview,.step,.price,.submit-card,.qa,.acard,.analysis-shell,.tabs,.coverage-panel,.rstat,.rcard,.verdict,.proofitem,.pcard,.usage-device-chip,.job-state,.job-action,.choice-card,.qa-release,.qa-release-count,.qa-release-item,.startbar-step,.gate-action) { background: var(--surface) !important; border-color: var(--line) !important; }
html[data-theme="dark"] :is(.fld input,.fld select,.fld textarea,.searchbox input,.modal-card input,.actionrow input,.actionrow select,.field input,#shareUrl) { background: var(--soft) !important; border-color: var(--line) !important; color: var(--ink) !important; }
html[data-theme="dark"] nav { background: rgba(15,20,32,.92); border-color: var(--line); }
html[data-theme="dark"] :is(.mock-top,.hv-chrome,.hv-side,.hv-chart,.hv-rephead,.analysis-stage,.usage-grid,.analysis-pb,.startbar) { background: var(--soft) !important; border-color: var(--line) !important; }
html[data-theme="dark"] :is(.btn-dark,.step .num) { background: #2b3650; color: #fff; }
html[data-theme="dark"] .cta-band { background: #0b1437; }
html[data-theme="dark"] .scorebox::after { background: var(--surface); }
html[data-theme="dark"] #authGate { background: var(--surface) !important; border-color: var(--line) !important; color: var(--ink2) !important; }
html[data-theme="dark"] :is(.ophome-card.warn,.dkpi.warn,.summary-item.warn) { background: #2b2110 !important; border-color: #6a4b16 !important; }
html[data-theme="dark"] .ophome-card.bad { background: #2b171a !important; border-color: #71303a !important; }
html[data-theme="dark"] .job-state.ready { background: var(--surface) !important; border-color: var(--line) !important; color: var(--ink2) !important; }
html[data-theme="dark"] .job-state.paused { background: #2b2110 !important; border-color: #6a4b16 !important; color: #ffd08a !important; }
html[data-theme="dark"] :is(.job-state.active,.job-state.done) { background: #10271c !important; border-color: #245b3d !important; color: #9fe3bb !important; }
html[data-theme="dark"] .appmap-scroll { --ink:#0f172a;--ink2:#39425f;--mut:#626c84;--faint:#9aa3b8;--line:#dfe5f2; color-scheme:light; }
html[data-theme="dark"] #sharePanel, html[data-theme="dark"] #ga4Panel { background: var(--surface) !important; border-color: var(--line) !important; }
html[data-theme="dark"] #qaStory { --ink: #0f172a; --ink2: #39425f; --mut: #626c84; --faint: #9aa3b8; --line: #e6eaf4; background: #f0f2f8; }
