:root {
  --bg: #f0f2f5;
  --card: #ffffff;
  --primary: #2563EB;
  --primary-deep: #1d4ed8;
  --ink: #1a1a2e;
  --label: #666666;
  --stamp: #9ca3af;
  --border: #e5e7eb;
  --announce-bg: #eff6ff;
  --announce-text: #1d4ed8;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  --radius: 12px;
  --font-brand: "Syne", sans-serif;
  --font-body: "Manrope", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  word-wrap: break-word;
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  padding: 12px 12px;
  min-width: 0;
  min-height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.card {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 14px 12px;
  display: grid;
  gap: 10px;
  overflow: hidden;
  animation: rise 0.4s ease both;
}

/* —— 1. 标题行 —— */
.brand {
  display: flex;
  align-items: center;
  min-width: 0;
}

.brand__mark {
  margin: 0;
  min-width: 0;
  width: 100%;
  font-family: var(--font-brand);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
}

/* 统一按钮基础 */
.btn {
  font: inherit;
  border: 0;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.btn:active {
  transform: scale(0.96);
}

.btn--icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.btn--icon:hover {
  background: rgba(37, 99, 235, 0.06);
  border-color: #c7d2fe;
}

.refresh-icon {
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}

.refresh-icon:disabled {
  cursor: wait;
  opacity: 0.7;
}

.refresh-icon.is-loading {
  animation: spin 0.8s linear infinite;
}

/* —— 公告与推荐（紧凑，不抢主视觉） —— */
.promo {
  margin: 0;
  max-height: 120px;
  min-height: 80px;
  overflow: hidden;
  background: #f8fafc;
  border: 1px solid #eef2f7;
  border-radius: 10px;
  padding: 8px 10px;
  color: #64748b;
}

.promo__row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
}

.promo__main {
  flex: 1;
  min-width: 0;
}

.promo__eyebrow {
  margin: 0 0 2px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #94a3b8;
}

.promo__heading {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  color: #334155;
}

.promo__desc {
  margin: 2px 0 0;
  font-size: 11px;
  line-height: 1.35;
  color: #64748b;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.promo__btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e2e8f0;
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.promo__btn:hover {
  background: rgba(37, 99, 235, 0.06);
  border-color: #bfdbfe;
}

.promo__btn:active {
  transform: scale(0.97);
}

.promo__btn--ghost {
  height: 24px;
  padding: 0 8px;
  font-size: 10px;
}

.promo__list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.promo__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.promo__item-title {
  font-size: 11px;
  color: #64748b;
}

/* —— 地区识别提示（弱化） —— */
.locale-tip {
  margin: 0;
  font-size: 11px;
  font-weight: 400;
  color: #9ca3af;
  line-height: 1.3;
}

/* —— 转换区 skeleton —— */
.converter {
  min-width: 0;
}

.converter__skeleton {
  display: grid;
  gap: 10px;
}

.converter[data-ready="true"] .converter__skeleton {
  display: none;
}

.skeleton-line,
.skeleton-box,
.skeleton-swap {
  background: linear-gradient(90deg, #eef2f7 25%, #f7f9fc 50%, #eef2f7 75%);
  background-size: 200% 100%;
  animation: shimmer 1.1s ease infinite;
  border-radius: 8px;
}

.skeleton-line--label {
  width: 48px;
  height: 12px;
}

.skeleton-box {
  height: 52px;
  border-radius: 12px;
}

.skeleton-swap {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  margin: 0 auto;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* —— 金额 / 结果配对行 —— */
.field__label {
  display: block;
  width: fit-content;
  max-width: calc(50% - 28px);
  font-size: 13px;
  font-weight: 500;
  color: var(--label);
}

.io-stack {
  display: grid;
  gap: 0;
  min-width: 0;
  position: relative;
}

.io-block {
  display: grid;
  gap: 6px;
  min-width: 0;
}

/* 两种货币之间：整体下移约 8~10px，上疏下密；标签已收窄，可与标签行垂直交叠但不挡字 */
.io-swap-rail {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 0 -16px;
  padding: 14px 0 2px;
  pointer-events: none;
}

.swap-mid {
  pointer-events: auto;
  width: 32px;
  height: 32px;
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.swap-mid.is-spinning {
  transform: rotate(180deg);
}

.io-box {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius);
  /* 右侧选择区距边框约 14~16px */
  padding: 10px 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.io-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.io-box--result {
  background: #fafbfc;
}

.io-box__amount {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  max-width: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  margin: 0;
  font: inherit;
  font-family: var(--font-brand);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  outline: none;
  appearance: textfield;
}

.io-box__amount::-webkit-outer-spin-button,
.io-box__amount::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.io-box__amount--result {
  display: block;
  text-align: left;
  border-radius: 6px;
  overflow-wrap: anywhere;
  user-select: none;
}

.io-box__amount--result.is-updating {
  animation: pulse 0.3s ease;
}

.io-box__currency {
  flex: 0 0 auto;
  min-width: 5.5rem;
  max-width: none;
  margin: 0 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 6px 0 6px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  position: relative;
  outline: none;
  transition: background 0.2s ease;
}

.io-box__currency:hover,
.io-box__currency:focus {
  background: rgba(37, 99, 235, 0.06);
}

.io-box__currency.is-local-value .io-box__code {
  color: var(--primary);
}

.io-box__flag {
  flex-shrink: 0;
  width: 20px;
  height: 15px;
  object-fit: cover;
  border-radius: 2px;
  background: #f3f4f6;
}

.io-box__code {
  flex: 0 0 auto;
  min-width: 2.6em;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.local-dot {
  position: static;
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  margin: 0;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 2px #fff;
}

/* 下拉指示：与蓝点同属右侧选择区，距边框约 14px（随 .io-box padding） */
.io-box__currency::after {
  content: "";
  flex-shrink: 0;
  width: 0;
  height: 0;
  margin-left: 2px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #9ca3af;
  opacity: 0.9;
}

.is-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.card__meta,
.sync-panel {
  display: grid;
  gap: 6px;
  justify-items: stretch;
  text-align: left;
  padding-top: 2px;
}

.sync-status {
  text-align: center;
}

.sync-status__title {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
}

.sync-status__desc {
  margin: 2px 0 0;
  font-size: 11px;
  color: #94a3b8;
}

.sync-status__desc[hidden] {
  display: none !important;
}

.sync-divider {
  height: 1px;
  background: #eef2f7;
  border: 0;
  margin: 0;
}

.stamp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  max-width: 100%;
}

.meta-line {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.meta-line__label {
  font-size: 10px;
  color: #94a3b8;
  line-height: 1.2;
}

.meta-line__value {
  font-size: 11px;
  color: #64748b;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.meta-line--source .meta-line__value {
  font-weight: 500;
}

/* —— 底部半屏选择面板 —— */
body.sheet-open {
  overflow: hidden;
}

.sheet-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 16px 16px;
  box-sizing: border-box;
}

.sheet-root[hidden] {
  display: none !important;
}

.sheet-root__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  animation: fade-in 0.2s ease both;
  cursor: pointer;
}

.currency-sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 360px;
  height: 45vh;
  max-height: 50vh;
  min-height: 40vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
  animation: sheet-up 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
  will-change: transform;
  overflow: hidden;
}

.currency-sheet.is-dragging {
  animation: none;
  transition: none;
}

.currency-sheet.is-closing {
  animation: sheet-down 0.22s ease both;
}

.currency-sheet__grab {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  padding: 10px 0 4px;
  cursor: grab;
  touch-action: none;
}

.currency-sheet__handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: #d1d5db;
}

.currency-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 12px 8px 16px;
  flex-shrink: 0;
}

.currency-sheet__close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--label);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.currency-sheet__close:hover {
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary);
}

