:root {
  color-scheme: dark;
  --bg: #17161d;
  --surface: #22212b;
  --surface-up: #2a2835;
  --input: #1b1a24;
  --ink: #f6f4fc;
  --muted: #b3aebf;
  --line: #383443;
  --input-line: #504a60;
  --accent: #c8b4ff;
  --on-accent: #211538;
  --primary: #c2a9ff;
  --accent-soft: #342948;
  --accent-line: #655189;
  --mint: #8de0b8;
  --mint-soft: #213a35;
  --sky: #a1cbff;
  --sky-soft: #263449;
  --warn: #f2cc86;
  --warn-soft: #3c3027;
  --bad: #f5b1ba;
  --bad-soft: #422932;
  --nav: #1e1c26;
  --lift: 0 10px 30px #09071021;
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f3f8;
  --surface: #fff;
  --surface-up: #f1eef6;
  --input: #faf8fd;
  --ink: #211b2b;
  --muted: #625a70;
  --line: #e3deea;
  --input-line: #b8abc9;
  --accent: #5a37bf;
  --on-accent: #fff;
  --primary: #6342cc;
  --accent-soft: #ede6ff;
  --accent-line: #cfbdfc;
  --mint: #156848;
  --mint-soft: #e0f3e8;
  --sky: #235da5;
  --sky-soft: #e6effc;
  --warn: #805312;
  --warn-soft: #fff0d7;
  --bad: #a23c4b;
  --bad-soft: #fbe9ed;
  --nav: #fcfaff;
  --lift: 0 12px 32px #39225d0d;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink); }
button, textarea, input, select { font: inherit; }
button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.78rem, 7.2vw, 2.65rem); font-weight: 760; line-height: 1.08; letter-spacing: -.048em; overflow-wrap: anywhere; }
h2 { font-size: 1.125rem; font-weight: 730; line-height: 1.23; letter-spacing: -.025em; }
h3 { font-size: .95rem; font-weight: 690; line-height: 1.3; }
p, small { overflow-wrap: anywhere; }

.shell {
  width: min(100%, 1000px);
  padding: max(10px, var(--tg-content-safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right))
    calc(88px + max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px))) max(16px, env(safe-area-inset-left));
  margin-inline: auto;
}
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 54px; gap: 8px; margin-bottom: 17px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: .98rem; font-weight: 760; letter-spacing: -.025em; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--primary); color: var(--on-accent); }
.brand-mark i { position: relative; width: 12px; height: 12px; border: 1.5px solid currentColor; border-radius: 3px; transform: translateY(-2px) rotate(45deg); }
.brand-mark i::before { content: ''; position: absolute; inset: 3px; background: currentColor; border-radius: 1px; }
.brand-mark i::after { content: ''; position: absolute; width: 11px; height: 11px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; border-radius: 2px; left: 2px; top: 2px; }
.topbar-status { display: flex; align-items: center; gap: 8px; min-width: 0; }
.connection {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 9px; border-radius: 9px;
  color: var(--mint); background: var(--mint-soft); font-size: .73rem; font-weight: 690; white-space: nowrap;
}
.connection i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.connection.attention { color: var(--warn); background: var(--warn-soft); }

.button, .icon-button, .nav-inner button { border: 1px solid transparent; border-radius: 11px; background: transparent; }
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-color: var(--line); color: var(--muted); background: var(--surface); }
.button {
  display: inline-flex; place-content: center; align-items: center; gap: 6px; min-height: 44px; padding: 7px 12px;
  font-size: .84rem; font-weight: 690; line-height: 1.2; text-decoration: none;
}
.primary { background: var(--primary); color: var(--on-accent); border-color: var(--primary); }
.secondary { background: var(--surface); border-color: var(--line); }
.danger { color: var(--bad); background: var(--bad-soft); }
.link-button { color: var(--accent); padding-inline: 4px; }
.subtle { color: var(--muted); padding-inline: 2px; }
.wide { width: 100%; }
.muted { color: var(--muted); }
.pre-line { white-space: pre-wrap; overflow-wrap: anywhere; }

