:root {
  --bg: var(--tg-theme-bg-color, #0f1419);
  --text: var(--tg-theme-text-color, #e7e9ea);
  --hint: var(--tg-theme-hint-color, #8b98a5);
  --btn: var(--tg-theme-button-color, #1d9bf0);
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --secondary: var(--tg-theme-secondary-bg-color, #1a2332);
  --mine: #1b4f72;
  --other: #243447;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
}

#header {
  padding: 12px 16px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: var(--secondary);
}
#title { font-weight: 700; font-size: 16px; }
#subtitle { color: var(--hint); font-size: 12px; margin-top: 2px; }

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.mine {
  align-self: flex-end;
  background: var(--mine);
  border-bottom-right-radius: 4px;
}
.msg.other {
  align-self: flex-start;
  background: var(--other);
  border-bottom-left-radius: 4px;
}
.msg .meta {
  font-size: 11px;
  color: var(--hint);
  margin-bottom: 3px;
}
.msg .time {
  font-size: 10px;
  color: var(--hint);
  margin-top: 4px;
  text-align: right;
}

#composer {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: var(--secondary);
}
#input {
  flex: 1;
  border: none;
  border-radius: 20px;
  padding: 10px 14px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
#send {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 18px;
  cursor: pointer;
}

#error {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 72px;
  background: #5c1a1a;
  color: #fff;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 10;
}
.hidden { display: none !important; }

.empty {
  margin: auto;
  color: var(--hint);
  text-align: center;
  padding: 24px;
}
