:root {
  color-scheme: light;
  --ink: #141414;
  --muted: #5f625e;
  --paper: #f8f7f2;
  --panel: #fffdf7;
  --line: #1d1d1b;
  --soft-line: #d9d4c7;
  --accent: #0e6f5c;
  --accent-dark: #0a4d41;
  --warning: #b7791f;
  --danger: #b42318;
  --safe: #146c43;
  --blue: #2457a6;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-family: Georgia, "Times New Roman", serif;
  background: var(--paper);
  color: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.masthead {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: clamp(24px, 5vw, 72px);
  align-items: start;
  padding: 26px 0 32px;
  border-bottom: 4px double var(--line);
}

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

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  font: 700 14px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.brand-text {
  font: 700 18px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.eyebrow,
.section-label,
.metric-label,
.result-label {
  margin: 0;
  color: var(--accent-dark);
  font: 800 12px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  margin-top: 10px;
  font-size: clamp(44px, 8vw, 86px);
  line-height: 0.94;
  text-transform: uppercase;
}

h2 {
  font-size: clamp(24px, 3vw, 34px);
}

.lede {
  max-width: 740px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.55;
}

.equation-panel,
.workbench {
  background: var(--panel);
  border: 2px solid var(--line);
}

.equation-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin: 28px 0 18px;
  padding: 22px;
  text-align: center;
  font-size: clamp(20px, 3vw, 31px);
}

.equation-name {
  font-weight: 800;
}

.workbench {
  padding: clamp(18px, 4vw, 34px);
}

.search-section,
.selected-market,
.metrics-panel,
.calculator-panel,
.results-panel {
  border: 2px solid var(--line);
  background: #fff;
}

.search-section,
.calculator-panel {
  padding: clamp(18px, 3vw, 28px);
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
}

.search-row input,
.money-input input {
  width: 100%;
  min-width: 0;
  border: 2px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

.search-row input {
  min-height: 48px;
  padding: 12px 14px;
  font: 700 16px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.search-row input:focus,
.money-input input:focus {
  box-shadow: 0 0 0 3px rgba(14, 111, 92, 0.18);
}

.search-row button,
.quick-amounts button,
#share-button {
  min-height: 44px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--ink);
  color: #fff;
  font: 800 14px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.search-row button {
  padding: 0 22px;
}

.help-text,
.status-line,
.metric-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.help-text {
  margin: 10px 0 0;
}

.status-line {
  min-height: 22px;
  margin-top: 12px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.status-line.error {
  color: var(--danger);
  font-weight: 700;
}

.results-list {
  margin-top: 14px;
  border: 2px solid var(--line);
}

.result-option {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  width: 100%;
  padding: 14px;
  border: 0;
  border-bottom: 1px solid var(--soft-line);
  background: #fff;
  color: inherit;
  text-align: left;
}

.result-option:last-child {
  border-bottom: 0;
}

.result-option:hover,
.result-option:focus-visible {
  background: #f2f7f5;
  outline: 0;
}

.result-option img,
.placeholder-image {
  width: 64px;
  height: 64px;
  border: 1px solid var(--soft-line);
  object-fit: cover;
  background: var(--paper);
}

.placeholder-image {
  display: grid;
  place-items: center;
  color: var(--muted);
  font: 800 20px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.option-title {
  display: block;
  margin-bottom: 8px;
  font: 800 17px/1.25 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.option-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font: 700 13px/1.25 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.selected-market {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 16px;
  margin-top: 18px;
  padding: 18px;
}

.selected-market[hidden] {
  display: none;
}

.selected-market img,
.selected-market .placeholder-image {
  width: 86px;
  height: 86px;
}

.selected-market h2 {
  margin-bottom: 8px;
  font-size: clamp(22px, 3vw, 30px);
}

.metrics-panel,
.calculator-panel,
.results-panel {
  margin-top: 18px;
}

.panel-heading,
.result-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-bottom: 2px solid var(--line);
  background: #f6f6f0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font: 800 12px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-transform: uppercase;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.metric {
  min-width: 0;
  padding: 22px;
  border-right: 2px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric strong {
  display: block;
  margin: 10px 0 4px;
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1;
}

.metric-total {
  background: #fff7dc;
}

.metric-total strong {
  color: var(--warning);
}

.progress-track {
  height: 10px;
  margin: 0 18px 14px;
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

#metrics-detail {
  margin: 0;
  padding: 0 18px 18px;
}

.money-input {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  margin-top: 12px;
  border: 2px solid var(--line);
  background: #fff;
}

.money-input span {
  padding-left: 16px;
  color: var(--muted);
  font: 800 28px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.money-input input {
  min-height: 62px;
  padding: 12px 16px 12px 8px;
  border: 0;
  font: 800 30px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.quick-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.quick-amounts button {
  min-height: 38px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.quick-amounts button:hover,
.quick-amounts button:focus-visible {
  background: var(--ink);
  color: #fff;
}

.result-status {
  align-items: stretch;
}

.result-status.safe {
  background: #ecfdf3;
}

.result-status.risky {
  background: #fff4e5;
}

#ratio-value {
  display: block;
  margin-top: 6px;
  font-size: clamp(44px, 8vw, 78px);
  line-height: 0.95;
}

#ratio-interpretation {
  margin: 8px 0 0;
  font-size: 18px;
}

#share-button {
  align-self: center;
  padding: 0 18px;
  background: #fff;
  color: var(--ink);
}

.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.breakdown-table th,
.breakdown-table td {
  padding: 14px 18px;
  border-top: 1px solid var(--soft-line);
  text-align: left;
}

.breakdown-table td {
  text-align: right;
  font-weight: 800;
}

.breakdown-final th,
.breakdown-final td {
  border-top: 2px solid var(--line);
  background: #fff7dc;
  font-size: 18px;
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 20px, 1160px);
    padding-top: 18px;
  }

  .masthead,
  .selected-market {
    grid-template-columns: 1fr;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .metric {
    border-right: 0;
    border-bottom: 2px solid var(--line);
  }

  .metric:last-child {
    border-bottom: 0;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .result-option {
    grid-template-columns: 52px 1fr;
  }

  .result-option img,
  .placeholder-image {
    width: 52px;
    height: 52px;
  }

  .panel-heading,
  .result-status {
    flex-direction: column;
    align-items: flex-start;
  }

  #share-button {
    align-self: stretch;
  }
}
