:root {
  --bg: #0b141a;
  --panel: #111b21;
  --sidebar: #1e2429;
  --bubble-mine: #005c4b;
  --bubble-other: #202c33;
  --accent: #5865f2;
  --text: #e9edef;
  --muted: #8696a0;
  --divider: #2a3942;
  --input: #2a3942;
  --danger: #f04747;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: flex;
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.sidebar {
  width: 320px;
  min-width: 260px;
  background: var(--panel);
  border-right: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--divider);
}

.logo {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.btn-lang {
  background: var(--input);
  color: var(--text);
  border: none;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-lang:hover {
  filter: brightness(1.08);
}

.sections {
  flex: 1;
  overflow-y: auto;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.section-label.discord {
  color: var(--accent);
}

.thread {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.thread:hover {
  background: rgba(255, 255, 255, 0.04);
}

.thread.active {
  background: rgba(88, 101, 242, 0.12);
  border-left-color: var(--accent);
}

.thread-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.thread-body {
  flex: 1;
  min-width: 0;
}

.thread-title {
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.thread-preview {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.main-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.main-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-head {
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-head h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.chat-head .sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.row.mine {
  justify-content: flex-end;
}

.bubble-wrap {
  max-width: 82%;
}

.bubble {
  border-radius: 12px;
  padding: 8px 12px;
  position: relative;
}

.bubble.mine {
  background: var(--bubble-mine);
  border-bottom-right-radius: 2px;
}

.bubble.other {
  background: var(--bubble-other);
  border-bottom-left-radius: 2px;
}

.bubble .sender {
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
}

.bubble .body {
  font-size: 15px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble .hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.bubble .time {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--input);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn.primary {
  background: var(--accent);
  color: #fff;
}

.icon-btn:hover {
  filter: brightness(1.06);
}

.icon-btn.listening {
  background: rgba(240, 71, 71, 0.25);
  color: var(--danger);
}

.speak-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.speak-btn:hover {
  color: var(--text);
}

.composer {
  background: var(--panel);
  padding: 8px 10px 10px;
  border-top: 1px solid var(--divider);
}

.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  border-radius: 22px;
  border: none;
  background: var(--input);
  color: var(--text);
  padding: 12px 16px;
  font-size: 16px;
  font-family: inherit;
}

.composer textarea:focus {
  outline: 2px solid rgba(88, 101, 242, 0.35);
  outline-offset: 0;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  overflow: auto;
  background: var(--sidebar);
  border-radius: 16px 16px 0 0;
  padding: 16px 20px 24px;
  border: 1px solid var(--divider);
  border-bottom: none;
}

.modal-panel h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.modal-hint {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
}

.lang-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lang-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-list li:last-child {
  border-bottom: none;
}

.lang-list .name {
  font-weight: 600;
}

.lang-list .native {
  font-size: 13px;
  color: var(--muted);
}

.lang-list li.active .check {
  color: var(--accent);
}

@media (max-width: 720px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 38vh;
    border-right: none;
    border-bottom: 1px solid var(--divider);
  }
}
