:root {
  color-scheme: dark;
  --bg: #070d1b;
  --surface: #101a2c;
  --raised: #192941;
  --text: #e8f2ff;
  --muted: #92a9c8;
  --border: #243954;
  --accent: #76d9ff;
  --accent-ink: #06162b;
  --accent-gradient: linear-gradient(135deg, #76d9ff, #78b1ff);
  --accent-soft: #45a6ff18;
  --accent-border: #4aaaff45;
  --accent-glow: 0 0 24px #268aff24;
  --ambient: #2458b51c;
  --danger: #efa4a0;
  --shadow: 0 12px 50px #0003;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-synthesis: none;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f1f6fd;
  --surface: #fff;
  --raised: #e5eefb;
  --text: #122542;
  --muted: #506789;
  --border: #ccdaed;
  --accent: #145fbb;
  --accent-ink: #fff;
  --accent-gradient: linear-gradient(135deg, #176fd1, #274dc4);
  --accent-soft: #1975dc0d;
  --accent-border: #1975dc33;
  --accent-glow: 0 4px 18px #2364ce16;
  --ambient: #3687ef0c;
  --danger: #b53a39;
  --shadow: 0 12px 50px #142d560c;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 560px 340px at 90% 0, var(--ambient), transparent 75%),
    var(--bg);
  background-repeat: no-repeat;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button,
input,
textarea {
  font: inherit;
}
button,
a,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}
button {
  color: inherit;
  cursor: pointer;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
button {
  border: 0;
}
a {
  color: var(--accent);
  text-underline-offset: 3px;
}
button svg {
  pointer-events: none;
}
svg {
  width: 20px;
  height: 20px;
  flex: none;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 31px;
  line-height: 1.18;
  letter-spacing: -1.1px;
  font-weight: 600;
}
h2 {
  font-size: 18px;
  letter-spacing: -0.4px;
  font-weight: 550;
}
h3 {
  font-size: 16px;
  font-weight: 550;
}
.shell {
  max-width: 840px;
  margin: auto;
  padding: 0 24px calc(108px + env(safe-area-inset-bottom));
}
.topbar {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: var(--tg-content-safe-area-inset-top, 0);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  padding: 0;
  font-weight: 650;
  font-size: 28px;
  letter-spacing: -1px;
}
.brand-mark {
  display: grid;
  place-items: center;
  font-size: 29px;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--accent-gradient);
  box-shadow: var(--accent-glow);
  color: var(--accent-ink);
  font-style: italic;
  font-family: Georgia, serif;
}
.brand-dot {
  color: var(--accent);
}
.connection {
  display: flex;
  gap: 7px;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.2px;
}
.status-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 4px var(--accent-soft), 0 0 12px var(--accent-border);
}
.connection.offline .status-dot {
  background: var(--danger);
  box-shadow: none;
}
.hero {
  padding: 20px 0 27px;
}
.eyebrow {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.4px;
  margin-bottom: 10px;
}
.hero p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 10px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.stat {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  text-align: left;
  padding: 17px 15px;
  min-height: 119px;
  position: relative;
}
.stat svg {
  color: var(--muted);
  width: 18px;
  height: 18px;
}
.stat .number {
  display: block;
  font-size: 32px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -1px;
  margin-top: 9px;
}
.stat .label {
  font-size: 12px;
  color: var(--muted);
}
.stat.featured {
  background: var(--accent-gradient);
  color: var(--accent-ink);
  border-color: transparent;
  box-shadow: var(--accent-glow);
}
.stat.featured svg,
.stat.featured .label {
  color: var(--accent-ink);
}
.section {
  margin-top: 30px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}
.quiet-button {
  color: var(--muted);
  background: transparent;
  padding: 7px 0;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}
.quiet-button svg {
  width: 15px;
  height: 15px;
}
.stack {
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  background: var(--surface);
}
.row {
  display: flex;
  width: 100%;
  gap: 13px;
  text-align: left;
  align-items: center;
  padding: 16px;
  background: transparent;
  color: var(--text);
}
.row + .row {
  border-top: 1px solid var(--border);
}
.row:hover {
  background: var(--raised);
}
.row-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border-radius: 12px;
  color: var(--accent);
  flex: none;
}
.row-body {
  flex: 1;
  min-width: 0;
}
.row-title {
  display: flex;
  align-items: center;
  gap: 7px;
  justify-content: space-between;
  min-width: 0;
  font-size: 14px;
  font-weight: 550;
}
.row-title span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.arrow {
  width: 16px;
  height: 16px;
  color: var(--muted);
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--raised);
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 400;
}
.pill.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.pill.warn {
  color: var(--danger);
}
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.menu-tile {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 70px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: left;
  padding: 15px;
  font-size: 13px;
}
.menu-tile > svg {
  color: var(--muted);
}
.menu-tile .arrow {
  margin-left: auto;
  width: 14px;
}
.footnote {
  font-size: 11px;
  color: var(--muted);
  margin-top: 18px;
  line-height: 1.7;
}
.nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  max-width: 840px;
  width: 100%;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
  z-index: 4;
}
.nav[hidden] {
  display: none;
}
.nav button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  background: transparent;
  padding: 8px 4px;
  border-radius: 12px;
  font-size: 10px;
}
.nav button.selected {
  color: var(--accent);
  background: var(--accent-soft);
}
.nav svg {
  width: 21px;
  height: 21px;
}
.page-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 0;
}
.page-head h1 {
  font-size: 26px;
}
.page-head p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
}
.primary {
  background: var(--accent-gradient);
  box-shadow: var(--accent-glow);
  color: var(--accent-ink);
  border-radius: 12px;
  min-height: 44px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 550;
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
}
.primary svg {
  width: 17px;
  height: 17px;
}
.secondary {
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  min-height: 42px;
  font-size: 13px;
}
.danger {
  color: var(--danger);
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
}
.tabs {
  display: flex;
  gap: 4px;
  border-radius: 11px;
  background: var(--surface);
  padding: 4px;
}
.tabs button {
  background: transparent;
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
}
.tabs button.selected {
  background: var(--raised);
  color: var(--text);
}
.search {
  position: relative;
  flex: 1;
  min-width: 0;
}
.search input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.empty {
  border: 1px dashed var(--border);
  border-radius: 18px;
  padding: 30px 22px;
  text-align: center;
  color: var(--muted);
}
.empty svg {
  width: 28px;
  height: 28px;
  margin-bottom: 10px;
}
.empty h3 {
  color: var(--text);
  margin-bottom: 6px;
}
.empty p {
  font-size: 13px;
  max-width: 380px;
  margin: 0 auto 14px;
}
.back {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--muted);
  padding: 10px 0;
  font-size: 12px;
}
.back svg {
  width: 16px;
  height: 16px;
}
.thread-head {
  padding: 12px 0 17px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.thread-head h1 {
  font-size: 24px;
  overflow-wrap: anywhere;
}
.thread-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 9px;
}
.thread-controls {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.thread-controls button {
  font-size: 11px;
  min-height: 35px;
  padding: 7px 11px;
}
.history-start {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 8px 0 20px;
}
.messages {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.message {
  max-width: 100%;
  overflow-wrap: anywhere;
}
.message.user {
  align-self: flex-end;
  max-width: 90%;
  background: var(--raised);
  border: 1px solid var(--accent-border);
  border-radius: 17px 17px 4px 17px;
  padding: 14px 17px;
}
.message.assistant {
  padding: 0 1px;
}
.message-label {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 7px;
}
.message-label strong {
  font-size: 11px;
  font-weight: 550;
  color: var(--accent);
}
.markdown {
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.markdown p {
  margin: 0 0 10px;
}
.markdown p:last-child {
  margin-bottom: 0;
}
.markdown pre {
  white-space: pre;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 12px;
  max-width: 100%;
}
.markdown code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  background: var(--raised);
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 0.9em;
}
.markdown pre code {
  padding: 0;
  background: none;
}
.markdown h2,
.markdown h3 {
  font-size: 16px;
  margin: 14px 0 8px;
}
.markdown ul,
.markdown ol {
  margin: 5px 0;
  padding-left: 20px;
}
.commentary {
  font-size: 12px;
  color: var(--muted);
  padding-left: 12px;
  border-left: 2px solid var(--border);
}
.commentary summary {
  cursor: pointer;
  font-size: 11px;
}
.composer {
  margin-top: 24px;
  position: sticky;
  bottom: 94px;
  background: var(--bg);
  padding-top: 9px;
  z-index: 3;
}
.compose-box {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--surface);
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 17px;
  box-shadow: var(--shadow);
}
.compose-box:focus-within {
  border-color: var(--accent);
}
.compose-box textarea {
  resize: none;
  flex: 1;
  min-width: 0;
  min-height: 43px;
  max-height: 180px;
  background: none;
  border: 0;
  outline: 0;
  color: var(--text);
  padding: 10px 5px;
  line-height: 1.4;
  font-size: 14px;
}
.send {
  width: 43px;
  height: 43px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent-gradient);
  box-shadow: var(--accent-glow);
  color: var(--accent-ink);
  flex: none;
}
.compose-note {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  padding-top: 7px;
}
.menu-screen {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 18px;
  padding: 20px;
}
.menu-text {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}
.button-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
}
.button-row {
  display: flex;
  gap: 8px;
}
.button-row button {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.notice {
  padding: 12px 15px;
  border-radius: 12px;
  background: var(--raised);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0;
}
.prompt {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}
.prompt textarea {
  width: 100%;
  min-height: 95px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  padding: 12px;
  color: var(--text);
}
.prompt .primary {
  margin-top: 8px;
}
.toast {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  padding: 13px 19px;
  border-radius: 13px;
  box-shadow: var(--shadow);
  background: var(--text);
  color: var(--bg);
  width: max-content;
  max-width: calc(100% - 40px);
  font-size: 13px;
  z-index: 10;
}
.loading {
  min-height: 50vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  font-size: 13px;
  color: var(--muted);
}
.spinner {
  width: 25px;
  height: 25px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.notification {
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 15px;
  margin: 12px 0;
  background: var(--surface);
}
.notification .menu-text {
  font-size: 12px;
  max-height: 230px;
  overflow: auto;
}
.load-more {
  display: block;
  margin: 16px auto;
}
.last-updated {
  font-size: 10px;
  color: var(--muted);
  margin-left: auto;
}
.error-box {
  padding: 30px 0;
}
.error-box p {
  color: var(--muted);
  margin: 12px 0 20px;
}
.no-margin {
  margin: 0;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (max-width: 550px) {
  .shell {
    padding-left: 18px;
    padding-right: 18px;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .stat {
    min-height: 110px;
    padding: 14px 16px;
  }
  .stat .number {
    font-size: 33px;
    margin-top: 3px;
  }
  .stat svg {
    position: absolute;
    top: 17px;
    right: 15px;
  }
  .topbar {
    height: 76px;
  }
  .hero {
    padding-top: 14px;
  }
  .menu-tile {
    padding: 13px;
    font-size: 12px;
  }
  .toolbar {
    flex-wrap: wrap;
  }
  .search {
    min-width: 130px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

[hidden] {
  display: none !important;
}
.menu-grid,
.stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.menu-tile {
  min-width: 0;
}
.menu-tile span {
  min-width: 0;
  overflow-wrap: anywhere;
}
@media (min-width: 551px) {
  .stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
