:root {
  color-scheme: dark;
  --bg: #15110e;
  --rail: #19130f;
  --panel: #211a16;
  --panel-2: #30251e;
  --panel-3: #3a2b22;
  --chat: #352922;
  --line: #554032;
  --text: #fff5ec;
  --muted: #c7b5a6;
  --brand: #ff8a1f;
  --brand-2: #ffbd5a;
  --brand-3: #f05d1a;
  --danger: #d83a2f;
  --channel-width: 270px;
  --member-width: 270px;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #1d1007;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  filter: brightness(1.08);
}

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

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(35, 18, 8, 0.18), rgba(22, 14, 9, 0.84)),
    url("https://images.unsplash.com/photo-1551434678-e076c223a692?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.login-panel {
  width: min(940px, 100%);
  min-height: 560px;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  align-items: end;
  gap: 32px;
  padding: 44px;
  background: rgba(30, 19, 13, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--brand-2);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-panel h1 {
  max-width: 640px;
  margin: 0;
  font-size: clamp(38px, 5vw, 72px);
  line-height: 0.98;
}

.login-form {
  display: grid;
  gap: 16px;
  padding: 22px;
  background: rgba(37, 27, 21, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border-radius: 8px;
  background: #180f0a;
}

.auth-tabs button {
  height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.auth-tabs button.active {
  background: var(--brand);
  color: #1d1007;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #150f0b;
  color: var(--text);
  outline: 0;
}

input {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 46px;
  max-height: 46px;
  resize: none;
  padding: 12px;
}

.login-form button,
.composer button,
.call-actions button {
  min-height: 42px;
  padding: 0 16px;
}

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

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 72px var(--channel-width) 6px minmax(0, 1fr) 6px var(--member-width);
  overflow: hidden;
}

.server-rail,
.channel-panel,
.member-panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.server-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px 10px;
  background: var(--rail);
}

.server-mark,
.icon-button,
.profile-button {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
}

.server-mark {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #1d1007;
  font-size: 26px;
  font-weight: 900;
}

.icon-button {
  background: var(--panel-2);
  color: var(--text);
}

.profile-button {
  margin-top: auto;
  padding: 0;
  overflow: hidden;
  background: transparent;
  color: var(--text);
}

.resize-handle {
  position: relative;
  background: var(--panel);
  border-right: 1px solid var(--line);
  cursor: col-resize;
}

.resize-handle::after {
  content: "";
  position: absolute;
  inset: 0 2px;
  border-radius: 999px;
  background: transparent;
}

.resize-handle:hover::after,
body.is-resizing .resize-handle::after {
  background: rgba(255, 138, 31, 0.62);
}

body.is-resizing {
  cursor: col-resize;
  user-select: none;
}

.channel-panel,
.member-panel {
  overflow-y: auto;
}

.channel-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}

.channel-scroll,
.member-panel {
  padding: 18px 14px;
  overflow-y: auto;
}

.workspace-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 900;
}

.workspace-title small {
  color: var(--brand-2);
}

h2 {
  margin: 22px 4px 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.channel-list,
.member-list {
  display: grid;
  gap: 6px;
}

.channel {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  padding: 10px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.channel.active,
.channel:hover {
  background: var(--panel-3);
  color: var(--text);
}

.voice-participants {
  display: grid;
  gap: 4px;
  margin: -2px 0 6px 18px;
}

.voice-participant {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.voice-participant:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.voice-avatar,
.profile-avatar {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #1d1007;
  font-size: 11px;
  font-weight: 900;
  border: 2px solid transparent;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.profile-avatar {
  width: 48px;
  height: 48px;
  flex-basis: 48px;
  font-size: 18px;
  border: 0;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.16);
}

.voice-avatar.speaking {
  border-color: #ffd06b;
  box-shadow: 0 0 0 3px rgba(255, 138, 31, 0.34);
}

.voice-empty {
  padding: 3px 8px;
  color: #7f858f;
  font-size: 12px;
}

.chat-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--chat);
  overflow: hidden;
}

.chat-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--chat);
  border-bottom: 1px solid #281e18;
}

.chat-header p,
.chat-header h1 {
  margin: 0;
}

.chat-header p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chat-header h1 {
  font-size: 22px;
}

