:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f12;
  --panel: #16161b;
  --bar: #111114;
  --line: #2a2a32;
  --text: #d8d8de;
  --muted: #7a7a86;
  --accent: #8fd4b0;
  --lounge: #8eb6e8;
  --danger: #e07a7a;
  --self: #c4b5e8;
  --btn: #22222a;
  --hover: #2a2a34;
  --active: #1e1e26;
  --focus: #4a4a58;
  --overlay: rgb(0 0 0 / 45%);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f3f6;
  --panel: #ffffff;
  --bar: #f7f7fa;
  --line: #d9d9e1;
  --text: #1c1c22;
  --muted: #6b6b76;
  --accent: #217a57;
  --lounge: #215ea8;
  --danger: #b42323;
  --self: #5b3d99;
  --btn: #ececf1;
  --hover: #e4e4ec;
  --active: #ececf2;
  --focus: #b8b8c4;
  --overlay: rgb(20 20 28 / 28%);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 12px/1.4 ui-sans-serif, system-ui, -apple-system, sans-serif;
}

.lounge-page {
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.join {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  position: relative;
}

.join-card {
  width: min(100%, 280px);
  display: grid;
  gap: 8px;
}

.join-kicker {
  margin: 0;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 10px;
}

.join h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.join-copy {
  margin: 0 0 8px;
  color: var(--muted);
}

.join input,
.composer input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 10px;
  outline: none;
}

.join input:focus,
.composer input:focus {
  border-color: var(--focus);
}

.join button,
.composer button[type="submit"] {
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 10px;
  cursor: pointer;
}

.join button:hover,
.composer button[type="submit"]:hover,
.icon-btn:hover,
.list button:hover {
  background: var(--hover);
}

.error {
  margin: 0;
  color: var(--danger);
}

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: 36px 1fr 32px 36px;
  align-items: center;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  padding: 0 4px;
  padding-top: env(safe-area-inset-top);
}

.theme-float {
  position: absolute;
  top: 8px;
  right: 8px;
}

.theme-icon {
  width: 12px;
  height: 12px;
  display: block;
  border-radius: 50%;
  box-shadow: inset -3px -2px 0 1px currentColor;
}

[data-theme="dark"] .theme-icon {
  box-shadow: none;
  border: 1.5px solid currentColor;
}

.title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  border-radius: 4px;
}

.hamburger,
.hamburger::before,
.hamburger::after {
  display: block;
  width: 14px;
  height: 1.5px;
  background: currentColor;
  position: relative;
}

.hamburger::before,
.hamburger::after {
  content: "";
  position: absolute;
  left: 0;
}

.hamburger::before {
  top: -5px;
}

.hamburger::after {
  top: 5px;
}

.badge {
  position: absolute;
  top: 2px;
  right: 1px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 7px;
  background: var(--btn);
  color: var(--muted);
  font-size: 9px;
  line-height: 14px;
  text-align: center;
}

.shell {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

.overlay {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  z-index: 2;
}

.drawer {
  position: absolute;
  top: 0;
  bottom: 0;
  width: min(78vw, 220px);
  background: var(--panel);
  border: 0 solid var(--line);
  z-index: 3;
  overflow: auto;
  padding: 8px 0 12px;
}

.drawer-left {
  left: 0;
  border-right-width: 1px;
}

.drawer-right {
  right: 0;
  border-left-width: 1px;
}

.drawer-label {
  margin: 0;
  padding: 4px 12px 8px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.list {
  display: grid;
}

.list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 7px 12px;
  cursor: pointer;
  color: var(--text);
}

.list button.active {
  background: var(--active);
}

.list .meta {
  color: var(--muted);
  font-size: 10px;
}

.list .self {
  color: var(--muted);
  cursor: default;
}

.main {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
}

.messages {
  overflow: auto;
  padding: 8px 10px 6px;
}

.msg {
  display: grid;
  grid-template-columns: 42px 1fr;
  column-gap: 8px;
  margin: 0 0 4px;
  font-size: 13px;
  word-break: break-word;
}

.msg .ts {
  color: var(--muted);
  font-size: 10px;
  padding-top: 3px;
  font-variant-numeric: tabular-nums;
}

.msg .from {
  color: var(--accent);
  font-weight: 600;
  margin-right: 6px;
}

.msg.mine .from {
  color: var(--self);
}

.msg.system {
  grid-template-columns: 42px 1fr;
  color: var(--muted);
  font-style: italic;
  font-size: 12px;
}

.composer-wrap {
  border-top: 1px solid var(--line);
  background: var(--bar);
}

.attach-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 0;
}

.attach-preview img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.attach-meta {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 2px;
}

.attach-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.attach-bar {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}

.attach-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}

.composer {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
}

.composer button[type="submit"] {
  padding-inline: 12px;
}

.msg-image-wrap {
  position: relative;
  display: inline-block;
  margin-top: 4px;
}

.msg-image {
  display: block;
  max-width: min(220px, 70vw);
  max-height: 160px;
  border-radius: 4px;
  border: 1px solid var(--line);
  cursor: zoom-in;
}

.msg-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: rgb(0 0 0 / 55%);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.msg-del:hover {
  background: rgb(0 0 0 / 75%);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgb(0 0 0 / 72%);
  display: grid;
  place-items: center;
  padding: 40px 12px 12px;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: 8px;
  right: 8px;
  color: #fff;
  font-size: 18px;
}

a {
  color: var(--lounge);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.quiet,
.brand {
  color: var(--muted);
}

.home-body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.home-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  padding-top: calc(8px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: var(--bar);
}

.brand {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.home {
  width: min(100% - 32px, 520px);
  margin: 0 auto;
  padding: 36px 0 24px;
  flex: 1;
}

.home h1 {
  margin: 6px 0 10px;
  font-size: 22px;
  font-weight: 650;
  line-height: 1.25;
}

.lede {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  max-width: 42ch;
}

.cta {
  display: inline-block;
  background: var(--btn);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 13px;
}

.cta:hover {
  background: var(--hover);
  text-decoration: none;
}

.features {
  display: grid;
  gap: 12px;
  margin-top: 28px;
}

.features article {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 4px;
  padding: 10px 12px;
}

.features h2 {
  margin: 0 0 4px;
  font-size: 13px;
}

.features p {
  margin: 0;
  color: var(--muted);
}

.home-foot {
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 11px;
}

.home-foot p {
  margin: 0;
  text-align: center;
}

@media (min-width: 720px) {
  .app.chats-open .drawer-left {
    position: relative;
    width: 200px;
    flex: 0 0 200px;
    display: block;
  }

  .app.chats-open .overlay.for-chats {
    display: none;
  }

  .features {
    grid-template-columns: repeat(3, 1fr);
  }
}

