/* 네오브루탈리즘: 굵은 테두리, 흐림 없는 그림자, 평평한 색. 값은 전부 변수로만 쓴다. */
:root {
  color-scheme: light;
  --bg: #eef0ff;
  --side: #ffd93d;
  --surface: #ffffff;
  --surface-2: #e3e6ff;
  --ink: #000000;
  --muted: #3f4152;
  --line: #000000;
  --rule: #c9cce0;
  --shadow: #000000;
  --accent: #ffd93d;
  --on-color: #000000;
  --blue: #1f46e0;
  --stamp: #2f5bff;
  --pass: #0b6b45;
  --fail: #c81e1a;
  --warn: #7a5200;
  --tile-1: #ffd93d;
  --tile-2: #5ce1b5;
  --tile-3: #ff9ccf;
  --tile-4: #b8a6ff;
  --fail-fill: #ff8a80;
  --chart-pass: #2f5bff;
  --chart-fail: #e5322d;
  --border: 3px;
  --lift: 4px;
  --gothic: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15131f;
  --side: #221f30;
  --surface: #221f30;
  --surface-2: #322d47;
  --ink: #f7f5ff;
  --muted: #c4bfdb;
  --line: #f7f5ff;
  --rule: #4a4463;
  --shadow: #7a5cff;
  --blue: #a9baff;
  --stamp: #a9baff;
  --pass: #5ce1b5;
  --fail: #ff9d94;
  --warn: #ffd93d;
  --chart-pass: #6b8aff;
  --chart-fail: #e5544d;
}

* { box-sizing: border-box; }

/* display를 지정한 요소에서도 hidden이 이기게 한다 */
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  background: var(--bg);
  color: var(--ink);
  font: 500 15px/1.6 var(--gothic);
  word-break: keep-all;
  overflow-wrap: anywhere;
}

h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }

button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: var(--mono); }

:focus-visible { outline: 3px solid var(--stamp); outline-offset: 2px; }

/* 왼쪽 메뉴 */
.side {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  padding: 20px 16px;
  background: var(--side);
  border-right: var(--border) solid var(--line);
}

.brand { flex: none; font: 900 23px/1.1 var(--gothic); letter-spacing: -0.03em; white-space: nowrap; }
.brand a { color: inherit; text-decoration: none; }
.side > .primary { text-align: center; background: var(--surface); color: var(--ink); }

.menu { display: grid; gap: 6px; }

.menu a {
  display: block;
  padding: 7px 10px;
  border: var(--border) solid transparent;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.menu a:hover { border-color: var(--line); }

.menu a[aria-current="page"] {
  border-color: var(--line);
  background: var(--surface);
  box-shadow: var(--lift) var(--lift) 0 var(--shadow);
}

.account { margin-top: auto; display: grid; gap: 8px; font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.theme { margin-top: auto; }
.account:not([hidden]) + .theme { margin-top: 0; }

/* 버튼 */
.primary, .ghost, .danger {
  display: inline-block;
  padding: 7px 14px;
  border: var(--border) solid var(--line);
  border-radius: 0;
  box-shadow: var(--lift) var(--lift) 0 var(--shadow);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 80ms, box-shadow 80ms;
}

.primary { background: var(--accent); color: var(--on-color); }
.ghost { background: var(--surface); color: var(--ink); }
.danger { background: var(--fail-fill); color: var(--on-color); }

.primary:hover, .ghost:hover, .danger:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--shadow); }
.primary:active, .ghost:active, .danger:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--shadow); }

.primary:disabled, .ghost:disabled {
  background: var(--surface-2);
  color: var(--muted);
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}

/* 오른쪽 작업면 */
.desk { display: flex; flex-direction: column; min-height: 0; height: 100dvh; }
.view { flex: 1; min-height: 0; overflow-y: auto; }

.page {
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-width: 1120px;
  padding: 26px 30px 40px;
}

