:root {
  color-scheme: light dark;
  background: var(--tg-theme-secondary-bg-color, #e9eeef);
  color: var(--tg-theme-text-color, #192a2c);
  font: 16px/1.5 system-ui, sans-serif;
  --surface: var(--tg-theme-bg-color, #fff);
  --line: var(--tg-theme-secondary-bg-color, #e3e9e8);
  --accent: var(--tg-theme-button-color, #146358);
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --muted: var(--tg-theme-hint-color, #516769);
}
* { box-sizing: border-box; }
body { margin: 0; }
main { width: min(100%, 510px); margin: auto; padding: 24px 16px 40px; }
h1 { margin: 0; font-size: 1.7rem; line-height: 1.15; letter-spacing: -.045em; }
h2 { margin-top: 0; font-size: 1.15rem; }
p { margin: .55rem 0 .9rem; }
header { margin: 10px 0 25px; }
header p, small, #saved { color: var(--muted); }
section, fieldset { min-width: 0; padding: 16px; margin: 0 0 18px; border-radius: 14px; background: var(--surface); border: 0; }
legend { padding: 0 8px; font-weight: 700; }
label { display: grid; gap: 6px; margin: 0 0 12px; }
input, select, button, .button { font: inherit; width: 100%; }
input, select { min-width: 0; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--muted); background: var(--surface); color: inherit; }
button, .button { display: block; padding: 10px 12px; border: 0; border-radius: 8px; text-align: center; text-decoration: none; background: var(--accent); color: var(--accent-text); font-weight: 700; cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
.secondary { background: var(--line); color: inherit; margin-top: 10px; }
.choice { display: flex; align-items: center; gap: 10px; overflow-wrap: anywhere; }
.choice input { width: 19px; height: 19px; accent-color: var(--accent); flex: 0 0 auto; }
.chat { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line); }
.chat small { margin-left: auto; }
#channels { max-height: 230px; overflow-y: auto; }
#qr { display: block; width: min(230px, 100%); margin: 12px auto; }
#error { background: var(--surface); color: var(--tg-theme-destructive-text-color, #a3342a); border-radius: 8px; padding: 10px; }
a { color: var(--tg-theme-link-color, #146358); }
[hidden] { display: none !important; }
@media (prefers-color-scheme: dark) {
  :root {
    background: var(--tg-theme-secondary-bg-color, #162122);
    color: var(--tg-theme-text-color, #eef8f7);
    --surface: var(--tg-theme-bg-color, #233031);
    --line: var(--tg-theme-secondary-bg-color, #334444);
    --accent: var(--tg-theme-button-color, #1c776b);
    --muted: var(--tg-theme-hint-color, #aac1bf);
  }
  #error { color: var(--tg-theme-destructive-text-color, #ffaba5); }
  a { color: var(--tg-theme-link-color, #80d9ca); }
}
