/* Room chat. Marketing pages are styled elsewhere. */

.czx-room-intro {
  box-sizing: border-box;
  height: 56px;
  padding: 6px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
}

.czx-room-intro h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 750;
  line-height: 1.2;
  letter-spacing: -0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.czx-room-intro p,
.czx-room-intro #czatix-lead {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body:has(#czatix-app) {
  height: 100dvh;
  overflow: hidden;
}

#czatix-app {
  box-sizing: border-box;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 240px;
  grid-template-rows: minmax(0, 1fr);
  height: calc(100dvh - 120px);
  max-height: calc(100dvh - 120px);
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  border-top: 1px solid var(--line);
}

#czatix-app *,
#czatix-app *::before,
#czatix-app *::after {
  box-sizing: border-box;
}

#czatix-app button,
#czatix-app input,
#czatix-app textarea {
  font-family: inherit;
  color: inherit;
}

#czatix-app button {
  cursor: pointer;
}

#czatix-app button:disabled {
  opacity: 0.55;
  cursor: default;
}

#czatix-app [hidden] {
  display: none !important;
}

#czatix-app :focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

/* Side columns scroll on their own. The page does not. */
#czatix-app > .czx-drawer,
#czatix-app > .czx-side {
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--paper);
  -webkit-overflow-scrolling: touch;
}

#czatix-app > .czx-drawer:first-of-type,
#czatix-app > .czx-side:first-of-type {
  grid-column: 1;
  border-right: 1px solid var(--line);
}

#czatix-app > .czx-drawer:last-of-type,
#czatix-app > .czx-side:last-of-type {
  grid-column: 3;
  border-left: 1px solid var(--line);
}

#czatix-app > .czx-main,
#czatix-app > section,
#czatix-app > :has(> .czx-compose),
#czatix-app > :has(> .czx-log) {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

#czatix-app .czx-search,
#czatix-app .czx-side input[type="search"],
#czatix-app .czx-drawer input[type="search"] {
  display: block;
  width: auto;
  margin: 12px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  position: sticky;
  top: 0;
  z-index: 1;
}

#czatix-app .czx-search::placeholder,
#czatix-app input[type="search"]::placeholder,
#czatix-app textarea::placeholder {
  color: var(--muted);
}

#czatix-app .czx-group {
  margin: 0;
  padding: 14px 14px 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.06em;
  line-height: 1.3;
  text-transform: uppercase;
}

#czatix-app .czx-room,
#czatix-app .czx-person {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 16px);
  min-height: 44px;
  margin: 1px 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  text-decoration: none;
  font-size: 15px;
  line-height: 1.3;
}

#czatix-app .czx-room.on,
#czatix-app .czx-person:hover,
#czatix-app .czx-room:hover {
  background: var(--soft);
}

#czatix-app .czx-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
}

#czatix-app .czx-log,
#czatix-app [role="log"] {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

#czatix-app .czx-msg {
  align-self: flex-start;
  max-width: min(78%, 520px);
  margin: 0;
  padding: 8px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 6px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

#czatix-app .czx-msg.mine {
  align-self: flex-end;
  background: var(--soft);
  border-color: var(--blue);
  border-radius: 16px 16px 6px 16px;
}

#czatix-app .czx-msg .who,
#czatix-app .czx-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
}

#czatix-app .czx-msg time {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

#czatix-app .czx-msg .text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.45;
}

#czatix-app .czx-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.45;
  text-transform: uppercase;
  vertical-align: middle;
}

#czatix-app .czx-img {
  display: block;
  width: auto;
  max-width: min(280px, 100%);
  height: auto;
  margin-top: 6px;
  border-radius: 12px;
  background: var(--bg);
}

#czatix-app .czx-empty {
  margin: auto;
  max-width: 280px;
  padding: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

#czatix-app .czx-pill {
  position: absolute;
  left: 50%;
  bottom: 76px;
  z-index: 4;
  transform: translateX(-50%);
  min-height: 36px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 750;
  box-shadow: var(--shadow);
}

#czatix-app .czx-compose {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 12px;
  background: var(--paper);
  border-top: 1px solid var(--line);
}

#czatix-app .czx-compose-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
}

#czatix-app .czx-status {
  flex: 1 0 100%;
  min-height: 0;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
}

#czatix-app .czx-status:empty {
  display: none;
}

#czatix-app .czx-compose textarea {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 12px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
}

#czatix-app .czx-attach,
#czatix-app .czx-send {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
}

#czatix-app .czx-attach {
  width: 44px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

#czatix-app .czx-attach:hover {
  background: var(--soft);
}

#czatix-app .czx-send {
  padding: 0 14px;
  border: 0;
  background: var(--blue);
  color: #fff;
  font-size: 15px;
  font-weight: 750;
}

