:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #687284;
  --line: #d8dde7;
  --panel: #ffffff;
  --page: #f4f6f9;
  --accent: #1769ff;
  --accent-2: #0f9f8f;
  --danger: #e85d2a;
  --shadow: 0 24px 80px rgba(18, 32, 56, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(23, 105, 255, 0.10), transparent 32%),
    linear-gradient(315deg, rgba(15, 159, 143, 0.12), transparent 34%),
    var(--page);
}

.app {
  width: min(760px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px 0;
}

.calculator {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(216, 221, 231, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.calculator {
  width: 100%;
  border-radius: 8px;
  padding: 30px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
}

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

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 17px;
  margin-bottom: 10px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 22px;
}

.mode-tab,
.primary-action {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.mode-tab {
  background: #f8fafc;
  color: var(--muted);
}

.mode-tab.active {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.converter-row {
  grid-column: span 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

.currency-box {
  min-height: 116px;
  display: grid;
  align-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.currency-box strong {
  font-size: 18px;
  letter-spacing: 0;
}

.box-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.output-box {
  background: #f8fafc;
}

.swap-button {
  width: 48px;
  height: 48px;
  margin-bottom: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input[type="number"] {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  font-size: 18px;
  font-weight: 750;
  outline: none;
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

input[readonly] {
  width: 100%;
  min-height: 50px;
  border: none;
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: transparent;
  font-size: 20px;
  font-weight: 850;
  outline: none;
}

.live-rate-box div {
  min-height: 50px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #f8fafc;
  font-size: 16px;
  font-weight: 750;
}

input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(23, 105, 255, 0.12);
}

.inline-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-input span {
  font-size: 18px;
  color: var(--ink);
}

.primary-action {
  grid-column: span 2;
  color: #fff;
  border-color: var(--ink);
  background: var(--ink);
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.72;
}

[hidden] {
  display: none !important;
}

@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
    align-items: start;
    padding: 20px 0;
  }

  .calculator {
    padding: 20px;
  }

  .form-grid,
  .mode-tabs {
    grid-template-columns: 1fr;
  }

  .primary-action,
  .converter-row {
    grid-column: span 1;
  }

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

  .swap-button {
    margin: 0 auto;
    transform: rotate(90deg);
  }

}
