:root {
  --brand: #2f6f73;
  --brand-dark: #24585c;
  --brand-soft: #e8f1f1;
  --accent: #ffa45b;
  --accent-soft: #fff3e8;
  --ink: #173034;
  --muted: #66787b;
  --line: #d9e3e3;
  --surface: #ffffff;
  --surface-alt: #f6f9f9;
  --danger: #a23b32;
  --danger-soft: #fff0ed;
  --success: #28664a;
  --success-soft: #eaf6ef;
  --shadow: 0 14px 36px rgba(24, 52, 56, 0.08);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
  min-width: 0;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
  background: #f6f9f9;
  color: var(--ink);
  font-family:
    "Noto Sans KR",
    Pretendard,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Arial,
    sans-serif;
  line-height: 1.32;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(100% - 12px, 1120px);
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(217, 227, 227, 0.9);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.header-inner,
.footer-inner {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand strong,
.brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 0.88rem;
}
.brand small {
  color: var(--muted);
  font-size: 0.68rem;
}

.tool-link {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--brand-dark);
  background: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  text-decoration: none;
}
.language-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-size: 0.68rem;
  font-weight: 850;
  white-space: nowrap;
}
.language-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.language-switch label {
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
}
.language-switch input:checked + label {
  color: #fff;
  background: var(--brand);
}
.language-switch input:focus-visible + label {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.language-switch > span {
  color: var(--line);
}

.page {
  display: grid;
  gap: 6px;
  padding-block: 7px 16px;
}

.intro,
.calculator,
form {
  display: grid;
  gap: 6px;
}

.tool-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-alt);
}

.tool-tab {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

.tool-tab.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 3px 10px rgba(36, 88, 92, 0.2);
}

.tab-panel {
  display: grid;
  gap: 6px;
}

.eyebrow {
  margin: 0;
  color: var(--brand);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.42rem;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.formula-note {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.formula-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
}

.formula-note code {
  display: block;
  color: var(--brand-dark);
  font-size: 0.9rem;
  font-weight: 800;
}

.intro-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: center;
}
.intro-title-row h1 {
  margin: 0;
  white-space: nowrap;
}
.calculator-info {
  display: contents;
}
.calculator-info summary {
  grid-column: 2;
  grid-row: 1;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--brand-dark);
  background: #fff;
  cursor: pointer;
  list-style: none;
  font-size: 1.05rem;
}
.calculator-info summary::-webkit-details-marker {
  display: none;
}
.calculator-info summary:focus-visible {
  outline: 3px solid rgba(47, 111, 115, 0.18);
  outline-offset: 2px;
}
.calculator-info-panel {
  grid-column: 1 / -1;
  grid-row: 2;
  min-width: 0;
}
.calculator-info-panel .lede {
  margin-top: 4px;
}
.calculator-info-panel .formula-note {
  margin-top: 6px;
}

.step-card,
.result-card {
  padding: 8px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(24, 52, 56, 0.06);
}

.section-stock {
  border-left-color: #2f6f73;
  background: linear-gradient(90deg, rgba(232, 241, 241, 0.86), #fff 44%);
}

.section-input {
  border-left-color: #5d77b8;
  background: linear-gradient(90deg, rgba(235, 239, 250, 0.9), #fff 44%);
}

.section-result {
  border-left-color: #ffa45b;
  background: linear-gradient(90deg, rgba(255, 243, 232, 0.92), #fff 44%);
}

.section-serial {
  border-left-color: #7b6bb8;
  background: linear-gradient(90deg, rgba(240, 237, 250, 0.9), #fff 44%);
}

.section-treat {
  border-left-color: #b86b8d;
  background: linear-gradient(90deg, rgba(250, 237, 244, 0.9), #fff 44%);
}

.step-heading,
.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 5px;
}

.step-title {
  display: flex;
  align-items: flex-start;
  gap: 7px;
}

.step-number {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
}

.step-heading h2,
.result-header h2 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
}

.field {
  display: grid;
  grid-template-columns: minmax(104px, 0.6fr) minmax(0, 1fr);
  align-items: center;
  column-gap: 6px;
  min-height: 40px;
  padding-block: 1px;
}

.field-label {
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.15;
}

.input-unit {
  min-height: 44px;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.input-unit:focus-within,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 111, 115, 0.14);
  outline: none;
}

.input-unit input {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  outline: 0;
  padding: 7px 9px;
  color: var(--ink);
  background: transparent;
  font-size: 1rem;
  font-weight: 750;
}

select {
  width: 100%;
  min-height: 44px;
  padding: 7px 24px 7px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: #fff;
  font-size: 1rem;
  font-weight: 750;
}

.compound-control {
  display: grid;
  grid-template-columns: minmax(58px, 1fr) 96px;
  gap: 4px;
}

.ratio-unit span {
  min-width: 38px;
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-alt);
  font-weight: 850;
}

.extra-fieldset {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
  min-height: 40px;
  margin: 4px 0 0;
  padding: 0;
  border: 0;
}

.extra-fieldset legend {
  margin: 0;
  padding: 0;
  font-size: 0.76rem;
  font-weight: 800;
}

.segmented-control {
  display: flex;
  gap: 3px;
  width: 100%;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-alt);
}

