:root {
  --bg: #0d1118;
  --panel: #141b25;
  --panel-soft: #1a2431;
  --line: #2a3648;
  --text: #e7edf7;
  --muted: #95a6be;
  --accent: #2f74ff;
  --accent-strong: #2057c2;
  --success: #1ea97c;
  --danger: #d6525f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Plus Jakarta Sans", sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(47, 116, 255, 0.18), transparent 60%),
    radial-gradient(900px 600px at 0% 100%, rgba(30, 169, 124, 0.16), transparent 55%),
    linear-gradient(180deg, #0d1118 0%, #0f131d 100%);
}

.shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex: 0 0 auto;
}

main {
  flex: 1 1 auto;
  min-height: 0;
}

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

.brand h1 {
  margin: 0;
  font-size: 1.13rem;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: linear-gradient(145deg, #2f74ff, #2057c2);
}

.status {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #101722;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.status-online {
  color: #6ce8bd;
}

.status-offline {
  color: #b5c1d1;
}

.glass {
  border: 1px solid var(--line);
  background: linear-gradient(165deg, rgba(20, 27, 37, 0.94), rgba(20, 27, 37, 0.86));
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(4, 8, 14, 0.34);
  backdrop-filter: blur(8px);
}

.auth-card {
  max-width: 430px;
  margin: 44px auto 0;
  padding: 20px;
}

.auth-card h2 {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 15px;
}

.tab {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #0f1621;
  color: var(--text);
  padding: 10px;
  cursor: pointer;
  font-weight: 700;
}

.tab-active {
  background: #1d2d46;
  border-color: #35598f;
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(520px, 1fr) 320px;
  gap: 12px;
  height: 100%;
  min-height: 0;
}

.rooms-panel,
.chat-panel,
.members-panel {
  padding: 14px;
  min-height: 0;
  height: 100%;
}

.rooms-panel,
.members-panel {
  display: flex;
  flex-direction: column;
}

.chat-panel {
  display: flex;
  flex-direction: column;
}

.in-up {
  animation: inUp 420ms ease both;
}

@keyframes inUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.me-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.me-login {
  margin: 3px 0 0;
  font-weight: 700;
}

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

.form.compact {
  margin-top: 12px;
}

label {
  color: var(--muted);
  font-size: 0.82rem;
}

input,
select {
  width: 100%;
  border: 1px solid #324157;
  border-radius: 11px;
  background: #0f1621;
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.94rem;
  font-family: inherit;
}

input:focus,
select:focus {
  outline: none;
  border-color: #4679d6;
  box-shadow: 0 0 0 3px rgba(47, 116, 255, 0.2);
}

.inline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.btn {
  border-radius: 11px;
  border: 1px solid transparent;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  padding: 9px 12px;
  font-family: inherit;
  transition: transform 0.16s ease, filter 0.16s ease, background-color 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-primary {
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
}

.btn-neutral {
  background: #1c2735;
  border-color: #34465f;
}

.btn-ghost {
  background: #101722;
  border-color: #2e3e56;
}

.btn-danger {
  background: #2a1a20;
  border-color: #5e2e3a;
  color: #ffbfc8;
}

.rooms-header {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rooms-header h3 {
  margin: 0;
}

.rooms-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
  overflow: auto;
}

.rooms-list li {
  border: 1px solid #304057;
  background: #111a26;
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease;
}

.rooms-list li:hover {
  background: #172232;
}

.rooms-list li.active {
  border-color: #4f75b4;
  background: #1b2a3f;
}

.room-title {
  margin: 0;
  font-weight: 700;
  font-size: 0.93rem;
}

.room-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  word-break: break-all;
}

.chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.chat-head h2 {
  margin: 0;
  font-size: 1.06rem;
}

.chat-head-actions {
  display: flex;
  gap: 8px;
}

.messages {
  margin-top: 10px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 3px;
}

.empty-state {
  margin: 14px 0 0;
  color: var(--muted);
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: popIn 220ms ease both;
}

.message-row.self {
  justify-content: flex-end;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  flex: 0 0 auto;
}

.bubble {
  border: 1px solid #30425b;
  background: #121c29;
  border-radius: 14px;
  padding: 10px 11px;
  max-width: min(70ch, 78%);
  min-width: 180px;
}

.message-row.self .bubble {
  background: #18263b;
  border-color: #3d5d8e;
}

.bubble-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
}

