:root {
  color-scheme: dark;
  --bg: #0b0e0d;
  --panel: #111514;
  --panel-2: #171c1a;
  --panel-3: #1e2421;
  --border: #29312e;
  --border-soft: #202724;
  --text: #f3f6f4;
  --muted: #8e9b96;
  --accent: #90e4bc;
  --accent-strong: #b5f2d2;
  --accent-ink: #082619;
  --danger: #ff8d8d;
  --user: #dff7e9;
  --user-ink: #10231a;
  --shadow: 0 18px 60px rgba(0, 0, 0, .38);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; width: 100%; height: 100%; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
button, textarea, input { font: inherit; }
button { color: inherit; }

.app-shell { display: grid; grid-template-columns: 286px minmax(0, 1fr); width: 100%; height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.sidebar { display: flex; flex-direction: column; min-width: 0; padding: 22px 18px 18px; background: #0d1110; border-right: 1px solid var(--border-soft); z-index: 20; }
.brand-row { display: flex; align-items: center; gap: 12px; padding: 0 4px 24px; }
.brand-mark { width: 54px; height: 54px; border-radius: 17px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 850; font-size: 26px; letter-spacing: -1px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.brand-mark.small { width: 40px; height: 40px; border-radius: 12px; font-size: 19px; }
.brand-name { font-weight: 760; font-size: 17px; letter-spacing: -.2px; }
.brand-caption, .topbar-title span { display: flex; align-items: center; gap: 6px; margin-top: 3px; color: var(--muted); font-size: 12px; }
.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgba(144,228,188,.6); }
.icon-button { border: 0; background: transparent; color: var(--muted); border-radius: 10px; cursor: pointer; font-size: 21px; line-height: 1; padding: 9px; }
.icon-button:hover { background: var(--panel-2); color: var(--text); }
.sidebar-close, .menu-button { display: none; }
.sidebar-close { margin-left: auto; }

.new-chat-button { width: 100%; display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 46px; border: 1px solid #46735e; background: #17241e; color: var(--accent-strong); border-radius: 13px; font-weight: 680; cursor: pointer; }
.new-chat-button:hover { background: #1b2d25; border-color: #639d80; }
.button-icon { font-size: 21px; font-weight: 300; }
.sidebar-section { margin-top: 28px; }
.sidebar-label, .eyebrow, .balance-label { color: #63706b; font-size: 10px; font-weight: 760; letter-spacing: 1.4px; margin: 0 0 8px 10px; }
.nav-item { width: 100%; display: flex; gap: 11px; align-items: center; border: 0; background: transparent; color: #aab4b0; border-radius: 11px; padding: 11px 12px; cursor: pointer; text-align: left; }
.nav-item:hover, .nav-item.active { color: var(--text); background: var(--panel-2); }
.nav-item.active { box-shadow: inset 2px 0 var(--accent); }
.memory-note { margin: 24px 4px 0; padding: 14px 14px 13px; background: #111715; border: 1px solid var(--border-soft); border-radius: 12px; }
.memory-note-title { color: #c9d2ce; font-size: 12px; font-weight: 700; }
.memory-note p { margin: 6px 0 0; color: #73807b; font-size: 11px; line-height: 1.55; }
.sidebar-spacer { flex: 1; min-height: 20px; }
.balance-card { display: flex; justify-content: space-between; align-items: center; width: 100%; border: 1px solid #385b4b; border-radius: 14px; padding: 13px 14px; background: #132019; cursor: pointer; text-align: left; }
.balance-card:hover { border-color: #56866f; }
.balance-card strong { display: block; margin-top: 4px; font-size: 19px; }
.balance-label { margin: 0; color: #799487; }
.balance-plus { color: var(--accent); font-size: 23px; }
.crystal { color: var(--accent); }
.user-row { display: flex; align-items: center; gap: 10px; padding: 16px 4px 0; }
.avatar { width: 35px; height: 35px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; background: #28332e; color: var(--accent); font-weight: 750; }
.user-copy { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 2px; }
.user-copy strong, .user-copy span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-copy strong { font-size: 13px; }
.user-copy span { color: var(--muted); font-size: 11px; }

.chat-panel { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg); }
.topbar { min-height: 68px; display: flex; align-items: center; gap: 12px; padding: 0 26px; border-bottom: 1px solid var(--border-soft); background: rgba(11,14,13,.93); }
.topbar-title { display: flex; flex-direction: column; }
.topbar-title strong { font-size: 15px; }
.topbar-balance { margin-left: auto; display: flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--panel); border-radius: 12px; padding: 8px 11px; cursor: pointer; font-weight: 700; }
.topbar-balance:hover { border-color: #4a6659; }
.topbar-plus { color: var(--muted); }

.messages { min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 34px max(24px, calc((100% - 820px) / 2)) 28px; scroll-behavior: smooth; }
.empty-state { max-width: 620px; margin: max(7vh, 48px) auto 0; text-align: center; }
.hero-mark { width: 74px; height: 74px; margin: 0 auto 22px; display: grid; place-items: center; border: 1px solid #47725d; border-radius: 24px; background: #15241d; color: var(--accent); font-weight: 850; font-size: 34px; box-shadow: 0 18px 50px rgba(0,0,0,.25); }
.empty-state h1 { margin: 0; font-size: clamp(30px, 4vw, 44px); letter-spacing: -1.5px; }
.empty-state > p { max-width: 480px; margin: 14px auto 0; color: var(--muted); line-height: 1.6; font-size: 14px; }
.suggestions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 34px; }
.suggestions button { min-height: 70px; border: 1px solid var(--border); background: var(--panel); border-radius: 14px; color: #bac4c0; cursor: pointer; padding: 12px; }
.suggestions button:hover { border-color: #4f6c5e; color: var(--text); background: var(--panel-2); }

.message-row { display: flex; width: 100%; margin: 0 auto 24px; animation: messageIn .22s ease-out; }
.message-row.user { justify-content: flex-end; }
.message-bubble { max-width: min(82%, 680px); font-size: 15px; line-height: 1.64; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-row.user .message-bubble { color: var(--user-ink); background: var(--user); border-radius: 17px 17px 5px 17px; padding: 11px 15px; }
.message-row.assistant .message-bubble { color: #dfe5e2; padding: 2px 0; }
.message-label { display: block; margin-bottom: 7px; color: var(--accent); font-size: 11px; font-weight: 760; letter-spacing: .8px; }
.message-meta { display: block; margin-top: 8px; color: #64716c; font-size: 10px; }
.typing { display: flex; align-items: center; gap: 5px; min-height: 28px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: #76827d; animation: typing 1.1s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
.queue-status { min-height: 28px; display: flex; align-items: center; color: #7f8d87; font-size: 12px; }
.continue-button { display: inline-flex; margin-top: 12px; border: 1px solid #406b56; border-radius: 10px; background: #15251d; color: var(--accent); padding: 8px 11px; cursor: pointer; }

.composer-wrap { position: relative; z-index: 2; width: 100%; flex: 0 0 auto; padding: 8px max(20px, calc((100% - 860px) / 2)) 16px; background: var(--bg); }
.composer-toolbar { display: flex; align-items: center; justify-content: flex-start; padding: 0 8px 8px; color: #6f7b76; font-size: 12px; font-weight: 400; }
.composer { min-height: 58px; display: flex; align-items: flex-end; gap: 9px; padding: 9px; border: 1px solid #333c38; background: var(--panel); border-radius: 18px; box-shadow: 0 16px 40px rgba(0,0,0,.18); }
.composer:focus-within { border-color: #517a66; box-shadow: 0 0 0 3px rgba(144,228,188,.06), 0 16px 40px rgba(0,0,0,.18); }
.attach-button, .send-button { width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; cursor: pointer; }
.attach-button { color: #9aa7a2; font-size: 25px; }
.attach-button:hover { background: var(--panel-3); color: var(--text); }
.send-button { border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 21px; }
.send-button:hover { background: var(--accent-strong); }
.send-button:disabled { background: #37413d; color: #76807c; cursor: default; }
.composer textarea { flex: 1; min-width: 0; max-height: 170px; resize: none; border: 0; outline: 0; background: transparent; color: var(--text); padding: 10px 4px 8px; line-height: 1.45; }
.composer textarea::placeholder { color: #65706c; }
.composer-meta { display: flex; justify-content: space-between; color: #5f6a66; font-size: 10px; padding: 7px 8px 0; }
.file-chip { width: fit-content; max-width: 100%; display: flex; align-items: center; gap: 9px; margin: 0 0 7px 8px; border: 1px solid #385548; background: #132019; border-radius: 11px; padding: 7px 9px; color: #c9d5d0; font-size: 12px; }
.file-type { color: var(--accent); font-size: 9px; font-weight: 800; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip button { border: 0; background: transparent; color: #80908a; cursor: pointer; }
.hidden { display: none !important; }

.modal { width: min(620px, calc(100% - 28px)); color: var(--text); background: #121615; border: 1px solid var(--border); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); }
.modal.narrow { max-width: 470px; }
.modal::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(5px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.modal-head .eyebrow { margin: 0 0 7px; }
.modal h2 { margin: 0; font-size: 25px; letter-spacing: -.6px; }
.modal-description, .privacy-copy { color: var(--muted); font-size: 13px; line-height: 1.6; }
.package-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 20px; }
.package-card { position: relative; display: flex; flex-direction: column; align-items: flex-start; min-height: 116px; border: 1px solid var(--border); border-radius: 15px; background: var(--panel-2); padding: 16px; cursor: pointer; }
.package-card:hover { border-color: #59826e; transform: translateY(-1px); }
.package-card:disabled { cursor: default; opacity: .68; transform: none; }
.package-card strong { font-size: 19px; }
.package-card .package-price { margin-top: auto; color: var(--accent); font-weight: 760; }
.package-card .package-saving { position: absolute; top: 12px; right: 12px; color: #8fa39a; font-size: 10px; }
.payment-note { margin: 16px 0 0; color: #69756f; font-size: 11px; line-height: 1.5; }
.payment-note a { color: #8fa99c; }
.danger-button, .secondary-button, .primary-button { min-height: 43px; border-radius: 12px; padding: 0 16px; cursor: pointer; font-weight: 700; }
.danger-button { border: 1px solid #704545; color: #ffaaaa; background: #241717; }
.danger-button:hover { border-color: #a65e5e; }
.secondary-button { border: 1px solid var(--border); background: var(--panel-2); color: #cbd2cf; }
.primary-button { width: 100%; border: 0; background: var(--accent); color: var(--accent-ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.toast-region { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 9px; z-index: 100; }
.toast { max-width: 340px; border: 1px solid #3a4a43; background: #17201c; border-radius: 12px; padding: 11px 14px; box-shadow: var(--shadow); color: #dce4e0; font-size: 13px; animation: messageIn .2s ease-out; }
.toast.error { border-color: #704545; background: #241717; color: #ffb4b4; }
.public-page-body { min-height: 100%; overflow-x: hidden; overflow-y: auto; background: var(--bg); }
.public-topbar { position: sticky; top: 0; z-index: 30; min-height: 72px; display: flex; align-items: center; gap: 28px; padding: 12px max(22px, calc((100% - 1120px) / 2)); border-bottom: 1px solid rgba(41,49,46,.8); background: rgba(11,14,13,.92); backdrop-filter: blur(16px); }
.public-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 18px; }
.public-nav { display: flex; align-items: center; justify-content: center; gap: 26px; margin-left: auto; }
.public-nav a, .public-footer a { color: #9ba7a2; text-decoration: none; }
.public-nav a { font-size: 13px; }
.public-nav a:hover, .public-footer a:hover { color: var(--accent); }
.public-login-link { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; border: 1px solid #456d5a; border-radius: 11px; padding: 0 17px; color: var(--accent-strong); text-decoration: none; font-weight: 700; }
.public-login-link:hover { background: #17241e; }
.public-site { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }
.public-hero { display: flex; min-height: min(720px, calc(100dvh - 72px)); flex-direction: column; align-items: center; justify-content: center; padding: 84px 0 92px; text-align: center; }
.public-eyebrow { margin: 0 0 16px; color: #6f857a; font-size: 11px; font-weight: 800; letter-spacing: 2px; }
.public-hero h1 { max-width: 920px; margin: 0; font-size: clamp(42px, 7vw, 78px); line-height: 1.02; letter-spacing: clamp(-3.2px, -.06em, -1.8px); text-wrap: balance; }
.public-hero-copy { max-width: 720px; margin: 28px auto 0; color: #aab5b0; font-size: clamp(17px, 2vw, 21px); line-height: 1.65; text-wrap: balance; }
.public-accent-copy { margin: 20px 0 0; color: var(--accent); font-size: 16px; font-weight: 760; }
.public-actions { display: flex; justify-content: center; gap: 12px; margin-top: 34px; }
.public-primary, .public-secondary { display: inline-flex; min-height: 50px; align-items: center; justify-content: center; border-radius: 13px; padding: 0 22px; text-decoration: none; font-weight: 750; }
.public-primary { background: var(--accent); color: var(--accent-ink); }
.public-primary:hover { background: var(--accent-strong); }
.public-secondary { border: 1px solid var(--border); background: var(--panel); color: #cbd4d0; }
.public-secondary:hover { border-color: #4b695b; background: var(--panel-2); }
.welcome-bonus { margin: 20px 0 0; color: #78857f; font-size: 13px; }
.welcome-bonus strong { color: #a9bbb2; }
.public-section { padding: 90px 0; border-top: 1px solid var(--border-soft); scroll-margin-top: 72px; }
.public-section-heading { max-width: 680px; margin-bottom: 38px; }
.public-section-heading h2, .service-section h2, .public-login-section h2 { margin: 0; font-size: clamp(30px, 4vw, 48px); line-height: 1.13; letter-spacing: -1.8px; text-wrap: balance; }
.public-section-heading > p:last-child { margin: 16px 0 0; color: var(--muted); font-size: 16px; line-height: 1.65; }
.public-section-heading > p strong { color: var(--text); }
.feature-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.feature-grid article, .steps-grid article { border: 1px solid var(--border); border-radius: 18px; background: linear-gradient(145deg, #111715, #101412); padding: 26px; }
.feature-grid article > span { color: #62736b; font-size: 11px; font-weight: 800; letter-spacing: 1.3px; }
.feature-grid h3, .steps-grid h3 { margin: 18px 0 9px; font-size: 19px; }
.feature-grid p, .steps-grid p, .service-copy p { margin: 0; color: var(--muted); line-height: 1.7; }
.steps-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.steps-grid article > strong { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 12px; background: #17241e; color: var(--accent); }
.public-price-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.public-price-grid article { display: flex; min-height: 130px; flex-direction: column; justify-content: space-between; border: 1px solid var(--border); border-radius: 17px; background: var(--panel); padding: 22px; }
.public-price-grid article.featured { border-color: #4d765f; background: #142019; }
.public-price-grid strong { font-size: 16px; }
.public-price-grid span { color: var(--accent); font-size: 25px; font-weight: 800; }
.public-section-note { margin: 20px 0 0; color: #78847f; font-size: 13px; line-height: 1.65; }
.service-section { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 70px; align-items: start; }
.service-copy { display: grid; gap: 18px; }
.service-copy a { color: var(--accent); }
.public-login-section { margin: 90px 0; border: 1px solid #3c5e4e; border-radius: 28px; background: radial-gradient(circle at top, #1b2b23 0, #121715 52%, #101412 100%); padding: clamp(38px, 7vw, 76px); text-align: center; }
.public-login-section .brand-mark { margin: 0 auto 24px; }
.public-login-section > p:not(.public-eyebrow) { max-width: 520px; margin: 18px auto 0; color: var(--muted); line-height: 1.65; }
.telegram-login-widget { min-height: 54px; display: flex; align-items: center; justify-content: center; margin-top: 28px; }
.public-footer { width: min(1120px, calc(100% - 40px)); display: grid; grid-template-columns: .9fr 1fr 1.2fr; gap: 36px; margin: 0 auto; border-top: 1px solid var(--border-soft); padding: 42px 0 54px; color: #74817b; font-size: 12px; }
.public-footer p { margin: 8px 0 0; line-height: 1.6; }
.public-footer-links, .public-footer-details { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; }
.login-page { min-height: 100dvh; display: grid; place-items: center; overflow: auto; padding: 20px; }
.login-card { width: min(410px, 100%); text-align: center; border: 1px solid var(--border); background: var(--panel); border-radius: 22px; padding: 34px; box-shadow: var(--shadow); }
.login-card .brand-mark { margin: 0 auto 18px; }
.login-card h1 { margin: 0 0 10px; }
.login-card p { color: var(--muted); line-height: 1.55; }
.login-card form { margin-top: 22px; }
.login-card.public-login { width: min(720px, 100%); }
.public-login .login-lead { max-width: 560px; margin: 0 auto 24px; }
.public-login .login-welcome { max-width: 600px; color: var(--text); font-size: 18px; font-weight: 700; line-height: 1.5; letter-spacing: 0; }
.login-auth-block h2 { margin: 0 0 8px; font-size: 18px; }
.login-auth-block { padding: 8px 0 18px; }
.public-contact { font-size: 13px; }
.public-contact a { color: var(--accent); }
.checkout-price { color: var(--accent) !important; font-size: 28px; font-weight: 800; }
.text-link { display: inline-block; margin-top: 18px; color: var(--muted); }
.legal-links { display: flex; align-items: center; justify-content: center; gap: 8px; color: #64716c; font-size: 12px; }
.legal-links a { color: #91a49b; }
.sidebar-legal { justify-content: flex-start; padding: 0 12px 12px; }
.legal-page { min-height: 100dvh; overflow: auto; padding: 32px 18px 60px; }
.legal-card { width: min(780px, 100%); margin: 0 auto; border: 1px solid var(--border); background: var(--panel); border-radius: 22px; padding: clamp(24px, 5vw, 48px); box-shadow: var(--shadow); }
.legal-card .brand-mark { margin-bottom: 24px; }
.legal-card h1 { margin: 0 0 10px; font-size: clamp(28px, 5vw, 42px); letter-spacing: -1px; }
.legal-card h2 { margin: 30px 0 10px; font-size: 19px; }
.legal-card p, .legal-card li { color: #aeb9b4; line-height: 1.7; }
.legal-card ul { padding-left: 20px; }
.legal-card a { color: var(--accent); }
.legal-updated { color: #6f7b76 !important; font-size: 12px; }
.legal-warning { border: 1px solid #544b34; border-radius: 13px; background: #1d1a12; padding: 13px 15px; color: #d5c490 !important; }
.sidebar-backdrop { display: none; }

@keyframes messageIn { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes typing { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

@media (max-width: 760px) {
  .public-topbar { min-height: 62px; padding: 10px 16px; }
  .public-nav { display: none; }
  .public-login-link { margin-left: auto; min-height: 38px; }
  .public-site, .public-footer { width: min(100% - 28px, 1120px); }
  .public-hero { min-height: auto; padding: 82px 0 74px; }
  .public-hero h1 { font-size: clamp(38px, 12vw, 56px); }
  .public-actions { width: 100%; flex-direction: column; }
  .public-primary, .public-secondary { width: 100%; }
  .public-section { padding: 64px 0; }
  .feature-grid, .steps-grid, .public-price-grid, .service-section, .public-footer { grid-template-columns: 1fr; }
  .service-section { gap: 28px; }
  .public-login-section { margin: 64px 0; }
  .public-footer { gap: 26px; }
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(310px, 88vw); transform: translateX(-105%); transition: transform .22s ease; box-shadow: 18px 0 50px rgba(0,0,0,.45); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close, .menu-button { display: inline-grid; place-items: center; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 15; background: rgba(0,0,0,.58); }
  .sidebar-backdrop.visible { display: block; }
  .chat-panel { height: 100dvh; }
  .topbar { min-height: 60px; padding: 0 12px; }
  .topbar-title span { display: none; }
  .messages { padding: 24px 16px 22px; }
  .empty-state { margin-top: max(5vh, 34px); }
  .suggestions { grid-template-columns: 1fr; margin-top: 25px; }
  .suggestions button { min-height: 50px; }
  .composer-wrap { padding: 7px 10px max(10px, env(safe-area-inset-bottom)); }
  .composer-meta { padding-inline: 5px; }
  .message-bubble { max-width: 90%; }
  .package-grid { grid-template-columns: 1fr; }
  .modal { padding: 20px; }
  .toast-region { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
}
