:root {
  color-scheme: dark;
  --background: #07111f;
  --background-deep: #030a13;
  --surface: #101d2d;
  --surface-soft: #15253a;
  --line: #2b3d53;
  --line-strong: #49627f;
  --text: #f5f8fb;
  --text-muted: #aab8ca;
  --accent: #00d7ff;
  --accent-strong: #37e2ff;
  --accent-ink: #031019;
  --danger: #ff9c9c;
  --focus: #8befff;
  --shadow: 0 32px 90px rgb(0 0 0 / 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--background);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 14% 12%, rgb(0 215 255 / 0.13), transparent 32rem),
    radial-gradient(circle at 90% 90%, rgb(48 86 255 / 0.12), transparent 38rem),
    linear-gradient(145deg, var(--background-deep), var(--background));
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: 0.12;
  background-image:
    linear-gradient(rgb(255 255 255 / 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 0.12) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

button,
input {
  font: inherit;
}

button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}

.page-shell {
  width: min(1160px, calc(100% - 40px));
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.site-header {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 10px 30px rgb(0 215 255 / 0.22);
}

.brand:focus-visible,
.button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.version {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

main {
  align-self: center;
  padding: 32px 0 56px;
}

.calculator {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgb(16 29 45 / 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.calculator-intro {
  padding: clamp(32px, 5vw, 56px) clamp(24px, 5vw, 56px) 32px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

.intro-copy {
  max-width: 650px;
  margin: 20px 0 0;
  color: var(--text-muted);
  font-size: clamp(1rem, 2vw, 1.15rem);
  line-height: 1.65;
}

.calculator-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
}

.calculator-form {
  padding: clamp(28px, 5vw, 48px) clamp(24px, 5vw, 56px);
}

.field-group + .field-group {
  margin-top: 24px;
}

label {
  display: block;
  margin-bottom: 10px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
}

.input-wrap {
  position: relative;
}

input {
  width: 100%;
  min-height: 60px;
  padding: 14px 104px 14px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  outline: none;
  color: var(--text);
  background: var(--background);
  font-size: 1.12rem;
  font-weight: 700;
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

input::placeholder {
  color: #6f8298;
  opacity: 1;
}

input:hover {
  border-color: #6683a5;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgb(0 215 255 / 0.14);
  background: #0a1726;
}

input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgb(255 156 156 / 0.12);
}

.input-unit {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  padding: 6px 9px;
  border-radius: 8px;
  color: var(--text-muted);
  background: var(--surface-soft);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
}

.field-hint,
.field-error {
  margin: 8px 0 0;
  font-size: 0.83rem;
  line-height: 1.45;
}

.field-hint {
  color: var(--text-muted);
}

.field-error {
  min-height: 0;
  color: var(--danger);
  font-weight: 650;
}

.field-error:not(:empty) {
  min-height: 1.2em;
}

.same-currency-note {
  margin: 28px 0 0;
  padding-left: 14px;
  border-left: 2px solid var(--accent);
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.form-actions {
  margin-top: 30px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button {
  min-height: 50px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button-primary {
  color: var(--accent-ink);
  background: var(--accent);
}

.button-primary:hover {
  background: var(--accent-strong);
}

.button-secondary {
  color: var(--text);
  border-color: var(--line-strong);
  background: transparent;
}

.button-secondary:hover {
  border-color: #6d88a7;
  background: rgb(255 255 255 / 0.04);
}

.result-panel {
  min-height: 100%;
  padding: clamp(30px, 5vw, 48px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: var(--accent-ink);
  background:
    radial-gradient(circle at 90% 10%, rgb(255 255 255 / 0.55), transparent 15rem),
    linear-gradient(145deg, #8befff, var(--accent));
}

.result-label {
  margin: 0;
  color: #0c4050;
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.result-value {
  display: block;
  margin-top: 18px;
  font-size: clamp(3.6rem, 8vw, 6.8rem);
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  line-height: 0.95;
  letter-spacing: -0.075em;
  overflow-wrap: anywhere;
}

.result-value.is-updated {
  animation: result-in 320ms ease-out;
}

.result-summary {
  min-height: 3em;
  margin: 24px 0 0;
  color: #0b3b49;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.55;
}

.formula {
  width: fit-content;
  margin-top: 32px;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 9px;
  color: #0a3541;
  font-size: 0.78rem;
  font-weight: 800;
}

.formula-divider {
  width: 100%;
  height: 1px;
  grid-column: 1;
  background: currentColor;
}

.formula span:last-child {
  grid-column: 2;
  grid-row: 1 / span 3;
}

.site-footer {
  padding: 20px 0 30px;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.5;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.noscript-message {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  padding: 16px;
  border-radius: 12px;
  color: #3b1010;
  background: #ffd5d5;
  text-align: center;
  font-weight: 700;
}

@keyframes result-in {
  from {
    opacity: 0.45;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 800px) {
  .page-shell {
    width: min(100% - 28px, 680px);
  }

  .site-header {
    min-height: 76px;
  }

  .brand span:last-child {
    display: none;
  }

  main {
    padding: 16px 0 36px;
  }

  .calculator {
    border-radius: 22px;
  }

  .calculator-workspace {
    grid-template-columns: 1fr;
  }

  .result-panel {
    min-height: 330px;
  }
}

@media (max-width: 480px) {
  .calculator-intro,
  .calculator-form,
  .result-panel {
    padding-right: 20px;
    padding-left: 20px;
  }

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

  .button {
    width: 100%;
  }

  .result-value {
    font-size: clamp(3.4rem, 21vw, 5.4rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
