:root {
  color-scheme: dark;
  --bg: #1d1410;
  --panel: #2b1e17;
  --panel-2: #36261d;
  --line: #5a4030;
  --gold: #f2c45a;
  --gold-soft: #e7b45222;
  --text: #f6eadb;
  --muted: #c4ad94;
  --staff: #3a2c22;
  --player: #6d4a1f;
  --danger: #ff8f7a;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(12px, env(safe-area-inset-left));
}

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.bar-close {
  width: 44px;
  height: 44px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-2);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.bar-title { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.bar-title strong { font-size: 19px; color: var(--gold); letter-spacing: 0.02em; }
.bar-title span { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: 6px; }
.tab {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab[aria-selected="true"] { background: var(--gold); border-color: var(--gold); color: #2a1a08; font-weight: 700; }
.badge {
  display: inline-block;
  min-width: 20px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e2483a;
  color: #fff;
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.panel { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 0; }

.faq-search {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.faq-list { flex: 1; overflow-y: auto; margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.faq { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.faq summary { padding: 13px 14px; cursor: pointer; font-weight: 600; list-style-position: inside; }
.faq[open] summary { color: var(--gold); }
.faq p { margin: 0; padding: 0 14px 14px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.faq-more { margin: 10px 0 0; color: var(--muted); }
.link { padding: 0; border: 0; background: none; color: var(--gold); text-decoration: underline; cursor: pointer; }

.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 8px; }
.msg { max-width: min(78%, 640px); padding: 9px 12px; border-radius: var(--radius); overflow-wrap: anywhere; }
.msg p { margin: 2px 0 0; white-space: pre-wrap; }
.msg-meta { display: block; font-size: 12px; color: var(--muted); }
.msg-player { align-self: flex-end; background: var(--player); border-bottom-right-radius: 4px; }
.msg-player .msg-meta { color: #f0d5a8; }
.msg-staff { align-self: flex-start; background: var(--staff); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-staff .msg-meta { color: var(--gold); }
.msg-system { align-self: center; max-width: 92%; background: var(--gold-soft); color: var(--muted); font-size: 13px; text-align: center; }
.note { margin: 24px auto; max-width: 520px; color: var(--muted); text-align: center; }

.composer { display: flex; gap: 10px; align-items: flex-end; padding-top: 10px; border-top: 1px solid var(--line); }
.composer textarea {
  flex: 1;
  min-height: 48px;
  max-height: 140px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  resize: vertical;
}
.composer-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.counter { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.send {
  min-width: 96px;
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  background: var(--gold);
  color: #2a1a08;
  font-weight: 700;
  cursor: pointer;
}
.send:disabled { opacity: 0.6; cursor: default; }
.status { min-height: 1.4em; margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.status.is-error { color: var(--danger); }

@media (max-width: 560px) {
  .tabs { width: 100%; }
  .tab { flex: 1; }
  .msg { max-width: 88%; }
}
