:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f3f5f7;
  --surface-raised: #ffffff;
  --surface-hover: #e8ebef;
  --surface-soft-hover: #dde2e8;
  --border: #d7dce2;
  --text: #111418;
  --muted: #69717d;
  --muted-soft: #a2a9b3;
  --accent: #0876d9;
  --action: #5f8fbd;
  --action-hover: #4e7fae;
  --equals: #4a515b;
  --equals-hover: #3c434d;
  --shadow: 0 18px 50px rgba(26, 35, 48, 0.12);
  --topbar-height: 52px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101317;
  --surface: #171b20;
  --surface-soft: #20252c;
  --surface-raised: #1c2128;
  --surface-hover: #2a3038;
  --surface-soft-hover: #313944;
  --border: #303741;
  --text: #f2f5f8;
  --muted: #a5aeb9;
  --muted-soft: #6f7885;
  --accent: #4aa3ff;
  --action: #4d7fae;
  --action-hover: #5d8dbc;
  --equals: #3b414a;
  --equals-hover: #4a525d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

[hidden] {
  display: none !important;
}

html {
  scrollbar-width: none;
}

html::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

body {
  scrollbar-width: none;
}

body::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

*::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

body {
  background: var(--bg);
  color: var(--text);
}

.not-found-page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.not-found-topbar {
  min-height: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}

.not-found-theme {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 21px;
  cursor: pointer;
}

.not-found-theme:hover {
  background: var(--surface-hover);
}

.not-found-main {
  width: min(100% - 32px, 760px);
  flex: 1;
  margin: 0 auto;
  padding: clamp(64px, 12vh, 132px) 0 44px;
}

.not-found-code {
  margin: 0;
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
}

.not-found-main h1 {
  margin: 8px 0 0;
  font-size: clamp(34px, 7vw, 54px);
  line-height: 1.08;
  letter-spacing: 0;
}

