:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e2e4e9;
  --text: #1c1e21;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-contrast: #ffffff;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --unread-dot: #2563eb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

/* Login */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 {
  font-size: 18px;
  margin: 0 0 8px;
}
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
}
.login-card input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.login-card button {
  margin-top: 6px;
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 14px;
  cursor: pointer;
}
.login-card button:hover { opacity: 0.92; }

.error {
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  margin: 0;
}

/* App shell */
.app-view {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 52px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.topbar-title { font-weight: 600; }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-muted); }
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}

.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* Conversation list */
.conversation-list {
  width: 320px;
  flex: none;
  border-right: 1px solid var(--border);
  background: var(--panel);
  overflow-y: auto;
}
.list-empty {
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 13px;
}
.conversation-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  cursor: pointer;
}
.conversation-item:hover { background: #fafafa; }
.conversation-item.active { background: #eef2ff; }
.conversation-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 500;
}
.conversation-item-number {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--unread-dot);
  flex: none;
}
.suppressed-tag {
  font-size: 11px;
  color: var(--danger);
}

/* Thread pane */
.thread-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.thread-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
}
.thread-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.thread-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.thread-counterparty { font-weight: 600; }
.thread-number { font-size: 12px; color: var(--text-muted); }
.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
}
.badge-suppressed {
  background: var(--danger-bg);
  color: var(--danger);
}

.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.message-bubble {
  max-width: 60%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
}
.message-in {
  align-self: flex-start;
  background: #f1f2f5;
}
.message-out {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-contrast);
}
.message-meta {
  font-size: 11px;
  margin-top: 4px;
  opacity: 0.75;
}
.message-out .message-meta { color: rgba(255,255,255,0.85); }

.reply-form {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.reply-form textarea {
  flex: 1;
  resize: none;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.reply-form button {
  padding: 0 18px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
}
.reply-form button:disabled { opacity: 0.5; cursor: not-allowed; }
#reply-error { margin: 0 20px 10px; }
