:root {
  --bg: #111315;
  --panel: #181b1f;
  --panel-2: #1f2328;
  --line: #2b3138;
  --text: #e6e9ed;
  --muted: #98a2ad;
  --accent: #4f8cff;
  --accent-2: #356fe0;
  --outgoing: #242a31;
}

* {
  box-sizing: border-box;
}

[x-cloak] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
}

button,
input {
  font: inherit;
}

button,
input {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}

button {
  cursor: pointer;
}

.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.login-card h1,
.login-card p {
  margin: 0;
}

.login-card p {
  color: var(--muted);
}

.login-card label {
  display: grid;
  gap: 8px;
}

.login-card input,
.composer input {
  width: 100%;
  padding: 12px;
}

.login-card button,
.composer button {
  padding: 12px;
}

.error {
  color: #ff8d8d;
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.small-text {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.secondary {
  padding: 8px 10px;
}

.filters {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.filters button {
  padding: 8px 10px;
}

.filters button.active,
.toggle.on {
  border-color: var(--accent);
  background: var(--accent-2);
  color: #ffffff;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 8px;
  overflow-y: auto;
}

.group-dropdown {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.group-builder {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.group-builder input {
  width: 100%;
  padding: 10px;
}

.group-builder-actions {
  display: flex;
  gap: 8px;
}

.chat-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
}

.chat-item.active {
  border-color: var(--line);
  background: var(--panel-2);
}

.chat-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-name {
  font-weight: 700;
}

.chat-preview,
.chat-subtitle,
.meta {
  color: var(--muted);
}

.chat-preview {
  font-size: 13px;
}

.small-badge {
  padding: 2px 6px;
  font-size: 11px;
  border: 1px solid var(--line);
  color: var(--accent);
}

.chat {
  min-width: 0;
  min-height: 0;
}

.chat-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-title {
  font-size: 18px;
  font-weight: 700;
}

.chat-subtitle {
  margin-top: 4px;
  font-size: 13px;
  text-transform: lowercase;
}

.toggle {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  white-space: nowrap;
}

.compact {
  padding: 8px 10px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  background: #13161a;
}

.message {
  display: flex;
}

.message.outbound {
  justify-content: flex-end;
}

.bubble {
  max-width: 680px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.bubble.deleted {
  opacity: 0.75;
}

.message.outbound .bubble {
  background: var(--outgoing);
}

.meta {
  display: flex;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 12px;
}

.reply-block {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
  padding-left: 10px;
  border-left: 2px solid var(--accent);
  font-size: 12px;
  color: var(--muted);
}

.message-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.attachment {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent);
  text-decoration: none;
}

.message-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.message-actions.inline {
  margin-top: 0;
}

.linkish {
  padding: 4px 8px;
  font-size: 12px;
}

.danger {
  color: #ff8d8d;
}

.edit-box {
  display: grid;
  gap: 10px;
}

.edit-box input {
  width: 100%;
  padding: 10px;
}

.composer-tools {
  display: grid;
  gap: 10px;
  padding: 12px 20px 0;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.emoji-row,
.file-row,
.reply-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.emoji-row button {
  padding: 6px 10px;
}

.reply-banner {
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #15181c;
  color: var(--muted);
}

.file-button {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  cursor: pointer;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.composer {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 12px;
  padding: 16px 20px;
  background: var(--panel);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 100vh;
  color: var(--muted);
}

@media (max-width: 800px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    max-height: 34vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat-shell,
  .empty-state {
    height: 66vh;
    min-height: 0;
  }

  .reply-banner {
    align-items: flex-start;
    flex-direction: column;
  }
}