#czatix-app .czx-send:hover {
  background: color-mix(in srgb, var(--blue) 86%, #000);
}

#czatix-app .czx-attach svg,
#czatix-app .czx-send svg {
  width: 20px;
  height: 20px;
  display: block;
}

#czatix-app .czx-compose input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

#czatix-app > .czx-gate,
#czatix-app .czx-gate {
  position: absolute;
  z-index: 60;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 32px));
  margin: 0;
  padding: 28px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

#czatix-app > .czx-gate::before,
#czatix-app .czx-gate::before {
  content: "";
  position: absolute;
  inset: -100vmax;
  z-index: -1;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
}

#czatix-app .czx-gate h1,
#czatix-app .czx-gate h2 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

#czatix-app .czx-gate p {
  margin: 0 0 14px;
  color: var(--muted);
}

#czatix-app .czx-gate input {
  display: block;
  width: 100%;
  min-height: 48px;
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  font-size: 16px;
}

#czatix-app .czx-gate button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-size: 16px;
  font-weight: 750;
}

#czatix-app .czx-ban {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 32px 20px;
  background: var(--bg);
  color: var(--ink);
  text-align: center;
  box-shadow: inset 0 3px 0 var(--danger);
}

#czatix-app .czx-ban h1,
#czatix-app .czx-ban h2,
#czatix-app .czx-ban p {
  width: min(420px, 100%);
  margin-left: auto;
  margin-right: auto;
}

#czatix-app .czx-ban h1,
#czatix-app .czx-ban h2 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 1.5rem;
  letter-spacing: -0.03em;
}

#czatix-app .czx-ban p {
  margin-top: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

@media (max-width: 820px) {
  #czatix-app {
    grid-template-columns: minmax(0, 1fr);
  }

  #czatix-app > .czx-main,
  #czatix-app > section,
  #czatix-app > :has(> .czx-compose),
  #czatix-app > :has(> .czx-log) {
    grid-column: 1;
  }

  #czatix-app > .czx-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    grid-column: auto;
    width: min(320px, 88vw);
    border-right: 1px solid var(--line);
    border-left: 0;
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  #czatix-app > .czx-drawer:last-of-type,
  #czatix-app > .czx-drawer.czx-people,
  #czatix-app > .czx-drawer[data-drawer="people"] {
    left: auto;
    right: 0;
    border-right: 0;
    border-left: 1px solid var(--line);
    transform: translateX(105%);
  }

  #czatix-app > .czx-drawer.open {
    transform: none;
  }

  #czatix-app:has(> .czx-drawer.open)::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(14, 21, 37, 0.38);
  }

  #czatix-app .czx-msg {
    max-width: 88%;
  }

  #czatix-app .czx-compose {
    padding-bottom: calc(10px + var(--safe-b));
  }

  #czatix-app .czx-pill {
    bottom: calc(76px + var(--safe-b));
  }
}

@media (hover: hover) and (pointer: fine) {
  #czatix-app .czx-room:hover,
  #czatix-app .czx-person:hover {
    background: var(--soft);
  }
}

/* The script nests columns inside .czx-shell > .czx-body. */
#czatix-app {
  display: block;
  height: calc(100dvh - 120px);
}

#czatix-app .czx-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

#czatix-app .czx-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 52px;
  padding: 8px 12px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

#czatix-app .czx-bar-title {
  flex: 1;
  min-width: 0;
}

#czatix-app .czx-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#czatix-app .czx-count {
  color: var(--muted);
  font-size: 12px;
}

#czatix-app .czx-body {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 240px;
  flex: 1;
  min-height: 0;
}

#czatix-app .czx-rooms,
#czatix-app .czx-people,
#czatix-app .czx-main {
  min-height: 0;
  min-width: 0;
  overflow: auto;
  background: var(--paper);
}

#czatix-app .czx-main {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

#czatix-app .czx-log {
  flex: 1;
  overflow: auto;
}

#czatix-app .czx-navbtn {
  display: none;
}

@media (max-width: 820px) {
  #czatix-app .czx-body {
    display: block;
    position: relative;
  }

  #czatix-app .czx-navbtn {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 10px;
    border: 0;
    border-radius: 10px;
    background: var(--soft);
    color: var(--blue);
    font-weight: 700;
  }

  #czatix-app .czx-rooms,
  #czatix-app .czx-people {
    position: absolute;
    z-index: 5;
    top: 0;
    bottom: 0;
    width: min(320px, 88vw);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  #czatix-app .czx-people {
    right: 0;
    left: auto;
    transform: translateX(105%);
  }

  #czatix-app .czx-shell.is-rooms .czx-rooms,
  #czatix-app .czx-shell.is-people .czx-people {
    transform: none;
  }
}
