:root {
  color-scheme: light;
  --bg: #f5f4fa;
  --surface: #ffffff;
  --surface-soft: #fbfaff;
  --text: #242432;
  --muted: #858797;
  --line: #e9e8f0;
  --accent: #922be1;
  --accent-deep: #7420bf;
  --accent-soft: #f0e5ff;
  --blue: #5479e9;
  --green: #23a66f;
  --shadow: 0 10px 30px rgba(53, 43, 90, .08);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}
body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15151c;
  --surface: #24232d;
  --surface-soft: #2a2934;
  --text: #f5f2fb;
  --muted: #aaa6b6;
  --line: #3d3a49;
  --accent-soft: #38234d;
  --shadow: 0 10px 30px rgba(0, 0, 0, .24);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { padding: var(--tg-content-safe-area-inset-top, 0px) 0 calc(84px + var(--tg-content-safe-area-inset-bottom, 0px)); }
button, input { font: inherit; }
button { border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(146, 43, 225, .25); outline-offset: 2px; }
.app-shell { width: min(100%, 460px); min-height: 100svh; margin: 0 auto; background: var(--bg); }
.appbar { position: sticky; top: 0; z-index: 4; display: grid; grid-template-columns: 40px 36px 1fr auto; align-items: center; gap: 9px; min-height: 66px; padding: 10px 16px; background: color-mix(in srgb, var(--surface) 90%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(18px); }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; color: #fff; background: linear-gradient(145deg, #ad43ed, #7520c6); box-shadow: 0 8px 16px rgba(146, 43, 225, .24); font-size: 12px; font-weight: 900; letter-spacing: -.04em; }
.app-title { display: grid; gap: 1px; min-width: 0; }
.app-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.app-title span { color: var(--muted); font-size: 10px; }
.appbar-actions { display: flex; align-items: center; gap: 7px; }
.icon-button { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: 12px; color: var(--text); background: var(--surface-soft); border: 1px solid var(--line); font-size: 20px; line-height: 1; }
.icon-button.subtle { width: 34px; height: 34px; color: var(--muted); font-size: 18px; }
.status-dot { padding: 5px 8px; border-radius: 999px; color: var(--muted); background: var(--surface-soft); font-size: 10px; font-weight: 800; white-space: nowrap; }
.status-dot.ok { color: var(--green); background: rgba(35, 166, 111, .12); }
.status-dot.error { color: #d84c62; background: rgba(216, 76, 98, .12); }
.main-content { display: grid; padding: 15px 16px 18px; }
.view { display: none; gap: 14px; animation: view-in .22s ease both; }
.view.active { display: grid; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.hero-card { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 21px 20px; border-radius: 24px; color: #fff; background: radial-gradient(circle at 100% 0, rgba(255,255,255,.25), transparent 38%), linear-gradient(135deg, #a33be9, #7622c7); box-shadow: 0 14px 28px rgba(132, 38, 201, .22); }
.eyebrow, .kicker { color: var(--accent); font-size: 10px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.hero-card .eyebrow { color: rgba(255,255,255,.78); }
h1, h2, p { margin: 0; }
h1 { margin-top: 5px; font-size: 29px; letter-spacing: -.05em; }
h2 { margin-top: 3px; font-size: 19px; letter-spacing: -.03em; }
.hero-subtitle { margin-top: 10px; color: rgba(255,255,255,.82); font-size: 12px; }
.hero-count { display: grid; align-content: center; justify-items: end; min-width: 74px; padding-top: 3px; }
.hero-count strong { font-size: 36px; line-height: .95; letter-spacing: -.06em; }
.hero-count span { margin-top: 7px; color: rgba(255,255,255,.76); font-size: 11px; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat-card, .panel-card { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.stat-card { display: flex; align-items: center; gap: 10px; min-height: 84px; padding: 14px; border-radius: 18px; }
.wide-stat { grid-column: 1 / -1; min-height: 70px; }
.stat-card span { display: block; color: var(--muted); font-size: 11px; }
.stat-card strong { display: block; margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; }
.stat-icon { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; border-radius: 12px; font-size: 20px; font-weight: 900; }
.stat-icon.purple { color: var(--accent); background: var(--accent-soft); }
.stat-icon.blue { color: var(--blue); background: rgba(84, 121, 233, .12); }
.stat-icon.green { color: var(--green); background: rgba(35, 166, 111, .12); }
.panel-card { border-radius: 20px; }
.quick-panel { padding: 17px; }
.panel-heading, .page-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.text-button { padding: 5px 0; color: var(--accent); background: transparent; font-size: 12px; font-weight: 800; }
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 14px; }
.quick-button, .menu-button, .message-button { display: flex; align-items: center; gap: 9px; min-height: 58px; padding: 11px 12px; border-radius: 15px; color: var(--text); background: var(--surface-soft); border: 1px solid var(--line); text-align: left; font-size: 13px; font-weight: 800; transition: transform .15s ease, border-color .15s ease, background .15s ease, opacity .15s ease; }
.quick-button:hover, .menu-button:hover, .message-button:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: var(--accent-soft); }
.quick-button:active, .menu-button:active, .message-button:active { transform: scale(.975); }
.quick-button.wide { grid-column: 1 / -1; }
.button-icon { display: grid; place-items: center; flex: 0 0 30px; width: 30px; height: 30px; border-radius: 10px; color: var(--accent); background: var(--accent-soft); font-size: 15px; }
.button-copy { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.button-arrow { margin-left: auto; color: var(--muted); font-size: 17px; }
.sync-card { display: flex; align-items: center; gap: 11px; padding: 15px; }
.sync-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; color: var(--accent); background: var(--accent-soft); font-size: 18px; }
.sync-card strong { font-size: 13px; }
.sync-card p { margin-top: 3px; color: var(--muted); font-size: 11px; }
.pulse-dot { width: 8px; height: 8px; margin-left: auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(35, 166, 111, .1); }
.page-heading { min-height: 44px; }
.page-heading > div { flex: 1; min-width: 0; }
.page-heading h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-button { width: 38px; height: 38px; padding: 0 0 4px; border-radius: 12px; color: var(--text); background: var(--surface); border: 1px solid var(--line); font-size: 30px; line-height: 1; }
.workspace-feed { display: grid; gap: 10px; min-height: 120px; }
.empty { display: grid; place-items: center; min-height: 150px; padding: 22px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: 18px; text-align: center; font-size: 13px; }
.message { padding: 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.message.user { background: var(--accent-soft); }
.message-text { overflow-wrap: anywhere; color: var(--text); font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.message-text a { color: var(--accent); font-weight: 800; text-decoration: none; }
.message-meta { margin-top: 8px; color: var(--muted); font-size: 10px; }
.message-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.message-button { min-height: 44px; padding: 9px 11px; color: #fff; background: linear-gradient(135deg, #9a31e3, #7a24c7); border: 0; font-size: 12px; }
.message-button .button-icon { color: #fff; background: rgba(255,255,255,.16); }
.message-button.busy, .quick-button.busy, .menu-button.busy { opacity: .55; pointer-events: none; }
.composer { display: grid; gap: 9px; padding: 14px; }
.composer label { color: var(--muted); font-size: 11px; font-weight: 700; }
.compose-row { display: flex; gap: 8px; }
#text-input { flex: 1; min-width: 0; padding: 12px 13px; color: var(--text); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 13px; outline: 0; }
#text-input:focus { border-color: var(--accent); }
.primary { padding: 0 16px; border-radius: 13px; color: #fff; background: var(--accent); font-weight: 900; }
.file-row { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: 10px; }
#file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-button { display: inline-flex !important; flex: 0 0 auto; padding: 7px 10px; border-radius: 10px; color: var(--accent) !important; background: var(--accent-soft); cursor: pointer; }
#file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottom-nav { position: fixed; z-index: 5; right: 0; bottom: 0; left: 50%; display: grid; grid-template-columns: repeat(4, 1fr); width: min(100%, 460px); padding: 8px 12px calc(8px + var(--tg-content-safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: color-mix(in srgb, var(--surface) 94%, transparent); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(56, 42, 90, .07); backdrop-filter: blur(18px); }
.nav-item { display: grid; justify-items: center; gap: 3px; padding: 5px 3px; color: var(--muted); background: transparent; font-size: 19px; }
.nav-item small { font-size: 10px; }
.nav-item.active { color: var(--accent); font-weight: 800; }
.drawer { position: fixed; inset: 0; z-index: 10; visibility: hidden; pointer-events: none; }
.drawer.open { visibility: visible; pointer-events: auto; }
.drawer-overlay { position: absolute; inset: 0; background: rgba(20, 18, 30, .48); opacity: 0; transition: opacity .2s ease; }
.drawer-panel { position: absolute; top: 0; bottom: 0; left: 0; display: flex; flex-direction: column; width: min(88vw, 360px); padding: calc(16px + var(--tg-content-safe-area-inset-top, 0px)) 16px calc(16px + var(--tg-content-safe-area-inset-bottom, 0px)); overflow: auto; background: var(--surface); transform: translateX(-100%); transition: transform .23s ease; box-shadow: 16px 0 40px rgba(20, 14, 40, .18); }
.drawer.open .drawer-overlay { opacity: 1; }
.drawer.open .drawer-panel { transform: translateX(0); }
.drawer-head, .drawer-brand, .drawer-user { display: flex; align-items: center; gap: 10px; }
.drawer-head { justify-content: space-between; }
.drawer-brand { min-width: 0; }
.drawer-brand > div:last-child, .drawer-user > div:last-child { display: grid; gap: 3px; min-width: 0; }
.drawer-brand span, .drawer-user span { color: var(--muted); font-size: 11px; }
.drawer-user { margin: 18px 0 16px; padding: 12px; border-radius: 16px; background: var(--accent-soft); }
.avatar { display: grid; place-items: center; flex: 0 0 38px; width: 38px; height: 38px; border-radius: 13px; color: #fff; background: linear-gradient(145deg, #a53be8, #7520c4); font-size: 12px; font-weight: 900; }
.drawer-menu { display: grid; gap: 16px; padding-bottom: 20px; }
.drawer-group { display: grid; gap: 5px; }
.drawer-group-title { padding: 0 8px 4px; color: var(--muted); font-size: 11px; font-weight: 900; }
.menu-button { min-height: 45px; width: 100%; background: transparent; border: 0; border-radius: 12px; font-weight: 700; }
.menu-button .button-icon { flex-basis: 28px; width: 28px; height: 28px; }
.back-bot { width: 100%; margin-top: auto; padding: 12px; border-radius: 13px; color: var(--text); background: var(--surface-soft); border: 1px solid var(--line); font-weight: 800; }
.toast { position: fixed; z-index: 20; right: 16px; bottom: calc(82px + var(--tg-content-safe-area-inset-bottom, 0px)); left: 16px; max-width: 430px; margin: auto; padding: 11px 14px; border-radius: 14px; color: #fff; background: #292332; box-shadow: var(--shadow); text-align: center; font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(9px); transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
@media (min-width: 700px) { body { padding-bottom: 20px; } .bottom-nav { position: sticky; margin: 12px auto 0; transform: none; } }
@media (max-width: 360px) { .appbar { padding-inline: 11px; gap: 6px; } .main-content { padding-inline: 11px; } .status-dot { display: none; } .hero-card { padding-inline: 16px; } .quick-grid { grid-template-columns: 1fr; } .quick-button.wide { grid-column: auto; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
