:root {
  color-scheme: dark;
  --bg: #081018;
  --bg-2: #0d1724;
  --surface: rgba(16, 28, 42, 0.78);
  --surface-strong: rgba(20, 35, 52, 0.96);
  --surface-soft: rgba(255, 255, 255, 0.06);
  --text: #edf6ff;
  --muted: #98a8ba;
  --line: rgba(164, 188, 214, 0.2);
  --blue: #4f8cff;
  --cyan: #18d5d0;
  --green: #46e6a5;
  --amber: #ffbd63;
  --violet: #a78bfa;
  --red: #ff6b80;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f8fc;
  --bg-2: #eaf1f8;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --surface-soft: rgba(20, 42, 68, 0.06);
  --text: #122033;
  --muted: #5d6d7f;
  --line: rgba(30, 58, 91, 0.14);
  --shadow: 0 24px 70px rgba(24, 43, 67, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(160deg, rgba(24, 213, 208, 0.1), transparent 34rem),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  color: var(--text);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(to bottom, #000, transparent 86%);
}

#flowCanvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  opacity: 0.7;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-strong) 76%, transparent);
  backdrop-filter: blur(22px);
}

.brand,
.top-actions,
.nav,
.account-row,
.console-top,
.model-toolbar,
.composer-foot,
.section-head,
.wallet-head,
.wallet-actions,
.table-title,
.api-panel,
.deposit-box {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  min-width: 220px;
}

.brand-mark,
.avatar,
.card-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: #ffffff;
  font-weight: 900;
  background:
    linear-gradient(135deg, rgba(79, 140, 255, 0.95), rgba(24, 213, 208, 0.95) 54%, rgba(70, 230, 165, 0.95)),
    #1a6cff;
  box-shadow: 0 0 32px rgba(24, 213, 208, 0.22);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
}

.nav a {
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
}

.nav a:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.top-actions {
  gap: 10px;
  justify-content: flex-end;
  min-width: 260px;
}

.primary,
.secondary,
.ghost,
.icon-button,
.oauth {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 16px;
  color: var(--text);
  background: var(--surface-soft);
}

.primary {
  color: #061016;
  font-weight: 800;
  background: linear-gradient(135deg, var(--green), var(--cyan) 52%, var(--blue));
  box-shadow: 0 16px 32px rgba(24, 213, 208, 0.22);
}

.secondary,
.ghost,
.oauth {
  border-color: var(--line);
  background: color-mix(in srgb, var(--surface-strong) 72%, transparent);
}

.secondary:hover,
.ghost:hover,
.icon-button:hover,
.oauth:hover {
  border-color: color-mix(in srgb, var(--cyan) 56%, var(--line));
  transform: translateY(-1px);
}

.compact {
  min-height: 34px;
  border-radius: 10px;
  padding: 0 12px;
  font-size: 13px;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  place-items: center;
  padding: 0;
  border-color: var(--line);
}

.product-shell,
.section {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
}

.product-shell {
  display: grid;
  grid-template-columns: minmax(320px, 0.72fr) minmax(460px, 1fr);
  gap: 22px;
  min-height: calc(100vh - 74px);
  padding: 34px 0 28px;
  align-items: stretch;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 640px;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.kicker::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 20px var(--green);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.hero-copy h1 {
  margin: 18px 0 18px;
  max-width: 720px;
  font-size: clamp(36px, 5vw, 66px);
  line-height: 1.04;
  letter-spacing: 0;
}

.hero-copy p,
.api-panel p,
.integration-card p {
  color: var(--muted);
  line-height: 1.75;
}

.account-card,
.chat-console,
.integration-card,
.wallet-panel,
.usage-panel,
.model-card,
.api-panel,
.auth-card,
.recharge-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-strong) 78%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.account-card {
  margin: 22px 0 14px;
  padding: 16px;
}

