.heart-rate-calculator-container,
.heart-rate-calculator-container *,
.heart-rate-calculator-container *::before,
.heart-rate-calculator-container *::after {
  box-sizing: border-box;
}

.heart-rate-calculator-container {
  --heart-shell: #faf2e8;
  --heart-paper: #fff7e8;
  --heart-panel: #fffdf7;
  --heart-input: #fffdf8;
  --heart-ink: #2b2119;
  --heart-muted: #67584a;
  --heart-line: #6b5745;
  --heart-line-soft: rgba(107, 87, 69, 0.26);
  --heart-grid: rgba(107, 87, 69, 0.055);
  --heart-primary-bg: #f2e3d3;
  --heart-primary-ink: #2b2119;
  --heart-green: #e3efd2;
  --heart-green-ink: #2f4e2e;
  --heart-blue: #dfeef8;
  --heart-blue-ink: #28455a;
  --heart-amber: #f4dfba;
  --heart-warn: #fff2c1;
  --heart-danger: #a43e2d;
  --heart-shadow: 4px 4px 0 rgba(72, 55, 40, 0.22);
  --heart-shadow-soft: 2px 2px 0 rgba(72, 55, 40, 0.14);
  --heart-zone-1: #dfe7dc;
  --heart-zone-2: #dbeaf8;
  --heart-zone-3: #e3efd2;
  --heart-zone-4: #faecd4;
  --heart-zone-5: #f2d7c8;
  --heart-zone-1-ink: #40533d;
  --heart-zone-2-ink: #28455a;
  --heart-zone-3-ink: #2f4e2e;
  --heart-zone-4-ink: #614316;
  --heart-zone-5-ink: #6b2f23;

  width: min(980px, calc(100vw - 28px));
  margin: 16px auto 24px;
  padding: 0;
  color: var(--heart-ink);
  background:
    linear-gradient(var(--heart-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--heart-grid) 1px, transparent 1px),
    var(--heart-shell);
  background-size: 20px 20px, 20px 20px, auto;
  border: 2px solid var(--heart-line);
  border-radius: 0;
  box-shadow: var(--heart-shadow);
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
  letter-spacing: 0;
  overflow: visible;
}

@media (prefers-color-scheme: dark) {
  .heart-rate-calculator-container {
    --heart-shell: #201811;
    --heart-paper: #2b2119;
    --heart-panel: #33271d;
    --heart-input: #241c15;
    --heart-ink: #f7ebd8;
    --heart-muted: #f0dfc5;
    --heart-line: #a98b6b;
    --heart-line-soft: rgba(169, 139, 107, 0.48);
    --heart-grid: rgba(229, 196, 139, 0.06);
    --heart-primary-bg: #ead6b8;
    --heart-primary-ink: #2b2119;
    --heart-green: #344a32;
    --heart-green-ink: #f7ebd8;
    --heart-blue: #233c43;
    --heart-blue-ink: #f1e8cf;
    --heart-amber: #3b2d21;
    --heart-warn: #3b2d21;
    --heart-danger: #d08b75;
    --heart-shadow: 4px 4px 0 rgba(0, 0, 0, 0.34);
    --heart-shadow-soft: 2px 2px 0 rgba(0, 0, 0, 0.24);
    --heart-zone-1: #2f3b31;
    --heart-zone-2: #243d49;
    --heart-zone-3: #344a32;
    --heart-zone-4: #4c3a22;
    --heart-zone-5: #543126;
    --heart-zone-1-ink: #f7ebd8;
    --heart-zone-2-ink: #f7ebd8;
    --heart-zone-3-ink: #f7ebd8;
    --heart-zone-4-ink: #f7ebd8;
    --heart-zone-5-ink: #f7ebd8;
    color-scheme: dark;
  }
}

.heart-rate-calculator-container button,
.heart-rate-calculator-container input,
.heart-rate-calculator-container select {
  font: inherit;
  letter-spacing: 0;
}

