:root {
  color-scheme: light dark;
  font: 16px/1.5 system-ui, sans-serif;
  --canvas: #f5f6f8;
  --surface: #fff;
  --ink: #172433;
  --muted: #5c6b7b;
  --line: #dce4ea;
  --accent: #0a675a;
  --active: #dcefe9;
  --bubble: #e4eee9;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #13191e;
    --surface: #1d262d;
    --ink: #ecf2f7;
    --muted: #adbdca;
    --line: #384650;
    --accent: #0b685b;
    --active: #2a403c;
    --bubble: #293f3a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
.workspace {
  min-height: 100dvh;
  min-height: var(--tg-viewport-stable-height, 100dvh);
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}
.rail { padding: 2rem 1.25rem; background: var(--surface); border-inline-end: 1px solid var(--line); }
.rail h1, h2 { margin: 0 0 1rem; font-size: 1.2rem; }
.rail a { display: block; padding: .65rem 1rem; border-radius: .6rem; color: inherit; text-decoration: none; background: var(--active); }
.conversation { width: min(100%, 860px); margin-inline: auto; padding: 2rem 2rem max(1rem, env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
h2 { display: none; }
.messages { flex: 1; display: grid; gap: 1.25rem; align-content: start; }
.entry { display: grid; gap: .45rem; }
.prompt, .result { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; padding: .85rem 1rem; border-radius: .9rem; }
.prompt { background: var(--bubble); justify-self: end; max-width: min(90%, 600px); }
.result { background: var(--surface); }
.meta { color: var(--muted); font-size: .82rem; margin: 0; }
#notice { min-height: 1.5em; color: var(--muted); margin: .75rem 0 .25rem; }
form { display: flex; gap: .5rem; align-items: end; border: 1px solid var(--line); background: var(--surface); border-radius: .9rem; padding: .6rem; position: sticky; bottom: max(.6rem, env(safe-area-inset-bottom)); }
textarea { resize: vertical; min-height: 3.1rem; max-height: 40vh; width: 100%; font: inherit; color: inherit; background: transparent; border: 0; padding: .45rem; }
button { font: inherit; color: white; background: var(--accent); border: 0; border-radius: .55rem; padding: .65rem .9rem; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (max-width: 720px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .conversation { padding: 1rem .8rem max(.8rem, env(safe-area-inset-bottom)); }
  h2 { display: block; }
}
