:root {
  --navy: #102a43;
  --navy-2: #243b53;
  --accent: #486581;
  --bg: #eef2f6;
  --page: #cdd7e2;
  --bubble-in: #ffffff;
  --bubble-out: #cfe0f0;
  --me: #2f7a4f;
  --danger: #d64545;
  --text: #102a43;
  --muted: #627d98;
  --divider: rgba(16, 42, 67, 0.08);
  --hint-bg: #fff7e6;
  --hint-br: #f5e0b0;
  --hint-fg: #8a6d2f;
  --sidebar-width: 360px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--page);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  height: 100%;
}

/* Two-pane layout */
.layout {
  display: flex;
  height: 100vh;
  max-width: 1100px;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.14);
  overflow: hidden;
}

.sidebar {
  flex: 0 0 var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fff;
  border-right: 1px solid var(--divider);
}

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

.main-empty {
  align-items: center;
  justify-content: center;
}

.empty-pane {
  text-align: center;
  color: var(--muted);
  padding: 20px;
}

.empty-logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 8px;
}

/* Top bar */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--navy);
  color: #fff;
  padding: 14px 16px;
}

.topbar-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
  flex: 1;
}

.topbar-me {
  text-decoration: none;
}

/* Avatars */
.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 19px;
  font-weight: 600;
  background: var(--accent);
}

.avatar.sm {
  width: 30px;
  height: 30px;
  font-size: 13px;
}

.avatar.you {
  background: var(--me);
}

.lock {
  font-size: 0.8em;
}

/* Channel list */
.chan-list {
  flex: 1 1 auto;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
  background: #fff;
}

.chan-empty,
.chat-empty {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

.chan-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  text-decoration: none;
  color: inherit;
}

.chan-row:hover {
  background: var(--bg);
}

.chan-row.active {
  background: var(--bg);
}

.chan-main {
  flex: 1 1 auto;
  min-width: 0;
}

.chan-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.chan-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.chan-time {
  font-size: 11px;
  color: var(--muted);
  flex: 0 0 auto;
}

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

/* Chat */
.chat-head {
  gap: 10px;
}

.back {
  color: #fff;
  text-decoration: none;
  font-size: 26px;
  line-height: 1;
  margin-right: -2px;
}

.chat-head-main {
  min-width: 0;
}

.chat-head-name {
  font-size: 16px;
  font-weight: 600;
}

.chat-head-sub {
  font-size: 11px;
  opacity: 0.75;
  margin-top: 1px;
}

.chat {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-more {
  text-align: center;
  margin: 4px 0;
}

.chat-more a {
  display: inline-block;
  background: rgba(16, 42, 67, 0.07);
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 12px;
}

.msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 72%;
}

.msg.out {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.bubble {
  background: var(--bubble-in);
  border-radius: 14px;
  padding: 7px 11px 5px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}

.msg.out .bubble {
  background: var(--bubble-out);
}

.b-name {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 2px;
}

.b-text {
  font-size: 14px;
  color: #1a1a1a;
  line-height: 1.35;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.b-time {
  font-size: 10px;
  color: #8a97a3;
  text-align: right;
  margin-top: 2px;
}

/* Compose bar */
.compose {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  background: #dde4ec;
  border-top: 1px solid var(--divider);
}

.compose-input {
  flex: 1;
  background: #fff;
  border: none;
  border-radius: 20px;
  padding: 11px 15px;
  font-size: 14px;
  color: var(--text);
  outline: none;
}

.compose-send {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 18px;
  flex: 0 0 auto;
  cursor: pointer;
}

/* Desktop: hide the mobile back arrow, keep both panes */
@media (min-width: 768px) {
  .back {
    display: none;
  }
}

/* Phone: one pane at a time */
@media (max-width: 767px) {
  .layout {
    max-width: none;
    box-shadow: none;
  }
  .sidebar {
    flex: 1 1 auto;
    border-right: none;
  }
  .view-home .main {
    display: none;
  }
  .view-chat .sidebar {
    display: none;
  }
  .msg {
    max-width: 82%;
  }
}

/* Centered card screens (name, unlock, error) */
.centered {
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
}

.brand {
  color: #cfe0f0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-bottom: 18px;
}

.card-form {
  background: #fff;
  border-radius: 18px;
  padding: 28px 24px;
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.big-avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 34px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.big-avatar.you {
  background: var(--me);
}

.big-avatar.lock {
  background: var(--accent);
}

.card-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
}

.card-sub {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 18px;
}

.field {
  width: 100%;
  background: #f0f3f7;
  border: 1px solid #d6dde6;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 14px;
  outline: none;
}

.field:focus {
  border-color: var(--accent);
}

.btn {
  width: 100%;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.hint {
  background: var(--hint-bg);
  border: 1px solid var(--hint-br);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--hint-fg);
  text-align: left;
  margin-bottom: 14px;
}

.hint b {
  color: #6b531f;
}

.form-error {
  background: #fdeaea;
  border: 1px solid #f3c2c2;
  color: var(--danger);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

.card-link {
  display: inline-block;
  margin-top: 14px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}