.page-head, .section-head { display: flex; justify-content: space-between; align-items: center; gap: 9px; }
.page-head { margin: 9px 0 17px; }
.page-head p { margin-top: 7px; color: var(--muted); font-size: .9rem; }
.section { margin-top: 19px; min-width: 0; }
.section-head { min-height: 36px; margin-bottom: 7px; }
.section-head > .button { flex-shrink: 0; text-align: right; }
.stack { display: grid; gap: 9px; }
.flow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.card, .item, .empty, .list-row { min-width: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.card, .empty { padding: 15px; }
.empty p { margin-top: 5px; color: var(--muted); font-size: .875rem; }
.initial { padding: 22px; box-shadow: var(--lift); }
.initial .button { margin-top: 14px; }
.compose-panel, .activity { min-width: 0; }
.compose-head .button { flex: none; white-space: nowrap; }
.compose-card { padding: 13px; border-radius: 19px; box-shadow: var(--lift); }

.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: var(--input); }
.provider { gap: 7px; min-width: 0; border-radius: 10px; color: var(--muted); padding: 5px; font-size: .875rem; }
.provider[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); border-color: var(--accent-line); }
.provider-label { display: grid; text-align: left; }
.provider-label small { margin-top: 2px; color: var(--warn); font-size: .66rem; font-weight: 630; }
.provider-mark, .recipient-icon {
  display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 8px;
  background: var(--surface-up); font-size: .95rem; line-height: 1;
}
.provider-mark.codex { color: var(--mint); background: var(--mint-soft); }
.provider-mark.antigravity { color: var(--sky); background: var(--sky-soft); }
.provider-mark.row-icon { width: 32px; height: 32px; border-radius: 10px; font-size: 1rem; }

.row-button {
  display: flex; align-items: center; width: 100%; gap: 10px; padding: 0;
  text-align: left; color: inherit; background: transparent; border: 0;
}
.recipient { padding: 10px 8px; margin-top: 7px; min-height: 60px; border-radius: 10px; }
.recipient-icon { width: 35px; height: 35px; color: var(--accent); background: var(--accent-soft); border-radius: 10px; }
.recipient-copy { flex: 1 1 auto; min-width: 0; }
.recipient-copy strong, .recipient-copy small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recipient-copy strong { font-size: .96rem; line-height: 1.3; }
.recipient-copy small { margin-top: 3px; font-size: .76rem; }
.recipient > .glyph { color: var(--muted); }
.compose-tools { padding: 0 0 8px; border-bottom: 1px solid var(--line); margin-bottom: 11px; }
.tag { padding-inline: 9px; color: var(--muted); background: var(--surface-up); border-color: var(--line); font-size: .78rem; }

.composer { display: grid; gap: 9px; }
.schedule-panel { color: var(--accent); font-size: .84rem; }
.schedule-panel summary { display: list-item; padding: 11px 5px; min-height: 44px; cursor: pointer; font-weight: 690; }
.schedule-panel .field { padding: 1px 5px 0; }
textarea, input, select {
  width: 100%; border: 1px solid var(--input-line); border-radius: 11px; padding: 10px 12px;
  background: var(--input); color: var(--ink); font-size: 1rem;
}
textarea::placeholder, input::placeholder { color: var(--muted); opacity: 1; }
textarea { display: block; min-height: 94px; resize: vertical; }
.composer-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; align-items: center; }
.composer-footer .primary { margin-left: auto; min-width: 118px; }
.preview-option { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; cursor: pointer; }
.preview-option input { margin: 0; width: 17px; height: 17px; }
.preview-card h3 { overflow-wrap: anywhere; }
.preview-media:empty { display: none; }
.preview-media img, .preview-media video { display: block; width: 100%; max-height: 62vh; object-fit: contain; border-radius: 8px; }
.compose-card > .link-button { margin-top: 5px; }

