/* GoChainX shared styles */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #0d9488;
  --accent-deep: #0f766e;
  --in: #059669;
  --out: #dc2626;
  --gold: #f0b90b;
  --dark-poster: #0a0e17;
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --font: "Plus Jakarta Sans", "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", sans-serif;
  --display: "Outfit", "Plus Jakarta Sans", "PingFang SC", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  padding-bottom: var(--safe-b);
  overscroll-behavior-y: contain;
}
button, a, .tab, .dir-tab, .chain-seg, .dock-btn, .ghost-btn, .share-act {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}
.site-header-inner {
  max-width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-left: max(16px, var(--safe-l));
  padding-right: max(16px, var(--safe-r));
}
.brand-lockup {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.brand-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.brand-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 480px) {
  .brand-sub { display: none; }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.nav-links {
  display: none;
  gap: 2px;
}
@media (min-width: 720px) {
  .nav-links { display: flex; }
}
.nav-link {
  font-size: 13px;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
  transition: color .15s, background .15s;
}
.nav-link:hover, .nav-link.active {
  color: var(--ink);
  background: #f1f5f9;
}

.lang-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.lang-globe-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 10px;
  cursor: pointer;
  line-height: 1.2;
  box-shadow: var(--shadow-card);
  transition: border-color .15s, background .15s;
}
.lang-globe-btn:hover,
.lang-switch.open .lang-globe-btn {
  border-color: rgba(13, 148, 136, 0.4);
  background: #f8fafc;
}
.lang-globe-icon {
  font-size: 14px;
  line-height: 1;
}
.lang-globe-flag {
  font-size: 14px;
  line-height: 1;
}
.lang-globe-code {
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}
.lang-globe-caret {
  font-size: 9px;
  color: var(--muted);
  margin-left: 1px;
}
.lang-globe-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 80;
  min-width: 200px;
  max-height: min(360px, 70vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  padding: 6px;
}
.lang-switch.open .lang-globe-menu { display: block; }
.lang-globe-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}
.lang-globe-item:hover { background: #f1f5f9; }
.lang-globe-item.active {
  background: rgba(13, 148, 136, 0.1);
  color: var(--accent-deep);
  font-weight: 600;
}
.lang-globe-item .flag { font-size: 16px; line-height: 1; width: 1.25em; text-align: center; }
.lang-globe-item .native { flex: 1; min-width: 0; }
.lang-globe-item .code {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}
.lang-globe-item.active .code { color: var(--accent-deep); }

/* Legacy small lang buttons (unused if globe is active) */
.lang-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 7px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
}
.lang-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.page-wrap {
  max-width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px max(16px, var(--safe-l)) 48px;
}

/* Home */
.home-hero {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  padding: clamp(28px, 6vw, 56px) clamp(20px, 4vw, 40px);
  background:
    radial-gradient(ellipse 80% 60% at 100% 0%, rgba(13, 148, 136, 0.22), transparent 55%),
    radial-gradient(ellipse 70% 50% at 0% 100%, rgba(15, 23, 42, 0.08), transparent 50%),
    linear-gradient(145deg, #ecfdf8 0%, #f8fafc 45%, #e2e8f0 100%);
  border: 1px solid rgba(148, 163, 184, 0.25);
  margin-bottom: 28px;
  animation: fadeUp .55s cubic-bezier(.22, 1, .36, 1) both;
}
.home-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%230f766e' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}
.home-hero > * { position: relative; z-index: 1; }
.home-brand {
  font-family: var(--display);
  font-size: clamp(40px, 9vw, 72px);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 0.95;
  margin: 0 0 14px;
  color: var(--ink);
}
.home-title {
  font-size: clamp(18px, 3.5vw, 24px);
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--ink);
}
.home-desc {
  margin: 0;
  max-width: 42ch;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}
.home-feats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}
.feat-chip {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-deep);
  background: rgba(13, 148, 136, 0.1);
  border: 1px solid rgba(13, 148, 136, 0.18);
  padding: 6px 10px;
  border-radius: 999px;
}

.tools-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  animation: fadeUp .55s .08s cubic-bezier(.22, 1, .36, 1) both;
}
@media (min-width: 900px) {
  .tools-grid { gap: 14px; }
}
.tools-heading {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  color: var(--ink);
}
.tool-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  transition: transform .2s, border-color .2s, box-shadow .2s;
  min-height: 0;
}
@media (min-width: 720px) {
  .tool-tile { padding: 18px 16px; gap: 8px; border-radius: 16px; }
}
.tool-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(13, 148, 136, 0.35);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}
.tool-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ccfbf1, #e2e8f0);
  color: var(--accent-deep);
  font-weight: 800;
  font-size: 13px;
  font-family: var(--display);
}
.tool-tile h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
@media (min-width: 720px) {
  .tool-tile h2 { font-size: 16px; }
}
.tool-tile p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (min-width: 720px) {
  .tool-tile p { font-size: 13px; -webkit-line-clamp: 2; }
}
.tool-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  align-self: flex-start;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 8px;
  transition: background .15s;
}
@media (min-width: 720px) {
  .tool-cta { font-size: 12px; padding: 8px 12px; }
}
.tool-tile:hover .tool-cta { background: var(--accent-deep); }

