﻿:root {
  --paper: #f7f6f1;
  --surface: #ffffff;
  --ink: #1e2a27;
  --muted: #66716c;
  --line: #d7d4ca;
  --green: #2f6b4f;
  --green-soft: #e7f0e8;
  --blue: #385b7c;
  --amber: #a56d20;
  --danger: #9b2f2f;
  --shadow: 0 12px 30px rgba(32, 39, 35, 0.08);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  line-height: 1.55;
}
button, input, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  padding: 10px 16px;
  cursor: pointer;
}
button:disabled { background: #b8c0ba; cursor: not-allowed; }
button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}
a { color: var(--green); }

.shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 120px;
}
.shell.narrow { width: min(720px, calc(100% - 32px)); }
.admin-shell { width: min(1320px, calc(100% - 28px)); }
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 18px;
  margin-bottom: 24px;
}
.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(26px, 4vw, 40px); line-height: 1.15; }
h2 { font-size: 20px; margin-bottom: 10px; }
h3 { font-size: 17px; margin-bottom: 8px; }
.muted { color: var(--muted); }
.text-link { margin-top: 10px; font-weight: 700; text-decoration: none; }
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 12px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.intro-panel { margin-top: 34px; }
.stack-form { display: grid; gap: 14px; max-width: 540px; }
.stack-form.compact { max-width: 420px; }
label { display: grid; gap: 6px; font-weight: 700; }
label span { font-size: 13px; color: var(--muted); }
input, textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}
textarea { resize: vertical; }
input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.12); }
.message { min-height: 22px; margin: 12px 0 0; color: var(--muted); }
.message.error { color: var(--danger); }
.message.ok { color: var(--green); }
.message-list { display: grid; gap: 8px; margin-top: 16px; }
.notice,
.message-list .notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfaf6;
  font-size: 13px;
  word-break: break-all;
}
.notice.error {
  border-color: rgba(155, 47, 47, 0.35);
  background: #fff7f5;
  color: var(--danger);
}

.survey { display: grid; gap: 34px; }
.part-block {
  background: transparent;
  padding-top: 0;
  scroll-margin-top: 18px;
}
.part-heading {
  display: grid;
  grid-template-columns: 76px 1fr;
  align-items: stretch;
  gap: 14px;
  margin: 0 0 18px;
  padding: 16px;
  border: 1.5px solid rgba(47, 107, 79, 0.24);
  border-left: 6px solid var(--green);
  border-radius: 8px;
  background: #eef5ee;
  box-shadow: 0 8px 20px rgba(32, 39, 35, 0.06);
}
.part-heading b {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
}
.part-heading span {
  display: flex;
  align-items: center;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.65;
}
.question {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.question-head {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.question-num {
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 800;
}
.question-text { font-weight: 800; }
.option-list {
  display: grid;
  gap: 8px;
  margin-left: 50px;
}
.option-button {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: start;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  padding: 11px 13px;
}
.option-button:hover { border-color: var(--green); }
.option-button.selected { border-color: var(--green); background: var(--green-soft); }
.option-mark {
  width: 18px;
  height: 18px;
  border: 2px solid #9aa39d;
  border-radius: 5px;
  margin-top: 2px;
}
.option-button.selected .option-mark { background: var(--green); border-color: var(--green); position: relative; }
.option-button.selected .option-mark::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(40deg);
}
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.08);
}
.dock-inner {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
}
.count { min-width: 72px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.progress {
  flex: 1;
  height: 9px;
  border-radius: 999px;
  background: #e5e3dc;
  overflow: hidden;
}
.progress i { display: block; height: 100%; width: 0; background: var(--green); transition: width 0.2s; }
.result-panel { margin-top: 28px; }
.type-code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: clamp(46px, 12vw, 74px);
  line-height: 1;
  color: var(--green);
  font-weight: 900;
  margin: 12px 0 14px;
}
.score-grid {
  display: grid;
  gap: 18px;
  margin: 24px 0;
}
.score-row {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
}
.score-label {
  display: grid;
  grid-template-columns: minmax(74px, 1fr) auto minmax(74px, 1fr);
  align-items: center;
  gap: 10px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
}
.score-end {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
}
.score-end:last-child { justify-content: flex-end; }
.score-end b { color: inherit; font-size: 16px; }
.score-end em {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 24px;
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}
.score-end.is-active { color: var(--ink); }
.score-end.is-active b { color: var(--green); }
.score-end.is-active em {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}
.score-clarity {
  color: var(--ink);
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}
.score-meter {
  display: flex;
  height: 24px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8e3d8;
  box-shadow: inset 0 0 0 1px rgba(30, 42, 39, 0.12);
}
.score-meter span { min-width: 0; }
.score-meter i {
  flex: 0 0 4px;
  background: rgba(255, 255, 255, 0.9);
}
.score-fill-left {
  flex: 0 1 var(--left, 50%);
  background: linear-gradient(90deg, color-mix(in srgb, var(--left-color) 82%, white), var(--left-color));
}
.score-fill-right {
  flex: 0 1 var(--right, 50%);
  background: linear-gradient(90deg, var(--right-color), color-mix(in srgb, var(--right-color) 78%, white));
}
.type-map {
  margin: 28px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}
