/* 태블릿 성능 테스트 — 공통 스타일 (구형 웹뷰 호환: nesting / :has / container query 미사용) */

:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --line: #dde3ea;
  --line-strong: #c5ced8;
  --text: #1c2632;
  --muted: #5e6b79;
  --primary: #2459d6;
  --primary-weak: #e8eefc;
  --pass: #1e8e4e;
  --pass-weak: #e3f4ea;
  --warn: #c76a00;
  --warn-weak: #fdf0de;
  --fail: #d0312d;
  --fail-weak: #fce6e5;
  --na: #7b8794;
  --na-weak: #eef1f4;
  --radius: 12px;
  --nav-w: 184px;
  --tap: 48px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 24px; }
h2 { font-size: 18px; margin-bottom: 10px; }
p { margin: 0 0 8px; }
b { font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 18px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- 앱 틀: 가로는 왼쪽 메뉴, 세로는 아래 메뉴 ---------- */
.app {
  height: 100%;
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "nav guide" "nav main";
}
.nav {
  grid-area: nav;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  gap: 4px;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 17px; color: var(--primary);
  padding: 6px 8px 14px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 0 12px;
  border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 16px;
}
.nav-item svg { width: 24px; height: 24px; flex: none; }
.nav-item.active { background: var(--primary-weak); color: var(--primary); }
.guide-bar {
  grid-area: guide;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px;
  background: #fffbe8; border-bottom: 1px solid #f1df9a;
}
.guide-text { font-weight: 600; }
.guide-actions { display: flex; gap: 8px; }
.main {
  grid-area: main;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}
.screen { padding: 20px 24px 32px; max-width: 1200px; margin: 0 auto; }
.screen-fill {
  height: 100%;
  max-width: none;
  display: flex; flex-direction: column;
  padding: 14px 16px;
  gap: 12px;
}

@media (orientation: portrait), (max-width: 720px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "guide" "main" "nav";
  }
  .nav {
    flex-direction: row;
    border-right: 0; border-top: 1px solid var(--line);
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    overflow: visible;
  }
  .brand { display: none; }
  .nav-item {
    flex: 1 1 0;
    flex-direction: column; justify-content: center; gap: 2px;
    min-height: 60px; padding: 4px 2px; font-size: 13px;
  }
  .screen { padding: 16px 16px 28px; }
}

/* ---------- 공통 부품 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.screen-fill .card { margin-bottom: 0; }
.screen-head { margin-bottom: 16px; }
.screen-head .sub { color: var(--muted); margin: 4px 0 0; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-title { margin: 8px 0 12px; }
.hint { color: var(--muted); font-size: 14px; margin: 10px 0 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); min-width: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: #fff; color: var(--text);
  font: inherit; font-weight: 600; font-size: 16px;
  cursor: pointer; touch-action: manipulation;
}
.btn:active { background: #eef1f5; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:active { background: #1c48b0; }
.btn-danger { color: var(--fail); border-color: #efb9b7; }
.btn-lg { min-height: 64px; padding: 0 36px; font-size: 20px; }

.field {
  display: block; width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: #fff; color: var(--text);
  font: inherit; font-size: 17px;
}
textarea.field { resize: vertical; }
.field:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(36,89,214,.18); }
.field-big { font-size: 20px; }
.field-label { display: block; font-weight: 600; font-size: 14px; color: var(--muted); margin: 10px 0 6px; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button {
  min-height: var(--tap); min-width: 96px; padding: 4px 16px;
  border: 0; border-right: 1px solid var(--line); background: transparent;
  font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; touch-action: manipulation;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2;
}
.seg button:last-child { border-right: 0; }
.seg button small { font-size: 12px; font-weight: 500; }
.seg button.active { background: var(--primary); color: #fff; }
.seg button:disabled { opacity: .5; }
.seg-tabs { margin-bottom: 12px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 판정 표시 */
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 700; white-space: nowrap;
  background: var(--na-weak); color: var(--na);
}
.chip.pass { background: var(--pass-weak); color: var(--pass); }
.chip.warn { background: var(--warn-weak); color: var(--warn); }
.chip.fail { background: var(--fail-weak); color: var(--fail); }
.chip.ref { background: transparent; color: var(--muted); font-weight: 500; padding: 2px 0; }

.badge {
  display: inline-block; align-self: flex-start;
  padding: 3px 12px; border-radius: 10px; font-size: 14px; font-weight: 700;
  background: var(--na-weak); color: var(--na);
}
.badge.pass { background: var(--pass-weak); color: var(--pass); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }
.badge.fail { background: var(--fail-weak); color: var(--fail); }