.sender {
  font-size: 0.82rem;
  font-weight: 700;
}

.time {
  font-size: 0.74rem;
  color: var(--muted);
}

.translated {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.original-wrap {
  margin-top: 7px;
  border-top: 1px dashed #304057;
  padding-top: 7px;
}

.original-text {
  margin: 0;
  color: #d1deef;
  white-space: pre-wrap;
  word-break: break-word;
}

.toggle-original {
  margin-top: 6px;
  border: 1px solid #395073;
  background: #1a2638;
  color: #cad9ef;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 0.76rem;
  cursor: pointer;
}

.meta {
  margin-top: 6px;
  font-size: 0.74rem;
  color: var(--muted);
}

.composer {
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding-top: 10px;
  display: grid;
  gap: 8px;
}

.lang-controls {
  display: grid;
  grid-template-columns: auto 120px auto 120px;
  align-items: center;
  gap: 8px;
}

.members-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.members-head h3 {
  margin: 0;
}

.counter {
  border: 1px solid #32445e;
  background: #101825;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.76rem;
}

.participants {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  overflow: auto;
  max-height: 46vh;
}

.participant {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid #2f3f56;
  border-radius: 11px;
  padding: 8px;
  background: #111a27;
}

.participant-name {
  margin: 0;
  font-weight: 700;
  font-size: 0.86rem;
}

.participant-joined {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.owner-badge {
  border: 1px solid #3b5b89;
  background: #16243a;
  color: #a9c6f3;
  font-size: 0.68rem;
  padding: 3px 6px;
  border-radius: 999px;
}

.admin-block {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.admin-section {
  margin-top: 10px;
  border: 1px solid #34435a;
  border-radius: 12px;
  padding: 10px;
  background: #101926;
}

.admin-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-top h4 {
  margin: 0;
}

.admin-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(90px, 1fr));
  gap: 8px;
}

.admin-stat {
  margin: 0;
  padding: 7px;
  border: 1px solid #334763;
  border-radius: 10px;
  background: #141f30;
}

.admin-stat p {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.admin-stat strong {
  display: block;
  margin-top: 2px;
}

.admin-section h5 {
  margin: 10px 0 6px;
}

.mini-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.mini-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid #2f415a;
  border-radius: 9px;
  padding: 7px;
  font-size: 0.74rem;
  background: #111a27;
}

.admin-actions {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.check-inline input {
  width: auto;
  margin: 0;
}

.btn-mini {
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.72rem;
}

.notice {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 420px;
  border-radius: 10px;
  padding: 12px 14px;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.34);
}

.notice-ok {
  background: var(--success);
}

.notice-error {
  background: var(--danger);
}

.hidden {
  display: none !important;
}

@media (max-width: 1220px) {
  .workspace {
    grid-template-columns: 300px 1fr;
    height: 100%;
  }

  .members-panel {
    grid-column: span 2;
  }

  .participants {
    max-height: 220px;
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .shell {
    height: auto;
    min-height: 100vh;
  }

  main {
    min-height: auto;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .rooms-panel,
  .chat-panel,
  .members-panel {
    min-height: auto;
  }

  .lang-controls {
    grid-template-columns: auto 1fr auto 1fr;
  }

  .chat-head {
    flex-direction: column;
    align-items: stretch;
  }
}

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

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

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

  .message-row,
  .message-row.self {
    justify-content: flex-start;
  }

  .bubble {
    max-width: 100%;
  }
}
