:root {
  --bg: #0b0d11;
  --surface: #111318;
  --surface-2: #171a20;
  --surface-3: #1d2129;
  --text: #f7f8fa;
  --muted: #8d96a5;
  --muted-2: #626b79;
  --accent: #70e1b3;
  --accent-soft: rgba(112, 225, 179, 0.12);
  --border: rgba(255, 255, 255, 0.075);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 50% -10%, rgba(112, 225, 179, 0.09), transparent 32rem),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body.modal-open { overflow: hidden; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  margin-bottom: 4px;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  letter-spacing: -0.055em;
  line-height: 1;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #dba45c;
  box-shadow: 0 0 0 4px rgba(219, 164, 92, 0.09);
}

.status-pill.live .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.status-pill.offline .status-dot {
  background: #8d96a5;
  box-shadow: 0 0 0 4px rgba(141, 150, 165, 0.08);
}

.converter {
  border: 1px solid var(--border);
  border-radius: 28px;
  background: rgba(17, 19, 24, 0.92);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.currency-block { padding: 22px 22px 24px; }
.input-block { padding-bottom: 18px; }
.output-block { padding-top: 18px; }

.currency-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d6dae1;
  font-size: 0.78rem;
  font-weight: 780;
  letter-spacing: 0.04em;
}

.flag { font-size: 1rem; }
.currency-name {
  color: var(--muted-2);
  font-weight: 580;
  letter-spacing: 0;
  margin-left: 2px;
}

.amount-row,
.result-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.result-row { grid-template-columns: auto minmax(0, 1fr); }

.currency-symbol,
.result-symbol {
  color: var(--muted);
  font-size: clamp(1.6rem, 7vw, 2.2rem);
  font-weight: 700;
  line-height: 1;
}

#amountInput,
#amountOutput {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-size: clamp(3.05rem, 15vw, 5.25rem);
  font-weight: 730;
  letter-spacing: -0.065em;
  line-height: 1.05;
}

#amountInput {
  padding: 0;
  caret-color: var(--accent);
}

#amountInput::placeholder { color: #343a44; }

#amountOutput {
  display: block;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clear-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease, background .15s ease;
}

.clear-button.visible {
  opacity: 1;
  pointer-events: auto;
}

.clear-button:active { transform: scale(.93); }

.direction {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
}

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

.flip-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  transition: transform .22s ease, background .15s ease, color .15s ease, border-color .15s ease;
}

.flip-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .22s ease;
}

.flip-button:hover,
.flip-button:focus-visible {
  color: var(--accent);
  border-color: rgba(112, 225, 179, .25);
  outline: none;
}

.flip-button:active { transform: scale(.92); }
.flip-button.flipped svg { transform: rotate(180deg); }

.markup-card {
  margin-top: 12px;
  padding: 15px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(17, 19, 24, .62);
}

.markup-info {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.section-label {
  color: var(--muted-2);
  font-size: .68rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .08em;
}

#bankSummary {
  margin-top: 2px;
  color: #dce0e6;
  font-size: .9rem;
  font-weight: 760;
}

.markup-detail {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 620;
}

.settings-button {
  flex: 0 0 auto;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 720;
  cursor: pointer;
}

.settings-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-button:focus-visible,
.settings-button:hover {
  outline: none;
  color: var(--accent);
  border-color: rgba(112,225,179,.25);
}

.rate-card {
  margin-top: auto;
  padding-top: 24px;
}

.rate-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.rate-label {
  color: var(--muted-2);
  font-size: .72rem;
  font-weight: 700;
}

#rateText {
  color: #dce0e6;
  font-size: .88rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.effective-rate {
  margin-top: 7px;
  color: var(--accent);
  font-size: .72rem;
  font-weight: 650;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rate-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

#rateDate {
  color: var(--muted-2);
  font-size: .72rem;
  line-height: 1.35;
}

.refresh-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
  padding: 7px 0 7px 8px;
}

.refresh-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.refresh-button.loading svg { animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.footnote {
  margin: 14px 0 0;
  color: #555e6c;
  font-size: .66rem;
  line-height: 1.5;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  background: rgba(5, 7, 10, .78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.modal-backdrop[hidden] { display: none; }

.modal-card {
  position: relative;
  width: min(100%, 430px);
  max-height: min(760px, calc(100dvh - 40px));
  overflow-y: auto;
  padding: 25px 20px 20px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 26px;
  background: #111318;
  box-shadow: 0 30px 90px rgba(0,0,0,.55);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.modal-kicker {
  color: var(--accent);
  font-size: .66rem;
  font-weight: 820;
  letter-spacing: .17em;
}

.modal-card h2 {
  margin: 7px 38px 0 0;
  font-size: clamp(1.55rem, 7vw, 2rem);
  letter-spacing: -.045em;
  line-height: 1.08;
}

.modal-card > p {
  margin: 10px 0 18px;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.5;
}

.bank-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.bank-options button {
  min-height: 68px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,.025);
  color: #d5d9df;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}

.bank-options button span {
  font-size: .9rem;
  font-weight: 760;
}

.bank-options button small {
  color: var(--muted-2);
  font-size: .7rem;
  font-weight: 650;
}

.bank-options button.active {
  border-color: rgba(112,225,179,.35);
  background: var(--accent-soft);
  color: var(--accent);
}

.bank-options button.active small { color: rgba(112,225,179,.72); }
.bank-options button:active { transform: scale(.98); }
.bank-options button:focus-visible { outline: 2px solid rgba(112,225,179,.35); outline-offset: 2px; }

.modal-markup-row {
  margin-top: 14px;
  min-height: 62px;
  padding: 10px 12px 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,.02);
}

.modal-markup-row > span:first-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.modal-markup-row > span:first-child strong {
  color: #dce0e6;
  font-size: .8rem;
}

.modal-markup-row > span:first-child small {
  color: var(--muted-2);
  font-size: .67rem;
  line-height: 1.25;
}

.modal-markup-control {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
}

.modal-markup-control input {
  width: 70px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 780;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  margin-top: 14px;
  border: 0;
  border-radius: 15px;
  background: var(--accent);
  color: #0a1913;
  font-size: .86rem;
  font-weight: 820;
  cursor: pointer;
  transition: opacity .15s ease, transform .1s ease;
}

.primary-button:disabled {
  opacity: .28;
  cursor: default;
}

.primary-button:not(:disabled):active { transform: scale(.985); }

@media (max-width: 360px) {
  .app-shell { padding-left: 14px; padding-right: 14px; }
  .currency-block { padding-left: 18px; padding-right: 18px; }
  .direction { padding-left: 18px; padding-right: 18px; }
  .bank-options { grid-template-columns: 1fr; }
}
