:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #687383;
  --line: #d8dee7;
  --panel: #ffffff;
  --bg: #edf1f5;
  --accent: #1976d2;
  --accent-dark: #125aa0;
  --danger: #d64242;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.shell {
  min-height: 100vh;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand p {
  color: var(--muted);
  margin-top: 4px;
}

.mark,
.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #1f8a70;
  color: white;
  font-weight: 700;
}

.panel {
  width: min(420px, 100%);
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(27, 39, 51, 0.08);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.tab,
.secondary,
.composer button,
.account button,
.callTop button {
  height: 38px;
  border-radius: 6px;
  background: #e7ebf0;
  color: var(--ink);
}

.tab.active,
.primary {
  background: var(--accent);
  color: white;
}

label {
  display: grid;
  gap: 7px;
  margin: 12px 0;
  color: var(--muted);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  background: white;
  color: var(--ink);
}

textarea {
  resize: none;
  min-height: 42px;
  max-height: 120px;
}

.primary {
  width: 100%;
  height: 42px;
  border-radius: 6px;
  margin-top: 10px;
}

.primary:hover {
  background: var(--accent-dark);
}

.error {
  min-height: 20px;
  color: var(--danger);
}

.app {
  display: grid;
  grid-template-columns: 310px 1fr;
  height: 100vh;
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto 1fr;
  border-right: 1px solid var(--line);
  background: #f8fafc;
}

.account {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.account span,
.chatHead span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.search {
  padding: 12px;
}

.users {
  overflow: auto;
}

.user {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  background: transparent;
  border-top: 1px solid #edf0f4;
}

.user.active {
  background: #e8f2ff;
}

.user .avatar {
  width: 36px;
  height: 36px;
  font-size: 14px;
}

.chat {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  background: white;
}

.chatHead,
.callTop {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: white;
}

.chatHead .secondary {
  width: 96px;
}

.messages {
  overflow: auto;
  padding: 18px;
  background: #f5f7fa;
}

.empty {
  margin: 40px auto;
  color: var(--muted);
  text-align: center;
}

.msg {
  display: flex;
  margin: 10px 0;
}

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

.bubble {
  max-width: min(620px, 78%);
  padding: 10px 12px;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--line);
}

.mine .bubble {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

.bubble small {
  display: block;
  margin-top: 6px;
  color: inherit;
  opacity: 0.72;
  font-size: 12px;
}

.bubble img,
.bubble video {
  display: block;
  max-width: 280px;
  max-height: 240px;
  border-radius: 6px;
  margin-top: 8px;
}

.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: white;
}

#fileInput {
  display: none;
}

.composer .primary {
  width: 76px;
  margin: 0;
}

.composer #attachBtn {
  width: 68px;
}

.call {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #111820;
  color: white;
}

.callTop {
  background: #17202a;
  border-color: #263544;
}

.callTop button {
  padding: 0 12px;
  margin-left: 8px;
}

.danger {
  background: var(--danger) !important;
  color: white !important;
}

.videos {
  position: relative;
  min-height: 0;
}

video {
  background: #05080b;
}

#remoteVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#localVideo {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: min(260px, 34vw);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
  }

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

  .chat {
    height: 60vh;
  }

  .composer {
    grid-template-columns: auto 1fr;
  }

  .composer .primary {
    grid-column: 1 / -1;
    width: 100%;
  }
}
