:root {
  color-scheme: light;
  --paper: #f3f1eb; --surface: #faf9f5; --card: #ffffff; --ink: #302e29;
  --muted: #7d786f; --line: #e5e1d8; --accent: #b9583b; --soft: #eeeae2;
  --field: #f0ede6; --sent: #eeece5; --danger: #bc4141; --on-accent: #ffffff;
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --content-top: var(--tg-content-safe-area-inset-top, 0px);
  --content-bottom: var(--tg-content-safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-synthesis: none; -webkit-font-smoothing: antialiased;
  color: var(--ink); background: var(--paper);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #20201e; --surface: #262624; --card: #30302d; --ink: #eeeae2;
  --muted: #aaa69e; --line: #403e39; --accent: #da977c; --soft: #36342f;
  --field: #32312d; --sent: #373530; --danger: #ef9494; --on-accent: #25221e;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { position: fixed; inset: 0; width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body { font-size: 15px; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { border: 0; cursor: pointer; color: inherit; }
button:disabled { cursor: default; opacity: .5; }
button, a { transition: background-color 120ms ease, color 120ms ease, opacity 120ms ease; }
button:active:not(:disabled), a:active { opacity: .65; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); text-decoration: none; }
h1, h2, p { overflow-wrap: anywhere; }
h1 { font-size: 23px; font-weight: 600; letter-spacing: -.6px; line-height: 1.3; margin: 0 0 10px; }
h2 { font-size: 17px; font-weight: 550; line-height: 1.4; margin: 0 0 8px; }
p { line-height: 1.55; margin: 0 0 14px; }
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.app-viewport { position: fixed; top: var(--app-top, 0px); left: 0; right: 0; height: min(var(--app-height, 100dvh), 100dvh); overflow: hidden; display: flex; justify-content: center; }
.shell { flex: 1; max-width: 600px; min-width: 0; min-height: 0; height: 100%; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); padding: calc(var(--safe-top) + var(--content-top)) max(env(safe-area-inset-right, 0px), var(--tg-safe-area-inset-right, 0px)) 0 max(env(safe-area-inset-left, 0px), var(--tg-safe-area-inset-left, 0px)); }
.topbar { flex: 0 0 auto; height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 10px 6px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.service-nav { display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 11px; background: var(--soft); }
.tab { min-width: 53px; min-height: 34px; padding: 6px 10px; border-radius: 8px; background: none; color: var(--muted); font-size: 13px; font-weight: 550; }
.tab.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px #00000008; }
.header-tools { display: flex; align-items: center; gap: 1px; }
.icon-button { width: 40px; height: 42px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: transparent; color: var(--muted); border-radius: 10px; }
.icon-button:hover { color: var(--ink); background: var(--soft); }
.history-button { display: flex; align-items: center; gap: 5px; min-height: 42px; padding: 8px; border-radius: 10px; background: none; font-size: 12px; color: var(--muted); }
.history-button .icon { width: 18px; height: 18px; }
#admin-open[aria-current="page"] { color: var(--accent); background: var(--soft); }
body:not([data-screen="ready"]) .auth-only { display: none; }
body[data-screen="loading"] .service-nav, body[data-screen="gate"] .service-nav { visibility: hidden; }
#main { flex: 1; min-height: 0; overflow: hidden; }
.panel { height: 100%; min-height: 0; animation: panel-in 140ms ease-out; }
.chat-panel { display: flex; flex-direction: column; overflow: hidden; }
.chat-meta { flex: 0 0 auto; height: 32px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 20px 0; color: var(--muted); }
.model-name { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 500; }
.model-name .icon { width: 14px; height: 14px; color: var(--accent); stroke-width: 1.25; }
.send-status { font-size: 10px; }
#chat-workspace { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.chat-scroll { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.welcome { margin: auto 0; padding: 26px 20px; text-align: center; }
.welcome-mark { width: 34px; height: 34px; color: var(--accent); stroke-width: 1.1; margin-bottom: 18px; }
.welcome h1 { font-family: Georgia, "Times New Roman", serif; font-size: 25px; font-weight: 400; letter-spacing: -.5px; margin-bottom: 9px; }
.welcome p { font-size: 13px; color: var(--muted); margin: 0; }
.messages:empty { display: none; }
.messages { padding: 20px 18px 10px; }
.message { margin-bottom: 24px; animation: message-in 160ms ease-out; }
.message.user { max-width: 88%; width: fit-content; margin-left: auto; background: var(--sent); padding: 12px 15px; border-radius: 16px 16px 5px 16px; }
.message-label { display: flex; align-items: center; gap: 6px; color: var(--accent); font-size: 11px; font-weight: 550; margin-bottom: 9px; }
.message-label .icon { width: 16px; height: 16px; stroke-width: 1.2; }
.message-text { font-size: 16px; line-height: 1.65; overflow-wrap: anywhere; white-space: pre-wrap; }
.message-text.markdown { white-space: normal; }
.message-text p { margin: 0 0 12px; white-space: pre-wrap; }
.message-text p:last-child { margin-bottom: 0; }
.message-text h2, .message-text h3, .message-text h4 { font-size: 17px; font-weight: 600; line-height: 1.4; margin: 18px 0 8px; }
.message-text ul, .message-text ol { padding-left: 22px; margin: 10px 0 14px; }
.message-text li { padding-left: 2px; margin-bottom: 5px; }
.message-text pre { white-space: pre; overflow-x: auto; max-width: 100%; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 12px 0; line-height: 1.5; }
.message-text code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: var(--field); padding: 2px 4px; border-radius: 4px; }
.message-text pre code { padding: 0; background: none; }
.message-actions { display: flex; margin-top: 6px; }
.message-actions .icon-button { width: 36px; height: 34px; }
.message-actions .icon { width: 16px; height: 16px; }
.message.error { color: var(--danger); }
.typing { display: flex; gap: 4px; align-items: center; height: 22px; }
.typing span { width: 4px; height: 4px; border-radius: 50%; background: var(--muted); animation: typing 1s ease-in-out infinite; }
.typing span:nth-child(2) { animation-delay: 130ms; }
.typing span:nth-child(3) { animation-delay: 260ms; }
.composer-area { flex: 0 0 auto; padding: 6px 12px calc(8px + var(--safe-bottom) + var(--content-bottom)); background: var(--surface); }
body[data-keyboard="true"] .composer-area { padding-bottom: 6px; }
.suggestions { display: flex; justify-content: center; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 6px 0 12px; }
.suggestions button { min-height: 32px; flex-shrink: 0; padding: 7px 10px; border: 1px solid var(--line); background: transparent; border-radius: 9px; color: var(--muted); font-size: 11px; }
.suggestions button:hover { background: var(--soft); color: var(--ink); }
.composer-area:focus-within .suggestions { display: none; }
.composer { display: flex; align-items: flex-end; gap: 4px; padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 19px; box-shadow: 0 2px 6px #30291e04; }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { flex: 1; min-width: 0; resize: none; min-height: 42px; max-height: 114px; border: 0; outline: 0; background: transparent; color: var(--ink); padding: 9px 0; line-height: 24px; font-size: 16px; }
textarea::placeholder { color: var(--muted); opacity: 1; font-size: 14px; }
.attach-button { width: 34px; height: 42px; }
.attach-button .icon { width: 21px; height: 21px; }
.send-button { width: 36px; height: 36px; margin: 3px 1px; flex-shrink: 0; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); border-radius: 12px; }
.send-button .icon { width: 21px; height: 21px; stroke-width: 2; }
.send-button:disabled { background: var(--soft); color: var(--muted); opacity: 1; }
.composer-note { height: 20px; display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 9px; color: var(--muted); }
.composer-note .text-button { font-size: inherit; min-height: 20px; padding: 0; color: var(--muted); }
.attachments:empty { display: none; }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; max-height: 96px; overflow: auto; margin-bottom: 6px; }
.attachment { display: flex; align-items: center; gap: 6px; padding: 2px 4px 2px 10px; background: var(--soft); border-radius: 9px; color: var(--ink); font-size: 11px; max-width: 100%; overflow-wrap: anywhere; }
.attachment button { width: 30px; height: 30px; background: none; color: var(--muted); font-size: 20px; }
.primary, .secondary { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 16px; font-size: 14px; font-weight: 550; line-height: 1.4; border-radius: 12px; }
.primary { background: var(--accent); color: var(--on-accent); }
.secondary { background: var(--soft); color: var(--ink); }
.primary .icon, .secondary .icon { width: 18px; height: 18px; }
.full { width: 100%; }
.text-button { min-height: 40px; padding: 10px 0; background: none; color: var(--accent); text-align: left; font-size: 13px; }
.small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.loading { flex: 1; display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--muted); font-size: 13px; }
.loading-spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 700ms linear infinite; }
.login-gate, .access-gate { margin: auto; padding: 26px; text-align: center; max-width: 360px; }
.login-gate h1, .access-gate h1 { font-size: 21px; }
.login-gate p, .access-gate p { color: var(--muted); font-size: 13px; }
.gate-icon { width: 26px; height: 26px; color: var(--muted); margin-bottom: 18px; }
.id-label { display: inline-block; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.scroll-panel { overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; scrollbar-width: thin; padding: 0 16px calc(18px + var(--safe-bottom)); }
.page-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 24px 2px 18px; }
.page-title h1 { font-size: 22px; margin: 0; }
.page-title > span { color: var(--muted); font-size: 11px; }
.vpn-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 0 16px; }
.vpn-summary { display: flex; align-items: center; gap: 12px; padding: 18px 0 12px; }
.vpn-icon { width: 40px; height: 40px; display: grid; place-items: center; background: var(--soft); color: var(--accent); border-radius: 12px; }
.vpn-summary h2 { font-size: 16px; margin-bottom: 3px; }
.status-pill { font-size: 11px; color: var(--muted); }
.status-pill[data-active="true"] { color: var(--accent); }
.connection-state { font-size: 13px; color: var(--muted); margin: 0; padding-bottom: 16px; }
#vpn-controls, #vpn-refresh { border-top: 1px solid var(--line); }
.vpn-actions { display: flex; gap: 8px; margin: 14px 0 10px; }
.vpn-actions .primary { flex: 1; min-width: 0; font-size: 12px; }
#qr-container { width: 200px; max-width: 100%; padding: 12px; border-radius: 10px; background: #ffffff; margin: 16px auto; }
#qr-container img { width: 100%; display: block; }
.group-label { font-size: 12px; font-weight: 500; color: var(--muted); margin: 25px 2px 10px; }
.vpn-steps { padding: 0 16px; margin: 0; list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.vpn-steps li { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 12px 0; font-size: 13px; }
.vpn-steps li + li { border-top: 1px solid var(--line); }
.vpn-steps li > span { width: 23px; height: 23px; display: grid; place-items: center; flex-shrink: 0; border-radius: 7px; color: var(--muted); background: var(--soft); font-size: 10px; }
.guide-link { display: flex; justify-content: space-between; gap: 10px; padding: 16px 2px; font-size: 12px; }
.provider-state { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.provider-state .status-pill { padding: 6px 8px; background: var(--soft); border-radius: 6px; font-size: 10px; }
.search-field { display: flex; align-items: center; gap: 7px; padding-left: 12px; background: var(--field); border-radius: 12px; margin-bottom: 14px; }
.search-field > .icon { color: var(--muted); width: 16px; height: 16px; }
.search-field input { flex: 1; background: transparent !important; border: 0 !important; padding-inline: 0 !important; }
.client-list { display: grid; gap: 8px; }
.client-card { display: flex; gap: 11px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 13px; padding: 12px; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; flex-shrink: 0; background: var(--soft); color: var(--muted); border-radius: 11px; font-size: 13px; font-weight: 500; }
.client-who { flex: 1; min-width: 0; }
.client-name { display: block; font-size: 14px; font-weight: 550; overflow-wrap: anywhere; }
.client-id { display: block; margin-top: 3px; font-size: 10px; color: var(--muted); }
.client-status { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.client-edit { min-height: 42px; padding: 8px 0 8px 8px; font-size: 11px; color: var(--accent); background: none; }
.empty-list { margin: 0; padding: 24px 8px; text-align: center; font-size: 13px; color: var(--muted); }
.admin-note { margin: 16px 2px; font-size: 11px; }
input:not([type=checkbox]), select { width: 100%; min-width: 0; min-height: 46px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); font-size: 16px; }
input::placeholder { color: var(--muted); font-size: 14px; }
.field-label { display: block; color: var(--muted); font-size: 12px; margin: 18px 0 7px; }
.date-note { margin: 10px 0 0; font-size: 11px; }
dialog { position: fixed; inset: auto 0 var(--keyboard-inset, 0px); width: min(600px, 100%); max-width: 100%; max-height: min(88dvh, calc(var(--app-height, 100dvh) * .88)); margin: 0 auto; padding: 8px 18px max(20px, var(--safe-bottom)); border: 0; border-radius: 21px 21px 0 0; background: var(--card); color: var(--ink); overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
dialog[open] { animation: sheet-in 180ms cubic-bezier(.2,.8,.2,1); }
dialog::backdrop { background: #1b19154d; }
dialog p { font-size: 13px; color: var(--muted); }
.sheet-handle { width: 30px; height: 4px; border-radius: 3px; background: var(--line); margin: 0 auto 7px; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; margin-bottom: 12px; }
.dialog-header h2 { font-size: 18px; margin: 0; }
.dialog-close { width: 36px; height: 36px; }
.thread-list { min-height: 110px; margin-top: 12px; }
.thread-item { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.thread-open { flex: 1; min-width: 0; padding: 16px 0; background: none; text-align: left; font-size: 13px; overflow-wrap: anywhere; }
.thread-delete { color: var(--muted); background: none; font-size: 11px; min-height: 44px; }
.form-actions { display: grid; gap: 6px; margin-top: 23px; }
.form-actions .text-button { text-align: center; }
.form-error { color: var(--danger); font-size: 12px; margin: 10px 0 0; }
.danger-text { color: var(--danger); }
.toast { position: fixed; left: 50%; bottom: calc(var(--keyboard-inset, 0px) + 108px + var(--safe-bottom)); transform: translateX(-50%); z-index: 100; width: max-content; max-width: min(480px, calc(100% - 32px)); background: #3d3a35; color: #ffffff; padding: 12px 16px; border-radius: 11px; font-size: 12px; line-height: 1.45; animation: panel-in 140ms ease-out; }
.demo-banner { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 28px; padding: 2px 12px; font-size: 9px; color: var(--muted); border-bottom: 1px solid var(--line); }
.demo-banner select { width: 76px; border: 0; min-height: 22px; padding: 2px 4px; font-size: 10px; background: none; }
@keyframes panel-in { from { opacity: .4; } to { opacity: 1; } }
@keyframes message-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes sheet-in { from { opacity: .8; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes typing { 0%, 70%, 100% { opacity: .3; } 35% { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 340px) { .topbar { padding-inline: 10px 6px; } .tab { min-width: 49px; padding-inline: 8px; } .history-button { padding-inline: 5px; font-size: 11px; } .history-button .icon { display: none; } .icon-button { width: 36px; } .suggestions { gap: 4px; } .suggestions button { font-size: 10px; padding-inline: 9px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