.account-row {
  gap: 12px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.account-row div {
  flex: 1;
  min-width: 0;
}

.account-row small,
.permission-grid small,
.quick-metrics small,
.model-toolbar label,
.cost-chip span,
.balance-display small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.permission-grid span,
.quick-metrics article,
.metric-tile {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.permission-grid b,
.permission-grid small {
  display: block;
  overflow-wrap: anywhere;
}

.quick-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.quick-metrics strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.chat-console {
  display: flex;
  flex-direction: column;
  min-height: 640px;
  padding: 18px;
}

.console-top,
.section-head,
.wallet-head,
.table-title,
.api-panel {
  justify-content: space-between;
  gap: 16px;
}

.console-top h2,
.section-head h2,
.wallet-head h2,
.api-panel h2 {
  margin: 6px 0 0;
  font-size: 30px;
  letter-spacing: 0;
}

.provider-switch,
.chain-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
}

.provider-switch button,
.chain-tabs button {
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
}

.provider-switch .active,
.chain-tabs .active {
  color: #041016;
  font-weight: 900;
  background: var(--cyan);
}

.model-toolbar {
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 12px;
}

.model-toolbar label {
  flex: 1;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  color: var(--text);
  background: color-mix(in srgb, var(--surface-strong) 68%, transparent);
}

select,
input {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 86px;
  padding: 12px;
}

.cost-chip {
  min-width: 160px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.model-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.model-pills button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  background: var(--surface-soft);
}

.model-pills button.active {
  color: var(--text);
  border-color: color-mix(in srgb, var(--cyan) 64%, var(--line));
}

.messages {
  flex: 1;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 260px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent),
    rgba(0, 0, 0, 0.08);
}

.message {
  display: flex;
  gap: 10px;
  max-width: 86%;
  animation: riseIn 0.28s ease both;
}

.message > span {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #061016;
  font-size: 12px;
  font-weight: 900;
  background: var(--cyan);
}

.message div {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-strong) 72%, transparent);
}

.message p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.message.user {
  justify-self: end;
  flex-direction: row-reverse;
}

.message.user > span {
  background: var(--green);
}

.message.user div {
  background: color-mix(in srgb, var(--blue) 20%, var(--surface-strong));
}

.composer {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.composer-foot {
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.section {
  padding: 76px 0 12px;
}

.integration-grid,
.model-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.integration-card,
.model-card {
  padding: 18px;
}

.card-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  margin-bottom: 18px;
}

.openai-mark {
  background: linear-gradient(135deg, var(--green), #1a9d73);
}

.gemini-mark {
  background: linear-gradient(135deg, var(--blue), var(--violet));
}

.tg-mark {
  background: linear-gradient(135deg, #27a7e7, var(--cyan));
}

.integration-card h3,
.model-card h3 {
  margin-bottom: 8px;
}

.status,
.network-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.status.waiting {
  color: var(--amber);
  background: color-mix(in srgb, var(--amber) 16%, transparent);
}

.status.online {
  color: var(--green);
  background: color-mix(in srgb, var(--green) 16%, transparent);
}

.billing-layout {
  display: grid;
  grid-template-columns: 0.78fr 1.22fr;
  gap: 16px;
}

.wallet-panel,
.usage-panel {
  padding: 18px;
}

.network-badge {
  color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 14%, transparent);
}

.balance-display {
  margin: 22px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(70, 230, 165, 0.13), rgba(79, 140, 255, 0.1)),
    var(--surface-soft);
}

.balance-display strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1;
}

.wallet-actions {
  gap: 10px;
}

.usage-bars {
  display: grid;
  gap: 14px;
  margin: 8px 0 18px;
}

.usage-bars label {
  display: grid;
  grid-template-columns: 120px 42px 1fr;
  gap: 12px;
  align-items: center;
  color: var(--muted);
}

.usage-bars i {
  display: block;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.usage-bars b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--cyan), var(--blue));
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--text);
  font-size: 13px;
}

.pricing-table {
  display: table;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(320px, 100%);
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
}

.search-box input {
  min-height: auto;
  border: 0;
  padding: 0;
  background: transparent;
}

.model-card {
  position: relative;
  overflow: hidden;
  min-height: 190px;
}

.model-card::after {
  content: "";
  position: absolute;
  right: -42px;
  bottom: -42px;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--cyan) 18%, transparent);
}

.model-card p {
  min-height: 48px;
  color: var(--muted);
  line-height: 1.6;
}

.model-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.model-meta span {
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
}

.api-panel {
  margin-bottom: 90px;
  padding: 22px;
}

.api-panel > div:first-child {
  max-width: 560px;
}

.endpoint-card {
  position: relative;
  min-width: min(420px, 100%);
  padding: 16px 58px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.endpoint-card small,
.endpoint-card code {
  display: block;
}

.endpoint-card small {
  color: var(--muted);
  margin-bottom: 8px;
}

.endpoint-card code {
  overflow-wrap: anywhere;
}

.endpoint-card .icon-button {
  position: absolute;
  top: 14px;
  right: 14px;
}

.mobile-nav {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 35;
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface-strong) 88%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.mobile-nav a {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-height: 48px;
  padding: 7px 0 5px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
}

.mobile-nav a:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.auth-modal,
.recharge-modal {
  width: min(460px, calc(100% - 28px));
  padding: 0;
  border: 0;
  background: transparent;
}

.auth-modal::backdrop,
.recharge-modal::backdrop {
  background: rgba(2, 8, 14, 0.68);
  backdrop-filter: blur(6px);
}

.auth-card,
.recharge-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 26px;
}