.not-found-lead {
  max-width: 560px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.not-found-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.not-found-actions a {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border-radius: 8px;
  font-weight: 650;
  text-decoration: none;
}

.not-found-primary {
  background: var(--action);
  color: #ffffff;
}

.not-found-primary:hover {
  background: var(--action-hover);
}

.not-found-secondary {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
}

.not-found-secondary:hover {
  background: var(--surface-hover);
}

.not-found-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 40px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.not-found-links a {
  padding: 14px 4px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.not-found-links a:hover {
  color: var(--accent);
}

.not-found-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 18px 16px calc(18px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}

.not-found-footer a {
  color: inherit;
  text-decoration: none;
}

.not-found-footer a:hover {
  color: var(--text);
}

@media (min-width: 680px) {
  .not-found-links {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 12px 0;
  display: grid;
  grid-template-columns: 44px 1fr 52px;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.icon-button,
.theme-switch {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.menu-button {
  flex-direction: column;
  gap: 5px;
}

.menu-button span {
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.brand {
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}

.theme-switch {
  cursor: pointer;
  justify-self: end;
  border-radius: 8px;
  color: var(--text);
  transition: background 140ms ease;
}

.theme-switch:hover {
  background: var(--surface-soft);
}

.theme-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  font-size: 22px;
  line-height: 1;
}

.theme-icon--sun {
  display: none;
}

.theme-switch input:checked ~ .theme-icon--moon {
  display: none;
}

.theme-switch input:checked ~ .theme-icon--sun {
  display: grid;
}

.desktop-category-nav {
  display: none;
}

.main-area {
  width: 100%;
  flex: 1;
  display: block;
  padding-top: 10px;
}

.calc-column {
  width: 100%;
}

.info-page {
  width: 100%;
  padding: 22px 16px 30px;
  color: var(--text);
}

.info-page h1 {
  margin: 0;
  font-size: clamp(28px, 7vw, 42px);
  line-height: 1.12;
}

.info-page-lead {
  max-width: 720px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.info-page-content {
  display: grid;
  gap: 22px;
  max-width: 760px;
  margin-top: 28px;
}

.info-page-content section {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.info-page-content section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.info-page h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}

.info-page p {
  margin: 9px 0 0;
  line-height: 1.6;
}

.info-page a {
  color: var(--accent-strong);
}

.calculator {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto 44px;
  background: var(--surface);
}

.calculator--scientific {
  grid-template-rows: auto auto auto auto;
}

.calculator-title {
  margin: 0;
  padding: 7px 16px 0;
  color: var(--muted);
  font-size: clamp(13px, 3.2vw, 15px);
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
}

.display {
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: start;
  align-items: end;
  gap: 6px;
  padding: 2px 16px 14px;
  overflow: hidden;
}

.expression {
  max-width: 100%;
  min-height: 19px;
  color: var(--muted);
  font-size: clamp(13px, 3.2vw, 15px);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry {
  --entry-full-size: clamp(42px, 12.2vw, 64px);
  max-width: 100%;
  width: 100%;
  height: calc(var(--entry-full-size) * 1.04);
  font-size: var(--entry-full-size);
  font-weight: 700;
  line-height: calc(var(--entry-full-size) * 1.04);
  letter-spacing: 0;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry.is-condensed {
  font-size: clamp(28px, 8.13vw, 43px);
}

.memory-row {
  width: 100%;
  height: 44px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: stretch;
  color: var(--muted);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.memory-row button {
  position: relative;
  min-width: 0;
  border: 0;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  cursor: default;
  transition: background 140ms ease;
}

.memory-row button:hover {
  background: var(--surface-hover);
}

@media (hover: hover) and (pointer: fine) {
  .memory-row button::after {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    z-index: 1000;
    width: max-content;
    max-width: 220px;
    padding: 7px 9px;
    border-radius: 7px;
    background: var(--text);
    color: var(--surface);
    content: attr(data-tooltip);
    font-size: 12px;
    line-height: 1.2;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(4px);
    transition: opacity 140ms ease, transform 140ms ease;
    white-space: nowrap;
  }

  .memory-row button:first-child::after {
    left: 0;
    transform: translateY(4px);
  }

  .memory-row button:last-child::after {
    right: 0;
    left: auto;
    transform: translateY(4px);
  }

  .memory-row button::before {
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    z-index: 1000;
    border: 5px solid transparent;
    border-top-color: var(--text);
    content: "";
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(4px);
    transition: opacity 140ms ease, transform 140ms ease;
  }

  .memory-row button:hover::after,
  .memory-row button:focus-visible::after,
  .memory-row button:hover::before,
  .memory-row button:focus-visible::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  .memory-row button:first-child:hover::after,
  .memory-row button:first-child:focus-visible::after,
  .memory-row button:last-child:hover::after,
  .memory-row button:last-child:focus-visible::after {
    transform: translateY(0);
  }
}

.keypad {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(6, auto);
  gap: 2px;
  padding-bottom: var(--safe-bottom);
  background: var(--border);
  border-top: 1px solid var(--border);
}

.scientific-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 2px;
  background: var(--border);
  border-top: 1px solid var(--border);
}

.sci-key {
  aspect-ratio: 3 / 1.55;
  font-size: clamp(13px, 3.5vw, 17px);
}

.sci-key.soft,
.sci-key.operator {
  font-size: clamp(12px, 3.2vw, 16px);
}

.sci-key.equals {
  background: var(--equals);
  color: #ffffff;
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 600;
}

.sci-key.equals:hover {
  background: var(--equals-hover);
}

.scientific-bottom {
  display: grid;
  grid-template-columns: minmax(74px, 0.95fr) minmax(0, 5fr);
  min-height: 44px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.angle-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  margin: 0;
  padding: 0 5px;
  border: 0;
  border-right: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
}

.angle-toggle label {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  white-space: nowrap;
}

.angle-toggle input {
  width: 12px;
  height: 12px;
  margin: 0;
  accent-color: var(--accent);
}

.scientific-memory-row {
  border-top: 0;
}

.key {
  min-width: 0;
  min-height: 0;
  aspect-ratio: 3 / 2;
  border: 0;
  border-radius: 5px;
  background: var(--surface-raised);
  color: var(--text);
  font-size: clamp(18px, 5vw, 22px);
  line-height: 1;
  cursor: default;
  transition: background 140ms ease;
}

.key:hover {
  background: var(--surface-hover);
}

.key.soft,
.key.operator {
  background: var(--surface-soft);
  font-size: clamp(16px, 4.2vw, 19px);
}

.key.soft:hover,
.key.operator:hover {
  background: var(--surface-soft-hover);
}

.key.equals {
  background: var(--equals);
  color: #ffffff;
  font-size: 26px;
  font-weight: 600;
}

.key.equals:hover {
  background: var(--equals-hover);
}

.icon-text {
  font-size: 20px;
}

.percentage-page {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.percentage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.percentage-header h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(18px, 5vw, 24px);
  line-height: 1.15;
}

.decimal-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.decimal-control select {
  min-width: 64px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  padding: 7px 26px 7px 9px;
}

.percentage-tools {
  display: grid;
  gap: 10px;
}

.percentage-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.percentage-card h2 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
  text-align: center;
}

.percentage-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.percentage-row label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.percentage-row input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 9px 10px;
  font-size: 16px;
}

.percentage-row input::placeholder {
  color: color-mix(in srgb, var(--muted-soft) 78%, transparent);
  opacity: 1;
}

.percentage-row input:focus::placeholder {
  color: transparent;
}

.percentage-row input:focus,
.decimal-control select:focus {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 28%, transparent);
  outline-offset: 1px;
}

.date-fields,
.date-duration-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.date-fields label,
.date-duration-fields label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.date-fields input,
.date-fields select,
.date-duration-fields input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 9px 10px;
  font-size: 16px;
}

.date-fields input:focus,
.date-fields select:focus,
.date-duration-fields input:focus {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 28%, transparent);
  outline-offset: 1px;
}

.inline-token {
  align-self: end;
  color: var(--muted);
  font-size: 13px;
  line-height: 42px;
}

.percentage-actions {
  display: flex;
  gap: 8px;
}

.percentage-actions button {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 8px 13px;
  font-size: 14px;
  transition: background 140ms ease;
}

.percentage-actions button:first-child {
  border-color: var(--action);
  background: var(--action);
  color: #ffffff;
}

.percentage-actions button:hover {
  background: var(--surface-soft-hover);
}

.percentage-actions button:first-child:hover {
  background: var(--action-hover);
}

.percentage-result {
  display: block;
  color: color-mix(in srgb, var(--muted) 72%, var(--text));
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.percentage-formula {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.currency-card {
  display: grid;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.currency-card h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(18px, 5vw, 24px);
  line-height: 1.15;
}

.currency-rate-summary {
  display: grid;
  gap: 5px;
  padding: 2px 0 4px;
}

.currency-rate-lead {
  color: var(--muted);
  font-size: clamp(15px, 3.8vw, 17px);
  line-height: 1.3;
}

.currency-rate-value {
  color: var(--text);
  font-size: clamp(30px, 9vw, 44px);
  font-weight: 800;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.currency-rate-name {
  color: color-mix(in srgb, var(--text) 82%, var(--muted));
  font-size: 0.68em;
  font-weight: 600;
}

.currency-rate-meta,
.currency-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

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

.currency-row {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.currency-control {
  display: grid;
  grid-template-columns: minmax(92px, 0.72fr) minmax(0, 1.28fr);
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-soft);
}

.currency-control input,
.currency-control select {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 11px 10px;
  font-size: 15px;
}

.currency-control select {
  cursor: pointer;
}

.currency-control [data-currency-amount] {
  border-right: 1px solid var(--border);
  font-weight: 700;
}

.currency-control input:focus,
.currency-control select:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 28%, transparent);
  outline-offset: -2px;
}

.currency-swap {
  justify-self: start;
  width: 42px;
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 0;
  font-size: 22px;
  line-height: 1;
  transition: background 140ms ease;
}

.currency-swap:hover {
  background: var(--surface-soft-hover);
}

.currency-swap-icon {
  transform: translateY(-1px);
}

.currency-status:empty {
  display: none;
}

.currency-chart-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.currency-chart-head {
  display: grid;
  gap: 10px;
}

.currency-chart-head h2,
.currency-chart-head p {
  margin: 0;
}

.currency-chart-head h2 {
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
}

.currency-chart-head p,
.currency-chart-source {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.currency-chart-ranges {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  width: 100%;
  max-width: 220px;
}

.currency-chart-ranges button {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
  transition: background 140ms ease, border-color 140ms ease;
}

.currency-chart-ranges button:hover {
  background: var(--surface-soft-hover);
}

.currency-chart-ranges button.is-active {
  border-color: color-mix(in srgb, var(--accent) 44%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-soft));
  color: var(--accent);
  font-weight: 700;
}

.currency-chart-plot {
  position: relative;
  min-height: 210px;
}

.currency-chart-plot svg {
  width: 100%;
  min-height: 210px;
  display: block;
  color: var(--text);
}

.currency-chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.currency-chart-empty[hidden] {
  display: none;
}

.currency-chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.currency-chart-baseline {
  stroke: var(--muted-soft);
  stroke-width: 1.2;
}

.currency-chart-axis,
.currency-chart-date {
  fill: var(--muted);
  font-size: 11px;
}

.currency-chart-area {
  fill: color-mix(in srgb, #2f9f54 13%, transparent);
}

.currency-chart-line {
  fill: none;
  stroke: #2f9f54;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.currency-chart-point {
  fill: #2f9f54;
  stroke: var(--surface);
  stroke-width: 1.5;
}

.currency-disclaimer {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-soft));
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.converter-card {
  display: grid;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.converter-card h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(18px, 5vw, 24px);
  line-height: 1.15;
}

.converter-summary {
  display: block;
  color: var(--text);
  font-size: clamp(24px, 7vw, 36px);
  font-weight: 800;
  line-height: 1.12;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

.converter-summary.is-condensed {
  font-size: clamp(12px, 3.5vw, 18px);
}

.converter-summary.is-scientific {
  font-size: clamp(20px, 6vw, 30px);
}

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

.converter-row {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.converter-control {
  display: grid;
  grid-template-columns: minmax(92px, 0.72fr) minmax(0, 1.28fr);
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-soft);
}

.converter-control input,
.converter-control select {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 11px 10px;
  font-size: 15px;
}

.converter-control input {
  border-right: 1px solid var(--border);
  font-weight: 700;
}

.converter-control select {
  cursor: pointer;
}

.converter-control input:focus,
.converter-control select:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 28%, transparent);
  outline-offset: -2px;
}

.converter-swap {
  justify-self: start;
  width: 42px;
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 0;
  font-size: 22px;
  line-height: 1;
  transition: background 140ms ease;
}

.converter-swap:hover {
  background: var(--surface-soft-hover);
}

.converter-formula {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

.converter-formula.is-condensed {
  font-size: 11px;
}

.converter-formula.is-scientific {
  font-size: 12px;
}

.converter-guide {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.converter-guide h2,
.converter-guide h3,
.converter-guide p {
  margin: 0;
}

.converter-guide h2,
.converter-guide h3 {
  color: var(--text);
  line-height: 1.25;
}

.converter-guide h2 {
  font-size: 18px;
}

.converter-guide h3 {
  margin-top: 4px;
  font-size: 15px;
}

.fraction-card {
  display: grid;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.fraction-card h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(18px, 5vw, 24px);
  line-height: 1.15;
}

.fraction-card h2 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
}

.fraction-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px minmax(0, 1fr);
  gap: 6px;
  align-items: stretch;
}

.fraction-box {
  min-width: 0;
  margin: 0;
  padding: 10px 5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.fraction-box--single {
  width: min(100%, 280px);
}

.fraction-box legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
}

.mixed-fraction {
  display: grid;
  grid-template-columns: minmax(40px, 0.8fr) minmax(48px, 1fr);
  gap: 6px;
  align-items: center;
}

.mixed-fraction label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.mixed-fraction input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 8px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.mixed-number-workspace {
  display: grid;
  gap: 10px;
}

.mixed-number-workspace label,
.fraction-text-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.mixed-number-workspace input,
.fraction-text-field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 9px 10px;
  font-size: 16px;
}

.mixed-number-workspace input::placeholder,
.fraction-text-field input::placeholder {
  color: color-mix(in srgb, var(--muted-soft) 78%, transparent);
  opacity: 1;
}

.mixed-number-workspace input:focus,
.fraction-text-field input:focus {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 28%, transparent);
  outline-offset: 1px;
}

.mixed-number-workspace input:focus::placeholder,
.fraction-text-field input:focus::placeholder {
  color: transparent;
}

.mixed-fraction input::placeholder {
  color: color-mix(in srgb, var(--muted-soft) 78%, transparent);
  opacity: 1;
}

.mixed-fraction input:focus {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 28%, transparent);
  outline-offset: 1px;
}