.call-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.call-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 138, 31, 0.16);
  color: #ffd06b;
  font-size: 13px;
  font-weight: 800;
}

.stage {
  padding: 18px 20px;
  border-bottom: 1px solid #281e18;
  background: #120d0a;
  max-height: 52vh;
  min-height: 260px;
  resize: vertical;
  overflow: auto;
}

.stage.audio-only {
  grid-template-columns: 1fr;
}

.media-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  grid-auto-rows: minmax(180px, 1fr);
  gap: 12px;
}

.media-tile {
  position: relative;
  min-height: 180px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f0a07;
  aspect-ratio: 16 / 9;
}

.media-tile video {
  width: 100%;
  height: 100%;
  min-height: 180px;
  display: block;
  object-fit: cover;
}

.media-tile.local-media video {
  transform: scaleX(-1);
}

.media-tile[data-tile-id="local-screen"] video {
  transform: none;
  object-fit: contain;
}

.media-tile span {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.66);
  font-size: 12px;
  font-weight: 800;
}

.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px;
}

.message {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
}

.avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #1d1007;
  font-weight: 900;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.18);
}

.avatar img,
.mini-avatar img,
.voice-avatar img,
.profile-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
  object-fit: cover;
}

.message-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 4px;
}

.message-meta strong {
  font-size: 14px;
}

.message-meta time {
  color: var(--muted);
  font-size: 12px;
}

.message-body {
  color: #f3dfcf;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-body a {
  color: var(--brand);
}

.attachment {
  max-width: min(520px, 100%);
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #130d09;
}

.attachment img,
.attachment video {
  max-width: 100%;
  display: block;
}

.attachment img {
  cursor: zoom-in;
}

.attachment audio {
  width: 100%;
}

.composer {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 14px 24px 18px;
  border-top: 1px solid #281e18;
  background: var(--chat);
}

.composer #attachButton {
  width: 46px;
  height: 46px;
  padding: 0;
  font-size: 22px;
  background: var(--panel-2);
  color: var(--text);
}

.composer textarea {
  height: 46px;
  min-height: 46px;
  max-height: 46px;
  overflow-y: auto;
  border-radius: 8px;
}

.composer button[type="submit"] {
  height: 46px;
  min-height: 46px;
  padding: 0 22px;
}

.voice-dock {
  margin: 0;
  padding: 12px;
  background: #241914;
  border-top: 1px solid #1b120e;
}

.voice-status {
  display: grid;
  gap: 2px;
  margin-bottom: 10px;
}

.voice-status strong {
  color: #ffd06b;
  font-size: 13px;
}

.voice-status span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.voice-controls button {
  min-width: 0;
  height: 36px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--panel-3);
  color: var(--text);
  font-size: 12px;
}

.voice-controls button.active {
  background: var(--brand);
  color: #1d1007;
}

.voice-controls button.danger {
  background: #3a2326;
  color: #ff8f8f;
}

.attachment-tray {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 12px;
}

.attachment-chip,
.member {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
}

.mini-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #1d1007;
  font-size: 13px;
  font-weight: 900;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.16);
}

.attachment-chip button {
  width: 24px;
  height: 24px;
  padding: 0;
  background: #443328;
  color: var(--text);
}

.status-dot {
  width: 9px;
  height: 9px;
  margin-left: -14px;
  align-self: flex-end;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--panel-2);
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.86);
}

.image-viewer img {
  max-width: 90vw;
  max-height: 88vh;
  transform: translate(var(--pan-x, 0), var(--pan-y, 0)) scale(var(--zoom, 1));
  transform-origin: center;
  cursor: grab;
  user-select: none;
}

.image-viewer img:active {
  cursor: grabbing;
}

.viewer-close {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  padding: 0;
  background: var(--panel-2);
  color: var(--text);
  font-size: 20px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 64px 210px minmax(0, 1fr);
  }

  .member-panel,
  .resize-handle {
    display: none;
  }
}

@media (max-width: 720px) {
  .login-panel {
    min-height: auto;
    grid-template-columns: 1fr;
    padding: 24px;
  }

  .login-panel h1 {
    font-size: 40px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .server-rail {
    flex-direction: row;
    justify-content: space-between;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .icon-button {
    margin-top: 0;
  }

  .channel-panel {
    max-height: 170px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat-header {
    align-items: flex-start;
    flex-direction: column;
  }

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