.auth-card h2,
.recharge-card h2 {
  margin: 0;
}

.oauth-stack {
  display: grid;
  gap: 10px;
}

.oauth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
}

.auth-card label,
.recharge-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.wide {
  width: 100%;
}

.close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 22px;
}

.deposit-box {
  gap: 14px;
  align-items: stretch;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.qr-pattern {
  width: 112px;
  min-height: 112px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, #fff 10px, transparent 10px 18px, #fff 18px 28px, transparent 28px),
    linear-gradient(#fff 10px, transparent 10px 18px, #fff 18px 28px, transparent 28px),
    #041016;
  background-size: 28px 28px;
  box-shadow: inset 0 0 0 10px #041016;
}

.deposit-box div:last-child {
  display: grid;
  gap: 8px;
  flex: 1;
}

.deposit-box code {
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  transform: translateY(18px);
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  opacity: 0;
  color: var(--text);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  transition: 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.icon {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  vertical-align: -3px;
}

.icon.moon {
  border-radius: 50%;
  box-shadow: inset -5px -3px 0 0 var(--cyan);
}

.icon.google {
  border: 3px solid var(--blue);
  border-right-color: var(--green);
  border-bottom-color: var(--amber);
  border-radius: 50%;
}

.icon.telegram {
  clip-path: polygon(0 42%, 100% 0, 72% 100%, 47% 64%, 28% 82%);
  background: #27a7e7;
}

.icon.send {
  clip-path: polygon(0 0, 100% 50%, 0 100%, 18% 55%, 18% 45%);
  background: currentColor;
}

.icon.copy {
  border: 2px solid currentColor;
  border-radius: 4px;
}

.icon.copy::after {
  content: "";
  position: absolute;
  left: 5px;
  top: -5px;
  width: 9px;
  height: 9px;
  border: 2px solid currentColor;
  border-radius: 4px;
  background: var(--surface-strong);
}

.icon.search {
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon.search::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -3px;
  width: 7px;
  border-top: 2px solid currentColor;
  transform: rotate(45deg);
}

.icon.wallet,
.icon.key,
.icon.layers,
.icon.chat {
  border: 2px solid currentColor;
  border-radius: 4px;
}

.icon.key {
  border-radius: 50%;
}

.icon.chat::after {
  content: "";
  position: absolute;
  left: 3px;
  bottom: -5px;
  width: 6px;
  height: 6px;
  background: currentColor;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1040px) {
  .nav {
    display: none;
  }

  .product-shell,
  .billing-layout,
  .api-panel {
    grid-template-columns: 1fr;
  }

  .product-shell {
    min-height: auto;
  }

  .hero-copy,
  .chat-console {
    min-height: auto;
  }

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

@media (max-width: 720px) {
  body {
    padding-bottom: 78px;
  }

  .topbar {
    padding: 0 14px;
  }

  .brand {
    min-width: 0;
  }

  .brand small,
  .auth-shortcut.ghost {
    display: none;
  }

  .top-actions {
    min-width: auto;
  }

  .auth-shortcut.primary {
    padding: 0 12px;
  }

  .product-shell,
  .section {
    width: min(100% - 24px, 1240px);
  }

  .product-shell {
    padding-top: 22px;
  }

  .hero-copy h1 {
    font-size: 36px;
  }

  .permission-grid,
  .quick-metrics,
  .integration-grid,
  .model-grid {
    grid-template-columns: 1fr;
  }

  .console-top,
  .model-toolbar,
  .section-head,
  .wallet-head,
  .table-title,
  .api-panel,
  .deposit-box {
    align-items: stretch;
    flex-direction: column;
  }

  .provider-switch {
    width: 100%;
  }

  .provider-switch button {
    flex: 1;
  }

  .messages {
    min-height: 320px;
  }

  .message {
    max-width: 100%;
  }

  .usage-panel,
  .pricing-table {
    overflow-x: auto;
  }

  .usage-bars label {
    grid-template-columns: 1fr 40px;
  }

  .usage-bars i {
    grid-column: 1 / -1;
  }

  .mobile-nav {
    display: grid;
  }

  .toast {
    right: 14px;
    bottom: 86px;
  }
}