.segmented-control label {
  flex: 1 1 0;
  min-width: 0;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  min-height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.segmented-control input:checked + span {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 3px 10px rgba(36, 88, 92, 0.24);
}

.method-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
}

.method-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.method-control span {
  min-height: 44px;
  display: grid;
  place-items: center;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 850;
  line-height: 1.1;
  text-align: center;
}

.method-control input:checked + span {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.validation-message {
  margin-top: 5px;
  padding: 7px 8px;
  border: 1px solid #f3c8c2;
  border-radius: 10px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 0.82rem;
  font-weight: 700;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 5px;
}

.action-row .btn:only-child {
  grid-column: 1 / -1;
}

.btn {
  min-height: 44px;
  padding: 0 9px;
  border-radius: 10px;
  font-weight: 850;
}

.btn-primary {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
}
.action-row .btn-primary {
  min-height: 48px;
}
.btn-secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}
.btn:disabled {
  cursor: default;
  opacity: 0.46;
}

.result-header {
  flex-wrap: wrap;
}

.result-header > div:first-child {
  flex: 0 0 96px;
  min-width: 96px;
}

.result-controls {
  flex: 1 1 auto;
  display: inline-flex;
  justify-content: flex-end;
  align-items: center;
  gap: 5px;
}

.result-mode-button {
  min-height: 28px;
  padding: 0 7px;
  border: 1px solid rgba(47, 111, 115, 0.35);
  border-radius: 999px;
  background: #fff;
  color: var(--brand-dark);
  font-size: 0.7rem;
  font-weight: 850;
}

.result-mode-button.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 3px 10px rgba(36, 88, 92, 0.2);
}

.result-mode-button:disabled {
  cursor: default;
  opacity: 0.46;
}

.status-badge.sr-only {
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  background: transparent;
}

.primary-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--line);
}

.assist-results {
  margin-bottom: 5px;
}

.result-box {
  padding: 6px 5px;
  background: var(--surface-alt);
}

.result-box.emphasis {
  background: var(--brand-soft);
}
.result-box.total {
  background: var(--accent-soft);
}
.result-box span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
  line-height: 1.1;
}
.result-box strong {
  display: block;
  margin-top: 3px;
  font-size: 1rem;
  line-height: 1.08;
  overflow-wrap: anywhere;
}
.result-box small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.12;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  margin-top: 5px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--line);
}

.detail-item {
  display: grid;
  grid-template-columns: minmax(112px, 0.84fr) minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  padding: 6px 7px;
  background: #fff;
}

.detail-item span {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.15;
}
.detail-item strong {
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.serial-results {
  display: grid;
  gap: 1px;
  margin-top: 5px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--line);
}

.serial-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  padding: 6px 7px;
  background: #fff;
}

.serial-row span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.serial-row strong {
  display: block;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.serial-row small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.68rem;
}

.mix-instruction {
  margin-top: 5px;
  padding: 7px 8px;
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: #fffaf5;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.export-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-top: 5px;
}

.research-note {
  display: none;
}

.research-note strong {
  color: var(--ink);
}
.research-note p {
  margin: 4px 0 0;
}

.site-footer {
  padding: 8px 0 14px;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: center;
}

.site-footer a {
  color: var(--brand-dark);
  font-weight: 800;
  text-decoration: none;
}

.footer-inner {
  align-items: flex-start;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 0.74rem;
}

@media (max-width: 374px) {
  .shell {
    width: min(100% - 8px, 1120px);
  }
  .field {
    grid-template-columns: minmax(94px, 0.56fr) minmax(0, 1fr);
    column-gap: 4px;
  }
  .field-label {
    font-size: 0.8rem;
  }
  .compound-control {
    grid-template-columns: minmax(0, 1fr) 76px;
    gap: 3px;
  }
  .result-box strong {
    font-size: 0.92rem;
  }
  .method-control span {
    font-size: 0.6rem;
    letter-spacing: 0;
  }
  .export-actions .btn {
    font-size: 0.74rem;
  }
}

@media (max-width: 360px) {
  .primary-results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .primary-results .result-box:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
  .export-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .export-actions .btn:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}

@media (min-width: 720px) {
  .shell {
    width: min(100% - 40px, 1120px);
  }
  .page {
    grid-template-columns: minmax(230px, 0.34fr) minmax(0, 1fr);
    gap: 24px;
    padding-block: 28px 40px;
  }
  .intro {
    position: sticky;
    top: 78px;
    align-self: start;
  }
  h1 {
    font-size: clamp(1.4rem, 2.4vw, 2rem);
  }
  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .method-control span {
    font-size: 0.8rem;
  }
  .footer-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}
