:root {
  --bg: #f6f7f9; --card: #ffffff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --accent: #2563eb; --accent-text: #ffffff; --bonus: #0f9d58; --bonus-bg: #e7f6ee; --warn: #b45309;
  --bad: #c62828; --bubble: #eef2ff; --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --card: #1b2029; --text: #e7e9ee; --muted: #9aa3b2; --line: #2b3240;
    --accent: #4f8bff; --bonus: #3ecf8e; --bonus-bg: #173327; --warn: #f0b049; --bad: #ff6b6b; --bubble: #232c40;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 0; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; margin-right: auto; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border-radius: 999px; padding: 3px 10px; font-size: 13px; background: var(--bg); border: 1px solid var(--line);
  white-space: nowrap; }
.chip.bonus { background: var(--bonus-bg); color: var(--bonus); border-color: transparent; }
nav.tabs { display: flex; gap: 4px; overflow-x: auto; }
nav.tabs button { border: 0; background: none; color: var(--muted); padding: 8px 12px; font: inherit; cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap; }
nav.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
main { padding: 16px 0 40px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  margin-bottom: 14px; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
input, textarea, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; max-width: 100%; }
textarea { width: 100%; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button.btn, a.btn { display: inline-block; font: inherit; border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer;
  background: var(--accent); color: var(--accent-text); }
button.btn.sec { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
button.btn:disabled { opacity: .55; cursor: default; }
button.link { border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.err { color: var(--bad); }
.ok { color: var(--bonus); }
.hidden { display: none !important; }
.notice { border-left: 4px solid var(--warn); }
/* чат */
.chat-layout { display: grid; grid-template-columns: 220px 1fr; gap: 14px; }
.chat-list { max-height: 70vh; overflow: auto; padding: 8px; }
.chat-list .item { padding: 6px 8px; border-radius: 8px; cursor: pointer; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 14px; }
.chat-list .item.on, .chat-list .item:hover { background: var(--bg); }
.msgs { min-height: 40vh; max-height: 62vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  padding-bottom: 6px; }
.msg { padding: 8px 12px; border-radius: 12px; max-width: 92%; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--bubble); white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--bg); }
.msg .price { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.msg pre { background: var(--card); padding: 8px; border-radius: 8px; overflow-x: auto; }
.msg p { margin: .3em 0; }
.composer { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 200px; }
/* картинки, песни */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tile { background: var(--bg); border-radius: 10px; overflow: hidden; }
.tile img { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; cursor: zoom-in; }
.tile .cap { padding: 6px 8px; font-size: 13px; }
.song { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.song audio { width: 100%; margin-top: 6px; }
.lyrics { white-space: pre-wrap; font-size: 14px; max-height: 260px; overflow: auto; background: var(--bg);
  padding: 8px; border-radius: 8px; }
/* расходы */
.bar { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: var(--bonus); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px; }
.stat b { display: block; font-size: 18px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 6px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; white-space: nowrap; }
.tbl { overflow-x: auto; }
.tag { font-size: 12px; border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.tag.bonus { background: var(--bonus-bg); color: var(--bonus); }
.tag.paid { background: var(--bubble); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center;
  justify-content: center; z-index: 20; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; }
@media (max-width: 700px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-list { max-height: 160px; }
  .msgs { max-height: 55vh; }
}
