:root,
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5f7;
  --panel: #ffffff;
  --panel-soft: #f8f9fb;
  --line: #dde3ea;
  --line-strong: #cdd6df;
  --text: #101418;
  --muted: #66707c;
  --accent: #1f6feb;
  --accent-soft: #eaf2ff;
  --success: #1f8f5f;
  --danger: #d04d4d;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --transition: 180ms ease;
  font-family: "Segoe UI", "Helvetica Neue", "Noto Sans", system-ui, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1318;
  --panel: #171c22;
  --panel-soft: #12171d;
  --line: #28303a;
  --line-strong: #3a4552;
  --text: #eef2f6;
  --muted: #99a4b2;
  --accent: #7cb0ff;
  --accent-soft: #172439;
  --success: #38a36d;
  --danger: #d76565;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(31, 111, 235, 0.08), transparent 24%),
    linear-gradient(180deg, #f7f8fa, var(--bg));
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(124, 176, 255, 0.12), transparent 24%),
    linear-gradient(180deg, #11161c, var(--bg));
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  min-height: 100vh;
  padding: 20px;
}

.sidebar,
.workspace,
.details-panel {
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 4px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--text);
  color: var(--panel);
  font: 700 1.2rem/1 "Trebuchet MS", "Segoe UI", sans-serif;
}

.brand-block h1,
.topbar h2,
.section-heading h2,
.section-heading h3,
.empty-chat-card h3 {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

.caption {
  margin: 0 0 4px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.stack-md {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.section-heading {
  display: grid;
  gap: 4px;
}

.section-heading.tight {
  gap: 2px;
}

.section-heading p,
.muted {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.section-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 0.95rem;
  font-weight: 500;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  padding: 13px 14px;
  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    background var(--transition);
}

textarea {
  min-height: 92px;
  resize: none;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: rgba(31, 111, 235, 0.5);
  box-shadow: 0 0 0 4px rgba(31, 111, 235, 0.08);
}

.button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 11px 16px;
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    transform var(--transition);
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

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

.button-secondary {
  background: var(--panel-soft);
  border-color: var(--line);
  color: var(--text);
}

.button-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.status-card {
  padding: 18px;
  display: grid;
  gap: 10px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--danger);
}

.status-dot.online {
  background: var(--success);
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 20px;
}

.topbar {
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 92%, transparent);
  backdrop-filter: blur(18px);
  border-radius: 26px;
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topbar-actions,
.composer-actions,
.message-actions,
.message-meta,
.room-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.95rem;
}

.pill.compact {
  min-width: 38px;
  padding-inline: 12px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  min-height: 0;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  padding: 18px;
  min-height: 0;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.message-feed {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 4px;
}

.message-feed.empty-state {
  justify-content: flex-start;
  padding-top: 4px;
}

.empty-chat-card {
  max-width: 520px;
  padding: 28px;
  border-radius: 24px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.empty-chat-card p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.composer {
  display: grid;
  gap: 12px;
  padding-top: 10px;
}

.reply-banner {
  padding: 10px 14px;
  border-radius: 14px;
  background: #fff7eb;
  border: 1px solid #f0d7ab;
  color: #8a5a00;
}

.hidden {
  display: none;
}

.details-panel {
  display: grid;
  gap: 16px;
  min-height: 0;
}

.call-overlay {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: min(420px, calc(100vw - 24px));
  z-index: 20;
}

.call-overlay-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.18);
  padding: 18px;
  display: grid;
  gap: 14px;
}

.call-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.rooms-list,
.participant-list,
.call-stage {
  display: grid;
  gap: 10px;
}

.participant-search {
  display: grid;
  gap: 10px;
}

.search-directory-card {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent 42%),
    var(--panel);
}

.directory-search-shell {
  display: grid;
  gap: 10px;
}

.participant-search-modes {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.participant-search-mode.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--panel);
}

.global-search-results {
  display: grid;
  gap: 10px;
  max-height: 280px;
  overflow: auto;
}

.directory-user-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent),
    var(--panel-soft);
}

.directory-user-head,
.directory-user-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.directory-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--muted);
}

.device-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font: 600 0.8rem/1 "Consolas", "SFMono-Regular", monospace;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.directory-user-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--line-strong);
}

.directory-user-dot.online {
  background: var(--success);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--success) 18%, transparent);
}

.rooms-list {
  max-height: 260px;
  overflow: auto;
}

.room-item {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  text-align: left;
  display: grid;
  gap: 8px;
}

.room-item.active {
  border-color: rgba(31, 111, 235, 0.35);
  background: var(--accent-soft);
}

.room-item strong {
  font-size: 0.98rem;
}

.create-room-form {
  display: flex;
  gap: 10px;
}

.participant-card,
.sticker-card,
.message-card,
.video-card,
.audio-card {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.participant-card {
  padding: 12px 14px;
  display: grid;
  gap: 4px;
}

.message-card {
  max-width: min(82%, 720px);
  padding: 14px 16px;
  display: grid;
  gap: 10px;
  background: var(--panel);
}

.message-card.self {
  align-self: flex-end;
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
}

.message-card.replying {
  border-color: #f0d7ab;
}

.sender-chip {
  font-weight: 600;
}

.message-meta {
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.88rem;
}

.message-body {
  display: grid;
  gap: 8px;
  line-height: 1.55;
  word-break: break-word;
}

.message-body blockquote {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff7eb;
  border-left: 3px solid #e8b85c;
  color: #7e5608;
}

.sticker-bubble {
  font-size: 2.4rem;
  line-height: 1;
}

.message-actions {
  justify-content: space-between;
  flex-wrap: wrap;
}

.reply-action,
.edit-action,
.reaction-button,
.reaction-chip {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 11px;
}

.message-card:not(.self) .edit-action {
  display: none;
}

.reaction-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.call-stage {
  min-height: 220px;
}

.call-stage.active {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.call-placeholder {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 16px;
  border-radius: 20px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  text-align: center;
}

.video-card {
  overflow: hidden;
  position: relative;
  min-height: 180px;
}

.audio-card {
  min-height: 180px;
  padding: 18px;
  display: grid;
  align-content: end;
  gap: 12px;
  position: relative;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent),
    var(--panel-soft);
}

.audio-glyph {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 1.35rem;
}

.audio-card audio {
  width: 100%;
}

.video-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: color-mix(in srgb, var(--panel-soft) 80%, #dfe6ee);
}

.video-label {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 84%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 92%, transparent);
  backdrop-filter: blur(10px);
  font-size: 0.88rem;
}

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

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
    gap: 12px;
  }

  .topbar,
  .chat-header,
  .composer-actions,
  .create-room-form,
  .section-row {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .call-overlay {
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
  }

  .composer-actions .button {
    width: 100%;
  }

  .message-card {
    max-width: 100%;
  }
}