/* Generic tool form pages */
.tool-panel {
  max-width: 560px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  padding: 18px 16px 22px;
}
.tool-panel h1 {
  font-family: var(--display);
  font-size: 22px;
  margin: 0 0 6px;
  letter-spacing: -0.03em;
}
.tool-panel .lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.tool-panel label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.tool-panel .field { margin-bottom: 12px; }
.tool-panel input,
.tool-panel textarea,
.tool-panel select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 15px;
  outline: none;
  background: #fff;
  font-family: inherit;
}
.tool-panel textarea {
  min-height: 120px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}
.tool-panel input:focus,
.tool-panel textarea:focus,
.tool-panel select:focus {
  border-color: rgba(13, 148, 136, 0.45);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}
.tool-panel .btn {
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: #0f172a;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.tool-panel .btn:active { transform: scale(0.98); }
.tool-panel .out {
  margin-top: 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.tool-panel .grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.ok { color: #059669; font-weight: 700; }
.bad { color: #dc2626; font-weight: 700; }
#qrBox { display: flex; justify-content: center; padding: 12px; background: #fff; border-radius: 12px; }

/* Futures PnL calculator */
.futures-wrap {
  --futures-long: #059669;
  --futures-long-bg: rgba(5, 150, 105, 0.1);
  --futures-short: #e11d48;
  --futures-short-bg: rgba(225, 29, 72, 0.1);
  --futures-theme: var(--futures-long);
  --futures-theme-bg: var(--futures-long-bg);
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  max-width: 960px;
  margin: 0 auto;
}
.futures-wrap[data-dir="short"] {
  --futures-theme: var(--futures-short);
  --futures-theme-bg: var(--futures-short-bg);
}
@media (min-width: 800px) {
  .futures-wrap {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: stretch;
  }
}
.futures-panel {
  max-width: none;
  margin: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.futures-dir {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.futures-dir-btn {
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 11px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.futures-dir-btn#btn-long.active {
  background: var(--futures-long-bg);
  border-color: rgba(5, 150, 105, 0.45);
  color: var(--futures-long);
}
.futures-dir-btn#btn-short.active {
  background: var(--futures-short-bg);
  border-color: rgba(225, 29, 72, 0.4);
  color: var(--futures-short);
}
.futures-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 10px;
  margin-bottom: 16px;
}
.futures-fields .field { margin-bottom: 0; }
.futures-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.futures-input-wrap input {
  padding-right: 44px;
  font-family: var(--mono);
  font-size: 14px;
}
.futures-input-wrap input:focus {
  border-color: color-mix(in srgb, var(--futures-theme) 55%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--futures-theme) 18%, transparent);
}
.futures-unit {
  position: absolute;
  right: 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  pointer-events: none;
}
.futures-calc-btn {
  margin-top: auto;
  background: var(--futures-theme) !important;
  color: #fff !important;
}
.futures-calc-btn:hover { filter: brightness(0.96); }
.futures-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.futures-metric {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.futures-metric-hero {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #f8fafc 0%, var(--futures-theme-bg) 100%);
  border-left: 4px solid var(--futures-theme);
}
.futures-mlabel {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.futures-mval {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: -0.02em;
}
.futures-metric-hero .futures-mval { font-size: 24px; }
.futures-profit { color: var(--futures-long) !important; }
.futures-loss { color: var(--futures-short) !important; }
.futures-mval.neutral { color: var(--ink); }
.futures-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}
.futures-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.futures-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  padding: 4px 0;
}
.futures-detail-row .muted { color: var(--muted); }
.futures-detail-row span:last-child {
  font-family: var(--mono);
  font-weight: 600;
  text-align: right;
}
@media (max-width: 480px) {
  .futures-fields { gap: 10px 8px; }
  .futures-mval { font-size: 16px; }
  .futures-metric-hero .futures-mval { font-size: 20px; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -10px) scale(.96); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translate(-50%, 0) scale(1); }
  to { opacity: 0; transform: translate(-50%, -8px) scale(.96); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes sheetUp {
  from { transform: translateY(100%); opacity: .6; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.94) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.anim-fade-up { animation: fadeUp .45s cubic-bezier(.22, 1, .36, 1) both; }
.anim-toast-in { animation: toastIn .32s cubic-bezier(.22, 1, .36, 1) both; }
.anim-toast-out { animation: toastOut .22s ease-in both; }

.skeleton {
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
}

.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after {
  content: '';
  position: absolute; inset: 0; margin: auto;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
.btn-spin { animation: spin .8s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  .anim-fade-up, .home-hero, .tools-grid, .skeleton, .btn-spin,
  .anim-toast-in, .anim-toast-out, .settings-sheet {
    animation: none !important;
  }
}
