:root {
  color-scheme: dark;
  --bg: #0a0b10;
  --surface: #11131a;
  --surface-deep: #0d0f16;
  --line: #252936;
  --line-soft: #303543;
  --text: #f5f7fb;
  --muted: #8d95a5;
  --gold: #e8c88a;
  --green: #7ee09b;
  --red: #f09aa0;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
[hidden] { display: none !important; }
.shell { width: min(100% - 40px, 980px); margin: 0 auto; padding: 22px 0 40px; }

/* Header and wallet connection */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; flex: 0 0 auto; align-items: center; gap: 10px; }
.brand b { font-size: 20px; }
.brand small { display: block; color: #737a88; font-size: 9px; letter-spacing: .16em; }
.logo {
  position: relative;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  transform-style: preserve-3d;
  animation: logo-coin-flip 16s linear infinite;
  font-size: 0;
  font-weight: 900;
}
.logo::before, .logo::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 1px solid #ffffff;
  border-radius: inherit;
  backface-visibility: hidden;
  font-size: 18px;
  font-weight: 900;
}
.logo::before { background: #fff; color: var(--bg); content: "K"; }
.logo::after { transform: rotateY(180deg); border-color: #414653; background: #171a22; color: #fff; content: "K"; }
@keyframes logo-coin-flip {
  0%, 5% { transform: perspective(500px) rotateY(0); }
  7% { transform: perspective(500px) rotateY(180deg); }
  9%, 100% { transform: perspective(500px) rotateY(360deg); }
}
.wallet-connect { display: flex; min-width: 0; min-height: 40px; align-items: center; justify-content: flex-end; }
#ton-connect { max-width: 100%; }
.banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid #4a3a1c;
  border-radius: 14px;
  background: #1c1710;
  color: var(--gold);
  font-size: 13px;
  line-height: 1.45;
}
.banner[data-kind="error"] { border-color: #4d2326; background: #1c1113; color: #f0a5aa; }
.banner-close { padding: 0 2px; border: 0; background: none; color: inherit; font-size: 18px; line-height: 1; cursor: pointer; }

/* Page title */
.hero { padding: 38px 0 18px; }
.eyebrow, .label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .15em; }
.hero h1 {
  display: inline-block;
  margin: 10px 0 12px;
  padding: 5px 14px 9px;
  border: 1px solid #493d25;
  border-radius: 14px;
  background: #17150f;
  color: #f5dfa5;
  font-size: clamp(42px, 8vw, 76px);
  letter-spacing: -.055em;
  line-height: .96;
}
.hero h1 span {
  background-image:
    linear-gradient(110deg, transparent 42%, rgba(255,255,255,.16) 47%, #fff 50%, rgba(211,224,245,.22) 53%, transparent 59%),
    linear-gradient(105deg, #f5dfa5 0%, #d3a85a 54%, #f1d99b 100%);
  background-repeat: no-repeat;
  background-position: 100% 0, 0 0;
  background-size: 250% 100%, 100% 100%;
  background-clip: text;
  color: transparent;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: kir-metal-shine 5.5s ease-in-out infinite;
}
@keyframes kir-metal-shine {
  0%, 18% { background-position: 100% 0, 0 0; }
  72%, 100% { background-position: 0 0, 0 0; }
}
.muted { color: var(--muted); line-height: 1.5; }
.small { font-size: 11px; }

/* Wallet and Earn balances */
.card { margin: 0 0 16px; padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.portfolio-card { overflow: hidden; padding: 14px 24px 12px; }
.balance-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.balance-pane { min-width: 0; padding: 20px 18px 22px; }
.earn-pane { border-left: 1px solid #302b20; background: linear-gradient(135deg, #17150f 0%, transparent 72%); }
.big { margin: 12px 0 7px; font-size: 38px; font-weight: 800; letter-spacing: -.03em; overflow-wrap: anywhere; }
.earn-big { color: var(--gold); }
.earn-balance-value { display: inline-block; margin-top: 10px; padding: 0 12px; border: 1px solid #493d25; border-radius: 12px; background: #17150f; }
.earn-balance-value .big { margin: 9px 0; }
.earn-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 18px; margin-top: 18px; }
.earn-metrics span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.earn-metrics b { color: #d8dce5; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.earn-reserve { margin-top: 14px; color: #777d89; }
.addr-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 4px 0 6px; }
.addr { max-width: 100%; color: #cbd1db; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; }
.icon-btn { padding: 7px 10px; border: 1px solid #2c3140; border-radius: 9px; background: #191c25; color: #c8cedb; font-size: 11px; font-weight: 700; cursor: pointer; }
.icon-btn:hover { border-color: #3a4152; color: #fff; }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }
.meta-row { display: flex; min-height: 22px; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.chain-badge { padding: 5px 9px; border: 1px solid #24402c; border-radius: 999px; background: #17241b; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.chain-badge[data-network="other"] { border-color: #4d2326; background: #2a1518; color: var(--red); }
.status { color: var(--muted); font-size: 11px; }
.status[data-kind="ok"] { color: var(--green); }
.status[data-kind="error"] { color: var(--red); }
.status[data-kind="loading"] { color: #b9a675; }
.status[data-kind="warning"] { color: var(--gold); }
.link-btn { margin-left: auto; padding: 2px 0; border: 0; background: none; color: #aab2c2; font-size: 11px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn:disabled { opacity: .6; cursor: progress; }
.link-btn.is-loading { text-decoration: none; }
.earn-actions-card { padding: 6px 24px 18px; }
.earn-panels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 8px 0 20px; }
.earn-panel { display: flex; min-width: 0; flex-direction: column; gap: 10px; padding: 4px 18px 10px; }
.earn-panel + .earn-panel { border-left: 1px solid var(--line); }
.earn-panel h3 { margin: 0; color: #aab2c2; font-size: 12px; letter-spacing: .14em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button, .tabs button {
  border: 1px solid #2c3140;
  background: #191c25;
  color: #c8cedb;
  cursor: pointer;
}
.chips button { padding: 7px 12px; border-radius: 999px; font-size: 12px; }
.chips button:hover { border-color: #3a4152; color: #fff; }
.chips button:disabled, .earn-panel button:disabled { opacity: .5; cursor: not-allowed; }
.earn-input { width: 100%; min-width: 0; padding: 13px 14px; border: 1px solid #2c3140; border-radius: 12px; outline: none; background: #0b0d12; color: var(--text); font-size: 15px; }
.earn-input:focus { border-color: #4a5163; }
.earn-input:disabled { opacity: .55; }
.earn-panel button.primary, .earn-panel button.secondary { padding: 13px; border: 0; border-radius: 12px; font-size: 14px; font-weight: 800; cursor: pointer; }
.primary { background: #fff; color: #090a0e; }
.secondary { background: #242832; color: #fff; }
.earn-history-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 0; padding: 16px 18px 0; border-top: 1px solid var(--line); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs button { padding: 7px 12px; border-radius: 999px; background: transparent; color: var(--muted); font-size: 11px; }
.tabs button.is-active { border-color: #3a4152; background: #1b1f29; color: #fff; }
#earn-history { padding: 0 18px; }
.earn-status { color: #7d8593; font-size: 11px; white-space: nowrap; }
.earn-status-confirmed, .earn-status-completed { color: var(--green); }
.earn-status-failed, .earn-status-expired { color: var(--red); }
.earn-status-pending, .earn-status-sent { color: #b9a675; }

/* On-chain activity and token information */
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.section-head h2 { margin: 7px 0 0; font-size: 25px; }
.pill { padding: 7px 9px; border: 1px solid var(--line-soft); border-radius: 999px; color: var(--muted); font-size: 10px; letter-spacing: .12em; white-space: nowrap; }
.pill[data-kind="ok"] { border-color: #24402c; color: var(--green); }
.pill[data-kind="error"] { border-color: #4d2326; color: var(--red); }
.model-price-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0; padding: 0; }
.model-price-card strong { display: block; margin-top: 4px; font-size: 22px; }
.tag-neutral { padding: 9px 12px; border: 1px solid #2c3140; border-radius: 999px; background: #1b1f29; color: #aab2c2; font-size: 11px; font-weight: 700; letter-spacing: .08em; white-space: nowrap; }
.activity-row { display: flex; justify-content: space-between; gap: 12px; padding: 16px 0; border-bottom: 1px solid #242833; }
.activity-row:last-child { border-bottom: 0; }
.activity-row b { font-size: 15px; }
.activity-row span { color: #7d8593; font-size: 13px; }
.activity .empty { padding: 14px 0; color: #7d8593; font-size: 13px; }
.activity-main { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.activity-main small { color: #727987; font-size: 11px; }
.amount-in { color: var(--green); }
.amount-out { color: var(--text); }
.app-footer { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 6px 2px 0; }
.footer-master { display: flex; flex-wrap: wrap; align-items: baseline; gap: 7px 10px; color: #727987; font-size: 11px; line-height: 1.6; }
.footer-master-label { width: 100%; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.footer-master code { color: #8d95a5; font: inherit; overflow-wrap: anywhere; }
.footer-master a { color: #c9a766; text-decoration: none; }
.footer-master a:hover { text-decoration: underline; }
.footer-version { padding-top: 10px; border-top: 1px solid var(--line); color: #747b89; font-size: 13px; text-align: center; white-space: nowrap; }
.toast { position: fixed; z-index: 50; bottom: 22px; left: 50%; max-width: min(440px, calc(100vw - 32px)); padding: 12px 16px; transform: translate(-50%, 16px); border: 1px solid #2f3543; border-radius: 12px; background: #1b1f29; color: #e9edf5; font-size: 13px; line-height: 1.4; box-shadow: 0 12px 30px #0007; opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }
.toast[data-kind="error"] { border-color: #4d2326; color: #f3b3b8; }
.toast[data-kind="success"] { border-color: #24402c; color: #a5ecba; }
.toast[data-kind="warning"] { border-color: #4a3a1c; color: var(--gold); }

/* Ecosystem navigation */
.brand-group { display: flex; min-width: 0; flex: 0 1 auto; align-items: center; gap: 12px; }
.menu-trigger, .menu-close { display: grid; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); background: #11131a; color: #d8dce5; cursor: pointer; }
.menu-trigger { width: 38px; height: 38px; border-radius: 12px; }
.menu-trigger:hover { border-color: #555d6d; background: #171a22; }
.menu-trigger svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.6; }
.menu-layer { position: fixed; z-index: 80; inset: 0; }
.menu-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #05060ab8; opacity: 0; transition: opacity .18s ease; }
.app-menu { position: absolute; top: 0; bottom: 0; left: 0; display: flex; width: min(84vw, 330px); flex-direction: column; padding: max(20px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom)); transform: translateX(-103%); border-right: 1px solid #303543; background: #101218; box-shadow: 20px 0 60px #0008; transition: transform .2s cubic-bezier(.2,.75,.2,1); touch-action: pan-y; }
.menu-layer.is-open .menu-backdrop { opacity: 1; }
.menu-layer.is-open .app-menu { transform: translateX(0); }
.menu-heading { display: flex; align-items: center; justify-content: space-between; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.menu-close { width: 32px; height: 32px; border-radius: 10px; font-size: 22px; line-height: 1; }
.menu-links { display: grid; gap: 6px; padding-top: 14px; }
.menu-links button { display: flex; flex-direction: column; gap: 4px; padding: 12px 13px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: #e7eaf0; text-align: left; cursor: pointer; }
.menu-links button span { font-size: 15px; font-weight: 700; }
.menu-links button small { color: #7f8796; font-size: 11px; }
.menu-links button:hover { background: #171a22; }
.menu-links button.is-active { border-color: #423923; background: #1b1812; color: #f0d9a5; }
.menu-links button.is-active small { color: #ab9a75; }
.menu-foot { margin-top: auto; padding-top: 15px; border-top: 1px solid var(--line); color: #777f8d; font-size: 10px; letter-spacing: .12em; }
.menu-foot span { padding: 0 5px; color: #bd9d5c; }

/* One rotating editorial feature on the Earn home */
.editorial-card { display: flex; min-height: 140px; flex-direction: column; justify-content: space-between; gap: 18px; margin: 0 0 16px; padding: 19px 21px 16px; border: 1px solid #3a3428; border-radius: 18px; background: radial-gradient(ellipse at 100% 0%, #252016 0%, #14151a 52%, #11131a 100%); }
.editorial-copy { max-width: 700px; }
.editorial-eyebrow, .content-eyebrow { color: #c7a764; font-size: 10px; font-weight: 800; letter-spacing: .15em; }
.editorial-card h2 { margin: 9px 0 6px; font-size: clamp(20px, 4vw, 27px); letter-spacing: -.035em; }
.editorial-card p { max-width: 640px; margin: 0; color: #9da4b1; font-size: 13px; line-height: 1.5; }
.editorial-meta { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.content-status { display: inline-flex; width: fit-content; padding: 5px 8px; border: 1px solid #574925; border-radius: 999px; color: #d8bd81; font-size: 9px; font-weight: 800; letter-spacing: .12em; white-space: nowrap; }
.editorial-link, .text-action { padding: 0; border: 0; background: none; color: #e2c27d; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-decoration: none; cursor: pointer; }
.editorial-link:hover, .text-action:hover { color: #fff1c9; }

/* Editorial and ecosystem screens */
.ecosystem-view { min-height: calc(100dvh - 100px); padding-bottom: 30px; }
.content-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; padding: 38px 0 20px; }
.content-header h1 { margin: 8px 0 6px; font-size: clamp(32px, 7vw, 52px); letter-spacing: -.055em; line-height: 1; }
.content-header p { max-width: 560px; margin: 0; font-size: 13px; }
.content-index { padding-bottom: 3px; color: #6f7785; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.content-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.content-card { min-width: 0; padding: 20px; border: 1px solid #252936; border-radius: 17px; background: linear-gradient(145deg, #14161d, #101218 72%); }
.content-card h2 { margin: 8px 0; font-size: 19px; letter-spacing: -.025em; line-height: 1.2; }
.content-copy { margin: 0; color: #9ba2b0; font-size: 13px; line-height: 1.55; }
.research-card, .news-card, .activity-card { display: flex; flex-direction: column; align-items: flex-start; }
.research-card .content-copy, .news-card .content-copy, .activity-card .content-copy { flex: 1; }
.research-detail { margin: 15px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.65; }
.research-card .text-action { margin-top: 18px; }
.analytics-card { padding: 18px 20px; }
.analytics-list { margin: 12px 0 0; }
.analytics-list > div { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; padding: 10px 0; border-bottom: 1px solid #242833; }
.analytics-list > div:last-child { border-bottom: 0; }
.analytics-list dt { color: #838b9a; font-size: 12px; }
.analytics-list dd { margin: 0; color: #e5e8ef; font-size: 13px; font-weight: 650; text-align: right; overflow-wrap: anywhere; }
.analytics-transactions { margin: 12px 0 0; padding: 0; list-style: none; }
.analytics-transactions li { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid #242833; color: #e5e8ef; font-size: 13px; }
.analytics-transactions li:last-child { border-bottom: 0; }
.analytics-transactions time { color: #838b9a; font-size: 12px; }
.master-card code { display: block; margin: 14px 0 16px; color: #c9ced8; font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.market-ticker { display: flex; align-items: center; gap: 18px; margin: 0 0 14px; padding: 11px 13px; overflow-x: auto; border: 1px solid #292d37; border-radius: 14px; background: #11131a; scrollbar-width: none; }
.market-ticker::-webkit-scrollbar { display: none; }
.ticker-label { color: #d8bd81; font-size: 9px; font-weight: 900; letter-spacing: .12em; }
.market-ticker.is-live .ticker-label { color: var(--green); }
.ticker-quote { display: flex; flex: 0 0 auto; align-items: center; gap: 6px; color: #9ca3af; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.ticker-quote b { color: #e6e9ef; }
.ticker-date { margin-left: auto; color: #6f7785; font-size: 9px; letter-spacing: .1em; white-space: nowrap; }
.news-filters { display: flex; grid-column: 1 / -1; flex-wrap: wrap; gap: 7px; }
.filter-chip { padding: 7px 11px; border: 1px solid #2a2e39; border-radius: 999px; background: transparent; color: #929aa8; font-size: 10px; font-weight: 700; cursor: pointer; }
.filter-chip:hover, .filter-chip.is-active { border-color: #54462b; background: #1b1812; color: #e7cc90; }
.news-meta, .content-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.category-badge, .format-badge, .phase-badge { display: inline-flex; padding: 5px 8px; border: 1px solid #303543; border-radius: 999px; color: #b4bac5; font-size: 9px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.format-badge { color: #858d9b; }
.news-date { color: #717989; font-size: 9px; letter-spacing: .08em; }
.news-card .text-action { margin-top: 18px; }
.about-lead { grid-column: 1 / -1; padding: 24px; border-color: #3a3428; background: radial-gradient(ellipse at 100% 0%, #211d14 0%, #11131a 62%); }
.about-lead h2 { max-width: 640px; font-size: clamp(24px, 5vw, 34px); }
.roadmap-card, .creators-card, .master-card { grid-column: 1 / -1; }
.roadmap-row { display: grid; grid-template-columns: 98px minmax(0, 1fr) auto; align-items: center; gap: 13px; padding: 13px 0; border-top: 1px solid #242833; }
.roadmap-row:first-of-type { margin-top: 12px; }
.roadmap-row h3 { margin: 0 0 3px; font-size: 13px; }
.roadmap-row p { margin: 0; color: #87909e; font-size: 11px; line-height: 1.4; }
.phase-badge { color: #cbb16f; white-space: nowrap; }
.empty-card { grid-column: 1 / -1; }
.empty-card .content-copy { color: #858d9b; }

@media (max-width: 700px) {
  .shell { width: min(100% - 32px, 980px); padding-top: 14px; }
  .top { flex-wrap: nowrap; gap: 8px; }
  .brand-group { gap: 8px; }
  .brand { gap: 8px; }
  .wallet-connect { flex: 1 1 auto; }
  #ton-connect { max-width: 100%; }
  .hero { padding: 26px 0 14px; }
  .hero h1 { margin: 8px 0 10px; font-size: clamp(38px, 12vw, 56px); }
  .portfolio-card { padding: 8px 12px 4px; }
  .earn-actions-card { padding: 4px 12px 14px; }
  .balance-pane { padding: 16px 5px 18px; }
  .big { font-size: clamp(27px, 8vw, 34px); }
  .earn-metrics { gap: 11px 10px; }
  .earn-metrics span { font-size: 9px; letter-spacing: .06em; }
  .earn-metrics b { font-size: 12px; }
  .earn-panel { padding: 10px 5px 16px; }
  .earn-history-head { padding: 14px 5px 0; }
  #earn-history { padding: 0 5px; }
  .app-footer { align-items: stretch; }
  .footer-version { white-space: normal; }
  .content-header { padding: 30px 0 17px; }
  .content-grid { gap: 9px; }
  .content-card { padding: 16px; }
  .editorial-card { padding: 17px 16px 15px; }
  .market-ticker { gap: 13px; }
}
@media (max-width: 380px) {
  .shell { width: min(100% - 24px, 980px); }
  .brand b { font-size: 18px; }
  .brand small { font-size: 8px; letter-spacing: .1em; }
  .wallet-connect { margin-left: -18px; transform: scale(.9); transform-origin: right center; }
}
@media (max-width: 640px) {
  .balance-pair, .earn-panels { grid-template-columns: 1fr; }
  .content-grid { grid-template-columns: minmax(0, 1fr); }
  .about-lead, .roadmap-card, .creators-card, .master-card { grid-column: auto; }
  .roadmap-row { grid-template-columns: 82px minmax(0, 1fr); gap: 8px; }
  .roadmap-row .content-status { grid-column: 2; }
  .news-filters, .empty-card { grid-column: auto; }
  .content-index { align-self: flex-start; padding-top: 5px; }
  .earn-pane { border-top: 1px solid #302b20; border-left: 0; }
  .earn-panel + .earn-panel { padding-top: 18px; border-top: 1px solid var(--line); border-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
  .hero h1 span { animation: none; }
  .logo { animation: none; }
  .logo::after { visibility: hidden; }
  .menu-backdrop, .app-menu { transition: none; }
}