.mixed-fraction input:focus::placeholder {
  color: transparent;
}

.whole-field small {
  color: var(--muted);
  font-size: 10px;
}

.fraction-stack {
  display: grid;
  gap: 5px;
}

.fraction-line {
  height: 1px;
  background: var(--border);
}

.fraction-operations {
  display: grid;
  align-content: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

.fraction-operations label {
  display: block;
}

.fraction-operations input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.fraction-operations span {
  display: grid;
  place-items: center;
  width: 38px;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.fraction-operations span:hover {
  background: var(--surface-soft-hover);
}

.fraction-operations input:checked + span {
  border-color: var(--action);
  background: var(--action);
  color: #ffffff;
}

.fraction-operations--horizontal {
  grid-template-columns: repeat(4, 1fr);
  align-content: stretch;
}

.fraction-operations--horizontal span {
  width: 100%;
}

.fraction-actions {
  display: grid;
  grid-template-columns: 1fr auto;
}

.fraction-result {
  min-height: 28px;
}

.fraction-formula:empty {
  display: none;
}

.fraction-guide,
.calculator-guide,
.percentage-guide {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.calculator-guide {
  margin: 12px;
}

.fraction-guide h2,
.fraction-guide h3,
.calculator-guide h2,
.calculator-guide h3,
.percentage-guide h2,
.percentage-guide h3 {
  margin: 0;
  color: var(--text);
  line-height: 1.25;
}

.fraction-guide h2,
.calculator-guide h2,
.percentage-guide h2 {
  font-size: 18px;
}

.fraction-guide h3,
.calculator-guide h3,
.percentage-guide h3 {
  margin-top: 4px;
  font-size: 15px;
}

.fraction-guide p,
.calculator-guide p,
.percentage-guide p {
  margin: 0;
}

.fraction-guide ul,
.calculator-guide ul,
.percentage-guide ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
}

.fraction-guide strong,
.calculator-guide strong,
.percentage-guide strong {
  color: var(--text);
}

.fraction-guide a,
.calculator-guide a,
.percentage-guide a,
.converter-guide a,
.bmi-guide a {
  color: var(--accent-strong);
  font-weight: 600;
  text-underline-offset: 2px;
}

.bmi-page {
  gap: 14px;
}

.bmi-card {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.bmi-card h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(20px, 6vw, 28px);
  line-height: 1.15;
}

.bmi-unit-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.bmi-unit-toggle label {
  min-width: 0;
}

.bmi-unit-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.bmi-unit-toggle span {
  min-height: 38px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.bmi-unit-toggle input:checked + span {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.bmi-grid {
  display: grid;
  gap: 10px;
}

.bmi-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.bmi-grid input,
.bmi-grid select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 10px 11px;
  font-size: 15px;
}

.bmi-grid input::placeholder {
  color: var(--muted-soft);
}

.date-field-wrap {
  position: relative;
  display: block;
}

.date-field-wrap input {
  position: relative;
  z-index: 1;
}

.date-placeholder-input.is-empty:not(:focus) {
  color: transparent;
}

.date-placeholder-input.is-empty:not(:focus)::-webkit-datetime-edit,
.date-placeholder-input.is-empty:not(:focus)::-webkit-datetime-edit-text,
.date-placeholder-input.is-empty:not(:focus)::-webkit-datetime-edit-day-field,
.date-placeholder-input.is-empty:not(:focus)::-webkit-datetime-edit-month-field,
.date-placeholder-input.is-empty:not(:focus)::-webkit-datetime-edit-year-field {
  color: transparent;
}

.date-placeholder-input::-webkit-calendar-picker-indicator {
  opacity: 0.7;
}

.date-field-placeholder {
  position: absolute;
  left: 11px;
  top: 50%;
  z-index: 2;
  transform: translateY(-50%);
  color: var(--muted-soft);
  font-size: 15px;
  line-height: 1;
  pointer-events: none;
}

.date-placeholder-input:focus + .date-field-placeholder,
.date-placeholder-input:not(.is-empty) + .date-field-placeholder {
  display: none;
}

.bmi-grid input:focus,
.bmi-grid select:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 28%, transparent);
  outline-offset: 0;
}

.bmi-grid small {
  color: var(--muted-soft);
  font-size: 11px;
}

/* Keep the height input and reference selector visually aligned. */
.ideal-weight-field-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.ideal-weight-field-grid > label {
  grid-template-rows: auto 46px auto;
}

.ideal-weight-field-grid > label > input,
.ideal-weight-field-grid > label > select {
  box-sizing: border-box;
  height: 46px;
  min-height: 46px;
}

.ideal-weight-field-grid > label > small {
  min-height: 13px;
}

.bmi-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.bmi-actions {
  justify-content: start;
}

.bmi-result-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-soft) 70%, var(--surface)), var(--surface));
}

