:root {
  color-scheme: dark;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101114;
  --surface: #181a1f;
  --panel: rgba(24, 26, 31, 0.82);
  --field: #101114;
  --ink: #f3f0e8;
  --muted: #a9a39a;
  --line: #34373f;
  --dash: #4a4d56;
  --accent: #70d6aa;
  --accent-soft: rgba(112, 214, 170, 0.14);
  --warn: #ff8a70;
  --tab-bg: rgba(255, 255, 255, 0.05);
  --ad-bg: rgba(255, 255, 255, 0.04);
  --logo-bg: rgba(255, 255, 255, 0.05);
  --focus: rgba(112, 214, 170, 0.2);
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.26);
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --panel: rgba(255, 255, 255, 0.72);
  --field: #fbfaf7;
  --ink: #161616;
  --muted: #6f6d67;
  --line: #dedad0;
  --dash: #c9c3b7;
  --accent: #1f7a5b;
  --accent-soft: #e1f0e8;
  --warn: #b24532;
  --tab-bg: rgba(255, 255, 255, 0.6);
  --ad-bg: rgba(255, 255, 255, 0.5);
  --logo-bg: rgba(255, 255, 255, 0.62);
  --focus: rgba(31, 122, 91, 0.14);
  --shadow: 0 20px 70px rgba(29, 27, 23, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 20px 0;
}

.ad-banner {
  min-height: 76px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--dash);
  border-radius: 8px;
  background: var(--ad-bg);
  color: var(--muted);
}

.ad-banner span {
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.ad-banner-top {
  margin-bottom: 16px;
}

.ad-banner-bottom {
  margin-top: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-placeholder {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px dashed var(--dash);
  border-radius: 8px;
  background: var(--logo-bg);
  color: var(--muted);
}

.logo-placeholder span {
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 2.7vw, 2.8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.05rem, 1.45vw, 1.35rem);
  line-height: 1.08;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 14px;
  font-size: 0.78rem;
  letter-spacing: 0;
}

.calculator-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tab-bg);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.utility-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle,
.language-control {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tab-bg);
  color: var(--ink);
}

.theme-toggle {
  padding: 0 10px;
  font-size: 0.78rem;
}

.theme-toggle-track {
  width: 32px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: 999px;
  background: var(--line);
}

.theme-toggle-thumb {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--surface);
  transform: translateX(0);
  transition: transform 160ms ease, background-color 160ms ease;
}

.theme-toggle[aria-pressed="true"] .theme-toggle-track {
  background: var(--accent);
}

.theme-toggle[aria-pressed="true"] .theme-toggle-thumb {
  background: #101114;
  transform: translateX(14px);
}

.language-control {
  padding-left: 9px;
}

.language-flag {
  font-size: 1rem;
  line-height: 1;
}

.language-control select {
  width: auto;
  min-height: 36px;
  padding-left: 0;
  padding-right: 26px;
  border: 0;
  background-color: transparent;
}

.tab,
.ghost-button {
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  transition: color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.tab {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.82rem;
  white-space: nowrap;
}

.tab:hover,
.tab.is-active {
  color: var(--ink);
  background: var(--surface);
}

.tab.is-active {
  box-shadow: 0 8px 24px rgba(20, 20, 20, 0.08);
}

.ghost-button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  font-size: 0.82rem;
}

.ghost-button:hover {
  color: var(--ink);
  background: var(--surface);
}

.calculator-panel {
  display: none;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.calculator-panel.is-active {
  display: block;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.two-column-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 22px;
  align-items: start;
}

.two-column-grid.compact {
  grid-template-columns: repeat(2, minmax(280px, 1fr));
}

.input-panel,
.output-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.input-panel,
.output-panel {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.field,
.result-field {
  display: grid;
  grid-template-columns: minmax(128px, 34%) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.field > span,
.result-field > span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}

.input-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
}

.input-wrap:focus-within,
select:focus,
input:focus {
  border-color: var(--accent);
  outline: 3px solid var(--focus);
}

.input-wrap input,
.input-wrap span {
  min-width: 0;
}

.input-wrap input {
  border: 0;
  background: transparent;
}

.input-wrap span {
  padding-right: 12px;
  color: var(--muted);
  font-size: 0.76rem;
}

input,
select {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
}

input {
  appearance: textfield;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.result-list {
  display: grid;
  gap: 10px;
}

.result-wrap {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
}

.result-wrap strong {
  overflow-wrap: anywhere;
  font-size: 0.92rem;
  line-height: 1;
  letter-spacing: 0;
}

.result-wrap small {
  min-width: max-content;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.1;
  text-align: right;
}

.result-wrap.has-detail {
  flex-wrap: wrap;
}

.is-warning {
  color: var(--warn);
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 24px, 620px);
    padding: 14px 0;
  }

  .topbar,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-lockup {
    align-items: center;
  }

  .calculator-tabs {
    width: 100%;
    overflow-x: auto;
  }

  .tab {
    flex: 1 0 auto;
  }

  .calculator-panel {
    padding: 12px;
  }

  .two-column-grid,
  .two-column-grid.compact {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 420px) {
  .field,
  .result-field {
    grid-template-columns: minmax(104px, 38%) minmax(0, 1fr);
    gap: 8px;
  }

  .result-wrap {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
  }

  .input-panel,
  .output-panel {
    padding: 12px;
  }
}