.heart-rate-calculator-container h2,
.heart-rate-calculator-container h3,
.heart-rate-calculator-container p {
  margin: 0;
}

.heart-rec-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px 13px;
  background:
    linear-gradient(90deg, rgba(255, 253, 247, 0.99), rgba(255, 249, 238, 0.98) 64%, rgba(247, 223, 157, 0.28)),
    var(--heart-paper);
}

@media (prefers-color-scheme: dark) {
  .heart-rec-title {
    background:
      linear-gradient(90deg, rgba(51, 39, 29, 0.98), rgba(43, 33, 25, 0.98) 64%, rgba(90, 70, 30, 0.34)),
      var(--heart-paper);
  }
}

.heart-rec-title-copy {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.heart-rec-kicker {
  color: var(--heart-muted);
  font-size: 11px;
  font-weight: 950;
  line-height: 1.1;
}

.heart-rec-title-text {
  color: var(--heart-ink);
  font-size: 25px;
  font-weight: 950;
  line-height: 1.15;
  letter-spacing: 0;
}

.heart-rec-subtitle {
  max-width: 650px;
  color: var(--heart-muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.45;
}

.heart-rec-title-badge {
  display: grid;
  min-width: 86px;
  min-height: 44px;
  align-items: center;
  justify-items: center;
  padding: 8px 10px;
  color: var(--heart-green-ink);
  background: var(--heart-green);
  border: 2px solid var(--heart-line);
  box-shadow: 3px 3px 0 rgba(72, 55, 40, 0.2);
  line-height: 1;
  white-space: nowrap;
}

.heart-rec-title-badge span {
  font-size: 11px;
  font-weight: 900;
}

.heart-rec-title-badge strong {
  font-size: 13px;
  font-weight: 950;
}

.heart-rec-body {
  border-top: 2px solid var(--heart-line);
  padding: 14px;
}

.heart-rec-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.92fr) minmax(0, 1.08fr);
  gap: 14px;
  align-items: stretch;
}

.heart-rec-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 12px;
  padding: 13px;
  background: var(--heart-panel);
  border: 2px solid var(--heart-line);
  border-radius: 0;
  box-shadow: var(--heart-shadow-soft);
}

.heart-rec-panel-head {
  display: grid;
  gap: 4px;
  padding-bottom: 9px;
  border-bottom: 1px dashed var(--heart-line-soft);
}

.heart-rec-panel-head h3 {
  color: var(--heart-ink);
  font-size: 17px;
  font-weight: 950;
  line-height: 1.2;
}