.page.narrow { max-width: 760px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.page-head h2, .test-head h2 { font: 900 31px/1.2 var(--gothic); letter-spacing: -0.03em; }
.page-head p, .test-head p { margin-top: 3px; color: var(--muted); font-size: 14px; }

/* 테스트 상세 */
.test { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.test-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding: 18px 30px 14px;
  background: var(--surface);
}

.test-head:empty { display: none; }

.tabs { display: flex; flex: none; gap: 6px; overflow-x: auto; border-bottom: var(--border) solid var(--line); }
.test .tabs { padding: 0 30px; background: var(--surface); }

.tabs a {
  padding: 5px 14px;
  border: var(--border) solid var(--line);
  border-bottom: 0;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.tabs a:hover { background: var(--surface); }
.tabs a[aria-current="page"] { background: var(--accent); color: var(--on-color); font-weight: 800; }

/* 결재란: 끝난 단계에 도장이 찍힌다 */
.approval { display: flex; flex: none; border: var(--border) solid var(--line); box-shadow: var(--lift) var(--lift) 0 var(--shadow); }
.approval li { width: 60px; background: var(--surface); border-right: var(--border) solid var(--line); text-align: center; }
.approval li:last-child { border-right: 0; }

.approval span {
  display: block;
  padding: 2px 0;
  border-bottom: var(--border) solid var(--line);
  font-size: 12px;
  font-weight: 800;
}

.approval div { display: grid; place-items: center; height: 46px; }
.approval .now span { background: var(--accent); color: var(--on-color); }

.stamp {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 3px solid var(--stamp);
  border-radius: 50%;
  color: var(--stamp);
  font: 900 12px/1 var(--gothic);
  transform: rotate(-11deg);
}

.stamp.fresh { animation: press 220ms cubic-bezier(.2, .9, .3, 1.2); }

@keyframes press {
  from { opacity: 0; transform: rotate(-11deg) scale(1.6); }
  to { opacity: 1; transform: rotate(-11deg) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .stamp.fresh { animation: none; }
  .primary, .ghost, .danger { transition: none; }
}

/* 기록 */
.test-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  overflow-y: auto;
  padding: 24px max(30px, calc(100% - 830px)) 24px 30px;
}

.empty { margin: auto; padding: 18px 12px; max-width: 34em; color: var(--muted); text-align: center; }

.say { white-space: pre-wrap; }

.say.me {
  align-self: flex-end;
  width: fit-content;
  max-width: 62%;
  padding: 8px 12px;
  background: var(--accent);
  border: var(--border) solid var(--line);
  box-shadow: var(--lift) var(--lift) 0 var(--shadow);
  color: var(--on-color);
  font-weight: 600;
}

.say small { display: block; font-size: 12px; font-weight: 700; }
.say.hub { color: var(--ink); }
.note, .hint { color: var(--muted); font-size: 14px; }
.hint a { color: var(--blue); }
time { color: var(--muted); font-size: 12.5px; font-weight: 700; }

/* 서식 한 장 */
.sheet {
  background: var(--surface);
  border: var(--border) solid var(--line);
  box-shadow: 6px 6px 0 var(--shadow);
}

.sheet > header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: var(--surface-2);
  border-bottom: var(--border) solid var(--line);
}

.sheet h3 { font: 800 15.5px/1.5 var(--gothic); }
.sheet.bad > header { background: var(--fail-fill); color: var(--on-color); }
.sheet.bad h3, .sheet.bad time { color: var(--on-color); }

.scenario { padding: 8px 14px 4px; color: var(--muted); font-size: 13.5px; font-weight: 700; }

.line {
  display: grid;
  grid-template-columns: 22px 46px minmax(0, 1fr);
  gap: 6px;
  padding: 5px 14px;
  border-top: 2px solid var(--rule);
}

.line.plain { cursor: default; }
.line input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--stamp); }
.line .tag { color: var(--muted); font-size: 12.5px; font-weight: 700; padding-top: 2px; }
.line.off .text { color: var(--muted); text-decoration: line-through; }