.list-row { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 61px; padding: 11px 12px; }
.row-content, .item-body { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.row-content p { margin-top: 3px; color: var(--muted); font-size: .76rem; }
.row-tail { flex: none; color: var(--muted); font-size: .95rem; }
.row-button[aria-current="true"], .selected { color: var(--accent); border-color: var(--accent-line); }
.in-conversation .shell { padding-bottom: 0; }
.in-conversation .topbar { display: none; }
.conversation {
  width: min(100%, 740px); min-height: min(360px, 82dvh); margin-inline: auto; display: flex; flex-direction: column;
  height: calc(var(--tg-viewport-height, 100dvh) - 70px - max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px)) - max(10px, var(--tg-content-safe-area-inset-top, 0px)));
}
.chat-header { display: flex; flex: none; align-items: center; gap: 9px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.chat-header > .button { flex: none; padding-inline: 0 5px; }
.chat-header > .button > span { font-size: 1.5rem; }
.chat-heading { flex: 1; min-width: 0; }
.chat-heading h1 { font-size: 1rem; line-height: 1.25; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-heading small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .75rem; }
.chat-refresh { flex: none; }
.chat-messages { flex: 1 1 0; min-height: 74px; overflow: auto; overscroll-behavior: contain; overflow-anchor: none; scrollbar-width: thin; }
.chat-earlier { display: flex; justify-content: center; }
.chat-bubbles { display: flex; flex-direction: column; gap: 10px; padding: 12px 4px; }
.chat-day { align-self: center; padding: 3px 9px; margin: 5px 0; color: var(--muted); background: var(--surface-up); border-radius: 12px; font-size: .73rem; }
.bubble { width: fit-content; max-width: min(92%, 640px); border: 1px solid var(--line); border-radius: 16px; padding: 9px 12px; background: var(--surface); }
.bubble-assistant { align-self: start; border-bottom-left-radius: 5px; }
.bubble-user { align-self: end; max-width: min(86%, 570px); border-color: var(--accent-line); border-bottom-right-radius: 5px; background: var(--accent-soft); }
.bubble-meta { display: flex; gap: 12px; align-items: baseline; justify-content: space-between; margin-bottom: 4px; color: var(--muted); font-size: .74rem; }
.bubble-meta strong { color: var(--mint); }
.bubble-user .bubble-meta strong { color: var(--accent); }
.bubble-text { font-size: .92rem; overflow-wrap: anywhere; }
.bubble-text > .pre-line:empty { display: none; }
.chat-code { max-width: 100%; overflow: auto; padding: 9px; margin: 7px 0; background: var(--input); border: 1px solid var(--line); border-radius: 8px; font-size: .8rem; }
.chat-activity { flex: none; border-top: 1px solid var(--line); }
.chat-compose { flex: none; padding: 8px 0 2px; border-top: 1px solid var(--line); background: var(--bg); }
.chat-compose textarea { min-height: 56px; max-height: 140px; resize: vertical; }
.chat-compose .composer { gap: 3px; }
.chat-compose .schedule-panel summary { min-height: 34px; padding-block: 6px; }
.item { display: flex; align-items: start; gap: 9px; padding: 12px; }
.item-header { display: flex; align-items: start; justify-content: space-between; gap: 6px; }
.item-header h3 { min-width: 0; }
.item-header .badge { flex-shrink: 0; max-width: 48%; }
.item-meta { margin-top: 4px; color: var(--muted); font-size: .76rem; }
.item-actions { margin-top: 4px; }
.item-actions .button { min-height: 44px; font-size: .8rem; }
.task-detail { margin-top: 7px; color: var(--muted); font-size: .875rem; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 8px; padding: 4px 7px; color: var(--muted);
  background: var(--surface-up); font-size: .67rem; line-height: 1.2; font-weight: 700; overflow-wrap: anywhere;
}
.badge::before { content: ''; width: 5px; height: 5px; flex: none; border-radius: 50%; background: currentColor; }
.good, .badge.working { color: var(--mint); }
.badge.good, .badge.working { background: var(--mint-soft); }
.badge.preparing, .badge.sending, .badge.queued { color: var(--accent); background: var(--accent-soft); }
.badge.waiting, .badge.uncertain { color: var(--warn); background: var(--warn-soft); }
.badge.scheduled { color: var(--accent); background: var(--accent-soft); }
.badge.quota_wait, .badge.waiting_chat { color: var(--warn); background: var(--warn-soft); }
.failed { color: var(--bad); }
.badge.failed { background: var(--bad-soft); }
.report-text { font: inherit; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }

.search, .field { margin-bottom: 8px; }
.field { display: grid; gap: 5px; font-size: .86rem; color: var(--muted); }
.request { border-left: 3px solid var(--accent-line); }
.request .pre-line { margin: 8px 0 12px; font-size: .9rem; }
.request-input { margin-top: 8px; }
.option { text-align: left; justify-content: flex-start; width: 100%; }
.option small { display: block; color: var(--muted); font-weight: 400; }

.quota-grid { display: grid; gap: 9px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.quota strong { display: block; font-size: 2.15rem; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.06em; margin: 2px 0 5px; }
.quota progress { display: block; appearance: none; width: 100%; height: 7px; border: 0; border-radius: 10px; overflow: hidden; background: var(--surface-up); margin-bottom: 7px; }
.quota progress::-webkit-progress-bar { background: var(--surface-up); }
.quota progress::-webkit-progress-value { border-radius: 10px; background: var(--primary); }
.quota progress::-moz-progress-bar { background: var(--primary); }
.quota small { color: var(--muted); }
.setting-line { display: flex; align-items: center; justify-content: space-between; gap: 13px; padding: 10px 0; min-height: 57px; }
.setting-line + .setting-line { border-top: 1px solid var(--line); }
.setting-line select { width: auto; max-width: 48%; min-height: 44px; font-size: .82rem; }
.setting-line p { margin-top: 3px; color: var(--muted); font-size: .78rem; }
.switch { position: relative; flex: none; width: 46px; height: 44px; border: 0; padding: 0; background: transparent; }
.switch::before { content: ''; position: absolute; inset: 9px 0; border: 1px solid var(--input-line); border-radius: 20px; background: var(--surface-up); }
.switch::after { content: ''; position: absolute; top: 13px; left: 4px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); }
.switch[aria-checked="true"]::before { background: var(--primary); border-color: var(--primary); }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--on-accent); }