.heart-rec-panel-head p {
  color: var(--heart-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.heart-rec-fields {
  display: grid;
  gap: 10px;
}

.heart-rec-field {
  display: grid;
  gap: 6px;
}

.heart-rec-field.is-hidden,
.heart-rec-result-content.hidden,
.heart-rec-empty.hidden {
  display: none;
}

.heart-rec-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: var(--heart-ink);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.25;
}

.heart-rec-label small {
  min-width: 0;
  color: var(--heart-muted);
  font-size: 11px;
  font-weight: 700;
  text-align: right;
}

.heart-rec-input,
.heart-rec-select {
  width: 100%;
  min-height: 43px;
  padding: 9px 10px;
  color: var(--heart-ink);
  background: var(--heart-input);
  border: 2px solid var(--heart-line);
  border-radius: 0;
  box-shadow: inset 2px 2px 0 rgba(72, 55, 40, 0.06);
  font-size: 16px;
  font-weight: 850;
  line-height: 1.25;
}

.heart-rec-input {
  font-weight: 950 !important;
  font-variation-settings: "wght" 950;
  font-variant-numeric: tabular-nums;
}

.heart-rec-input::placeholder {
  color: rgba(103, 88, 74, 0.72);
  font-weight: 650;
}

@media (prefers-color-scheme: dark) {
  .heart-rec-input::placeholder {
    color: rgba(240, 223, 197, 0.7);
  }
}

.heart-rec-input:focus,
.heart-rec-select:focus {
  outline: 2px solid var(--heart-amber);
  outline-offset: 2px;
}

.heart-rec-actions {
  display: grid;
  gap: 9px;
  margin-top: 0;
}

.heart-rec-guide {
  display: grid;
  gap: 8px;
  padding: 10px;
  background:
    linear-gradient(var(--heart-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--heart-grid) 1px, transparent 1px),
    var(--heart-paper);
  background-size: 16px 16px, 16px 16px, auto;
  border: 2px solid var(--heart-line);
}

.heart-rec-guide h4 {
  margin: 0;
  color: var(--heart-ink);
  font-size: 13px;
  font-weight: 950;
  line-height: 1.2;
}

.heart-rec-guide-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.heart-rec-guide-list li {
  display: grid;
  grid-template-columns: 34px minmax(60px, auto) minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  min-height: 29px;
  padding: 5px 7px;
  background: var(--heart-panel);
  border: 1px dashed var(--heart-line-soft);
  color: var(--heart-ink);
  font-size: 12px;
  line-height: 1.2;
}

.heart-rec-guide-list strong {
  color: var(--heart-green-ink);
  font-size: 11px;
  font-weight: 950;
}

.heart-rec-guide-list span {
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.heart-rec-guide-list em {
  min-width: 0;
  color: var(--heart-muted);
  font-style: normal;
  font-weight: 800;
}

.heart-rec-action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.heart-rec-btn {
  display: inline-flex;
  min-width: 0;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 11px;
  color: var(--heart-primary-ink);
  background: var(--heart-primary-bg);
  border: 2px solid var(--heart-line);
  border-radius: 0;
  box-shadow: var(--heart-shadow-soft);
  cursor: pointer;
  font-size: 14px;
  font-weight: 950;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}

.heart-rate-calculator-container .heart-rec-btn {
  font-weight: 950 !important;
}

.heart-rec-btn:hover {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(72, 55, 40, 0.18);
}

.heart-rec-btn:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.heart-rec-btn:focus-visible {
  outline: 2px solid var(--heart-amber);
  outline-offset: 2px;
}

.heart-rec-btn-primary {
  width: 100%;
  min-height: 43px;
  background: var(--heart-primary-bg);
}

.heart-rec-btn-secondary,
.heart-rec-btn-save {
  color: var(--heart-ink);
  background: var(--heart-paper);
}

.heart-rec-btn-save {
  width: 100%;
  margin-top: 1px;
}

.heart-rec-btn-icon {
  flex: 0 0 auto;
}

.heart-rec-empty {
  display: grid;
  min-height: 286px;
  align-content: center;
  justify-items: center;
  gap: 7px;
  padding: 18px;
  color: var(--heart-muted);
  background:
    linear-gradient(var(--heart-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--heart-grid) 1px, transparent 1px),
    var(--heart-paper);
  background-size: 18px 18px, 18px 18px, auto;
  border: 2px dashed var(--heart-line-soft);
  text-align: center;
}

.heart-rec-empty strong {
  color: var(--heart-ink);
  font-size: 17px;
  font-weight: 950;
}

.heart-rec-empty span {
  max-width: 280px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.heart-rec-result-content {
  display: grid;
  gap: 11px;
}

.heart-rec-result-hero {
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 13px 12px;
  color: var(--heart-green-ink);
  background: var(--heart-green);
  border: 2px solid var(--heart-line);
  box-shadow: var(--heart-shadow-soft);
  text-align: center;
}

.heart-rec-result-hero span {
  font-size: 12px;
  font-weight: 900;
}

.heart-rec-result-hero strong {
  font-size: clamp(30px, 4vw, 42px);
  font-weight: 950;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.heart-rec-chart {
  position: relative;
  min-height: 214px;
  padding: 10px;
  background: var(--heart-paper);
  border: 2px solid var(--heart-line);
}

.heart-rec-chart canvas {
  display: block;
  width: 100% !important;
  height: 194px !important;
}

.heart-rec-zone-table-wrap {
  overflow: visible;
  background: var(--heart-panel);
  border: 2px solid var(--heart-line);
}

.heart-rec-zone-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  color: var(--heart-ink);
  font-size: 12px;
  line-height: 1.35;
}

.heart-rec-zone-table th,
.heart-rec-zone-table td {
  padding: 8px 7px;
  border-bottom: 1px dashed var(--heart-line-soft);
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.heart-rec-zone-table th {
  color: var(--heart-muted);
  background: rgba(107, 87, 69, 0.06);
  font-size: 11px;
  font-weight: 950;
}

.heart-rec-zone-table th:nth-child(1),
.heart-rec-zone-table td:nth-child(1) {
  width: 34%;
}

.heart-rec-zone-table th:nth-child(2),
.heart-rec-zone-table td:nth-child(2) {
  width: 25%;
}

.heart-rec-zone-table th:nth-child(3),
.heart-rec-zone-table td:nth-child(3) {
  width: 41%;
}

.heart-rec-zone-table tr:last-child td {
  border-bottom: 0;
}

.heart-rec-zone-name {
  display: inline-grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-width: 0;
  font-weight: 900;
}

.heart-rec-zone-chip {
  display: inline-flex;
  min-width: 30px;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  color: var(--heart-zone-ink, var(--heart-ink));
  background: var(--heart-zone-bg, var(--heart-green));
  border: 1px solid var(--heart-line);
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
}

.heart-rec-zone-range {
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  white-space: normal;
}

.heart-rec-toast {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 1000;
  max-width: min(320px, calc(100vw - 36px));
  padding: 10px 12px;
  color: var(--heart-ink);
  background: var(--heart-paper);
  border: 2px solid var(--heart-line);
  box-shadow: var(--heart-shadow);
  font-size: 13px;
  font-weight: 850;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.heart-rec-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.heart-rec-toast[data-type="success"] {
  background: var(--heart-green);
}

.heart-rec-toast[data-type="warning"] {
  background: var(--heart-warn);
}

.heart-rec-toast[data-type="error"] {
  color: #fff7e8;
  background: var(--heart-danger);
}

@media (max-width: 820px) {
  .heart-rate-calculator-container {
    width: min(100% - 20px, 720px);
    margin: 12px auto 20px;
  }

  .heart-rec-layout {
    grid-template-columns: 1fr;
  }

  .heart-rec-empty {
    min-height: 180px;
  }
}

@media (max-width: 430px) {
  .heart-rate-calculator-container {
    width: calc(100vw - 18px);
    box-shadow: 3px 3px 0 rgba(72, 55, 40, 0.18);
  }

  .heart-rec-title {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .heart-rec-title-badge {
    min-width: 0;
    width: 100%;
    min-height: 36px;
    grid-template-columns: auto auto;
    justify-content: center;
    gap: 8px;
  }

  .heart-rec-title-text {
    font-size: 22px;
  }

  .heart-rec-body {
    padding: 10px;
  }

  .heart-rec-panel {
    padding: 10px;
  }

  .heart-rec-label {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .heart-rec-label small {
    text-align: left;
  }

  .heart-rec-input,
  .heart-rec-select {
    min-height: 42px;
    font-size: 15px;
  }

  .heart-rec-btn {
    min-height: 39px;
    padding: 8px 9px;
    font-size: 13px;
  }

  .heart-rec-chart {
    min-height: 206px;
    padding: 8px;
  }

  .heart-rec-chart canvas {
    height: 188px !important;
  }

  .heart-rec-zone-table {
    font-size: 11px;
  }

  .heart-rec-zone-table th,
  .heart-rec-zone-table td {
    padding: 7px 5px;
  }

  .heart-rec-zone-chip {
    min-width: 26px;
    min-height: 22px;
    font-size: 10px;
  }
}