.type-map h3 { margin-bottom: 12px; }
.type-map-frame {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  grid-template-rows: auto auto auto;
  gap: 6px;
}
.axis {
  color: #17382b;
  font-size: 13px;
  font-weight: 900;
}
.axis span,
.axis-left span,
.axis-right span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 4px;
  background: #a9cf72;
  color: #17382b;
}
.axis-top {
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.axis-bottom {
  grid-column: 2;
  grid-row: 3;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.axis-left {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 4px;
  color: #17382b;
  font-size: 13px;
  font-weight: 900;
}
.axis-right {
  grid-column: 3;
  grid-row: 2;
  display: grid;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 4px;
  color: #17382b;
  font-size: 13px;
  font-weight: 900;
}
.axis-left span,
.axis-right span {
  min-height: 0;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}
.type-grid {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid #9d998d;
  border-radius: 6px;
  background: #c8c1b1;
}
.type-cell {
  display: flex;
  min-height: 72px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 6px;
  background: #f6f2e8;
  color: #2d3833;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  text-align: center;
}
.type-cell span {
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}
.type-cell small {
  color: var(--muted);
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
}
.type-cell.is-current {
  position: relative;
  background: var(--green);
  color: #fff;
  box-shadow: inset 0 0 0 3px #f0c75e;
}
.type-cell.is-current small { color: #fff3c4; }
.type-characteristic {
  margin: -10px 0 28px;
  padding: 18px;
  border: 1px solid #c9d8c8;
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: #f4faf4;
}
.type-characteristic h3 {
  margin-bottom: 8px;
  color: var(--ink);
}
.type-characteristic p:last-child {
  margin-bottom: 0;
  color: #283a34;
  font-size: 15px;
  line-height: 1.75;
}
.result-details {
  border-top: 1px solid var(--line);
  padding: 18px 0 0;
  margin-top: 18px;
}
.detail-section { margin-top: 16px; }
.detail-section:first-child { margin-top: 0; }
.detail-section p, .detail-section li { color: #34413c; }

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.admin-column { display: grid; gap: 16px; align-items: start; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; }
td.code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 900; color: var(--green); font-size: 18px; }
.score-mini { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; color: var(--muted); white-space: nowrap; }
.results-panel { min-width: 0; }
.results-panel .table-wrap { overflow-x: visible; }
.results-table {
  min-width: 0;
  table-layout: fixed;
}
.results-table th,
.results-table td {
  padding: 11px 6px;
}
.results-table td:nth-child(1) {
  line-height: 1.45;
  word-break: keep-all;
}
.results-table td:nth-child(2) {
  line-height: 1.45;
}
.summary-text {
  display: -webkit-box;
  overflow: hidden;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.results-table th:nth-child(1),
.results-table td:nth-child(1) { width: 100px; }
.results-table th:nth-child(2),
.results-table td:nth-child(2) { width: 155px; }
.results-table th:nth-child(3),
.results-table td:nth-child(3) { width: 58px; }
.results-table th:nth-child(4),
.results-table td:nth-child(4) { width: 140px; }
.results-table th:nth-child(6),
.results-table td:nth-child(6) { width: 58px; }
.results-table td:nth-child(2),
.results-table td:nth-child(5) {
  overflow-wrap: anywhere;
  word-break: keep-all;
}
.results-table .score-mini {
  white-space: normal;
  line-height: 1.4;
  overflow-wrap: anywhere;
  font-size: 11px;
}
.results-table tr.is-selected { background: var(--green-soft); }
button.danger-button {
  border-color: rgba(155, 47, 47, 0.35);
  color: var(--danger);
}
button.danger-button:hover,
button.danger-button:focus-visible {
  background: #fff7f5;
  border-color: var(--danger);
  outline: 2px solid rgba(155, 47, 47, 0.14);
  outline-offset: 2px;
}
.delete-result-button {
  padding: 6px 9px;
  font-size: 12px;
  white-space: nowrap;
}
.type-link {
  appearance: none;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--green);
  padding: 2px 4px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.2;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.type-link:hover,
.type-link:focus-visible {
  background: var(--green-soft);
  color: #174d35;
  outline: 2px solid rgba(47, 107, 79, 0.18);
  outline-offset: 2px;
}
.admin-result-detail {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.admin-result-detail[hidden] { display: none; }
.admin-detail-head {
  align-items: flex-start;
  margin-bottom: 18px;
}
.admin-detail-head h2 {
  margin-bottom: 4px;
  word-break: break-all;
}
.admin-detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.admin-result-body { margin-top: 0; }
.admin-result-body .type-code { margin-top: 8px; }

@media (min-width: 761px) {
  .admin-shell { padding-top: 18px; padding-bottom: 72px; }
  .admin-shell .topbar {
    padding-bottom: 14px;
    margin-bottom: 16px;
  }
  .admin-shell h1 { font-size: 36px; }
  .admin-shell .panel { padding: 18px; }
  .results-panel > .section-head { margin-bottom: 2px; }
  #invite-form textarea {
    height: 136px;
    min-height: 108px;
  }
  #invite-form { gap: 12px; }
  #health-output { gap: 7px; }
  #health-output .notice { padding-block: 8px; }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .admin-grid { grid-template-columns: 280px minmax(0, 1fr); }
  .results-table th:nth-child(1),
  .results-table td:nth-child(1) { width: 90px; }
  .results-table th:nth-child(2),
  .results-table td:nth-child(2) { width: 140px; }
  .results-table th:nth-child(4),
  .results-table td:nth-child(4) { width: 125px; }
}

@media (min-width: 761px) and (max-width: 900px) {
  .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .shell, .admin-shell, .shell.narrow { width: min(100% - 24px, 980px); padding-top: 24px; }
  .topbar { align-items: stretch; flex-direction: column; }
  .panel { padding: 18px; }
  .admin-grid { grid-template-columns: 1fr; }
  .part-heading {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px;
    margin-bottom: 16px;
  }
  .part-heading b {
    justify-content: flex-start;
    width: fit-content;
    min-height: auto;
    padding: 6px 10px;
    font-size: 14px;
  }
  .part-heading span { font-size: 14px; line-height: 1.6; }
  .question { padding: 16px 0; }
  .question-head { grid-template-columns: 34px 1fr; }
  .option-list { margin-left: 0; }
  .option-button { min-height: 48px; }
  .dock-inner {
    width: min(100% - 24px, 980px);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
  }
  .dock button { grid-column: 1 / -1; width: 100%; padding-inline: 12px; }

  .score-grid { gap: 14px; margin: 20px 0; }
  .score-row { padding: 10px; }
  .score-label {
    grid-template-columns: minmax(56px, 1fr) auto minmax(56px, 1fr);
    gap: 6px;
    font-size: 12px;
  }
  .score-end { gap: 4px; }
  .score-end b { font-size: 14px; }
  .score-end em {
    min-width: 24px;
    min-height: 22px;
    padding-inline: 5px;
  }
  .score-meter { height: 22px; }
  .type-map { margin: 22px 0; padding: 12px; }
  .type-characteristic {
    margin: -6px 0 22px;
    padding: 14px;
  }
  .type-characteristic p:last-child {
    font-size: 14px;
    line-height: 1.7;
  }
  .type-map-frame {
    grid-template-columns: 24px minmax(0, 1fr) 24px;
    gap: 4px;
  }
  .axis,
  .axis-left,
  .axis-right { font-size: 11px; }
  .axis span,
  .axis-left span,
  .axis-right span {
    min-height: 24px;
    border-radius: 3px;
  }
  .axis-top,
  .axis-bottom { gap: 4px; }
  .type-cell {
    min-height: 50px;
    gap: 3px;
    padding: 6px 2px;
  }
  .type-cell span { font-size: 15px; }
  .type-cell small { font-size: 10px; }
  .result-details {
    margin-top: 16px;
    padding-top: 16px;
  }
  .results-panel { overflow: hidden; }
  .results-panel .table-wrap { overflow-x: visible; }
  .results-table {
    display: block;
    min-width: 0;
  }
  .results-table thead { display: none; }
  .results-table tbody,
  .results-table tr,
  .results-table td {
    display: block;
    width: 100%;
  }
  .results-table tr {
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfaf6;
    padding: 10px;
  }
  .results-table tr.is-selected {
    border-color: rgba(47, 107, 79, 0.45);
    background: var(--green-soft);
  }
  .results-table th:nth-child(1),
  .results-table td:nth-child(1),
  .results-table th:nth-child(2),
  .results-table td:nth-child(2),
  .results-table th:nth-child(3),
  .results-table td:nth-child(3),
  .results-table th:nth-child(4),
  .results-table td:nth-child(4),
  .results-table th:nth-child(5),
  .results-table td:nth-child(5),
  .results-table th:nth-child(6),
  .results-table td:nth-child(6) {
    width: auto;
  }
  .results-table td {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    column-gap: 14px;
    row-gap: 2px;
    border-bottom: 0;
    padding: 6px 0;
  }
  .results-table td::before {
    content: attr(data-label);
    min-width: max-content;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
  }
  .results-table td.code {
    align-items: center;
    font-size: 16px;
  }
  .type-link {
    justify-self: start;
    padding-inline: 0;
    font-size: 18px;
  }
  .delete-result-button { justify-self: start; }
  .summary-text {
    display: block;
    overflow: visible;
    -webkit-line-clamp: unset;
  }
  .admin-result-detail {
    margin-top: 16px;
    padding-top: 16px;
  }
  .admin-detail-head {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .admin-detail-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .admin-detail-head button { width: 100%; }

}