.result {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  padding: 7px 14px;
  border-top: 2px solid var(--rule);
}

.result:first-of-type { border-top: 0; }
.mark { font-weight: 800; font-size: 13.5px; }
.mark.passed { color: var(--pass); }
.mark.failed, .mark.skipped { color: var(--fail); }

.result .blocked {
  grid-column: 2 / -1;
  margin: 0;
  color: var(--fail);
  font: 12.5px/1.5 var(--mono);
  overflow-wrap: anywhere;
}

.result .next {
  grid-column: 2 / -1;
  margin: 2px 0;
  padding: 6px 10px;
  border: 2px solid var(--ink);
  font-weight: 700;
  line-height: 1.5;
}

.result pre {
  grid-column: 2 / -1;
  max-height: 180px;
  margin: 2px 0 4px;
  overflow: auto;
  font: 12.5px/1.5 var(--mono);
  white-space: pre-wrap;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--blue);
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 14px; border-top: 2px solid var(--rule); text-align: left; font-weight: 500; }
thead th { border-top: 0; border-bottom: var(--border) solid var(--line); font-size: 13px; font-weight: 800; }
tbody tr:first-child td { border-top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
.table-wrap table { min-width: 640px; }
td a, h3 a { color: var(--blue); font-weight: 800; }
td small { display: block; color: var(--muted); font-size: 12.5px; }
.bad { color: var(--fail); font-weight: 700; }
.row-actions { display: flex; gap: 12px; white-space: nowrap; }

.code-sheet pre { margin: 0; padding: 12px 14px; overflow: auto; font: 12.5px/1.55 var(--mono); }

.issues { padding: 8px 14px 8px 30px; list-style: disc; }
.problem { color: var(--fail); font-weight: 700; white-space: pre-wrap; }

/* Overview */
.banner {
  padding: 11px 16px;
  background: var(--tile-2);
  border: var(--border) solid var(--line);
  box-shadow: 6px 6px 0 var(--shadow);
  color: var(--on-color);
  font-weight: 800;
}

.attention li { border-top: 2px solid var(--rule); }
.attention li:first-child { border-top: 0; }

.attention a {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
  padding: 8px 14px;
  color: inherit;
  text-decoration: none;
}

.attention a:hover { background: var(--surface-2); }
.attention .group { color: var(--blue); font-size: 13.5px; font-weight: 800; }
.attention .group.bad { color: var(--fail); }
.attention strong { font-weight: 700; }
.attention .detail { color: var(--muted); font-size: 13.5px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 0; }

.metric {
  padding: 11px 14px 13px;
  border: var(--border) solid var(--line);
  box-shadow: 6px 6px 0 var(--shadow);
  color: var(--on-color);
}

.metric:nth-child(1) { background: var(--tile-1); }
.metric:nth-child(2) { background: var(--tile-2); }
.metric:nth-child(3) { background: var(--tile-3); }
.metric:nth-child(4) { background: var(--tile-4); }
.metric dt { font-size: 13.5px; font-weight: 800; }
.metric dd { margin: 0; font: 900 31px/1.25 var(--gothic); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.metric dd.note { color: var(--on-color); font: 600 12.5px/1.5 var(--gothic); letter-spacing: 0; }

.trend > header { align-items: center; }
.ranges { display: flex; gap: 4px; }

.ranges button {
  padding: 1px 9px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.ranges button[aria-pressed="true"] { background: var(--accent); color: var(--on-color); }

.chart { position: relative; padding: 10px 14px 0; overflow-x: auto; }
.chart svg { display: block; width: 100%; min-width: 540px; height: auto; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .passed, .legend .passed { fill: var(--chart-pass); background: var(--chart-pass); }
.chart .failed, .legend .failed { fill: var(--chart-fail); background: var(--chart-fail); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: var(--surface-2); fill-opacity: 0.45; }

.tooltip {
  position: absolute;
  top: 2px;
  z-index: 1;
  padding: 3px 8px;
  background: var(--ink);
  color: var(--surface);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  transform: translateX(-50%);
}

.legend { display: flex; gap: 16px; padding: 4px 14px 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; }

details.data { border-top: var(--border) solid var(--line); }
details.data summary { padding: 6px 14px; font-size: 13.5px; font-weight: 700; cursor: pointer; }

/* Tests */
.filters { display: flex; flex-wrap: wrap; gap: 10px; }
.filters select, .filters input { width: auto; min-width: 150px; }
.filters input { flex: 1; max-width: 320px; }

/* 새 테스트 */
.compose { display: grid; gap: 14px; padding: 16px; }
.compose textarea { min-height: 120px; }
.setup { font-size: 14.5px; line-height: 2.4; }

.setup select {
  display: inline-block;
  width: auto;
  max-width: 100%;
  padding: 1px 6px;
  border-width: 2px;
  background: var(--surface-2);
  font-weight: 700;
}

.compose .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* Settings */
.settings dl { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 3px 12px; margin: 0; padding: 10px 14px; }
.settings dt { color: var(--muted); font-weight: 700; }
.settings dd { margin: 0; }

/* 아래 고정 영역 */
.alert { padding: 7px 30px; background: var(--fail-fill); border-top: var(--border) solid var(--line); color: var(--on-color); font-size: 14px; font-weight: 700; }
.form .alert { padding: 6px 10px; border: 2px solid var(--line); }

.notice { padding: 7px 30px; background: var(--tile-1); border-top: var(--border) solid var(--line); color: var(--on-color); font-size: 14px; font-weight: 700; }

.job {
  padding: 8px 30px;
  background: var(--tile-4);
  border-top: var(--border) solid var(--line);
  color: var(--on-color);
  font-size: 14px;
}

.job a { color: inherit; text-decoration: none; }
.job small { font-size: 12px; font-weight: 700; }
.job-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 2px 0; }
.job-line small { white-space: nowrap; }
.job-count { margin: 4px 0 0; font-weight: 900; }
.job-list { margin: 0; padding: 0; list-style: none; max-height: 96px; overflow-y: auto; }
.job .where { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job .ghost { margin-left: auto; padding: 2px 10px; white-space: nowrap; box-shadow: 2px 2px 0 var(--on-color); border-color: var(--on-color); background: #fff; color: var(--on-color); }

.actions { padding: 0 30px; background: var(--surface); }

.actions:not(:empty) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  padding-bottom: 12px;
  border-top: var(--border) solid var(--line);
}

/* 대화 탭: 왼쪽은 대화, 오른쪽은 실행 화면과 코드 */
.split { display: flex; flex: 1; min-height: 0; }
.split > .test-body { flex: 1 1 0; min-width: 0; }

.pane {
  display: flex;
  flex: 0 0 min(44%, 640px);
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border-left: var(--border) solid var(--line);
}

.pane-tabs { display: flex; flex: none; gap: 6px; padding: 10px 16px; border-bottom: var(--border) solid var(--line); }

.pane-tabs button {
  padding: 3px 12px;
  border: var(--border) solid var(--line);
  background: var(--surface-2);
  font-weight: 700;
  cursor: pointer;
}

.pane-tabs button[aria-pressed="true"] { background: var(--accent); color: var(--on-color); font-weight: 800; }

.pane-body { display: grid; flex: 1; align-content: start; gap: 14px; min-height: 0; overflow-y: auto; padding: 16px; }
.pane-body h3 { display: flex; justify-content: space-between; gap: 12px; font: 800 15.5px/1.5 var(--gothic); }
.pane-body h4 { display: flex; gap: 8px; margin: 0 0 6px; font-size: 14.5px; }
.pane-body .media { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.pane-body .media img, .pane-body .media video { display: block; max-width: 100%; border: 2px solid var(--ink); }
.pane-body .media video { margin-top: 6px; }

.pane-body pre {
  margin: 0;
  padding: 10px 12px;
  overflow: auto;
  border: var(--border) solid var(--line);
  font: 12.5px/1.55 var(--mono);
}

.sheet > header .tools { display: flex; gap: 12px; align-items: baseline; }

/* 여백의 %는 부모 폭 기준이라 옆 칸이 있으면 대화 폭 공식이 맞지 않는다 */
@media (min-width: 1101px) {
  .split:has(> .pane:not([hidden])) > .test-body { padding-right: 30px; }
}

@media (max-width: 1100px) {
  .split { flex-direction: column; }
  .pane { flex: none; max-height: 40dvh; border-left: 0; border-top: var(--border) solid var(--line); }
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 12px 30px 16px;
  background: var(--surface);
  border-top: var(--border) solid var(--line);
}

textarea, input:not([type]), input[type="search"], select {
  width: 100%;
  padding: 7px 9px;
  border: var(--border) solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
}

textarea { resize: vertical; min-height: 46px; max-height: 30dvh; }
textarea:disabled { background: var(--surface-2); color: var(--muted); }
::placeholder { color: var(--muted); opacity: 1; }

/* 대화상자 */
dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  background: var(--surface);
  border: 4px solid var(--line);
  border-radius: 0;
  box-shadow: 9px 9px 0 var(--shadow);
  color: var(--ink);
}

dialog::backdrop { background: rgb(0 0 0 / 55%); }

.form { display: grid; gap: 13px; padding: 20px 22px; }
.form h2 { font: 900 22px/1.25 var(--gothic); letter-spacing: -0.02em; }
.form label { display: grid; gap: 3px; font-size: 14px; font-weight: 700; }
.form .row { display: flex; justify-content: flex-end; gap: 10px; }
.warn { color: var(--warn); font-weight: 700; }

@media (max-width: 860px) {
  body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }

  .side {
    flex-flow: row wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: var(--border) solid var(--line);
  }

  .side > .primary { flex: none; order: 1; padding: 3px 10px; font-size: 14px; }
  .side nav { order: 3; width: 100%; overflow-x: auto; }
  .theme, .account:not([hidden]) + .theme { order: 2; margin: 0; padding: 3px 8px; font-size: 13px; }
  .account { order: 2; margin: 0; }
  .account #who { display: none; }
  .account .ghost { padding: 3px 8px; font-size: 13px; }
  .menu { display: flex; gap: 4px; padding-bottom: 8px; }
  .menu a { width: max-content; padding: 3px 8px; white-space: nowrap; }
  .desk { height: 100%; }
  .page { padding: 18px 16px 30px; }
  .page-head, .test-head { flex-direction: column; gap: 10px; }
  .test-head { padding: 12px 16px; }
  /* 좁은 창에서는 기록 칸이 사라지지 않게 화면 전체를 내린다 */
  .test { height: auto; }
  .test-body { flex: none; overflow: visible; padding: 16px; }
  .test .tabs { padding: 0 16px; }
  .approval li { width: 50px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .attention a { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .compose .row { flex-direction: column; align-items: stretch; }
  .actions, .composer, .job, .alert, .notice { padding-left: 16px; padding-right: 16px; }
  .split, .split > .test-body { flex: none; }
  .pane { max-height: none; }
  .pane-body { overflow: visible; }
  .say.me { max-width: 85%; }
}

body.login { grid-template-columns: 1fr; place-items: center; min-height: 100vh; }
.login-box { display: grid; gap: 16px; width: min(380px, calc(100vw - 32px)); padding: 28px; background: var(--surface); border: var(--border) solid var(--line); box-shadow: 8px 8px 0 var(--shadow); }
.login-box .primary { text-align: center; text-decoration: none; }
