:root {
  color-scheme: light;
  --ink: #1f2421;
  --muted: #68706b;
  --line: #d8ddd9;
  --paper: #f5f6f3;
  --white: #ffffff;
  --green: #155d3d;
  --green-soft: #dcebe2;
  --red: #a33a31;
  --blue: #2873b8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-header,
main,
footer {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  min-height: 104px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand,
.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  margin-bottom: 0;
  font-size: 21px;
}

.version {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

main {
  padding: 28px 0 40px;
}

.chart-section {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.section-heading.compact {
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.result-summary {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 28px;
  text-align: right;
}

.result-summary div span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.result-summary strong {
  font-size: 22px;
}

.result-summary p {
  grid-column: 1 / -1;
  margin: 7px 0 0;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

.chart-wrap {
  position: relative;
  width: 100%;
  margin-top: 18px;
  aspect-ratio: 1.9 / 1;
  min-height: 350px;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend i {
  display: inline-block;
}

.legend-box {
  width: 15px;
  height: 10px;
  background: var(--green-soft);
  border: 1px solid #9bb7a6;
}

.legend-line {
  width: 18px;
  border-top: 2px dashed;
}

.legend-line.tds {
  border-color: var(--blue);
}

.legend-line.yield {
  border-color: var(--green);
}

.control-section {
  display: grid;
  grid-template-columns: minmax(290px, 0.72fr) minmax(500px, 1.28fr);
  gap: 20px;
  margin-top: 20px;
}

.input-panel,
.log-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

label > span:first-child {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
}

.input-with-unit {
  display: flex;
  align-items: center;
  height: 46px;
  border: 1px solid #bcc3be;
  border-radius: 6px;
  background: var(--white);
}

.input-with-unit:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(21, 93, 61, 0.12);
}

.input-with-unit input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 12px;
  border: 0;
  outline: 0;
  background: transparent;
}

.input-with-unit b {
  padding-right: 13px;
  color: var(--muted);
  font-size: 13px;
}

.primary-button {
  height: 48px;
  margin-top: 4px;
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: var(--white);
  font-weight: 800;
}

.primary-button:hover {
  background: #0f4b31;
}

.text-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
}

.text-button {
  padding: 7px 10px;
  font-size: 12px;
}

.icon-button {
  width: 34px;
  height: 34px;
  font-size: 20px;
}

.icon-button.danger {
  color: var(--red);
}

.log-actions {
  display: flex;
  gap: 6px;
}

.form-message {
  min-height: 18px;
  margin: 8px 0 0;
  color: var(--red);
  font-size: 12px;
}

.table-wrap {
  position: relative;
  overflow-x: auto;
  margin-top: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 12px 8px;
  border-bottom: 1px solid #e7eae7;
  text-align: right;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 11px;
}

td:last-child,
th:last-child {
  width: 60px;
  text-align: center;
}

.load-button {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--white);
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
}

.empty-log {
  margin: 38px 0;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

footer {
  padding: 22px 0 34px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

footer p {
  margin-bottom: 5px;
}

.talk-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px 0 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  background: #03c75a;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.talk-button:hover {
  background: #02b351;
}

.talk-button:focus-visible {
  outline: 3px solid rgba(3, 199, 90, 0.28);
  outline-offset: 3px;
}

.talk-mark {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: #ffffff;
  color: #03c75a;
  font-family: Arial, sans-serif;
  font-size: 13px;
  font-weight: 900;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 800px) {
  .site-header,
  main,
  footer {
    width: min(100% - 24px, 680px);
  }

  .site-header {
    min-height: 84px;
  }

  h1 {
    font-size: 23px;
  }

  .chart-section {
    padding: 18px 14px;
  }

  .chart-section > .section-heading {
    display: block;
  }

  .result-summary {
    margin-top: 16px;
    text-align: left;
  }

  .chart-wrap {
    min-height: 390px;
    aspect-ratio: 0.95 / 1;
  }

  .control-section {
    grid-template-columns: 1fr;
  }

  .input-panel,
  .log-panel {
    padding: 18px 14px;
  }

  th,
  td {
    padding-inline: 6px;
  }

  .version {
    max-width: 100px;
    text-align: right;
  }

  .header-actions {
    gap: 8px;
  }

  .talk-button {
    min-height: 34px;
    padding-right: 9px;
  }

  .talk-mark {
    width: 20px;
    height: 20px;
  }

  .talk-button span:last-child {
    display: none;
  }
}
