:root {
  color-scheme: dark;
  --bg: #0b0c13;
  --panel: #13141e;
  --line: #ffffff16;
  --ink: #f8f7fe;
  --muted: #aaa9bf;
  --violet: #c9bbff;
  --green: #a5dfc4;
  --gold: #f4d291;
  --gutter: clamp(18px, 4vw, 40px);
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(ellipse 760px 410px at 77% 0%, #171526 0%, transparent 78%), var(--bg); }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button, input, textarea, select { font: inherit; }
a { color: inherit; text-decoration: none; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button, a { touch-action: manipulation; }
:focus-visible { outline: 2px solid #c5b1ff; outline-offset: 3px; }
button { border: 0; background: none; }
h1, h2, h3, p { margin: 0; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
svg { flex: none; vertical-align: middle; }

.topbar { position: sticky; z-index: 10; top: 0; padding: var(--safe-top) var(--gutter) 0; background: #0b0c13e8; border-bottom: 1px solid #ffffff0c; backdrop-filter: blur(20px); }
.top-inner { height: 71px; max-width: 1080px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wordmark, .header-actions { display: flex; align-items: center; gap: 11px; }
.wordmark strong { display: block; font-size: 18px; font-weight: 730; line-height: 1.06; letter-spacing: .14em; }
.wordmark small { display: block; margin-top: 5px; color: #afabc6; font-size: 9px; letter-spacing: .28em; font-weight: 650; }
.balance-pill { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 12px; border: 1px solid #c5b2ff2e; border-radius: 100px; background: #bc9dff12; font-size: 13px; font-weight: 720; }
.balance-pill svg, .coin { color: #c9b5ff; }
.balance-pill em { color: #b5a6d5; font-style: normal; font-size: 11px; font-weight: 650; }
.demo-tag { display: inline-flex; align-items: center; gap: 5px; color: #cdc1f6; border: 1px solid #bdabfb23; padding: 5px 8px; border-radius: 7px; font-size: 10px; font-weight: 700; letter-spacing: .065em; text-transform: uppercase; white-space: nowrap; }
.demo-tag::before, .eyebrow::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: #b7a5ff; box-shadow: 0 0 9px #aa8fff; }
.view { max-width: 1160px; min-height: 68vh; margin: 0 auto; padding: 26px var(--gutter) calc(111px + var(--safe-bottom)); }
.skeleton { min-height: 320px; display: grid; place-items: center; color: var(--muted); letter-spacing: .16em; }
.hero { position: relative; isolation: isolate; overflow: hidden; min-height: 305px; border: 1px solid #a896d637; border-radius: 30px; display: flex; align-items: center; padding: 35px 43px; background: radial-gradient(ellipse 70% 100% at 88% 70%, #2b1c50, transparent 82%), linear-gradient(118deg,#19192b,#131321 53%,#211a38); box-shadow: 0 16px 45px #0605105e, inset 0 1px #ffffff0b; }
.hero::after { content: ''; position: absolute; z-index: -1; inset: 0; background: linear-gradient(90deg,#19192a 5%,#19192a00 61%); }
.hero-art { position: absolute; z-index: -2; right: -10px; width: 61%; height: auto; top: 50%; transform: translateY(-49%); pointer-events: none; }
.hero-content { width: min(100%, 500px); }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; border: 1px solid #baa6f334; border-radius: 100px; padding: 7px 10px; background: #241e38c9; color: #ded2ff; font-size: 10px; letter-spacing: .15em; font-weight: 730; text-transform: uppercase; }
.hero h1 { margin-top: 13px; font-size: clamp(34px, 5.2vw, 59px); font-weight: 690; letter-spacing: -.069em; line-height: 1.01; }
.hero h1 span { color: #cdbdff; display: block; }
.hero p { margin: 12px 0 20px; color: #d0c9e2; font-size: 14px; line-height: 1.5; max-width: 310px; }
.primary, .secondary, .icon-button, .link-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; }
.primary, .secondary { border-radius: 14px; min-height: 46px; padding: 0 15px; line-height: 1.2; font-size: 14px; }
.primary { color: #1b1233; background: linear-gradient(110deg,#e3d6ff,#bda9ff 82%); box-shadow: inset 0 1px #ffffff7a, 0 5px 21px #a77bff26; border: 1px solid #d4c4ff; }
.primary:hover:not(:disabled) { background: #e9dfff; }
.primary:disabled { opacity: .49; box-shadow: none; }
.secondary { background: #fff1; border: 1px solid #fff2; color: var(--ink); }
.secondary:disabled { opacity: .52; }
.link-button { min-height: 42px; padding: 4px 2px; color: var(--violet); font-size: 13px; }
.icon-button { border: 1px solid var(--line); border-radius: 13px; width: 42px; height: 42px; padding: 0; color: #cec8e5; background: #fff1; }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: center; gap: 14px; justify-content: space-between; margin-bottom: 11px; }
.section-head h2 { font-size: clamp(22px, 3.2vw, 27px); line-height: 1.13; letter-spacing: -.043em; font-weight: 690; }
.section-head p { margin-top: 5px; font-size: 13px; color: var(--muted); }
.tools-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.tool { position: relative; text-align: left; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; min-height: 125px; padding: 15px 16px; border: 1px solid var(--line); border-radius: 20px; background: radial-gradient(ellipse at 0 0,var(--glow),transparent 89%), #14151f; box-shadow: inset 0 1px #ffffff08; }
.tool:is(:hover,:focus-visible), .row:is(:hover,:focus-visible) { border-color: #c8b6fd63; }
.tool-arrow { position: absolute; right: 13px; top: 16px; color: #8886a3; }
.tone-image { --tone: #d9c9ff; --tone-bg: #4c366d; --glow: #c09cff23; }
.tone-video { --tone: #b6d8ff; --tone-bg: #233b59; --glow: #6b9af524; }
.tone-audio { --tone: #ffcee8; --tone-bg: #572e4f; --glow: #ec79c520; }
.tone-text { --tone: #bdf2dc; --tone-bg: #23443e; --glow: #64c6aa1c; }
.tile-icon { display: inline-grid; flex: none; place-items: center; width: 43px; height: 43px; border-radius: 13px; color: var(--tone,var(--violet)); background: linear-gradient(145deg,var(--tone-bg,#34284d),#151421); border: 1px solid #ffffff19; box-shadow: inset 0 1px #ffffff15; }
.tool b { display: block; font-weight: 690; letter-spacing: -.02em; font-size: 17px; line-height: 1.08; }
.tool small { display: block; color: #b5b4ca; margin-top: 5px; font-size: 12px; line-height: 1.35; }
.featured-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.panel, .row, .notice, .empty { border-radius: 18px; border: 1px solid var(--line); background: var(--panel); }
.row { width: 100%; text-align: left; display: flex; align-items: center; gap: 11px; padding: 12px; min-height: 64px; }
.row .tile-icon { width: 37px; height: 37px; border-radius: 11px; }
.row-main { flex: 1; min-width: 0; }
.row strong { font-size: 14px; letter-spacing: -.018em; line-height: 1.3; display: block; }
.row small { color: var(--muted); line-height: 1.35; font-size: 12px; display: block; margin-top: 3px; }
.row > svg:last-child { color: #928aaa; }
.stack { display: grid; gap: 8px; }
.notice { padding: 13px 14px; margin-bottom: 15px; display: flex; align-items: flex-start; gap: 10px; color: #d4caec; font-size: 13px; line-height: 1.5; background: #1d1930; border-color: #a786f232; }
.notice svg { color: var(--violet); margin-top: 1px; }
.notice a { text-decoration: underline; text-underline-offset: 3px; }
.empty { padding: 35px 20px; text-align: center; display: grid; justify-items: center; gap: 10px; color: var(--muted); }
.empty strong { color: var(--ink); font-size: 18px; }
.empty .primary { margin-top: 5px; }
.empty p { font-size: 14px; line-height: 1.5; }
.tabbar { position: fixed; z-index: 15; bottom: calc(13px + var(--safe-bottom)); left: 50%; transform: translateX(-50%); width: min(440px, calc(100% - 28px)); display: grid; grid-template-columns: repeat(4,1fr); gap: 4px; padding: 6px; background: #171723ed; border: 1px solid #bfb1eb27; border-radius: 22px; box-shadow: 0 9px 30px #030309b0; backdrop-filter: blur(22px); }
.tabbar button { min-width: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; min-height: 50px; border-radius: 15px; padding: 3px; font-size: 11px; color: #b2aec7; font-weight: 650; }
.tabbar button[aria-current="page"] { color: #edddff; background: #b794f82b; }
.tabbar button svg { width: 20px; height: 20px; }
.toast { position: fixed; z-index: 25; max-width: min(450px,calc(100% - 28px)); width: max-content; padding: 12px 15px; bottom: calc(91px + var(--safe-bottom)); left: 50%; transform: translateX(-50%); border: 1px solid #d5bcff55; border-radius: 14px; background: #28223c; box-shadow: 0 8px 30px #0007; font-size: 14px; line-height: 1.4; }
.page-head { margin: 2px 0 19px; }
.page-head h1 { margin-top: 4px; font-size: clamp(31px, 5vw, 45px); font-weight: 690; letter-spacing: -.058em; }
.page-head p { margin-top: 5px; line-height: 1.5; font-size: 14px; color: var(--muted); }
.kicker { color: #c2b0fa; text-transform: uppercase; font-size: 10px; letter-spacing: .16em; font-weight: 750; }
.compose { display: grid; grid-template-columns: minmax(0,1.24fr) minmax(0,1fr); align-items: start; gap: 15px; }
.compose > div { min-width: 0; }
.composer-panel { padding: 16px; display: grid; gap: 16px; }
.panel-title { font-size: 15px; font-weight: 720; display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.panel-title svg { color: var(--violet); }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chips.mode-tabs { margin-bottom: 14px; }
.chip { min-height: 38px; border: 1px solid #ffffff19; border-radius: 11px; background: #ffffff08; padding: 5px 11px; font-size: 13px; font-weight: 660; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.chip[aria-pressed="true"] { background: #bda1ff28; border-color: #b397f965; color: #f0e4ff; }
.chip:disabled { opacity: .38; }
.field { display: grid; gap: 7px; min-width: 0; }
.field label, .field-title { font-size: 13px; color: #d6d1e5; font-weight: 660; }
.field small { font-size: 12px; color: var(--muted); line-height: 1.35; }
textarea, input[type="search"], select { width: 100%; border: 1px solid var(--line); background: #0d0e17; border-radius: 13px; color: var(--ink); padding: 11px 12px; font-size: 16px; }
textarea::placeholder, input::placeholder { color: #8e8ba5; opacity: 1; }
textarea { min-height: 144px; resize: vertical; line-height: 1.45; }
select { height: 45px; }
.file-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); background: #ffffff09; border-radius: 10px; padding: 4px 7px 4px 10px; }
.file-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .icon-button { width: 34px; height: 34px; }
.attach { min-height: 49px; border: 1px dashed #bba5ef57; border-radius: 12px; text-align: left; display: flex; gap: 9px; align-items: center; padding: 8px 11px; background: #bba5ef0a; color: #e0d4fa; font-size: 13px; }
.review { padding: 16px; background: radial-gradient(ellipse at 100% 0,#2e2250,transparent 81%), #171626; border-color: #baa3ff35; }
.review .primary { margin-top: 10px; width: 100%; }
.review-line { display: flex; justify-content: space-between; gap: 10px; align-items: center; font-size: 14px; font-weight: 650; }
.review-line strong { color: #e5d9ff; font-size: 20px; }
.review p { font-size: 12px; color: #c6badd; line-height: 1.45; margin-top: 5px; }
.review p.error { color: #ffd2d2; }
.page-grid { display: grid; gap: 12px; grid-template-columns: minmax(0,1.1fr) minmax(0,1fr); align-items: start; }
.wallet-hero { padding: 23px; background: radial-gradient(ellipse at 100% 0,#392b64,transparent 80%), #1b182d; border-color: #bda4f346; }
.wallet-hero .balance-value { margin: 9px 0 1px; color: #f5edff; font-size: 44px; font-weight: 720; letter-spacing: -.06em; }
.wallet-hero p { color: #c9beda; font-size: 14px; }
.pack-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.pack { display: grid; gap: 9px; padding: 14px; min-width: 0; }
.pack.featured { background: linear-gradient(135deg,#27203e,#161623); border-color: #a88cee69; }
.pack b { font-size: 15px; }
.pack .pack-amount { font-size: 24px; line-height: 1; letter-spacing: -.05em; font-weight: 730; }
.pack .pack-amount small { font-size: 11px; color: #beb6d0; letter-spacing: 0; font-weight: 580; }
.pack .secondary { width: 100%; }
.pack svg { color: var(--gold); }
.pack-note { font-size: 13px; margin-top: 10px; }
.muted { color: var(--muted); }
.ledger { font-size: 13px; color: var(--muted); }
.job-tag { align-self: center; padding: 5px 8px; border-radius: 8px; background: #bba2ff1f; color: #e1d2fb; white-space: nowrap; font-size: 11px; font-weight: 660; }
.job-tag.is-done { background: #89e1b219; color: var(--green); }
.job-tag.is-failed { background: #ffc1c217; color: #f8b3b7; }
.job-actions { padding: 0 12px 10px; display: flex; flex-wrap: wrap; gap: 5px 12px; }
.job-actions .link-button { min-height: 37px; }
.job-panel .row { background: none; border: 0; }
.avatar { display: grid; place-items: center; width: 54px; height: 54px; border: 1px solid #ad94ef5c; border-radius: 18px; background: linear-gradient(140deg,#514170,#28223c); color: #f4eaff; font-size: 24px; font-weight: 700; }
.profile-card { padding: 15px; display: flex; gap: 13px; align-items: center; }
.profile-card h2 { font-size: 20px; letter-spacing: -.03em; overflow-wrap: anywhere; }
.profile-card p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.padded { padding: 15px; }
.detail-copy { color: #cec6e2; font-size: 14px; line-height: 1.6; white-space: pre-line; }
.sheet { color: var(--ink); width: min(540px,calc(100% - 30px)); max-height: min(80dvh, 720px); overflow: auto; padding: 17px; border: 1px solid #bfa7ef44; background: #171724; border-radius: 24px; box-shadow: 0 16px 60px #0009; }
.sheet::backdrop { background: #060610ad; backdrop-filter: blur(5px); }
.sheet header { position: sticky; top: -17px; margin-top: -6px; padding: 6px 0 10px; display: flex; justify-content: space-between; align-items: center; gap: 9px; z-index: 1; background: #171724; }
.sheet h2 { font-size: 22px; letter-spacing: -.04em; }
.sheet .search-box { margin: 2px 0 9px; }
.sheet .model-list { margin-top: 10px; }
.sheet .row[aria-current="true"] { border-color: #bf9bff7a; }
.sheet .result-media { display: block; width: 100%; max-height: 55dvh; object-fit: contain; border-radius: 12px; }
.sheet pre.result-media { overflow: auto; padding: 12px; white-space: pre-wrap; background: #0d0e17; overflow-wrap: anywhere; }
.sheet-footer { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .65s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .tools-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
  .compose, .page-grid { grid-template-columns: minmax(0,1fr); gap: 10px; }
  .hero { min-height: 272px; padding: 23px 23px; }
  .hero h1 { font-size: clamp(34px,7.2vw,48px); }
  .hero-art { width: 75%; right: -22px; }
  .tool { min-height: 106px; gap: 9px; padding: 12px; border-radius: 16px; }
  .tool .tile-icon { width: 35px; height: 35px; border-radius: 11px; }
  .tool .tile-icon svg { width: 19px; height: 19px; }
  .tool b { font-size: 16px; }
  .view { padding-top: 15px; }
  .top-inner { height: 61px; }
  body[data-page="compose"] .tabbar { display: none; }
  body[data-page="compose"] .view { padding-bottom: calc(172px + var(--safe-bottom)); }
  #review { position: fixed; z-index: 11; bottom: calc(10px + var(--safe-bottom)); left: var(--gutter); right: var(--gutter); padding: 11px 14px; box-shadow: 0 5px 25px #000a; }
  #review .primary { margin-top: 7px; }
}
@media (max-width: 480px) {
  .view { padding-top: 12px; }
  .hero { border-radius: 23px; min-height: 216px; padding: 14px 16px; }
  .hero-art { width: 86%; right: -56px; transform: translateY(-38%); opacity: .91; }
  .hero::after { background: linear-gradient(90deg,#19192afa 3%,#19192abd 35%,#19192a00 100%); }
  .hero h1 { font-size: clamp(31px,8.2vw,39px); margin-top: 10px; }
  .hero p { max-width: 225px; font-size: 13px; margin: 7px 0 10px; }
  .hero .primary { min-height: 42px; }
  .hero .eyebrow { font-size: 8.5px; padding: 6px 8px; }
  .section { margin-top: 13px; }
  .section-head { margin-bottom: 7px; }
  .featured-grid { grid-template-columns: 1fr; }
  .tool { min-height: 91px; gap: 7px; padding: 10px 11px; }
  .pack-grid { grid-template-columns: 1fr; gap: 7px; }
  .pack { grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 5px 8px; padding: 12px; }
  .pack .pack-amount { grid-column: 1; font-size: 21px; }
  .pack .secondary { grid-column: 2; grid-row: 1 / span 2; width: auto; }
  .sheet { margin: auto auto 0; padding-bottom: calc(15px + var(--safe-bottom)); width: 100%; max-width: 100%; border-radius: 24px 24px 0 0; max-height: 85dvh; }
}
@media (max-width: 359px) {
  .header-actions { gap: 6px; }
  .wordmark { gap: 8px; }
  .balance-pill { padding: 0 8px; }
  .balance-pill em { display: none; }
  .tool small { font-size: 11px; }
  .mode-tabs .chip { padding-inline: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; scroll-behavior: auto !important; }
}
