:root {
  --bg: #f2f5fb;
  --panel: #ffffff;
  --line: #d8e0ed;
  --text: #1f2a44;
  --text-soft: #60728f;
  --primary: #1e4fa6;
  --primary-strong: #163f86;
  --ok-bg: #e6f7ed;
  --ok-text: #1f7a47;
  --err-bg: #fae7e7;
  --err-text: #a33a3a;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

[v-cloak] {
  visibility: hidden;
}

body {
  font-family: 'Manrope', 'Noto Sans SC', 'Segoe UI', sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f6f8fd 0%, var(--bg) 100%);
}

.page-shell {
  min-height: 100vh;
  padding: 12px;
  display: flex;
  flex-direction: column;
}

.container {
  width: min(1700px, calc(100vw - 24px));
  margin: 0 auto;
  flex: 1;
}

.hero,
.panel,
.footer {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.hero {
  padding: clamp(8px, 0.9vw, 14px) clamp(12px, 1.1vw, 18px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: clamp(72px, 8vh, 104px);
  flex-wrap: wrap;
}

.hero-main {
  min-width: 0;
  max-width: 680px;
  text-align: center;
}

h1 {
  margin-top: 2px;
  font-size: clamp(22px, 1.8vw, 30px);
  line-height: 1.04;
}

.hero-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.meta-pill {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #d4deee;
  background: #f6f9ff;
  color: #51678f;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}

.hero-qrcode {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  overflow: visible;
  background: #f0f3f8;
  border: 1px solid var(--line);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.hero-qrcode .qr-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  border-radius: 8px;
}

.hero-qrcode .qr-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.96);
  transform-origin: top center;
  width: 160px;
  height: 160px;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 100;
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0s linear 0.16s;
}

.hero-qrcode .qr-tooltip.show,
.hero-qrcode:focus-visible .qr-tooltip,
.hero-qrcode:focus-within .qr-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
  transition-delay: 0s;
}

.hero-qrcode .qr-tooltip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.panel {
  margin-top: 10px;
  padding: clamp(8px, 0.95vw, 16px);
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(560px, 1.5fr) minmax(340px, 1fr);
  gap: clamp(10px, 1vw, 16px);
  align-items: start;
}

.converter-block,
.market-block {
  min-width: 0;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-btn,
.btn,
input {
  min-height: clamp(40px, 2.4vw, 46px);
  border-radius: 10px;
  font-family: inherit;
  font-size: clamp(14px, 0.92vw, 16px);
}

.mode-btn {
  border: 1px solid var(--line);
  background: #f4f8ff;
  color: #54688f;
  font-weight: 700;
  cursor: pointer;
}

.mode-btn.active {
  color: #fff;
  border-color: var(--primary);
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
}

.input-group {
  margin-top: 10px;
}

.input-group.compact {
  margin-top: 0;
}

.input-label {
  display: block;
  margin-bottom: 5px;
  font-size: clamp(13px, 0.9vw, 15px);
  font-weight: 700;
  color: #3f567f;
}

.input-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
}

.input-wrapper input {
  flex: 1 1 auto;
  min-width: 0;
}

.input-wrapper .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

input:focus {
  outline: none;
  border-color: #7ea3de;
  box-shadow: 0 0 0 3px rgba(78, 126, 212, 0.15);
}

.btn {
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-strong);
}

.btn-secondary {
  color: #415882;
  border-color: var(--line);
  background: #f3f7ff;
}

.row-inline {
  margin-top: 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: end;
}

.decimals-control {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7faff;
  padding: 4px;
}

.decimals-control .btn {
  min-height: 34px;
  min-width: 34px;
  padding: 0;
  border-color: var(--line);
  background: #fff;
}

.decimals-value {
  min-width: 30px;
  text-align: center;
  font-weight: 800;
}

.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.result-box {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbff;
  padding: clamp(10px, 1vw, 16px);
  text-align: center;
}

.result-label {
  font-size: 12px;
  color: var(--text-soft);
}

.result-value {
  margin-top: 8px;
  font-size: clamp(30px, 3vw, 52px);
  line-height: 1.05;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.result-unit {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-soft);
}

.market-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fbff;
  padding: clamp(10px, 1vw, 14px);
}

.market-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.market-title {
  font-size: 14px;
  font-weight: 800;
}

.market-status {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid #b6e4c7;
  background: var(--ok-bg);
  color: var(--ok-text);
}

.market-status.error {
  border-color: #ebb6b6;
  background: var(--err-bg);
  color: var(--err-text);
}

.market-grid {
  margin-top: 9px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.market-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: clamp(8px, 0.85vw, 12px);
  display: grid;
  gap: 4px;
}

.market-label,
.market-meta {
  font-size: 12px;
  color: var(--text-soft);
}

.market-value {
  font-size: clamp(18px, 1.4vw, 24px);
  font-weight: 800;
  line-height: 1.08;
  font-variant-numeric: tabular-nums;
}

.market-card.loading .market-value,
.market-card.loading .market-meta,
.market-card.loading .market-status {
  color: transparent;
  border-color: transparent;
  border-radius: 8px;
  background: linear-gradient(90deg, #dbe5f6, #edf2fb, #dbe5f6);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

.footer {
  width: min(1700px, calc(100vw - 24px));
  margin: 10px auto 0;
  padding: 8px 10px;
  margin-top: auto;
}

.beian-info {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.beian-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.beian-info a {
  color: #4b618c;
  text-decoration: none;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.beian-divider {
  color: #a9bad8;
}

.beian-icon {
  width: 14px;
  height: 14px;
}

.copyright {
  font-size: 11px;
  color: #7a8cab;
  text-align: center;
}

.qr-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease;
}

.qr-modal-content {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 90vw;
  max-height: 90vh;
  text-align: center;
  animation: scaleIn 0.25s ease;
}

.qr-modal-content img {
  width: 280px;
  height: 280px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
}

.qr-modal-title {
  margin-top: 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.qr-modal-desc {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-soft);
}

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

  .market-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .market-item.market-item-wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .page-shell {
    padding: 10px;
  }

  .hero {
    min-height: auto;
    align-items: center;
    justify-content: center;
  }

  .hero-meta {
    justify-content: center;
  }

  .hero-main,
  h1 {
    max-width: none;
  }

  .hero-qrcode {
    width: 36px;
    height: 36px;
  }

  .hero-qrcode .qr-tooltip {
    display: none;
  }

  .row-inline,
  .action-buttons,
  .market-grid {
    grid-template-columns: 1fr;
  }

  .row-inline {
    display: grid;
    gap: 8px;
  }

  .beian-info {
    grid-template-columns: 1fr;
  }

  .beian-links {
    justify-content: center;
  }

  .beian-divider {
    display: none;
  }

  .copyright {
    text-align: center;
  }
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-18px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-16px);
  }
}
