:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #17201f;
  --muted: #64706f;
  --faint: #f5f8f7;
  --line: #dbe4e1;
  --line-strong: #c2d1cc;
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --amber: #fff3d6;
  --amber-line: #f4c66c;
  --danger: #b42318;
  --shadow: 0 24px 70px rgba(24, 44, 41, 0.1);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, #ffffff 0%, #f7fbfa 100%);
  color: var(--ink);
  font-family: var(--font);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.app-shell {
  width: min(1180px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 34px 0 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 0 30px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mark {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  width: 50px;
  height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  box-shadow: 0 16px 34px rgba(23, 32, 31, 0.14);
  overflow: hidden;
}

.mark span {
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 760;
}

.mark span:nth-child(2),
.mark span:nth-child(3) {
  background: rgba(255, 255, 255, 0.08);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
  font-weight: 760;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--teal);
  box-shadow: 0 0 0 6px rgba(13, 148, 136, 0.12);
}

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.sync-status svg {
  width: 16px;
  height: 16px;
}

.sync-status.is-loading svg {
  animation: spin 1.1s linear infinite;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}

.converter-panel,
.rates-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.converter-panel {
  padding: 18px;
}

.primary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.primary-button {
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  background: var(--teal);
  color: #ffffff;
  font-size: 14px;
  font-weight: 760;
}

.primary-button:hover {
  background: var(--teal-dark);
  transform: translateY(-1px);
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
}

.icon-button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.icon-button.ghost {
  background: transparent;
}

.base-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.base-label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.base-amount {
  width: 100%;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 16px;
  text-align: right;
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  outline: none;
}

.base-amount:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.12);
}

.currency-segments {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 4px;
  min-height: 44px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--faint);
}

.segment-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 76px;
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.segment-button:hover {
  color: var(--ink);
}

.segment-button.is-active {
  background: var(--ink);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(23, 32, 31, 0.13);
}

.segment-button span {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

.result-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 4px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.currency-list {
  display: grid;
  gap: 8px;
}

.currency-row {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(140px, auto) auto;
  gap: 12px;
  align-items: center;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.currency-row.is-active {
  border-color: var(--amber-line);
  background: var(--amber);
}

.currency-info {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.currency-marker {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--marker-color) 24%, var(--line));
  background: #ffffff;
  box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--marker-color) 8%, #ffffff);
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: 25px;
  font-weight: 800;
}

.currency-copy {
  min-width: 0;
}

.currency-code-line {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.currency-code {
  font-size: 18px;
  font-weight: 800;
}

.reference-tag {
  display: none;
  padding: 3px 7px;
  border-radius: 7px;
  background: rgba(244, 198, 108, 0.36);
  color: #71510d;
  font-size: 11px;
  font-weight: 800;
}

.currency-row.is-active .reference-tag {
  display: inline-flex;
}

.currency-name {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 620;
}

.converted-value {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 7px;
  min-width: 0;
  color: var(--ink);
  font-size: 24px;
  font-weight: 800;
}

.converted-value span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.paste-result {
  color: var(--teal-dark);
  background: #f2fbf9;
  border-color: rgba(13, 148, 136, 0.28);
}

.paste-result:hover {
  background: #e4f7f4;
  border-color: rgba(13, 148, 136, 0.5);
}

.helper-text {
  padding: 14px 4px 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.rates-card {
  position: sticky;
  top: 20px;
  padding: 18px;
}

.rates-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.rates-heading h2 {
  font-size: 18px;
  font-weight: 800;
}

.rates-heading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.rates-list {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.rate-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.rate-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.rate-row dt {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.rate-row dd {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
}

.rates-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  margin-top: 18px;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.rates-card p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 20;
  transform: translate(-50%, 14px);
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font-size: 14px;
  font-weight: 680;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 920px) {
  .app-shell {
    width: min(100vw - 28px, 720px);
    padding-top: 18px;
  }

  .topbar,
  .workspace {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar {
    gap: 18px;
    padding-bottom: 20px;
  }

  .status-row {
    justify-content: space-between;
  }

  .workspace {
    gap: 14px;
  }

  .rates-card {
    position: static;
  }
}

@media (max-width: 660px) {
  .app-shell {
    width: 100%;
    padding: 12px 12px 38px;
  }

  h1 {
    font-size: 24px;
  }

  .mark {
    width: 44px;
    height: 44px;
  }

  .status-row {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px 10px;
    font-size: 13px;
  }

  .converter-panel,
  .rates-card {
    box-shadow: none;
  }

  .converter-panel {
    padding: 12px;
  }

  .base-control {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .base-amount {
    height: 62px;
    font-size: 32px;
  }

  .currency-segments {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .segment-button {
    min-width: 0;
    padding: 0 8px;
  }

  .result-heading {
    padding-top: 14px;
  }

  .currency-row {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 0;
    gap: 12px;
    padding: 13px;
  }

  .converted-value {
    grid-column: 1 / -1;
  }

  .currency-info {
    grid-column: 1;
  }

  .row-actions {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
  }

  .converted-value {
    justify-content: space-between;
    padding-top: 2px;
    font-size: 22px;
  }

  .currency-marker {
    flex-basis: 42px;
    width: 42px;
    height: 42px;
  }
}