.currency-sheet__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.currency-sheet__search-wrap {
  padding: 0 16px 10px;
  flex-shrink: 0;
}

.currency-sheet__search {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  font: inherit;
  font-size: 15px;
  outline: none;
  background: #fafafa;
}

.currency-sheet__search:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.currency-sheet__list {
  list-style: none;
  margin: 0;
  padding: 0 0 env(safe-area-inset-bottom, 0);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.currency-sheet__item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 20px;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
  user-select: none;
}

.currency-sheet__item:active,
.currency-sheet__item:hover {
  background: #eff6ff;
}

.currency-sheet__item.is-active {
  background: #eff6ff;
  color: var(--primary-deep);
  font-weight: 600;
}

.currency-sheet__item.is-local {
  font-weight: 600;
  color: var(--primary);
}

.currency-sheet__item[hidden] {
  display: none;
}

.currency-sheet__flag {
  flex-shrink: 0;
  width: 24px;
  height: 18px;
  object-fit: cover;
  border-radius: 2px;
  background: #f3f4f6;
}

.currency-sheet__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.currency-sheet__empty {
  margin: 0;
  padding: 32px 16px;
  font-size: 14px;
  color: var(--stamp);
  text-align: center;
}

/* —— 嵌入 / 小屏 —— */
.mode-embed .shell {
  padding: 10px;
  min-height: auto;
}

.mode-embed .card {
  padding: 14px 12px 12px;
  gap: 12px;
}

@media (max-width: 380px) {
  .shell {
    padding: 12px 10px;
  }

  .card {
    padding: 14px 12px 12px;
    gap: 12px;
  }

  .brand__mark {
    font-size: 18px;
  }

  .io-box {
    gap: 10px;
    padding: 10px 14px;
  }

  .io-box__amount {
    font-size: 24px;
  }

  .io-box__currency {
    min-width: 5.25rem;
    gap: 6px;
  }

  .io-box__code {
    font-size: 12px;
  }

  .promo {
    padding: 7px 9px;
    min-height: 80px;
    max-height: 110px;
  }

  .promo__heading {
    font-size: 12px;
  }

  .promo__desc {
    font-size: 10px;
  }
}

@media (min-height: 700px) {
  .shell {
    padding: 24px 16px;
    align-items: center;
  }

  .card {
    padding: 22px 18px 16px;
    gap: 16px;
  }

  .io-box__amount {
    font-size: 32px;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes sheet-down {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(100%);
  }
}
