:root {
  color-scheme: light;
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1d1d1b; --muted: #6b6a65; --line: #e4e2db;
  --accent: #1f6f5c; --accent-ink: #ffffff; --bot: #ffffff; --me: #1f6f5c; --me-ink: #ffffff;
  --warn: #9a3b2e; --chip: #eef3f1;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #151614; --panel: #1e201d; --ink: #ecebe6; --muted: #a09f98; --line: #2f322d;
    --accent: #4fb39a; --accent-ink: #0f1311; --bot: #1e201d; --me: #2c6b5c; --me-ink: #f2f7f5;
    --warn: #e08a7b; --chip: #243029;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151614; --panel: #1e201d; --ink: #ecebe6; --muted: #a09f98; --line: #2f322d;
  --accent: #4fb39a; --accent-ink: #0f1311; --bot: #1e201d; --me: #2c6b5c; --me-ink: #f2f7f5;
  --warn: #e08a7b; --chip: #243029;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }

/* landing */
.landing { max-width: 560px; margin: 0 auto; padding: 12vh 20px 40px; }
.landing h1 { font-size: 30px; line-height: 1.2; margin: 0 0 16px; letter-spacing: -0.01em; }
.landing p { color: var(--muted); margin: 0 0 14px; }
.landing ul { padding-left: 20px; color: var(--muted); margin: 0 0 28px; }
.yandex { display: inline-flex; align-items: center; gap: 10px; background: #000; color: #fff; border: 0;
  border-radius: 10px; padding: 12px 20px; font-weight: 600; text-decoration: none; }
.yandex .ya { background: #fc3f1d; color: #fff; border-radius: 50%; width: 22px; height: 22px; display: grid;
  place-items: center; font-size: 14px; font-weight: 700; }
.err { color: var(--warn); }
.logins { display: flex; flex-wrap: wrap; gap: 10px; }
.google { display: inline-flex; align-items: center; gap: 10px; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 20px; font-weight: 600; text-decoration: none; }
.google .g { color: #4285f4; font-weight: 800; width: 22px; text-align: center; }
.doc { max-width: 680px; margin: 0 auto; padding: 28px 16px 60px; }
.fine { font-size: 13px; color: var(--muted); margin-top: 28px; }

/* app */
.app { display: grid; grid-template-rows: auto 1fr auto; height: 100%; max-width: 820px; margin: 0 auto; }
header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px;
  border-bottom: 1px solid var(--line); }
header .brand { font-weight: 650; }
header .actions { display: flex; gap: 8px; align-items: center; }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; }
.feed { overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 86%; padding: 11px 14px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.assistant { background: var(--bot); border: 1px solid var(--line); align-self: flex-start; border-top-left-radius: 4px; }
.msg.user { background: var(--me); color: var(--me-ink); align-self: flex-end; border-top-right-radius: 4px; }
.msg .md p { margin: 0 0 8px; } .msg .md p:last-child { margin-bottom: 0; }
.msg .md ul { margin: 4px 0 8px; padding-left: 20px; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.buttons button { background: var(--chip); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; }
.buttons button:hover { border-color: var(--accent); }
.rate { margin-top: 8px; display: flex; gap: 6px; }
.rate button { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; color: var(--muted); }
.rate button.on { border-color: var(--accent); color: var(--accent); }
.typing { color: var(--muted); font-style: italic; align-self: flex-start; padding: 0 4px; }
.composer { padding: 10px 16px 16px; border-top: 1px solid var(--line); background: var(--bg); }
.composer form { display: flex; gap: 8px; }
.composer input[type=text], .composer input[type=password] { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; }
.composer button.send { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 12px; padding: 0 18px; font-weight: 600; }
.composer .hint { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.composer label.file { display: inline-block; background: var(--accent); color: var(--accent-ink); border-radius: 12px; padding: 12px 18px; font-weight: 600; cursor: pointer; }
.composer .switch { font-size: 13px; margin-top: 6px; }
.composer .switch button { background: none; border: 0; color: var(--accent); padding: 0; text-decoration: underline; }

/* drawer */
.drawer { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: none; }
.drawer.open { display: block; }
.drawer .panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(420px, 100%); background: var(--panel);
  padding: 20px; overflow-y: auto; border-left: 1px solid var(--line); }
.drawer h2 { font-size: 18px; margin: 0 0 12px; } .drawer h3 { font-size: 15px; margin: 22px 0 8px; }
.src { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.src .row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.src small { color: var(--muted); }
.src .st-error { color: var(--warn); }
.danger { color: var(--warn); border-color: var(--warn); }

/* usage */
.usage { max-width: 1000px; margin: 0 auto; padding: 20px 16px 60px; }
.usage table { border-collapse: collapse; width: 100%; margin: 6px 0 22px; font-size: 14px; }
.usage th, .usage td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.usage td.n, .usage th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 22px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.tile b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 13px; }
.bar { height: 8px; background: var(--accent); border-radius: 4px; }
@media (max-width: 520px) { .msg { max-width: 94%; } }

/* theme switch */
.theme-toggle { font-size: 13px; white-space: nowrap; }
.theme-toggle.floating { position: fixed; right: 12px; bottom: 12px; z-index: 50; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