/* 측정값 칸 */
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; margin-top: 12px; }
.metrics:empty { display: none; }
.metric { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #fafbfc; }
.metric .m-label { font-size: 13px; color: var(--muted); }
.metric .m-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric .m-value small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.metric.pass { border-color: #a9dbbd; background: var(--pass-weak); }
.metric.warn { border-color: #f1c98e; background: var(--warn-weak); }
.metric.fail { border-color: #f0b0ae; background: var(--fail-weak); }

.progress { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.progress-track { flex: 1; height: 10px; border-radius: 5px; background: var(--na-weak); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); }
.progress-text { font-size: 14px; color: var(--muted); min-width: 140px; text-align: right; font-variant-numeric: tabular-nums; }

.demo-note {
  background: var(--primary-weak); color: var(--primary);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-weight: 600; font-size: 14px;
}

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: #1c2632; color: #fff; padding: 12px 20px; border-radius: 10px;
  font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50;
  max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; }

/* ---------- 홈 ---------- */
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.grid-2 .card { margin-bottom: 0; }
.info { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.info dt { color: var(--muted); font-size: 14px; }
.info dd { margin: 0; font-weight: 600; word-break: break-word; }
.hz-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.hz-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.test-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.test-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  min-height: 170px; padding: 16px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); text-decoration: none; font: inherit; cursor: pointer; touch-action: manipulation;
}
.test-card:active { background: #f4f7fb; }
.test-card-all { border-color: #b8c9f0; background: #f7f9ff; }
.tc-icon { width: 44px; height: 44px; border-radius: 10px; background: var(--primary-weak); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.tc-icon svg { width: 26px; height: 26px; }
.tc-title { font-size: 18px; font-weight: 700; }
.tc-desc { font-size: 14px; color: var(--muted); flex: 1; }

@media (orientation: portrait), (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .test-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- 스크롤 ---------- */
.scroll-panel { flex: none; }
.scroll-panel .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.list-wrap {
  position: relative; flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.list-head, .row-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 76px 96px 64px 76px 64px;
  align-items: center; column-gap: 12px;
}
.list-head { flex: none; padding: 8px 16px; font-size: 13px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); background: #fafbfc; }
.lh-num { text-align: right; }
.list { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; scroll-behavior: auto; }
.row-item { height: 64px; padding: 0 16px; border-bottom: 1px solid #edf0f4; }
.thumb {
  width: 44px; height: 44px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 17px;
}
.ri-main { min-width: 0; }
.ri-name, .ri-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-name { font-weight: 600; font-size: 15px; }
.ri-sub { font-size: 13px; color: var(--muted); }
.st { justify-self: start; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.st-ok { background: var(--pass-weak); color: var(--pass); }
.st-wait { background: var(--warn-weak); color: var(--warn); }
.st-bad { background: var(--fail-weak); color: var(--fail); }
.st-new { background: var(--primary-weak); color: var(--primary); }
.num { text-align: right; font-variant-numeric: tabular-nums; font-size: 15px; }
/* 무거움: 둥근 썸네일 + 그림자 + 카드형 행 */
.list.heavy { background: #f5f7fa; }
.list.heavy .row-item {
  height: 60px; margin: 4px 8px; padding: 0 8px;
  background: #fff; border: 0; border-radius: 10px;
  box-shadow: 0 1px 3px rgba(20,30,50,.12), 0 4px 10px rgba(20,30,50,.08);
}
.list.heavy .thumb { border-radius: 50%; box-shadow: 0 2px 6px rgba(0,0,0,.25), inset 0 0 0 2px rgba(255,255,255,.6); }
.list.heavy .st { box-shadow: 0 1px 2px rgba(0,0,0,.12); }

.run-pill {
  position: absolute; top: 48px; left: 50%; transform: translateX(-50%);
  background: rgba(28,38,50,.88); color: #fff; padding: 8px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 600; pointer-events: none; white-space: nowrap;
}
.fps-float {
  position: absolute; right: 12px; top: 48px; width: 240px;
  background: rgba(255,255,255,.96); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 8px 10px; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,.12);
}
.fps-num { font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums; }
.fps-float canvas { display: block; width: 220px; height: 70px; }
.fps-cap { font-size: 12px; color: var(--muted); }

@media (orientation: portrait), (max-width: 720px) {
  .scroll-panel .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .list-head, .row-item { grid-template-columns: 44px minmax(0, 1fr) 70px 88px 56px; column-gap: 10px; }
  .list-head .c3, .list-head .c4, .row-item .c3, .row-item .c4 { display: none; }
}

/* ---------- 입력 ---------- */
.prompt-box {
  background: #f6f8fb; border: 1px dashed var(--line-strong); border-radius: 10px;
  padding: 14px 16px; font-size: 20px; font-weight: 600; margin-bottom: 4px;
}
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); }
.form-grid .field { margin-top: 4px; color: var(--text); font-weight: 400; }
.form-grid .span-2 { grid-column: span 2; }
.table-wrap { overflow: auto; max-height: 520px; border: 1px solid var(--line); border-radius: 10px; }
.score-table { border-collapse: collapse; width: 100%; min-width: 640px; table-layout: fixed; font-variant-numeric: tabular-nums; }
.score-table th:first-child { width: 96px; }
.score-table th:last-child { width: 84px; }
.score-table th, .score-table td { border-bottom: 1px solid #edf0f4; padding: 2px 4px; text-align: center; }
.score-table thead th { position: sticky; top: 0; background: #fafbfc; z-index: 1; font-size: 14px; color: var(--muted); height: 44px; }
.score-table tfoot td { position: sticky; bottom: 0; background: #f3f6fb; font-weight: 700; height: 48px; }
.score-table .nm { text-align: left; padding-left: 12px; font-weight: 600; white-space: nowrap; }
.score-table .sum { font-weight: 700; min-width: 70px; }
.score-table input {
  width: 100%; min-width: 60px; height: 48px;
  border: 1px solid #e3e8ee; border-radius: 6px; background: #f8fafc;
  text-align: center; font: inherit; font-size: 17px; color: var(--text);
}
.score-table input:focus { outline: none; border-color: var(--primary); background: var(--primary-weak); }
.kb-status { font-weight: 600; }
.kb-tries { margin: 14px 0 0; padding-left: 22px; }
.kb-tries li { margin-bottom: 4px; }

@media (orientation: portrait), (max-width: 720px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- 터치 ---------- */
.touch-panel { flex: none; }
.arena {
  position: relative; flex: 1 1 auto; min-height: 240px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; touch-action: none;
  -webkit-user-select: none; user-select: none;
}
.arena-start { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.arena-count { position: absolute; left: 14px; top: 10px; font-weight: 700; color: var(--muted); }
.arena-msg { position: absolute; left: 0; right: 0; top: 14px; text-align: center; color: var(--muted); font-size: 15px; pointer-events: none; padding: 0 16px; }
.target {
  position: absolute; width: 72px; height: 72px; border-radius: 50%;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(36,89,214,.4);
}
.target.hit { background: var(--pass); box-shadow: none; }
.drag-dot {
  position: absolute; left: 0; top: 0; width: 64px; height: 64px; margin: -32px 0 0 -32px;
  border-radius: 50%; background: rgba(36,89,214,.85); border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.25); pointer-events: none;
  will-change: transform;
}

/* ---------- 결과 ---------- */
.overall {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 16px 20px; border-radius: var(--radius); margin-bottom: 16px;
  background: var(--na-weak); border: 1px solid var(--line);
  font-size: 18px; font-weight: 600;
}
.overall .ov-label { font-size: 24px; font-weight: 800; }
.overall.pass { background: var(--pass-weak); border-color: #a9dbbd; }
.overall.pass .ov-label { color: var(--pass); }
.overall.warn { background: var(--warn-weak); border-color: #f1c98e; }
.overall.warn .ov-label { color: var(--warn); }
.overall.fail { background: var(--fail-weak); border-color: #f0b0ae; }
.overall.fail .ov-label { color: var(--fail); }
.overall .ov-sub { font-size: 15px; font-weight: 500; color: var(--muted); width: 100%; }
.result-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.result-cards .card { margin-bottom: 0; }
.rc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.rc-head h2 { margin: 0; }
.rc-meta { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.items + .rc-meta { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.items { width: 100%; border-collapse: collapse; font-size: 15px; }
.items td { padding: 6px 0; border-bottom: 1px solid #edf0f4; vertical-align: middle; }
.items tr:last-child td { border-bottom: 0; }
.items .iv { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; padding: 6px 8px; white-space: nowrap; }
.items .ij { text-align: right; width: 1%; white-space: nowrap; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #edf0f4; flex-wrap: wrap; }
.history li:last-child { border-bottom: 0; }
.h-when { color: var(--muted); font-size: 14px; min-width: 120px; font-variant-numeric: tabular-nums; }
.h-what { font-weight: 600; min-width: 150px; }
.h-sum { flex: 1; color: var(--muted); font-size: 14px; min-width: 200px; }
.export summary { min-height: var(--tap); display: flex; align-items: center; font-weight: 600; cursor: pointer; }
.export-text { margin-top: 10px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.empty { color: var(--muted); padding: 8px 0; }

@media (orientation: portrait), (max-width: 720px) {
  .result-cards { grid-template-columns: 1fr; }
}
