:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #63717a;
  --line: #dce3e7;
  --soft: #f5f7f8;
  --panel: #ffffff;
  --accent: #087e8b;
  --accent-strong: #066a75;
  --warn: #b54708;
  --ok: #147d4c;
  --shadow: 0 18px 45px rgba(20, 33, 42, 0.12);
  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:
    linear-gradient(135deg, rgba(8, 126, 139, 0.12), transparent 38%),
    linear-gradient(315deg, rgba(242, 184, 75, 0.16), transparent 42%),
    #eef3f4;
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
}

button:disabled,
input:disabled,
.attach-button:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.55;
}

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

button.danger {
  border-color: rgba(181, 71, 8, 0.25);
  color: var(--warn);
}

.link-button {
  border: 0;
  min-height: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 750;
}

button.primary:hover,
.composer button:hover,
button:not(:disabled):hover {
  border-color: var(--accent-strong);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.sidebar,
.conversation {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(220, 227, 231, 0.92);
  box-shadow: var(--shadow);
}

.sidebar {
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  aspect-ratio: 1;
  border-radius: 8px;
  background: #102a2e;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.25rem;
}

h2 {
  font-size: 1rem;
}

.brand p,
.conversation-head p,
.panel-head span,
.peer,
.system,
.status-line {
  color: var(--muted);
  font-size: 0.9rem;
}

.join-form,
.panel,
.stack-form,
.room-form {
  display: grid;
  gap: 12px;
}

.user-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.user-panel strong {
  display: block;
}

.side-actions,
.tabs,
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tabs button {
  flex: 1 1 120px;
}

label,
.select-line {
  display: grid;
  gap: 6px;
  color: #31414a;
  font-size: 0.88rem;
  font-weight: 650;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(8, 126, 139, 0.22);
  outline-offset: 1px;
}

.panel {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.call-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#muteButton {
  grid-column: 1 / -1;
}

.peer-list {
  display: grid;
  gap: 8px;
}

.peer,
.request-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.peer button {
  min-height: 34px;
  padding: 0 10px;
}

.request-list {
  display: grid;
  gap: 8px;
}

.request-actions {
  display: flex;
  gap: 6px;
}

.request-actions button {
  min-height: 32px;
  padding: 0 10px;
}

.workspace {
  min-width: 0;
  align-content: start;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(220, 227, 231, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 26px;
}

.workspace.narrow {
  max-width: 520px;
  width: min(520px, 100%);
  justify-self: center;
  align-self: center;
}

.view-head {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.view-head h2 {
  font-size: 1.35rem;
}

.room-form {
  max-width: 520px;
}

.admin-users {
  display: grid;
  gap: 10px;
}

.admin-user {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.admin-user small {
  color: var(--muted);
}

.conversation {
  border-radius: 8px;
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.conversation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.network-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(8, 126, 139, 0.28);
  background: rgba(8, 126, 139, 0.08);
  color: var(--accent-strong);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.82rem;
  font-weight: 750;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  max-width: min(680px, 86%);
  width: fit-content;
  padding: 10px 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  word-break: break-word;
}

.message.mine {
  align-self: flex-end;
  background: #e8f6f7;
  border-color: rgba(8, 126, 139, 0.25);
}

.message strong {
  display: block;
  font-size: 0.82rem;
  margin-bottom: 4px;
}

.system {
  text-align: center;
  padding: 2px 0;
}

.composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.attachment-preview {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.88rem;
}

.upload-progress {
  grid-column: 1 / -1;
  display: grid;
  gap: 7px;
  padding: 9px 10px;
  border: 1px solid rgba(8, 126, 139, 0.24);
  border-radius: 8px;
  background: #f2fbfc;
}

.upload-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--accent-strong);
  font-size: 0.84rem;
  font-weight: 750;
}

.upload-progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(8, 126, 139, 0.14);
}

#uploadProgressBar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 160ms ease;
}

.attachment-preview span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-preview button {
  min-height: 32px;
  padding: 0 10px;
}

.attach-button {
  display: grid;
  place-items: center;
  width: 46px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 1.35rem;
  font-weight: 750;
}

.attach-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.composer input {
  min-height: 46px;
}

.composer button {
  min-width: 88px;
}

.attachment {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.attachment img,
.attachment video {
  display: block;
  max-width: min(420px, 100%);
  max-height: 260px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.attachment a {
  color: var(--accent-strong);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.is-online {
  color: var(--ok);
}

.is-warning {
  color: var(--warn);
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 10px;
  }

  .sidebar {
    gap: 14px;
  }

  .conversation {
    min-height: 62vh;
  }

  .conversation-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .message {
    max-width: 94%;
  }

  .composer {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .composer button {
    grid-column: 1 / -1;
  }

  .workspace {
    padding: 18px;
  }

  .admin-user {
    grid-template-columns: 1fr;
  }
}