.bmi-result-top {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.bmi-result-top span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.bmi-result-top strong {
  color: var(--text);
  font-size: clamp(34px, 11vw, 54px);
  line-height: 0.95;
}

.pregnancy-result-card .bmi-result-top {
  display: grid;
  justify-content: start;
  justify-items: start;
  gap: 6px;
}

.pregnancy-result-card .bmi-result-top strong {
  font-size: clamp(34px, 9vw, 48px);
  line-height: 1;
  text-align: left;
}

.pregnancy-result-card .bmi-result-top small {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

.bmi-result-category {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.bmi-result-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.bmi-meaning {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 82%, var(--surface-soft));
}

.bmi-meaning h2,
.bmi-meaning p {
  margin: 0;
}

.bmi-meaning h2 {
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
}

.bmi-meaning p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.bmi-healthy-advice {
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  color: var(--muted);
  font-weight: 700;
}

.bmi-scale {
  position: relative;
  display: grid;
  gap: 6px;
  padding-top: 18px;
}

.bmi-scale-value {
  position: absolute;
  top: 0;
  left: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  transform: translateX(-50%);
}

.bmi-scale-track {
  position: relative;
  height: 18px;
  display: grid;
  grid-template-columns: 23fr 23fr 18fr 36fr;
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
}

.bmi-segment:first-child {
  border-radius: 999px 0 0 999px;
}

.bmi-segment:last-of-type {
  border-radius: 0 999px 999px 0;
}

.bmi-segment.under {
  background: #7c3aed;
}

.bmi-segment.healthy {
  background: #10b981;
}

.bmi-segment.over {
  background: #f59e0b;
}

.bmi-segment.obese {
  background: #ef4444;
}

.bmi-marker {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.28);
  transform: translate(-50%, -50%);
}

.bmi-scale-labels {
  position: relative;
  height: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.bmi-scale-labels span {
  position: absolute;
  top: 0;
  white-space: nowrap;
  transform: translateX(-50%);
}

.bmi-scale-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.bmi-scale-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.bmi-scale-legend span::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.bmi-scale-legend .under::before {
  background: #7c3aed;
}

.bmi-scale-legend .healthy::before {
  background: #10b981;
}

.bmi-scale-legend .over::before {
  background: #f59e0b;
}

.bmi-scale-legend .obese::before {
  background: #ef4444;
}

.body-fat-scale-track {
  grid-template-columns: 6fr 8fr 4fr 7fr 20fr;
}

.bmi-segment.essential {
  background: #6366f1;
}

.bmi-segment.athlete {
  background: #06b6d4;
}

.bmi-segment.fitness {
  background: #10b981;
}

.bmi-segment.average {
  background: #f59e0b;
}

.body-fat-scale-legend .essential::before {
  background: #6366f1;
}

.body-fat-scale-legend .athlete::before {
  background: #06b6d4;
}

.body-fat-scale-legend .fitness::before {
  background: #10b981;
}

.body-fat-scale-legend .average::before {
  background: #f59e0b;
}

.body-fat-details {
  display: grid;
  gap: 0;
  margin: 2px 0 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.body-fat-details div {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(90px, 0.65fr);
  gap: 10px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
}

.body-fat-details div:last-child {
  border-bottom: 0;
}

.body-fat-details dt,
.body-fat-details dd {
  margin: 0;
  font-size: 13px;
  line-height: 1.25;
}

.body-fat-details dt {
  color: var(--muted);
}

.body-fat-details dd {
  color: var(--text);
  font-weight: 800;
  text-align: right;
}

.body-fat-result-card[data-state="essential"] .bmi-result-category {
  color: #4f46e5;
}

.body-fat-result-card[data-state="athlete"] .bmi-result-category {
  color: #0891b2;
}

.body-fat-result-card[data-state="fitness"] .bmi-result-category {
  color: #059669;
}

.body-fat-result-card[data-state="average"] .bmi-result-category {
  color: #d97706;
}

.body-fat-result-card[data-state="obese"] .bmi-result-category {
  color: #dc2626;
}

.bmr-result-card[data-state="calculated"] .bmi-result-category {
  color: #0891b2;
}

.tdee-result-card[data-state="calculated"] .bmi-result-category {
  color: #2563eb;
}

.ideal-weight-result-card[data-state="calculated"] .bmi-result-category {
  color: #059669;
}

.loan-result-card[data-state="calculated"] .bmi-result-category {
  color: #2563eb;
}

.mortgage-result-card[data-state="calculated"] .bmi-result-category {
  color: #0f766e;
}

.auto-loan-result-card[data-state="calculated"] .bmi-result-category {
  color: #2563eb;
}

.savings-result-card[data-state="calculated"] .bmi-result-category {
  color: #0f766e;
}

.auto-loan-options {
  display: grid;
  gap: 14px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.auto-loan-options summary {
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.compound-result-card[data-state="calculated"] .bmi-result-category {
  color: #2563eb;
}

.loan-term-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(112px, 0.55fr);
  gap: 8px;
}

.loan-term-grid label {
  grid-template-rows: auto minmax(46px, auto) auto;
}

.loan-term-grid > label > span {
  min-height: 16px;
}

.loan-term-grid > label > small {
  min-height: 14px;
}

.loan-term-grid > label > input,
.loan-term-row {
  align-self: stretch;
}

.loan-chart {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.loan-chart-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) minmax(92px, auto);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.loan-chart-row strong {
  color: var(--text);
  font-size: 12px;
  text-align: right;
}

.loan-chart-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.loan-chart-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #2563eb;
  transition: width 180ms ease;
}

.loan-chart-track.interest span {
  background: #f59e0b;
}

.loan-chart-track.initial span {
  background: #6366f1;
}

.loan-chart-track.contribution span {
  background: #0f766e;
}

.loan-chart-track.tax span {
  background: #0f766e;
}

.loan-chart-track.insurance span {
  background: #6366f1;
}

.loan-chart-track.pmi span {
  background: #d97706;
}

.loan-chart-track.hoa span {
  background: #64748b;
}

.loan-schedule {
  display: grid;
  gap: 8px;
}

.loan-schedule summary {
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.loan-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.loan-table-wrap table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
}

.compound-interest-card .loan-table-wrap table {
  min-width: 640px;
}

.savings-card .loan-table-wrap table {
  min-width: 640px;
}

.loan-table-wrap th,
.loan-table-wrap td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.loan-table-wrap th:first-child,
.loan-table-wrap td:first-child {
  text-align: left;
}

.loan-table-wrap th {
  color: var(--muted);
  font-weight: 800;
  background: var(--surface-soft);
}

.loan-table-wrap tr:last-child td {
  border-bottom: 0;
}

.bmr-activity-card {
  display: grid;
  gap: 8px;
}

.bmr-activity-card h2 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
}

.calorie-result-card[data-state="maintain"] .bmi-result-category {
  color: #2563eb;
}

.calorie-result-card[data-state="lose"] .bmi-result-category {
  color: #059669;
}

.calorie-result-card[data-state="gain"] .bmi-result-category {
  color: #d97706;
}

.calorie-result-card[data-state="low"] .bmi-result-category {
  color: #dc2626;
}

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

.calorie-macro-card {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.calorie-macro-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.calorie-macro-card strong {
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}

.calorie-macro-card.protein {
  border-top: 3px solid #2563eb;
}

.calorie-macro-card.fat {
  border-top: 3px solid #f59e0b;
}

.calorie-macro-card.carbs {
  border-top: 3px solid #10b981;
}

.pregnancy-progress-track {
  grid-template-columns: 35fr 35fr 30fr;
}

.bmi-segment.first {
  background: #8b5cf6;
}

.bmi-segment.second {
  background: #06b6d4;
}

.bmi-segment.third {
  background: #10b981;
}

.pregnancy-progress-legend .first::before {
  background: #8b5cf6;
}

.pregnancy-progress-legend .second::before {
  background: #06b6d4;
}

.pregnancy-progress-legend .third::before {
  background: #10b981;
}

.pregnancy-progress-value {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pregnancy-result-card[data-state="first"] .bmi-result-category {
  color: #7c3aed;
}

.pregnancy-result-card[data-state="second"] .bmi-result-category {
  color: #0891b2;
}

.pregnancy-result-card[data-state="third"] .bmi-result-category {
  color: #059669;
}

.pregnancy-result-card[data-state="post"] .bmi-result-category {
  color: #dc2626;
}

.pregnancy-result-card[data-state="early"] .bmi-result-category {
  color: #d97706;
}

.bmi-result-card[data-state="under"] .bmi-result-category {
  color: #7c3aed;
}

.bmi-result-card[data-state="healthy"] .bmi-result-category {
  color: #059669;
}

.bmi-result-card[data-state="over"] .bmi-result-category {
  color: #d97706;
}

.bmi-result-card[data-state="obese"] .bmi-result-category {
  color: #dc2626;
}

.bmi-guide {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.bmi-guide h2,
.bmi-guide h3,
.bmi-guide p {
  margin: 0;
}

.bmi-guide h2,
.bmi-guide h3 {
  color: var(--text);
  line-height: 1.25;
}

.bmi-guide h2 {
  font-size: 18px;
}

.bmi-guide h3 {
  margin-top: 4px;
  font-size: 15px;
}

.history-card {
  position: relative;
  margin: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  height: 220px;
  overflow: hidden;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: end;
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  pointer-events: none;
}

.history-head button {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 7px 10px;
  font-size: 13px;
  pointer-events: auto;
}

.history-list {
  display: grid;
  align-content: start;
  gap: 10px;
  max-height: 100%;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  user-select: text;
  -webkit-user-select: text;
}

.history-list::-webkit-scrollbar {
  width: 8px;
  display: block;
}

.history-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--border);
}

.history-item {
  display: block;
  padding: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  user-select: text;
  -webkit-user-select: text;
}

.history-item * {
  user-select: text;
  -webkit-user-select: text;
}

.history-item + .history-item {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.history-item span {
  color: inherit;
}

.history-item strong {
  color: var(--text);
  font-size: inherit;
  line-height: inherit;
}

.history-item.muted {
  color: var(--muted-soft);
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.drawer.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-panel {
  width: min(82vw, 320px);
  min-height: 100%;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 18px 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateX(-100%);
  transition: transform 180ms ease;
}

.drawer.is-open .drawer-panel {
  transform: translateX(0);
}

.drawer-title {
  margin-bottom: 16px;
  font-size: 18px;
  font-weight: 700;
}

.drawer-nav {
  display: grid;
  gap: 6px;
}

.drawer-section {
  border-radius: 8px;
}

.drawer-section-trigger {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.drawer-section-trigger:hover,
.drawer-section.is-open > .drawer-section-trigger {
  background: var(--surface-soft);
}

.drawer-chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 140ms ease;
}

.drawer-section.is-open .drawer-chevron {
  transform: rotate(225deg);
}

.drawer-submenu {
  display: none;
  gap: 2px;
  padding: 3px 0 6px 10px;
}

.drawer-section.is-open .drawer-submenu {
  display: grid;
}

.drawer-submenu a {
  display: block;
  border-radius: 8px;
  color: var(--text);
  padding: 10px;
  text-decoration: none;
}

.drawer-submenu a:hover,
.drawer-submenu a.is-active {
  background: var(--surface-soft);
}

.drawer-submenu a.is-active {
  font-weight: 600;
}

.site-footer {
  width: 100%;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, var(--bg));
  padding: 24px 16px calc(24px + var(--safe-bottom));
}

.site-footer-grid {
  width: min(1040px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 18px;
}

.site-footer-column h2 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
}

.site-footer-column ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer-column a {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-decoration: none;
}

.site-footer-column a:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.site-footer-column a.is-active {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.site-footer-bottom {
  width: min(1040px, 100%);
  margin: 22px auto 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

@media (min-width: 760px) {
  .app-shell {
    background: radial-gradient(circle at top, color-mix(in srgb, var(--accent) 12%, transparent), transparent 38%), var(--bg);
  }

  .main-area {
    width: min(460px, 100%);
    margin: 0 auto;
    padding: 10px 20px 28px;
    display: block;
  }

  .site-footer {
    padding: 30px 24px 32px;
  }

  .site-footer-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 24px;
  }

  .main-area.scientific-mode {
    width: min(600px, 100%);
  }

  .main-area.percentage-mode,
  .main-area.fraction-mode,
  .main-area.bmi-mode,
  .main-area.body-fat-mode,
  .main-area.bmr-mode,
  .main-area.tdee-mode,
  .main-area.loan-mode,
  .main-area.mortgage-mode,
  .main-area.auto-loan-mode,
  .main-area.savings-mode,
  .main-area.compound-interest-mode,
  .main-area.calorie-mode,
  .main-area.ideal-weight-mode,
  .main-area.pregnancy-mode,
  .main-area.currency-mode,
  .main-area.volume-mode,
  .main-area.length-mode,
  .main-area.mass-mode,
  .main-area.temperature-mode,
  .main-area.energy-mode,
  .main-area.area-mode,
  .main-area.date-mode,
  .main-area.discount-mode,
  .main-area.info-mode {
    width: min(760px, 100%);
  }

  .calculator {
    min-height: 0;
    max-height: calc(100svh - var(--topbar-height) - 66px);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: visible;
    box-shadow: var(--shadow);
  }

  .calculator--scientific {
    max-height: none;
  }

  .sci-key {
    aspect-ratio: 3 / 1.25;
  }

  .memory-row {
    border-right: 0;
    border-left: 0;
  }

  .history-card {
    margin: 18px 0 0;
    min-height: 220px;
    box-shadow: var(--shadow);
  }

  .percentage-page {
    padding: 0;
  }

  .percentage-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bmi-card,
  .bmi-guide {
    padding: 18px;
    box-shadow: var(--shadow);
  }

  .bmi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .loan-term-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mortgage-pair-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auto-loan-pair-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .savings-pair-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compound-interest-pair-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bmi-grid[data-bmi-fields] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bmi-grid[data-calorie-fields],
  .pregnancy-method-grid,
  .calorie-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .percentage-row {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: end;
  }

  .discount-fields,
  .date-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .date-duration-fields {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .percentage-card {
    box-shadow: var(--shadow);
  }

  .currency-card {
    padding: 18px;
    box-shadow: var(--shadow);
  }

  .currency-chart-card {
    padding: 16px 18px;
    box-shadow: var(--shadow);
  }

  .currency-chart-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .currency-disclaimer {
    padding: 14px 16px;
    box-shadow: var(--shadow);
  }

  .converter-card,
  .converter-guide {
    padding: 18px;
    box-shadow: var(--shadow);
  }

  .converter-fields {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: end;
  }

  .converter-swap {
    align-self: end;
  }

  .currency-fields {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: end;
  }

  .currency-swap {
    align-self: end;
    margin-bottom: 0;
  }

  .fraction-card {
    padding: 18px;
    box-shadow: var(--shadow);
  }

  .fraction-guide,
  .percentage-guide,
  .calculator-guide {
    padding: 18px;
    box-shadow: var(--shadow);
  }

  .calculator-guide {
    margin: 18px 0 0;
  }

  .fraction-workspace {
    grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
    gap: 14px;
  }

  .mixed-number-workspace {
    grid-template-columns: minmax(0, 1fr) minmax(176px, auto) minmax(0, 1fr);
    align-items: end;
  }

  .fraction-box {
    padding: 14px 10px;
  }

  .mixed-fraction {
    grid-template-columns: minmax(52px, 0.8fr) minmax(64px, 1fr);
    gap: 10px;
  }

  .fraction-operations span {
    width: 44px;
  }

  .percentage-card h2 {
    text-align: left;
  }
}

@media (min-width: 1000px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding-right: 24px;
    padding-left: 24px;
  }

  .menu-button,
  .drawer {
    display: none;
  }

  .brand {
    text-align: left;
  }

  .desktop-category-nav {
    display: block;
    min-width: 0;
  }

  .desktop-category-nav-inner {
    min-height: var(--topbar-height);
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 2px;
    margin: 0;
    padding: 0;
  }

  .desktop-nav-group {
    position: relative;
    display: flex;
    align-items: stretch;
  }

  .desktop-nav-trigger {
    min-height: var(--topbar-height);
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    padding: 0 13px;
    transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
  }

  .desktop-nav-trigger::after {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin: 0 0 3px 7px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    content: "";
    transform: rotate(45deg);
    transition: transform 140ms ease;
  }

  .desktop-nav-group:hover .desktop-nav-trigger,
  .desktop-nav-group:focus-within .desktop-nav-trigger,
  .desktop-nav-group.is-open .desktop-nav-trigger {
    color: var(--text);
    background: var(--surface-soft);
  }

  .desktop-nav-group.is-current .desktop-nav-trigger {
    color: var(--text);
    font-weight: 800;
    border-bottom-color: var(--accent);
  }

  .desktop-nav-group.is-open .desktop-nav-trigger::after,
  .desktop-nav-group:focus-within .desktop-nav-trigger::after {
    transform: rotate(225deg) translate(-2px, -2px);
  }

  .desktop-nav-dropdown {
    position: absolute;
    top: calc(100% - 1px);
    left: 0;
    z-index: 25;
    display: none;
    min-width: 192px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    background: var(--surface-raised);
    box-shadow: var(--shadow);
  }

  .desktop-nav-group.is-open .desktop-nav-dropdown,
  .desktop-nav-group:focus-within .desktop-nav-dropdown {
    display: grid;
  }

  .desktop-nav-dropdown a {
    display: block;
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    line-height: 1.3;
    padding: 9px 10px;
    text-decoration: none;
  }

  .desktop-nav-dropdown a:hover,
  .desktop-nav-dropdown a:focus-visible,
  .desktop-nav-dropdown a.is-active {
    background: var(--surface-soft);
  }

  .desktop-nav-dropdown a.is-active {
    font-weight: 700;
  }

  .calculator {
    max-height: calc(100svh - var(--topbar-height) - 66px);
  }
}

@media (max-width: 359px) {
  .brand {
    font-size: 15px;
  }

  .topbar {
    grid-template-columns: 40px 1fr 46px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .entry {
    --entry-full-size: 38px;
  }
}
