:root {
  --bg: #05070b;
  --panel: rgba(12, 18, 28, 0.84);
  --panel-strong: rgba(15, 23, 36, 0.94);
  --line: rgba(130, 244, 214, 0.2);
  --text: #eefcf8;
  --muted: #9fb8b3;
  --accent: #39e6b4;
  --accent-2: #60a5fa;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: #05070b url("../images/fondo_cthulhu.png") no-repeat center center fixed;
  background-size: cover;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 18% 16%, rgba(57, 230, 180, 0.18), transparent 26%),
    linear-gradient(135deg, rgba(5, 7, 11, 0.8), rgba(3, 8, 12, 0.9));
  pointer-events: none;
}

#matrix-bg {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  opacity: 0.42;
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 2;
  height: 100vh;
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.app-header,
.join-screen,
.chat-panel,
.users-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(18px);
}

.app-header {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(1.45rem, 3vw, 2.25rem); }
h2 { font-size: 0.92rem; }

.status-pill {
  padding: 7px 10px;
  border: 1px solid rgba(57, 230, 180, 0.38);
  border-radius: 999px;
  color: var(--accent);
  font-weight: 800;
  background: rgba(57, 230, 180, 0.1);
}

.join-screen {
  align-self: start;
  width: min(520px, 100%);
  padding: 18px;
}

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

.room-form label,
.composer label {
  display: block;
  margin-bottom: 7px;
  color: #d9f7ef;
  font-weight: 750;
}

.room-form input,
.room-form select,
.composer textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(3, 7, 12, 0.72);
  border: 1px solid rgba(159, 184, 179, 0.32);
  border-radius: 7px;
  outline: none;
}

.room-form input:focus,
.room-form select:focus,
.composer textarea:focus {
  border-color: rgba(57, 230, 180, 0.72);
  box-shadow: 0 0 0 3px rgba(57, 230, 180, 0.14);
}

.room-form input::placeholder,
.composer textarea::placeholder {
  color: rgba(217, 247, 239, 0.55);
}

.join-fields,
.create-fields {
  margin-top: 2px;
}

.room-select-row {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 8px;
}

.action-row,
.composer-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.primary-action,
.secondary-action,
.send-btn,
.file-picker,
.icon-action,
.leave-btn {
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid rgba(57, 230, 180, 0.38);
  color: var(--text);
  font-weight: 800;
  background: rgba(57, 230, 180, 0.12);
  cursor: pointer;
}

.secondary-action,
.file-picker,
.icon-action {
  border-color: rgba(96, 165, 250, 0.42);
  background: rgba(96, 165, 250, 0.12);
}

.leave-btn {
  border-color: rgba(255, 107, 107, 0.48);
  background: rgba(255, 107, 107, 0.12);
}

.chat-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 14px;
}

.chat-layout[hidden],
.join-screen[hidden] {
  display: none !important;
}

.chat-panel {
  min-height: 0;
  padding: 14px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
}

.room-bar {
  min-height: 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 7px;
  border: 1px solid rgba(57, 230, 180, 0.28);
  background: rgba(57, 230, 180, 0.08);
}

.room-bar span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.room-bar strong {
  font-size: 1.08rem;
}

.chat-feed {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  border-radius: 7px;
  border: 1px solid rgba(159, 184, 179, 0.22);
  background: rgba(3, 7, 12, 0.52);
}

.message {
  max-width: min(760px, 92%);
  padding: 9px 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.75rem;
}

.message-text {
  margin-top: 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.file-card {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 7px;
  border: 1px solid rgba(96, 165, 250, 0.28);
}

.file-card a {
  color: #bde9ff;
  font-weight: 800;
}

.composer {
  display: grid;
  gap: 10px;
}

.composer textarea {
  width: 100%;
  height: 78px;
  min-height: 78px;
  max-height: 78px;
  resize: none;
  overflow-y: auto;
}

#file-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.users-panel {
  min-height: 0;
  padding: 12px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

.users-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #d9f7ef;
}

#peer-count {
  min-width: 26px;
  min-height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--accent);
  border: 1px solid rgba(57, 230, 180, 0.28);
}

.users-list {
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 8px;
}

.user-pill {
  padding: 9px 10px;
  border: 1px solid rgba(57, 230, 180, 0.24);
  border-radius: 7px;
  color: #d9f7ef;
  background: rgba(57, 230, 180, 0.08);
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
}

.system-message {
  opacity: 0.78;
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .app-shell { min-height: 100vh; height: auto; padding: 12px; }
  .chat-layout { grid-template-columns: 1fr; }
  .users-panel { min-height: 140px; }
}


.toast-root {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid rgba(57, 230, 180, 0.34);
  color: var(--text);
  background: rgba(12, 18, 28, 0.96);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(14px);
  font-weight: 750;
}

.toast.error {
  border-color: rgba(255, 107, 107, 0.48);
}

.toast.success {
  border-color: rgba(57, 230, 180, 0.52);
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.mode-tab {
  min-height: 40px;
  border: 1px solid rgba(159, 184, 179, 0.26);
  border-radius: 7px;
  color: var(--muted);
  background: rgba(3, 7, 12, 0.5);
  cursor: pointer;
  font-weight: 850;
}

.mode-tab.is-active {
  color: var(--text);
  border-color: rgba(57, 230, 180, 0.46);
  background: rgba(57, 230, 180, 0.12);
}


.transfer-progress {
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid rgba(57, 230, 180, 0.24);
  background: rgba(3, 7, 12, 0.72);
}

.transfer-progress[hidden] {
  display: none !important;
}

.transfer-progress-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #d9f7ef;
  font-size: 0.78rem;
  font-weight: 800;
}

.transfer-progress-track,
.file-progress {
  width: 100%;
  height: 7px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(159, 184, 179, 0.18);
}

.transfer-progress-track span,
.file-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
}

.transfer-progress-detail {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-progress {
  grid-column: 1 / -1;
  margin-top: 2px;
}