.navigation {
  position: fixed; z-index: 2; inset: auto 0 0; padding: 4px 6px max(4px, env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
  background: var(--nav); border-top: 1px solid var(--line); box-shadow: 0 -4px 20px #0e0b170a;
}
.nav-inner { width: min(100%, 640px); margin: auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; }
.nav-inner button { display: grid; justify-items: center; align-content: center; gap: 2px; padding: 4px 0; min-height: 52px; color: var(--muted); font-size: .7rem; font-weight: 690; line-height: 1.15; }
.nav-inner button[aria-current="page"] { color: var(--accent); }
.nav-symbol { display: grid; width: 37px; height: 25px; place-items: center; border-radius: 9px; }
.nav-inner button[aria-current="page"] .nav-symbol { background: var(--accent-soft); }
#toast {
  position: fixed; z-index: 5; inset: auto 15px calc(72px + max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px)));
  margin: auto; width: fit-content; max-width: min(calc(100% - 30px), 530px); padding: 10px 13px;
  border-radius: 12px; background: var(--surface-up); border: 1px solid var(--input-line); box-shadow: var(--lift); font-size: .88rem;
}

.glyph { display: inline-block; position: relative; width: 18px; height: 18px; flex: none; }
.glyph::before, .glyph::after, .glyph i, .glyph i::before, .glyph i::after { position: absolute; display: block; content: ''; }
.glyph-home::before { width: 11px; height: 11px; border: solid currentColor; border-width: 1.5px 0 0 1.5px; top: 3px; left: 3.5px; transform: rotate(45deg); border-radius: 2px 0 0 0; }
.glyph-home::after { width: 12px; height: 9px; left: 3px; top: 7.5px; border: solid currentColor; border-width: 0 1.5px 1.5px; border-radius: 0 0 3px 3px; }
.glyph-home i { left: 8px; bottom: 2.5px; width: 2px; height: 4px; background: currentColor; border-radius: 1px 1px 0 0; }
.glyph-tasks i { inset: 1px 3px; border: 1.5px solid currentColor; border-radius: 3px; }
.glyph-tasks i::before { width: 5.5px; height: 1.5px; left: 2px; top: 3px; background: currentColor; box-shadow: 0 4px 0 currentColor; border-radius: 2px; }
.glyph-chat i { inset: 2px 1.5px 4px; border: 1.5px solid currentColor; border-radius: 4px; }
.glyph-chat i::before { width: 4px; height: 4px; border: solid currentColor; border-width: 0 0 1.5px 1.5px; left: 2px; bottom: -4px; transform: skewY(-35deg); }
.glyph-chat i::after { width: 1.5px; height: 1.5px; background: currentColor; top: 3.5px; left: 2.5px; border-radius: 50%; box-shadow: 3px 0 0 currentColor, 6px 0 0 currentColor; }
.glyph-chart::before, .glyph-chart::after, .glyph-chart i { bottom: 2px; width: 3px; background: currentColor; border-radius: 2px; }
.glyph-chart::before { left: 2px; height: 6px; }
.glyph-chart i { left: 7.5px; height: 13px; }
.glyph-chart::after { right: 2px; height: 9px; }
.glyph-sliders::before { width: 14px; height: 1.5px; left: 2px; top: 4px; border-radius: 2px; background: currentColor; box-shadow: 0 4.5px 0 currentColor, 0 9px 0 currentColor; }
.glyph-sliders i, .glyph-sliders i::before, .glyph-sliders i::after { width: 3px; height: 4px; border-radius: 1px; background: currentColor; }
.glyph-sliders i { left: 6px; top: 2.75px; }
.glyph-sliders i::before { left: 5px; top: 4.5px; }
.glyph-sliders i::after { left: -1px; top: 9px; }
.glyph-refresh i { inset: 2px; border: 1.5px solid currentColor; border-top-color: transparent; border-radius: 50%; transform: rotate(-24deg); }
.glyph-refresh i::before { left: 8px; top: -.5px; width: 4.5px; height: 4.5px; border: solid currentColor; border-width: 1.5px 1.5px 0 0; border-radius: 1px; transform: rotate(86deg); }
.glyph-chevron { width: 13px; }
.glyph-chevron i { width: 6px; height: 6px; left: 2px; top: 6px; border: solid currentColor; border-width: 1.5px 1.5px 0 0; transform: rotate(45deg); }
.glyph-plus::before, .glyph-plus::after { left: 3px; top: 8px; width: 12px; height: 1.5px; background: currentColor; border-radius: 1px; }
.glyph-plus::after { transform: rotate(90deg); }
.glyph-arrow i { width: 12px; height: 1.5px; left: 2px; top: 8px; background: currentColor; border-radius: 2px; }
.glyph-arrow i::after { right: 0; top: -3px; width: 7px; height: 7px; border: solid currentColor; border-width: 1.5px 1.5px 0 0; transform: rotate(45deg); }
.glyph-folder i { inset: 5px 1px 3px; border: 1.5px solid currentColor; border-radius: 3px; }
.glyph-folder i::before { width: 6px; height: 3px; top: -4px; left: 0; border: solid currentColor; border-width: 1.5px 1.5px 0 1.5px; border-radius: 3px 3px 0 0; }
.glyph-clip i { width: 7px; height: 15px; left: 5px; top: 1px; border: 1.5px solid currentColor; border-top-color: transparent; border-radius: 4px; transform: rotate(42deg); }
.glyph-clip i::before { height: 10px; left: 2px; top: 0; border-left: 1.5px solid currentColor; border-radius: 3px; }

@media (hover: hover) {
  .button:hover:not(:disabled), .icon-button:hover:not(:disabled) { filter: brightness(1.06); }
  .row-button:hover:not(:disabled) { background: var(--surface-up); }
  .link-button:hover:not(:disabled), .subtle:hover:not(:disabled) { background: var(--accent-soft); }
}
@media (min-width: 720px) {
  .shell { padding-inline: 25px; }
  .topbar { margin-bottom: 25px; }
  .dashboard { display: grid; grid-template-columns: minmax(0, 1.13fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .activity > .section:first-child { margin-top: 8px; }
  .activity .section-head { min-height: 52px; margin-bottom: 9px; }
  .compose-card { padding: 16px; }
}
@media (max-width: 355px) {
  .shell { padding-inline: 12px; }
  .compose-head h1 { font-size: 1.62rem; }
  .compose-head .button { padding-inline: 8px; }
  .compose-card { padding: 10px; }
  .item { padding-inline: 9px; gap: 7px; }
}

