:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #1a1c21;
  --panel-strong: #20242b;
  --line: #343a44;
  --text: #f3f4f6;
  --muted: #aab2c0;
  --soft: #747f91;
  --accent: #20c997;
  --accent-2: #ffd166;
  --danger: #ff6b6b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, rgba(32, 201, 151, 0.16), transparent 28rem),
    radial-gradient(circle at 88% 25%, rgba(255, 209, 102, 0.12), transparent 30rem),
    linear-gradient(135deg, #101114 0%, #151922 48%, #0f1418 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0;
}

.converter {
  min-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.top-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.account-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px 6px 12px;
  color: var(--muted);
  background: rgba(26, 28, 33, 0.78);
}

.account-pill span {
  font-size: 0.86rem;
  font-weight: 800;
}

.account-pill button,
.auth-tabs button,
.auth-fields button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #151820;
  cursor: pointer;
  font-weight: 800;
}

.account-pill button {
  min-height: 28px;
  padding: 0 9px;
  font-size: 0.78rem;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 7vw, 4.8rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.05rem;
}

.rate-state {
  min-width: 172px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(26, 28, 33, 0.78);
  text-align: center;
  font-size: 0.86rem;
  white-space: nowrap;
}

.rate-state.ready {
  color: #b7f8df;
  border-color: rgba(32, 201, 151, 0.45);
}

.rate-state.fallback {
  color: #ffe1a3;
  border-color: rgba(255, 209, 102, 0.45);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
}

body:not(.signed-in) .workspace,
body:not(.signed-in) .rate-state {
  display: none;
}

body:not(.signed-in) .converter {
  justify-content: center;
}

body:not(.signed-in) .top-actions {
  display: none;
}

body:not(.signed-in) .auth-panel {
  max-width: 840px;
  width: 100%;
  align-self: center;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(26, 28, 33, 0.9);
  box-shadow: var(--shadow);
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(320px, 1.2fr);
  gap: 18px;
  align-items: center;
  padding: 18px;
}

.auth-panel.signed-in {
  display: none;
}

.auth-copy {
  display: grid;
  gap: 6px;
}

.auth-copy p,
.auth-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-tabs button {
  min-height: 36px;
  padding: 0 12px;
}

.auth-tabs button.active,
.auth-fields button {
  color: #07130f;
  border-color: rgba(32, 201, 151, 0.6);
  background: var(--accent);
}

.auth-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.auth-fields label {
  display: grid;
  gap: 6px;
}

.auth-fields input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: var(--panel-strong);
  outline: none;
}

.auth-fields input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(32, 201, 151, 0.13);
}

.auth-fields button {
  min-height: 42px;
  padding: 0 14px;
  white-space: nowrap;
}

.auth-message.error {
  color: var(--danger);
}

.auth-message.success {
  color: #b7f8df;
}

.main-panel {
  padding: 22px;
}

.amount-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

#amount {
  width: 100%;
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 18px;
  color: var(--text);
  background: var(--panel-strong);
  font-size: clamp(1.7rem, 5vw, 3rem);
  font-weight: 800;
  outline: none;
}

.amount-stack {
  display: grid;
  gap: 10px;
}

.amount-presets,
.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.amount-presets button,
.mode-tabs button,
.result-actions button,
.history-head button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #151820;
  cursor: pointer;
  font-weight: 800;
}

.amount-presets button {
  min-height: 34px;
  padding: 0 12px;
}

.mode-tabs {
  margin-bottom: 18px;
}

.mode-tabs button {
  min-height: 38px;
  padding: 0 14px;
}

.mode-tabs button.active {
  color: #07130f;
  border-color: rgba(32, 201, 151, 0.6);
  background: var(--accent);
}

#amount:focus,
.search-wrap:focus-within,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(32, 201, 151, 0.13);
}

.exchange-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.currency-box {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.currency-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.favorite-toggle {
  width: 34px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--soft);
  background: #151820;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
}

.favorite-toggle.active {
  color: #12100a;
  border-color: rgba(255, 209, 102, 0.7);
  background: var(--accent-2);
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #151820;
}

.search-wrap svg,
.swap svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.search-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: none;
  color: var(--text);
  background: transparent;
}

select {
  width: 100%;
  min-height: 258px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  color: var(--text);
  background: var(--panel-strong);
  outline: none;
}

option {
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--text);
  background: var(--panel-strong);
}

.swap {
  width: 52px;
  height: 52px;
  border: 1px solid rgba(32, 201, 151, 0.45);
  border-radius: 8px;
  color: #07130f;
  background: var(--accent);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 150ms ease, filter 150ms ease;
}

.swap:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.result-card {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(32, 201, 151, 0.32);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(32, 201, 151, 0.13), rgba(255, 209, 102, 0.08));
  display: grid;
  gap: 6px;
}

.result-card span,
.result-card small {
  color: var(--muted);
}

.result-card strong {
  overflow-wrap: anywhere;
  font-size: clamp(2rem, 7vw, 4.5rem);
  line-height: 1;
}

.result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-actions button,
.history-head button {
  min-height: 34px;
  padding: 0 11px;
  font-size: 0.82rem;
}

.result-actions button.copied {
  color: #07130f;
  border-color: rgba(32, 201, 151, 0.6);
  background: var(--accent);
}

.history-panel {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #151820;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.history-item strong,
.history-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item span,
.history-empty {
  color: var(--muted);
  font-size: 0.84rem;
}

.history-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
}

.side-panel {
  padding: 18px;
  align-self: stretch;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.side-head span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 800;
}

.quick-list {
  display: grid;
  gap: 9px;
}

.quick-rate,
.favorite-rate {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #151820;
}

.quick-code {
  color: var(--accent);
  font-weight: 800;
}

.quick-name {
  color: var(--muted);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-value {
  color: var(--text);
  font-weight: 800;
}

.favorites-head {
  margin-top: 22px;
}

.favorites-list {
  display: grid;
  gap: 9px;
}

.favorite-rate {
  grid-template-columns: 46px minmax(0, 1fr) 34px;
}

.favorite-rate button {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255, 209, 102, 0.45);
  border-radius: 8px;
  color: var(--accent-2);
  background: transparent;
  cursor: pointer;
  line-height: 1;
}

.empty-favorites {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

@media (max-width: 880px) {
  .shell {
    width: min(100% - 24px, 680px);
    padding: 22px 0;
  }

  .converter {
    min-height: auto;
  }

  .topbar,
  .auth-panel,
  .workspace,
  .exchange-grid,
  .amount-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    align-items: start;
  }

  .top-actions {
    justify-items: stretch;
  }

  .account-pill {
    justify-content: space-between;
  }

  .auth-fields {
    grid-template-columns: 1fr;
  }

  .exchange-grid {
    gap: 12px;
  }

  .swap {
    justify-self: center;
    transform: rotate(90deg);
  }

  .swap:hover {
    transform: rotate(90deg) translateX(-1px);
  }
}

@media (max-width: 520px) {
  .main-panel,
  .side-panel {
    padding: 14px;
  }

  select {
    min-height: 220px;
  }

  #amount {
    min-height: 58px;
    padding: 0 14px;
  }
}
