: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;
}

html {
  scroll-behavior: smooth;
}

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.42;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(100% - 16px, 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: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 0.76rem;
  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.94rem;
}
.brand small {
  color: var(--muted);
  font-size: 0.74rem;
}

.version {
  flex: 0 0 auto;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-size: 0.72rem;
  font-weight: 800;
}
.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: 8px;
  padding-block: 10px 24px;
}

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

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

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

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

.lede {
  margin-bottom: 0;
  color: #52676a;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

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

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

.formula-note code {
  display: block;
  color: var(--brand-dark);
  font-size: 0.9rem;
  font-weight: 750;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.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;
}

.calculator {
  min-width: 0;
  display: grid;
  gap: 8px;
}

form {
  display: grid;
  gap: 8px;
}

.step-card,
.result-card {
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.step-card,
.result-card {
  padding: 10px;
}

.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%);
}

.step-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 9px;
  margin-bottom: 7px;
}

.step-title {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.step-heading > div,
.step-title > div {
  min-width: 0;
}

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

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

.step-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.mode-toggle {
  flex: 0 0 auto;
  max-width: 42%;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(47, 111, 115, 0.35);
  border-radius: 999px;
  background: #fff;
  color: var(--brand-dark);
  font-size: 0.72rem;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(26, 61, 64, 0.08);
}

.mode-toggle:hover,
.mode-toggle:focus-visible {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px rgba(47, 111, 115, 0.12);
}

.field-grid,
.field-grid.three-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
}

.field {
  display: grid;
  grid-template-columns: minmax(90px, 0.58fr) minmax(0, 1fr);
  grid-template-areas: "label control";
  align-items: center;
  column-gap: 8px;
  min-height: 43px;
  padding-block: 2px;
  min-width: 0;
}

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

.field-help {
  display: none;
  grid-area: help;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.15;
}

.input-unit {
  grid-area: control;
  min-height: 44px;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.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%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 8px 10px;
  color: var(--ink);
  background: transparent;
  font-size: 1rem;
  font-weight: 750;
}

.input-unit span {
  min-width: 42px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-alt);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

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

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

.compound-control .input-unit,
.compound-control select {
  grid-area: auto;
}

.compound-control .input-unit span {
  display: none;
}

.compound-control select {
  padding: 8px 24px 8px 8px;
  font-size: 0.9rem;
}

.inline-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-top: 6px;
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid #cfe0e0;
  background: #cfe0e0;
}

.inline-summary div {
  min-width: 0;
  padding: 7px 8px;
  background: var(--brand-soft);
}
.inline-summary span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
}
.inline-summary strong {
  display: block;
  margin-top: 1px;
  color: var(--brand-dark);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

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

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

.segmented-control {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  width: 100%;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-alt);
}

.segmented-control label {
  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;
  transition: 0.18s ease;
}

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

.validation-message {
  margin-top: 7px;
  padding: 8px 9px;
  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: 8px;
  margin-top: 7px;
}

.btn {
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 11px;
  font-weight: 850;
}

.btn-primary {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
}
.action-row .btn-primary {
  min-height: 48px;
}
.btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}
.btn-secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}
.btn-secondary:hover {
  background: var(--surface-alt);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 7px;
}

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

.result-controls {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.result-mode-button {
  min-height: 30px;
  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:hover:not(:disabled),
.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 {
  justify-self: start;
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-alt);
  font-size: 0.7rem;
  font-weight: 850;
}

.status-badge.success {
  color: var(--success);
  background: var(--success-soft);
}
.status-badge.error {
  color: var(--danger);
  background: var(--danger-soft);
}

.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);
}

.operator {
  display: none;
}

.result-box {
  min-width: 0;
  display: block;
  padding: 8px 6px;
  border: 0;
  border-radius: 0;
  background: var(--surface-alt);
}

.result-box.emphasis {
  border-color: rgba(47, 111, 115, 0.28);
  background: var(--brand-soft);
}

.result-box.total {
  border-color: rgba(255, 164, 91, 0.5);
  background: var(--accent-soft);
}

.result-box span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
}

.result-box strong {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.result-box small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.74rem;
}

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

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

.detail-item span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
}

.detail-item strong {
  display: block;
  margin-top: 0;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

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

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

.research-note {
  margin-top: 6px;
  padding: 8px 9px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.74rem;
}

.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;
}

.footer-inner {
  align-items: center;
  flex-direction: row;
  justify-content: center;
  gap: 8px;
}

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

@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;
  }

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

  .result-controls {
    width: 100%;
    justify-content: flex-end;
  }
}

@media (min-width: 720px) {
  .shell {
    width: min(100% - 40px, 1120px);
  }

  .page {
    grid-template-columns: minmax(230px, 0.34fr) minmax(0, 1fr);
    gap: 32px;
    padding-block: 48px 64px;
  }

  .intro {
    position: sticky;
    top: 100px;
    align-self: start;
  }

  h1 {
    font-size: clamp(1.4rem, 2.4vw, 2rem);
  }

  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .field-grid.three-col {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .inline-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .action-row {
    grid-template-columns: 1fr 1fr;
  }
  .result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
  }
  .status-badge {
    justify-self: auto;
  }

  .primary-results {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: 1px;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
  .footer-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}
