:root {
  color-scheme: dark;
  --bg: #0d1724;
  --panel: #152335;
  --line: #354458;
  --ink: #f0eee8;
  --muted: #b7c3cf;
  --accent: #f7b578;
  font:
    16px/1.6 system-ui,
    sans-serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
a {
  color: var(--accent);
}
header,
main,
footer {
  max-width: 1320px;
  margin: auto;
  padding: 24px;
}
header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}
nav {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.2;
  margin: 12px 0 20px;
  font-weight: 600;
}
h2 {
  font-size: 23px;
  margin: 0 0 18px;
}
h3 {
  font-size: 17px;
  margin: 0 0 12px;
}
.eyebrow {
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.08em;
}
.muted,
small {
  color: var(--muted);
}
section {
  margin: 28px 0;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}
.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 14px;
}
label.check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
input,
select,
textarea,
button {
  font: inherit;
  color: inherit;
  background: #0e1a29;
  border: 1px solid #566579;
  border-radius: 4px;
  padding: 8px 10px;
  min-width: 0;
}
textarea {
  width: 100%;
  min-height: 78px;
}
input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}
button {
  cursor: pointer;
}
button.primary {
  background: var(--accent);
  color: #172331;
  border-color: var(--accent);
  font-weight: 650;
}
button:hover {
  border-color: var(--accent);
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
canvas:focus-visible {
  outline: 3px solid #79c9f0;
  outline-offset: 3px;
}
button:disabled,
fieldset:disabled {
  opacity: 0.55;
  cursor: default;
}
fieldset {
  margin: 0;
  border: 1px solid var(--line);
  padding: 16px;
  min-width: 0;
}
legend {
  padding: 0 8px;
}
.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 18px 0;
}
.fields canvas {
  width: 100%;
  height: 350px;
  display: block;
  background: #0a1220;
  border: 1px solid var(--line);
  touch-action: manipulation;
}
.fields figure {
  margin: 0;
  min-width: 0;
}
figcaption {
  font-size: 14px;
  color: var(--muted);
  padding: 8px 0;
}
.legend {
  height: 12px;
  background: linear-gradient(
    90deg,
    rgb(29 49 79),
    rgb(58 105 144),
    rgb(113 167 180),
    rgb(218 199 162),
    rgb(233 154 104),
    rgb(194 83 67)
  );
  margin: 12px 0;
}
.scale {
  display: flex;
  justify-content: space-between;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
td,
th {
  padding: 9px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
th {
  font-weight: 600;
  color: var(--muted);
}
.table-scroll {
  overflow: auto;
}
output {
  display: block;
  min-height: 1.5em;
}
#status {
  color: var(--accent);
}
.change {
  display: inline-block;
  padding: 4px 9px;
  background: #24374d;
  margin: 3px;
  border-radius: 4px;
  font-size: 14px;
}
code {
  overflow-wrap: anywhere;
}
details {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 16px;
}
summary {
  cursor: pointer;
  color: var(--accent);
}
footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
footer img {
  height: 20px;
  width: auto;
}
#point {
  font-variant-numeric: tabular-nums;
}
.report-line {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#history {
  max-height: 220px;
  overflow: auto;
  font-size: 13px;
}
.error {
  color: #ffbd9d;
}
svg {
  max-width: 100%;
  height: auto;
}
canvas {
  max-width: 100%;
}
@media (max-width: 800px) {
  header,
  main,
  footer {
    padding: 16px;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  section {
    padding: 16px;
  }
  header {
    display: block;
  }
  nav {
    margin-top: 10px;
  }
  .fields canvas {
    height: 300px;
  }
}
@media print {
  body {
    background: white;
    color: black;
  }
  header,
  footer,
  .actions,
  button,
  input[type="file"] {
    display: none;
  }
  section {
    background: white;
    border-color: #999;
    break-inside: avoid;
  }
  .muted,
  small,
  th,
  figcaption {
    color: #333;
  }
  input,
  select,
  textarea {
    color: black;
    background: white;
    border: 0;
  }
  .grid {
    grid-template-columns: 1fr 1fr;
  }
  details {
    display: block;
  }
  details > * {
    display: block;
  }
  .legend {
    print-color-adjust: exact;
  }
  #status {
    color: black;
  }
}
#point,
#reference-values {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
pre {
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.section-nav {
  margin: 20px 0;
  font-size: 14px;
}
.fields .legend[hidden],
#scale[hidden],
#material-legend[hidden] {
  display: none;
}
input[type="range"] {
  accent-color: var(--accent);
  min-width: 200px;
  padding: 0;
}
#quick-value {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.quick-delta {
  flex: 1 0 100%;
  margin: 0;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.quick-delta[hidden] {
  display: none;
}
.quick-cause {
  flex: 1 0 100%;
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  color: var(--muted, #9fb0c4);
  word-break: keep-all;
  overflow-wrap: anywhere;
  max-width: 600px;
}
.quick-cause ul {
  list-style: none;
  margin: 6px 0 4px;
  padding: 0;
}
.quick-cause li {
  display: grid;
  grid-template-columns: 1fr auto 4.6em;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(159, 176, 196, 0.15);
}
.quick-cause li b {
  color: var(--text, #e8eef6);
  font-weight: 600;
}
.quick-cause li i {
  font-style: normal;
  text-align: right;
}
.quick-cause li.all span,
.quick-cause li.all b {
  color: var(--accent);
}
.quick-cause p {
  margin: 4px 0 0;
}
.quick-cause[hidden] {
  display: none;
}
#status {
  padding: 8px 0 16px;
  font-size: 14px;
}
/* Keep numbers intact on phones; tables and plots scroll within their panels. */
.table-scroll table {
  min-width: 640px;
}
.table-scroll td {
  white-space: nowrap;
}
.table-scroll th {
  min-width: 90px;
}
.table-scroll td:first-child {
  white-space: normal;
}
#metrics {
  overflow: auto;
}
#metrics table {
  min-width: 0;
}
#metrics td {
  white-space: nowrap;
}
.plot-scroll {
  overflow: auto;
}
.plot-scroll svg {
  min-width: 700px;
  width: 100%;
  display: block;
}

/* Hidden controls stay absent even when label is a grid container. */
[hidden] {
  display: none !important;
}
@media (max-width: 600px) {
  #metrics {
    overflow: visible;
  }
  #metrics table,
  #metrics tbody {
    display: block;
  }
  #metrics thead {
    display: none;
  }
  #metrics tbody tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 12px;
  }
  #metrics tbody th {
    grid-column: 1 / -1;
    padding: 6px 4px;
    border-bottom: 0;
  }
  #metrics td {
    padding: 6px 4px;
    min-width: 0;
    font-variant-numeric: tabular-nums;
  }
  #metrics td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 12px;
  }
}

.formula {
  font-family: monospace;
  line-height: 1.9;
  padding: 12px;
  background: #101b2d;
  overflow-wrap: anywhere;
}
#definitions p {
  max-width: 78ch;
}

/* 휴대폰: 누르는 링크·요약·칸의 높이를 40px 이상으로 (2026-12-03 M3.1) */
@media (max-width: 800px) {
  header nav a,
  .section-nav a,
  footer a,
  summary,
  button,
  select {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
  }
  .section-nav { display: flex; flex-wrap: wrap; gap: 0 14px; }
  summary { display: flex; }
  main li a,
  main p a { display: inline-block; padding: 8px 0; }
}
