/* The web client's look: the native client's colours, a phone first, then a wide screen. */
:root {
  --bg: #1e1f22;
  --panel: #2b2d31;
  --tile: #313338;
  --line: #3a3c42;
  --text: #f2f3f5;
  --muted: #a3a6ad;
  --accent: #2f9e5b;
  --accent-hi: #37b86a;
  --danger: #c0392b;
  --danger-hi: #d9493a;
  --radius: 12px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Inter", sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 0 16px;
  min-height: 44px;
  background: var(--tile);
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  background: var(--line);
}

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

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

button.danger {
  background: var(--danger);
  color: #fff;
}

button.danger:hover {
  background: var(--danger-hi);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

input {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: var(--panel);
  outline: none;
}

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

.status {
  min-height: 1.4em;
  color: var(--muted);
  font-size: 14px;
}

.status.error {
  color: #ff8a80;
}

/* ------------------------------------------------------------ start */

.start {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.card {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 24px 20px;
}

.card h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.card label {
  font-size: 14px;
  color: var(--muted);
}

.row {
  display: flex;
  gap: 8px;
}

/* The account's meetings: a row each, its title and when. */
.mine {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mine:empty {
  display: none;
}

.section {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

button.meeting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.meeting-row .title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.meeting-row .meta {
  font-size: 13px;
  color: var(--muted);
}

/* The access code: folded until asked for. */
.access {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.access summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
}

.access[open] {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.access-code {
  flex: 1;
  min-width: 0;
  align-self: center;
  font: 15px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace;
  overflow-wrap: anywhere;
}

.qr:empty {
  display: none;
}

.qr svg {
  shape-rendering: crispEdges;
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.or {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ------------------------------------------------------------ meeting */

/* As in Discord: the channels, the participants and the user on the left; the middle the chat, or in the
   voice channel its tiles, the chat beside them, and the bar of the voice channel below. */
.meeting {
  flex: 1;
  min-height: 0;
  display: flex;
}

.icon {
  flex: none;
  display: block;
}

/* A button that is an icon: quiet until the pointer is on it. */
button.icon-button {
  min-height: 40px;
  min-width: 40px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  color: var(--muted);
}

button.icon-button:hover {
  background: var(--tile);
  color: var(--text);
}

button.icon-button.danger,
button.icon-button.off {
  background: var(--danger);
  color: #fff;
}

button.icon-button.danger:hover,
button.icon-button.off:hover {
  background: var(--danger-hi);
}

button.icon-button.lit {
  background: var(--line);
  color: var(--text);
}

/* What cannot be undone, in the head and the lists: a red icon, red all over only under the pointer. */
.main-head button.icon-button.danger,
.member .acts button.icon-button.danger {
  background: transparent;
  color: var(--danger-hi);
}

.main-head button.icon-button.danger:hover,
.member .acts button.icon-button.danger:hover {
  background: var(--danger);
  color: #fff;
}

.only-phone {
  display: none !important;
}

.avatar {
  flex: none;
  width: var(--avatar, 64px);
  height: var(--avatar, 64px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--avatar, 64px) * 0.38);
  font-weight: 600;
  color: #fff;
}

/* ---- the left */

.side {
  width: 260px;
  flex: none;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.side-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 6px 8px 6px 16px;
  border-bottom: 1px solid var(--line);
}

.side-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-section {
  padding: 14px 8px 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

button.channel {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 8px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

button.channel span:not(.count) {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

button.channel:hover {
  background: var(--tile);
  color: var(--text);
}

button.channel.active {
  background: var(--line);
  color: var(--text);
}

.count {
  padding: 0 7px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
}

/* Who is in the voice channel, under it. */
.voice-users {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0 6px 26px;
}

.voice-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 14px;
}

.voice-user .name,
.member .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Who speaks: a green ring round the avatar. */
.voice-user.speaking .avatar,
.member.speaking .avatar {
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent-hi);
}

.member {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 4px 0 8px;
  border-radius: 8px;
}

.member:hover {
  background: var(--tile);
}

.member .mark {
  display: flex;
  color: var(--muted);
}

/* The host's buttons: under the pointer. */
.member .acts {
  display: none;
  gap: 2px;
}

.member:hover .acts,
.member:focus-within .acts {
  display: flex;
}

.member .acts button.icon-button,
.user-panel button.icon-button {
  min-width: 34px;
  min-height: 34px;
  padding: 0 7px;
}

.user-panel {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.user-panel .me {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: 4px;
  line-height: 1.25;
}

.user-panel .me b,
.user-panel .me small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-panel .me small {
  color: var(--muted);
  font-size: 12px;
}

/* ---- the middle */

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

.main-head {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding: 6px 8px 6px 16px;
  border-bottom: 1px solid var(--line);
}

.head-title {
  flex: 1;
  min-width: 0;
}

.head-title b {
  display: flex;
  align-items: center;
  gap: 6px;
}

.head-title b span,
.head-title small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.head-title small {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.main > .status {
  padding: 6px 16px;
  border-bottom: 1px solid var(--line);
}

.main > .status:empty {
  display: none;
}

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

.meeting.text-only .content {
  flex-direction: column;
}

/* The voice channel over the chat, for one not in it. */
.voice-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 16px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.banner-icon {
  display: flex;
  color: var(--accent-hi);
}

.banner-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.banner-text small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.join {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* The chat: the whole middle, or the panel beside the tiles. */
.chat {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.meeting.in-voice .chat {
  flex: none;
  width: 340px;
  border-left: 1px solid var(--line);
}

.meeting.in-voice.chat-closed .chat {
  display: none;
}

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

.msg .who {
  font-size: 13px;
  color: var(--muted);
}

.msg .text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.mine .who {
  color: var(--accent-hi);
}

.msg.pending .text {
  opacity: 0.6;
}

.typing {
  min-height: 1.4em;
  padding: 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.compose {
  display: flex;
  gap: 8px;
  padding: 8px 16px 12px;
}

.compose button.send {
  background: var(--accent);
  color: #fff;
  min-width: 44px;
  min-height: 44px;
}

.compose button.send:hover {
  background: var(--accent-hi);
}

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

/* ---- the tiles */

.people {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  padding: 12px;
  display: flex;
}

/* More tiles than fit: rows that scroll, the scrollbar always there (its coming and going would change
   the width the tiles are laid out in). */
.people.scrolls {
  overflow-y: scroll;
}

/* The tiles fill their pane: as many to a row and as large as layout.ts finds for how many there are, the
   last row in the middle. A crowd's grid, taller than the pane, starts at its top and scrolls (`margin:
   auto` centres only what fits). */
.grid {
  margin: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.tile {
  position: relative;
  flex: none;
  width: var(--tile-w, 220px);
  height: var(--tile-h, 160px);
  overflow: hidden;
  background: var(--tile);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  text-align: center;
}

.tile .name {
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tile .name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The host's buttons over the tile's corner; on small tiles only under the pointer, or once the tile is
   touched. */
.tile-acts {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
}

.tile-acts button.icon-button {
  min-width: 34px;
  min-height: 34px;
  padding: 0 7px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}

.tile-acts button.icon-button.danger {
  background: var(--danger);
}

.grid.compact .tile .tile-acts {
  display: none;
}

.grid.compact .tile:hover .tile-acts,
.grid.compact .tile.menu .tile-acts {
  display: flex;
}

/* Who speaks: a green frame, over the picture too. */
.tile.speaking {
  outline: 3px solid var(--accent-hi);
  outline-offset: -3px;
}

/* A tile with a picture: the video fills it, the name over it. */
.tile.video {
  padding: 0;
  justify-content: flex-end;
  background: #000;
}

.tile.video .video-box {
  position: absolute;
  inset: 0;
}

.tile.video video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile.video .name {
  position: relative;
  align-self: flex-start;
  margin: 8px;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
}

video.mirror {
  transform: scaleX(-1);
}

/* The bar of the voice channel: round buttons, leaving it red. */
.control-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.control-bar button.icon-button {
  min-width: 52px;
  min-height: 52px;
  border-radius: 26px;
  background: var(--tile);
  color: var(--text);
}

.control-bar button.icon-button:hover {
  background: var(--line);
}

.control-bar button.icon-button.lit {
  background: var(--text);
  color: var(--bg);
}

.control-bar button.icon-button.off,
.control-bar button.icon-button.danger {
  background: var(--danger);
  color: #fff;
}

.control-bar button.icon-button.wide {
  min-width: 72px;
}

/* ---- a phone: one pane at a time; the participants over the page. */
@media (max-width: 720px) {
  .only-phone {
    display: inline-flex !important;
  }

  .side {
    position: fixed;
    inset: 0;
    z-index: 10;
    width: auto;
    display: none;
    border-right: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }

  .meeting.pane-members .side {
    display: flex;
  }

  .main-head {
    padding-left: 4px;
  }

  .head-title small {
    display: none;
  }

  .voice-banner {
    margin: 8px 8px 0;
    flex-wrap: wrap;
  }

  .voice-banner button.join {
    flex: 1 0 100%;
    justify-content: center;
    white-space: normal;
  }

  .messages {
    padding: 12px;
  }

  .compose {
    padding: 8px 8px 10px;
  }

  .meeting.in-voice .chat {
    flex: 1;
    width: auto;
    border-left: 0;
  }

  .meeting.in-voice.chat-closed .chat {
    display: flex;
  }

  .meeting.in-voice.pane-voice .chat,
  .meeting.in-voice.pane-chat .people {
    display: none;
  }

  /* No pointer to hover with: the host's buttons always there. */
  .member .acts {
    display: flex;
  }

  .control-bar {
    gap: 10px;
    padding: 8px;
  }
}
