:root {
  --bg: #0b1118;
  --card: #151f2c;
  --card-soft: #1c2937;
  --line: rgba(255, 255, 255, 0.12);
  --text: #e9f2ff;
  --muted: #9cb1c9;
  --accent: #35d5a3;
  --accent-soft: #2ea8ff;
  --danger: #ff5c5c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 5% 0%, #17283d 0%, transparent 55%),
    radial-gradient(1000px 500px at 95% 100%, #123229 0%, transparent 60%),
    var(--bg);
}

.background {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, rgba(46, 168, 255, 0.06), rgba(53, 213, 163, 0.05));
  pointer-events: none;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 30px 18px 40px;
  position: relative;
  z-index: 1;
}

.card {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  backdrop-filter: blur(2px);
}

.card + .card {
  margin-top: 18px;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.1;
}

.hero-head,
.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.convert-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.convert-toggle-flags {
  font-size: 3em;
  line-height: 1;
}

.rate-row {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.badge {
  display: inline-flex;
  padding: 7px 14px;
  border-radius: 999px;
  color: #f2f7ff;
  background: linear-gradient(90deg, rgba(26, 77, 152, 0.88), rgba(23, 46, 88, 0.88));
  font-weight: 700;
}

.muted {
  color: var(--muted);
  font-size: 0.95rem;
}

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

.input-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}

.input-card span {
  display: block;
  font-size: 0.82rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.field-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-flag {
  width: 24px;
  height: 16px;
  flex: 0 0 auto;
  object-fit: cover;
  border-radius: 3px;
  opacity: 0.62;
}

.field-wrap input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 1.28rem;
  font-weight: 700;
  font-family: inherit;
}

.field-wrap input::placeholder {
  color: #6d7f95;
  font-weight: 600;
}

.field-wrap strong {
  color: var(--muted);
}

.result {
  margin-top: 14px;
  border-radius: 16px;
  padding: 18px;
  border: 1px solid rgba(46, 168, 255, 0.25);
  background: linear-gradient(130deg, rgba(45, 84, 147, 0.45), rgba(31, 112, 90, 0.32));
  text-align: center;
}

.result p {
  margin: 0 0 8px;
  color: #b4cadf;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.result h2 {
  margin: 0;
  font-size: clamp(34px, 6vw, 56px);
  color: #36d8cf;
  line-height: 1;
}

.actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  font-family: inherit;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 700;
}

.primary-btn {
  color: #051a1f;
  background: linear-gradient(90deg, #35d5a3, #49c9ff);
}

.ghost-btn {
  color: #dbe9fa;
  background: transparent;
  border-color: var(--line);
}

.ghost-btn:disabled {
  cursor: wait;
  opacity: 0.62;
}

.danger-btn {
  color: var(--danger);
  background: rgba(255, 92, 92, 0.08);
  border-color: rgba(255, 92, 92, 0.3);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  color: #dbe9fa;
  background: rgba(255, 255, 255, 0.02);
  font-weight: 700;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.back-btn:active {
  transform: translateY(1px);
}

.bottom-back {
  margin-top: 8px;
  display: flex;
  justify-content: flex-start;
}

.history h3 {
  margin: 0;
  font-size: 1.6rem;
}

.history-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.history-list li {
  border: 1px solid var(--line);
  background: var(--card-soft);
  border-radius: 12px;
  padding: 11px 13px;
}

.row-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
}

.row-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  margin: 16px 0 0;
}

.chart-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(14, 26, 40, 0.65);
  padding: 14px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.chart-head h4 {
  margin: 0;
  font-size: 1.05rem;
}

.periods {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.period-btn {
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

.period-btn.active {
  border-color: rgba(53, 213, 163, 0.55);
  color: #d8fff4;
  background: rgba(53, 213, 163, 0.18);
}

.chart-container {
  width: 100%;
  height: 300px;
  margin-top: 12px;
}

.chart-status {
  margin: 10px 0 0;
}

@media (max-width: 760px) {
  .inputs-grid {
    grid-template-columns: 1fr;
  }

  .hero-head,
  .history-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-actions {
    width: 100%;
    flex-direction: column;
  }

  .top-actions button {
    width: 100%;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button,
  .history-head button {
    width: 100%;
  }

  .chart-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Направления всегда видны рядом с расчётом. */
.convert-page .page { max-width: 1200px; }
.converter-layout { display: block; }
.converter-main { min-width: 0; }
.pair-sidebar { margin: 18px 0; }
.pair-sidebar h2 { margin: 0 0 14px; font-size: 20px; }
.pair-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.pair-option { min-height: 88px; text-align: left; display: grid; align-content: center; gap: 6px; }
.pair-flags { display: flex; align-items: center; gap: 6px; height: 40px; white-space: nowrap; }
.pair-flags img { width: 40px; height: 27px; object-fit: cover; border-radius: 4px; }
.pair-flags b { color: var(--orbit-text); font-size: 20px; line-height: 1; }
body.convert-page .pair-option[aria-pressed="true"] { color: var(--orbit-text); background: #fff; border-color: var(--orbit-red); }
body.convert-page .pair-option:hover { border-color: var(--orbit-red); }
.pair-option:focus-visible { outline: 2px solid var(--orbit-red); outline-offset: 3px; }
body.convert-page .input-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(53, 213, 163, 0.28);
}
.rate-note { line-height: 1.5; margin: 14px 0 0; }
.convert-page .result h2 { overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .pair-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .pair-options { grid-template-columns: minmax(0, 1fr); }
  .pair-option { min-height: 82px; }
}
