:root {
  --bg: #0b1320;
  --bg-soft: #101d2f;
  --panel: #111d2f;
  --panel-2: #17263b;
  --line: #2a3f5a;
  --text: #e5eef8;
  --muted: #9bb1c8;
  --accent: #8a63ad;
  --accent-2: #7ab2ea;
  --ok: #5fd2aa;
  --danger: #f18aa8;
  --danger-soft: #37202b;
  --input-bg: #162337;
  --input-bg-2: #1b2b43;
  --overlay: rgba(2, 7, 15, 0.65);
  --bg-glow: #1c2e48;
  --elev-shadow: 0 10px 26px rgba(0, 0, 0, 0.42);
  --footer-h: 30px;
  --page-bg: #0f172a;
}

:root[data-theme="light"] {
  --bg: #dfe8f2;
  --bg-soft: #d2deeb;
  --panel: #edf3fa;
  --panel-2: #e2ebf5;
  --line: #9fb3c8;
  --text: #132a44;
  --muted: #3f5c78;
  --accent: #845ea8;
  --accent-2: #4e78ab;
  --ok: #2f9b82;
  --danger: #b94b69;
  --danger-soft: #fbe8ee;
  --input-bg: #e6eef7;
  --input-bg-2: #dce7f3;
  --overlay: rgba(8, 26, 44, 0.22);
  --bg-glow: #c4d6ea;
  --elev-shadow: 0 10px 26px rgba(29, 65, 104, 0.25);
  --page-bg: #dce6f1;
}

* { box-sizing: border-box; }

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--page-bg);
  color: var(--text);
  overflow: hidden;
  overflow-x: hidden;
}

/* Slim, modern scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: #6b7f98 #0f1c2f;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: #0f1c2f;
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #7f94ad, #617a96);
  border-radius: 999px;
  border: 1px solid #0f1c2f;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #91a7c1, #6d87a5);
}

:root[data-theme="light"] * {
  scrollbar-color: #7b8ea5 #d7e1ed;
}

:root[data-theme="light"] *::-webkit-scrollbar-track {
  background: #d7e1ed;
}

:root[data-theme="light"] *::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #8ba0b7, #748aa3);
  border-color: #d7e1ed;
}

:root[data-theme="light"] .rail {
  background: #d5e1ef;
}

:root[data-theme="light"] .rooms {
  background: #e3edf8;
}

:root[data-theme="light"] .chat {
  background: #e8f0f8;
}

:root[data-theme="light"] .panel {
  background: #ecf3fa;
}

:root[data-theme="light"] .rooms-tools input,
:root[data-theme="light"] #chat-search-input,
:root[data-theme="light"] #sound-profile-select,
:root[data-theme="light"] #ringtone-select {
  background: #edf3fa;
  color: #132a44;
  border-color: #9fb3c8;
}

:root[data-theme="light"] .search-user {
  background: #edf3fa;
  color: #132a44;
  border-color: #9fb3c8;
}

:root[data-theme="light"] .search-user:hover,
:root[data-theme="light"] .room-item.active,
:root[data-theme="light"] .room-item:hover {
  background: #dce8f5;
}

:root[data-theme="light"] .sound-toggle-btn,
:root[data-theme="light"] .volume-wrap,
:root[data-theme="light"] .room-trash-btn {
  background: #e8f0f8;
  color: #17314e;
  border-color: #9fb3c8;
}

:root[data-theme="light"] .head-note,
:root[data-theme="light"] .chat-search-count,
:root[data-theme="light"] .logout,
:root[data-theme="light"] .settings-link {
  color: #204a74;
}

.layout {
  display: grid;
  grid-template-columns: 64px 240px minmax(0, 1fr) 390px;
  height: calc(100vh - var(--footer-h));
}

.layout > * {
  min-width: 0;
}

body.guest-mode .layout {
  grid-template-columns: minmax(0, 1fr);
}

body.guest-mode .rail,
body.guest-mode .rooms,
body.guest-mode .panel,
body.guest-mode #details-toggle-btn,
body.guest-mode #mobile-details-toggle-btn,
body.guest-mode #mobile-rooms-toggle-btn,
body.guest-mode #call-controls {
  display: none !important;
}

.rail,
.rooms,
.chat,
.panel {
  border-right: 1px solid var(--line);
}

.rail {
  background: #0b1220;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0.4rem;
  gap: 0.6rem;
}

.brand {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(120deg, #2563eb, #0891b2);
  font-weight: 700;
}

.rail-link {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  text-decoration: none;
  color: var(--text);
  background: #111827;
}

.rail-link.active { background: var(--accent); }

.rail-group-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: center;
  width: 100%;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  padding-right: 2px;
}

.rail-link-group {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.rail-group-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #1b2b43;
  color: #dbeafe;
  font-size: 0.63rem;
  font-weight: 700;
}

.rail-group-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rail-group-icon.has-image .rail-group-fallback {
  display: none;
}

.rooms {
  display: flex;
  flex-direction: column;
  background: #101827;
  height: 100%;
  overflow: hidden;
}

.rooms-head {
  padding: 0.85rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rooms-tools {
  padding: 0.55rem;
  border-bottom: 1px solid var(--line);
}

.rooms-tools input {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0b1220;
  color: #f8fafc;
  padding: 0.5rem;
}

.search-results {
  margin-top: 0.45rem;
  display: grid;
  gap: 0.3rem;
  max-height: 180px;
  overflow: auto;
  padding-right: 0.15rem;
}

.search-user {
  border: 1px solid #334155;
  background: #111827;
  color: #e2e8f0;
  border-radius: 8px;
  text-align: left;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  display: grid;
  gap: 0.2rem;
}

.search-user:hover {
  background: #1f2937;
}

.search-user-main {
  font-size: 0.9rem;
}

.search-user-badge {
  display: inline-block;
  font-size: 0.72rem;
  color: #fecaca;
  background: #3f1313;
  border: 1px solid #7f1d1d;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}

.search-user.pending {
  opacity: 0.86;
  cursor: not-allowed;
}

.search-user.pending:hover {
  background: #111827;
}

.search-hint {
  font-size: 0.8rem;
  color: #94a3b8;
  padding: 0.35rem 0.2rem;
}

.search-hint.error {
  color: #fca5a5;
}

.rooms-head button {
  border: 0;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

.rooms-list {
  padding: 0.5rem;
  overflow: auto;
  flex: 1;
}

.room-item {
  border-radius: 8px;
  padding: 0.25rem 0.35rem;
  margin-bottom: 0.25rem;
}

.room-item.active,
.room-item:hover {
  background: #1f2937;
}

.room-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.room-link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: var(--text);
  padding: 0.35rem 0.35rem;
}

.room-group-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  background: #1b2b43;
  color: #dbeafe;
  font-size: 0.65rem;
  font-weight: 700;
}

.room-group-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.room-group-icon.has-image .room-group-fallback {
  display: none;
}

.room-main {
  min-width: 0;
  display: grid;
  gap: 0.08rem;
}

.room-item-direct .room-link {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.14), rgba(59, 130, 246, 0));
  border-radius: 8px;
}

.room-item-group .room-link {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.14), rgba(16, 185, 129, 0));
  border-radius: 8px;
}

.room-item.active .room-link {
  outline: 1px solid #334155;
}

.room-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-presence {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 0.68rem;
  color: #94a3b8;
}

.room-presence-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.room-code {
  font-size: 0.65rem;
  color: #7dd3fc;
  letter-spacing: 0.03em;
}

.room-lock {
  font-size: 0.8rem;
}

.room-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  padding: 0 6px;
  background: #dc2626;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  margin-left: 0.35rem;
}

.room-mention-pearl {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  animation: mention-pearl-pulse 1.4s infinite;
  margin-left: 0.3rem;
  flex-shrink: 0;
}

@keyframes mention-pearl-pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.65); }
  70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.room-trash-btn {
  border: 1px solid #334155;
  border-radius: 6px;
  background: #0b1220;
  color: #fca5a5;
  font-size: 0.8rem;
  line-height: 1;
  padding: 0.2rem 0.35rem;
  cursor: pointer;
}

.room-trash-btn:hover {
  background: #2a1320;
}

.empty {
  color: var(--muted);
  padding: 0.5rem 0.65rem;
}

.user-box {
  border-top: 1px solid var(--line);
  padding: 0.85rem;
}

.user-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
  background: #334155;
  border: 1px solid #475569;
}

.avatar.me {
  width: 34px;
  height: 34px;
}

.user-name { font-weight: 600; }
.user-mail { color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }
.logout { color: #93c5fd; font-size: 0.85rem; text-decoration: none; display: inline-block; margin-top: 0.5rem; }

.settings-link {
  margin-top: 0.7rem;
  color: #bfdbfe;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.62);
  display: grid;
  place-items: center;
  z-index: 50;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(92vw, 440px);
  background: #111827;
  border: 1px solid #243044;
  border-radius: 12px;
  padding: 1rem;
}

.modal-card h3 {
  margin-top: 0;
}

.modal-card label {
  display: block;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.84rem;
  color: #cbd5e1;
}

.modal-card input {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #020617;
  color: #f8fafc;
  padding: 0.55rem;
}

.modal-actions {
  margin-top: 0.8rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.modal-actions button {
  border: 0;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

.modal-actions button.secondary {
  background: #334155;
}

.status-row {
  margin-top: 0.55rem;
}

.user-status-row {
  margin-top: 0.65rem;
}

.status-row select {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #020617;
  color: #f8fafc;
  padding: 0.5rem;
}

.profile-upload-label {
  display: block;
  font-size: 0.78rem;
  color: #94a3b8;
  margin: 0.55rem 0 0.3rem;
}

#profile-image-input {
  width: 100%;
  font-size: 0.8rem;
}

#profile-image-form button {
  width: 100%;
  margin-top: 0.4rem;
  border: 0;
  border-radius: 8px;
  background: #334155;
  color: #fff;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
}

.chat {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #0f172a;
  height: 100%;
  overflow: hidden;
}

.chat-head {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.75rem;
  min-width: 0;
}

.chat-head-left {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  flex: 0 1 auto;
  max-width: 36%;
}

.room-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.room-manage-btn {
  font-size: 0.78rem;
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  white-space: nowrap;
}

.chat-head-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  overflow: hidden;
  white-space: normal;
  max-width: 100%;
  min-width: 0;
  flex: 1 1 auto;
}

.call-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.call-controls.hidden {
  display: none;
}

.mobile-only {
  display: none;
}

.desktop-only {
  display: inline-flex;
}

#chat-search-input {
  border-radius: 8px;
  border: 1px solid #334155;
  background: #020617;
  color: #f8fafc;
  padding: 0.34rem 0.5rem;
  width: clamp(130px, 16vw, 220px);
  font-size: 0.75rem;
}

#sound-profile-select {
  border-radius: 8px;
  border: 1px solid #334155;
  background: #020617;
  color: #f8fafc;
  padding: 0.3rem 0.42rem;
  font-size: 0.75rem;
}

#ringtone-select {
  border-radius: 8px;
  border: 1px solid #334155;
  background: #020617;
  color: #f8fafc;
  padding: 0.3rem 0.42rem;
  font-size: 0.75rem;
}

.sound-toggle-btn {
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0b1220;
  color: #e2e8f0;
  padding: 0.28rem 0.42rem;
  cursor: pointer;
  font-size: 0.75rem;
}

.toolbar-icon-btn {
  min-width: 34px;
  height: 28px;
  padding: 0 0.38rem;
  display: inline-grid;
  place-items: center;
  line-height: 1;
}

.call-start-btn {
  background: #14532d;
  border-color: #22c55e;
  color: #dcfce7;
}

.call-start-btn:hover:not(:disabled) {
  background: #166534;
}

.call-video-start-btn {
  background: #0f3f73;
  border-color: #38bdf8;
  color: #e0f2fe;
}

.call-video-start-btn:hover:not(:disabled) {
  background: #0b4f8a;
}

.call-end-btn {
  background: #7f1d1d;
  border-color: #ef4444;
  color: #fee2e2;
}

.call-end-btn:hover:not(:disabled) {
  background: #991b1b;
}

.call-start-btn:disabled,
.call-video-start-btn:disabled,
.call-end-btn:disabled {
  opacity: 0.55;
}

.volume-control {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.volume-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0b1220;
  padding: 0.26rem 0.45rem;
}

.volume-wrap.hidden {
  display: none;
}

#sound-volume-range {
  width: 110px;
}

#sound-volume-value {
  color: #cbd5e1;
  font-size: 0.76rem;
  min-width: 2.2rem;
  text-align: right;
}

.chat-search-count {
  font-size: 0.75rem;
  color: #93c5fd;
  min-width: 2.2rem;
}

.head-note {
  font-size: 0.675rem;
  color: #86efac;
  white-space: nowrap;
  flex-shrink: 0;
}

.head-note.locked {
  color: #fca5a5;
}

.call-panel {
  border-bottom: 1px solid var(--line);
  background: #0b1220;
  padding: 0.5rem 0.7rem 0.65rem;
}

.call-panel.hidden {
  display: none;
}

.call-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}

.call-status-text {
  color: #93c5fd;
  font-size: 0.78rem;
}

.call-route-text {
  font-size: 0.82rem;
  color: #cbd5e1;
  margin-bottom: 0.45rem;
}

.call-traffic-text {
  font-size: 0.76rem;
  color: #93c5fd;
  margin-bottom: 0.45rem;
}

.call-device-row {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto 1fr;
  gap: 0.35rem 0.45rem;
  align-items: center;
  margin-bottom: 0.45rem;
}

.call-device-row label {
  font-size: 0.68rem;
  color: #9fb3cb;
}

.call-device-row select {
  min-width: 0;
  padding: 0.28rem 0.36rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.72rem;
}

@media (max-width: 980px) {
  .call-device-row {
    grid-template-columns: auto 1fr;
  }
}

.incoming-call-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid #22c55e;
  border-radius: 9px;
  background: #052e16;
  margin-bottom: 0.45rem;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.25), 0 0 18px rgba(34, 197, 94, 0.2);
}

.incoming-call-banner.hidden {
  display: none;
}

.incoming-call-actions {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

.missed-call-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid #f59e0b;
  border-radius: 9px;
  background: #3b2a06;
  margin-bottom: 0.45rem;
  color: #fde68a;
}

.missed-call-banner.hidden {
  display: none;
}

.missed-call-actions {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

.global-call-attempt-banner {
  position: fixed;
  top: 0.9rem;
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  width: min(92vw, 760px);
  z-index: 1200;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 2px solid #dc2626;
  background: linear-gradient(135deg, #450a0a, #7f1d1d);
  color: #fee2e2;
  box-shadow: 0 16px 34px rgba(2, 6, 23, 0.55), 0 0 0 2px rgba(220, 38, 38, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.global-call-attempt-banner.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
  animation: callAttemptPulse 1.1s ease-in-out infinite alternate;
}

.global-call-attempt-main {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  font-size: 0.92rem;
  line-height: 1.3;
}

.global-call-attempt-main strong {
  color: #fff;
}

.global-call-attempt-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.global-call-attempt-actions .mini-link-btn {
  border-color: rgba(254, 226, 226, 0.45);
  background: rgba(2, 6, 23, 0.28);
  color: #fff;
  font-weight: 700;
}

@keyframes callAttemptPulse {
  from {
    box-shadow: 0 16px 34px rgba(2, 6, 23, 0.55), 0 0 0 2px rgba(220, 38, 38, 0.35);
  }
  to {
    box-shadow: 0 16px 34px rgba(2, 6, 23, 0.55), 0 0 0 3px rgba(248, 113, 113, 0.6);
  }
}

@media (max-width: 860px) {
  .global-call-attempt-banner {
    width: min(95vw, 560px);
    top: 0.55rem;
    padding: 0.62rem 0.65rem;
    gap: 0.5rem;
  }

  .global-call-attempt-main {
    font-size: 0.82rem;
  }
}

.call-videos {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  gap: 0.5rem;
}

.call-remote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.45rem;
}

.call-audio-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.call-tile {
  border: 1px solid #334155;
  border-radius: 10px;
  overflow: hidden;
  background: #020617;
  position: relative;
  min-height: 92px;
}

.call-tile video {
  width: 100%;
  height: 100%;
  max-height: 170px;
  object-fit: cover;
  display: block;
  background: #000;
}

.call-tile.no-video video {
  display: none;
}

.call-tile.no-video {
  background: linear-gradient(160deg, #0b1220, #101a30);
}

.call-tile.screen-share {
  grid-column: span 2;
  min-height: 140px;
}

.call-tile.screen-share video {
  max-height: 260px;
  object-fit: contain;
  background: #01030a;
}

.call-label {
  position: absolute;
  left: 0.35rem;
  bottom: 0.35rem;
  font-size: 0.7rem;
  color: #e2e8f0;
  background: rgba(2, 6, 23, 0.72);
  border: 1px solid #334155;
  border-radius: 999px;
  padding: 0.08rem 0.42rem;
}

.call-tile-actions {
  position: absolute;
  right: 0.35rem;
  top: 0.35rem;
  display: inline-flex;
  gap: 0.25rem;
  z-index: 2;
}

.call-mini-btn {
  border: 1px solid #334155;
  border-radius: 6px;
  background: rgba(2, 6, 23, 0.78);
  color: #e2e8f0;
  font-size: 0.72rem;
  padding: 0.15rem 0.35rem;
  cursor: pointer;
}

.call-mini-btn:hover {
  background: rgba(15, 23, 42, 0.92);
}

.call-offline-badge {
  position: absolute;
  left: 0.35rem;
  top: 0.35rem;
  background: rgba(127, 29, 29, 0.9);
  border: 1px solid #ef4444;
  color: #fecaca;
  border-radius: 999px;
  font-size: 0.68rem;
  padding: 0.08rem 0.45rem;
  z-index: 2;
}

.call-cam-off {
  position: absolute;
  right: 0.35rem;
  bottom: 0.35rem;
  background: rgba(30, 41, 59, 0.82);
  border: 1px solid #475569;
  color: #f8fafc;
  border-radius: 999px;
  font-size: 0.68rem;
  padding: 0.08rem 0.4rem;
  z-index: 2;
}

.hidden {
  display: none !important;
}

.mobile-backdrop {
  display: none;
}

.messages {
  padding: 1rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.pinned-strip {
  border-bottom: 1px solid var(--line);
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: stretch;
  overflow: visible;
  max-height: none;
  background: var(--panel-2);
  min-height: 110px;
}

.pinned-item-btn {
  border: 1px solid var(--line) !important;
  background: #10233a !important;
  color: #e5eef8 !important;
  border-radius: 10px;
  font-size: 0.92rem;
  padding: 0.85rem 0.95rem;
  cursor: pointer;
  width: 100% !important;
  height: auto !important;
  text-align: left;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  line-height: 1.5;
  display: flex !important;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 96px;
  justify-content: flex-start;
  opacity: 1 !important;
}

.pinned-item-meta {
  color: #8fc2f5 !important;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: block;
}

.pinned-item-text {
  white-space: pre-wrap;
  word-break: break-word;
  color: #e5eef8 !important;
  font-size: 0.94rem;
  display: block;
}

.msg {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  background: #111827;
  width: min(78%, 920px);
}

.msg-mine {
  align-self: flex-start;
}

.msg-other {
  align-self: flex-end;
}

.msg .meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.meta-user {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.msg-id-tag {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--accent-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.05rem 0.35rem;
  line-height: 1.2;
}

.msg .meta strong {
  color: #cbd5e1;
}

.meta-status-text {
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  color: #93c5fd;
  white-space: pre-wrap;
}

.msg-other .meta,
.msg-other .meta-status-text,
.msg-other .body,
.msg-other .msg-actions {
  text-align: right;
}

.msg-other .meta-user {
  margin-left: auto;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
}

.status-dot.available { background: #22c55e; }
.status-dot.dnd { background: #ef4444; }
.status-dot.break { background: #f59e0b; }
.status-dot.offline { background: #64748b; }

.msg .body {
  white-space: pre-wrap;
}

.msg.mention-hit {
  outline: 1px solid #fbbf24;
}

.msg-read {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.msg-reactions {
  margin-top: 0.35rem;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.reaction-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.72rem;
  padding: 0.16rem 0.45rem;
  cursor: pointer;
}

.msg.search-hit {
  outline: 1px solid #60a5fa;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.msg.search-hidden {
  display: none;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.35rem 0;
}

.file-thumb-btn {
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 0;
  background: #020617;
  cursor: zoom-in;
}

.file-thumb {
  width: 78px;
  height: 78px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.file-meta {
  min-width: 0;
}

.file-name {
  font-weight: 600;
  color: #e2e8f0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 360px;
}

.file-size {
  color: #94a3b8;
  font-size: 0.82rem;
}

.file-download {
  display: inline-block;
  margin-top: 0.25rem;
  color: #93c5fd;
  font-size: 0.84rem;
  text-decoration: none;
}

.image-viewer-card {
  width: min(94vw, 920px);
}

.image-viewer-img {
  max-width: 100%;
  max-height: 70vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0.25rem auto 0.6rem;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #020617;
}

.viewer-download-link {
  border: 0;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  font-weight: 700;
}

.msg-actions {
  margin-top: 0.45rem;
  display: flex;
  gap: 0.45rem;
}

.msg-btn {
  border: 1px solid #334155;
  border-radius: 6px;
  background: #0b1220;
  color: #e2e8f0;
  padding: 0.28rem 0.5rem;
  font-size: 0.76rem;
  cursor: pointer;
}

.msg-btn.danger {
  border-color: #7f1d1d;
  color: #fca5a5;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 0.75rem;
  display: grid;
  gap: 0.6rem;
}

.reply-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  padding: 0.35rem 0.45rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

#reply-cancel-btn {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input-bg-2);
  color: var(--text);
  font-size: 0.7rem;
  padding: 0.16rem 0.45rem;
  cursor: pointer;
}

.dropzone {
  border: 1px dashed #334155;
  border-radius: 10px;
  padding: 0.55rem;
  color: var(--muted);
  text-align: center;
}

.dropzone.active {
  border-color: var(--ok);
  color: #86efac;
  background: #052e16;
}

.dropzone.disabled {
  border-style: solid;
  border-color: #7f1d1d;
  color: #fca5a5;
  background: #1f1111;
}

textarea {
  resize: vertical;
  min-height: 70px;
  max-height: 180px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #0b1220;
  color: var(--text);
  padding: 0.65rem;
}

.mention-suggest {
  border: 1px solid #334155;
  background: #0b1220;
  border-radius: 10px;
  padding: 0.3rem;
  display: grid;
  gap: 0.2rem;
  max-height: 180px;
  overflow: auto;
}

.mention-suggest.hidden {
  display: none;
}

.mention-item {
  border: 0;
  text-align: left;
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  background: #111827;
  color: #dbeafe;
  cursor: pointer;
}

.mention-item.active,
.mention-item:hover {
  background: #1e293b;
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
}

.composer-actions button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  padding: 0.45rem 0.82rem;
  cursor: pointer;
}

#emoji-toggle-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 600;
}

.emoji-picker {
  display: flex;
  flex-direction: column;
  gap: 0.34rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--input-bg);
  padding: 0.35rem;
  max-height: 220px;
  overflow: auto;
}

.emoji-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0.1rem 0.2rem 0;
}

.emoji-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}

.emoji-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg-2);
  color: var(--text);
  cursor: pointer;
  min-width: 56px;
  height: 44px;
  padding: 0.15rem 0.34rem 0.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.08rem;
}

.emoji-char {
  font-size: 1rem;
  line-height: 1;
}

.emoji-tag {
  font-size: 0.56rem;
  line-height: 1;
  color: var(--muted);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.composer-actions button:hover { background: var(--accent-2); }

.composer.locked {
  opacity: 0.9;
}

textarea:disabled,
.composer-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.panel {
  background: #0f172a;
  padding: 0.85rem;
  height: 100%;
  overflow: auto;
  font-size: 0.75rem;
}

.app-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--footer-h);
  border-top: 1px solid #263247;
  background: #0a1324;
  color: #94a3b8;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.75rem;
  z-index: 100;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.details-collapsed .layout {
  grid-template-columns: 64px 240px minmax(0, 1fr);
}

body.details-collapsed .panel {
  display: none;
}

.panel h3 { margin-top: 0; }
.panel ul { padding-left: 1rem; color: var(--muted); font-size: 0.875rem; }

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

.panel-collapse-btn {
  flex-shrink: 0;
}

.details-block {
  margin-top: 0.8rem;
}

.details-block h4 {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
}

.details-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.details-list li {
  margin: 0.25rem 0;
  color: #cbd5e1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.task-item {
  display: grid !important;
  gap: 0.34rem;
  align-items: stretch !important;
}

.task-item.done .task-toggle-label span {
  text-decoration: line-through;
  opacity: 0.78;
}

.task-row {
  display: grid;
  gap: 0.16rem;
}

.task-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
}

.task-meta {
  color: var(--muted);
  font-size: 0.7rem;
}

.task-edit-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.24rem;
}

.task-edit-row input,
.task-edit-row select {
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--input-bg-2);
  color: var(--text);
  padding: 0.28rem 0.36rem;
  font-size: 0.74rem;
}

.my-task-badge {
  margin-top: 0.26rem;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.08rem 0.42rem;
  font-size: 0.68rem;
  color: var(--accent-2);
  background: var(--input-bg);
}

.details-member-main {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.details-avatar-btn {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  line-height: 0;
}

.details-avatar {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid #334155;
  background: #1f2937;
}

.mini-link-btn {
  border: 1px solid #334155;
  border-radius: 6px;
  background: #0b1220;
  color: #93c5fd;
  font-size: 0.68rem;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
}

.invite-row {
  margin-top: 0.45rem;
  display: flex;
  gap: 0.4rem;
}

.invite-row input {
  flex: 1;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #020617;
  color: #e2e8f0;
  padding: 0.36rem 0.45rem;
  font-size: 0.76rem;
}

.invite-row select {
  border-radius: 8px;
  border: 1px solid #334155;
  background: #020617;
  color: #e2e8f0;
  padding: 0.36rem 0.45rem;
  font-size: 0.76rem;
}

#room-bg-color {
  flex: 0 0 52px;
  width: 52px;
  min-width: 52px;
  padding: 0.2rem;
}

#room-bg-hex {
  flex: 0 0 108px;
  min-width: 92px;
  text-transform: lowercase;
}

.invite-row button {
  border: 0;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  padding: 0.36rem 0.52rem;
  font-size: 0.74rem;
  cursor: pointer;
}

.invite-search-results {
  margin-top: 0.45rem;
  display: grid;
  gap: 0.35rem;
}

#group-icon-input,
#room-icon-input {
  width: 100%;
}

.room-icon-preview-wrap {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.room-icon-preview {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid #334155;
  background: #1b2b43;
}

.group-member-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.group-member-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--input-bg-2);
  font-size: 0.78rem;
}

.group-member-chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
}

.poll-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--input-bg);
  padding: 0.45rem 0.55rem;
  margin-top: 0.45rem;
}

.poll-options {
  margin-top: 0.35rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.invite-result-item {
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0b1220;
  padding: 0.45rem 0.55rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.invite-result-main {
  min-width: 0;
}

.invite-result-mail {
  font-size: 0.66rem;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Bildabgeleitete Chat-Farbpalette */
.rail,
.rooms,
.chat,
.panel,
.modal-card,
.msg,
.mention-item,
.search-user,
.invite-result-item {
  background: var(--panel);
}

.rail,
.rooms,
.chat,
.panel,
.call-panel,
.user-box,
.composer,
.app-footer,
.modal-card {
  border-color: var(--line);
}

.brand {
  background: linear-gradient(135deg, #7bb5ea, var(--accent));
  color: #fff;
}

.room-item.active,
.room-item:hover,
.search-user:hover,
.mention-item.active,
.mention-item:hover {
  background: var(--input-bg-2);
}

.room-item-direct .room-link {
  background: linear-gradient(90deg, rgba(123, 181, 234, 0.24), rgba(123, 181, 234, 0));
}

.room-item-group .room-link {
  background: linear-gradient(90deg, rgba(132, 94, 168, 0.2), rgba(132, 94, 168, 0));
}

.modal {
  background: var(--overlay);
}

.rooms-tools input,
.modal-card input,
.modal-card select,
.modal-card textarea,
.status-row select,
#chat-search-input,
#sound-profile-select,
.sound-toggle-btn,
.volume-wrap,
.invite-row input,
.invite-row select,
textarea,
.mention-suggest,
.file-thumb-btn,
.image-viewer-img,
.invite-result-item,
.call-tile,
.call-label,
.call-mini-btn,
.msg-btn,
.room-trash-btn,
.mini-link-btn,
.emoji-btn {
  border-color: var(--line);
  background: var(--input-bg);
  color: var(--text);
}

.msg .meta strong,
.file-name,
.modal-card label,
.details-list li,
#sound-volume-value {
  color: var(--text);
}

.profile-upload-label,
.room-presence,
.search-hint,
.invite-result-mail,
.app-footer,
.file-size {
  color: var(--muted);
}

.chat-search-count,
.meta-status-text,
.file-download,
.logout,
.settings-link {
  color: var(--accent-2);
}

.room-trash-btn,
.msg-btn.danger {
  color: var(--danger);
  border-color: #d6a0b2;
  background: var(--danger-soft);
}

.room-trash-btn:hover {
  background: #f6dfe8;
}

.dropzone.active {
  border-color: var(--ok);
  color: #1f705f;
  background: #e8f8f3;
}

.dropzone.disabled {
  border-color: #d6a0b2;
  color: var(--danger);
  background: var(--danger-soft);
}

.call-offline-badge {
  background: var(--danger-soft);
  border-color: #a66a7e;
  color: var(--danger);
}

.call-cam-off {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}

.app-footer {
  background: var(--panel-2);
}

@media (max-width: 1180px) {
  .layout { grid-template-columns: 64px 240px 1fr; }
  .panel { display: none; }
  .desktop-only { display: none; }
  .call-videos { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  body {
    overflow: hidden;
  }

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

  .rail {
    display: none;
  }

  .chat {
    border-right: 0;
  }

  .chat-head {
    padding: 0.65rem 0.7rem;
    gap: 0.45rem;
  }

  .chat-head-left {
    max-width: 100%;
  }

  .chat-head-tools {
    width: 100%;
    justify-content: flex-start;
    gap: 0.4rem;
    flex-wrap: wrap;
    overflow: visible;
    white-space: normal;
  }

  .mobile-only {
    display: inline-flex;
  }

  .desktop-only {
    display: none;
  }

  #chat-search-input {
    width: min(46vw, 210px);
  }

  .rooms,
  .panel {
    display: block;
    position: fixed;
    top: 0;
    bottom: var(--footer-h);
    z-index: 220;
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
    box-shadow: 0 10px 26px rgba(2, 6, 23, 0.55);
    transition: transform 0.2s ease;
  }

  .rooms {
    left: 0;
    width: min(88vw, 340px);
    transform: translateX(-105%);
  }

  .panel {
    right: 0;
    width: min(88vw, 340px);
    transform: translateX(105%);
    padding: 0.7rem;
  }

  body.mobile-rooms-open .rooms {
    transform: translateX(0);
  }

  body.mobile-details-open .panel {
    transform: translateX(0);
  }

  .mobile-backdrop {
    position: fixed;
    inset: 0 0 var(--footer-h) 0;
    background: rgba(2, 6, 23, 0.52);
    z-index: 210;
    display: none;
  }

  body.mobile-rooms-open .mobile-backdrop,
  body.mobile-details-open .mobile-backdrop {
    display: block;
  }

  .messages {
    padding: 0.7rem;
  }

  .msg {
    width: 100%;
  }
}

/* Finale Theme-Absicherung */
.rail-link,
.search-user,
.room-trash-btn,
.modal-actions button.secondary,
#profile-image-form button,
.details-avatar,
.msg,
.mention-item,
.sound-toggle-btn,
.volume-wrap,
.msg-btn,
.mini-link-btn {
  background: var(--input-bg);
  border-color: var(--line);
  color: var(--text);
}

.rooms-tools input,
#chat-search-input,
#sound-profile-select,
.modal-card input,
.modal-card select,
.status-row select,
textarea,
.invite-row input,
.invite-row select,
.mention-suggest {
  background: var(--input-bg-2);
  border-color: var(--line);
  color: var(--text);
}

.rooms-tools input::placeholder,
#chat-search-input::placeholder,
textarea::placeholder,
.invite-row input::placeholder {
  color: var(--muted);
}

.rooms,
.panel,
.chat,
.call-panel,
.composer,
.user-box {
  background: var(--panel);
}

.mobile-backdrop {
  background: var(--overlay);
}

.rooms,
.panel {
  box-shadow: var(--elev-shadow);
}

.invite-row button,
.viewer-download-link,
.modal-actions button,
.rooms-head button,
.composer-actions button {
  background: var(--accent);
  color: #fff;
}

#emoji-toggle-btn {
  background: var(--input-bg-2);
  color: var(--text);
}

/* Login */
body.login-page {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: #12304f;
  font-family: "Segoe UI", Tahoma, sans-serif;
  position: relative;
  overflow: hidden;
}

body.login-page::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    url("../img/Plauder-Start-bild.png") center center / cover no-repeat,
    radial-gradient(circle at 10% 10%, #1e3552 0%, #0b1320 60%);
  z-index: -2;
}

body.login-page::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(8, 24, 40, 0.34);
  z-index: -1;
}

.login-card {
  width: min(92vw, 420px);
  background: rgba(244, 250, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 12px;
  padding: 1rem;
  backdrop-filter: blur(4px);
  box-shadow: 0 14px 36px rgba(8, 24, 40, 0.25);
}

body.login-page h1 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
}

body.login-page label {
  display: block;
  margin: 0.7rem 0 0.25rem;
  font-size: 0.85rem;
  color: #234564;
}

body.login-page input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem;
  border-radius: 8px;
  border: 1px solid #b9cee2;
  background: #f8fbff;
  color: #12304f;
}

body.login-page .password-field-row {
  position: relative;
  display: block;
}

body.login-page .pw-toggle-btn {
  position: absolute;
  top: 50%;
  right: 0.45rem;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: 1px solid #b9cee2;
  border-radius: 7px;
  background: #f3f8fe;
  color: #12304f;
  cursor: pointer;
}

body.login-page .pw-toggle-btn:hover {
  background: #d8e5f2;
}

body.login-page #password {
  padding-right: 2.65rem;
}

body.login-page .login-submit {
  width: 100%;
  margin-top: 1rem;
  border: 0;
  border-radius: 8px;
  background: #7a5ba7;
  color: #fff;
  padding: 0.7rem;
  font-weight: 700;
  cursor: pointer;
}

body.login-page .err {
  margin-top: 0.75rem;
  color: #9f2f52;
  font-size: 0.9rem;
}

/* Settings */
body.settings-page {
  overflow: auto;
  min-height: 100vh;
}

body.settings-page .settings-wrap {
  max-width: 780px;
  margin: 2rem auto;
  background: #111827;
  border: 1px solid #243044;
  border-radius: 12px;
  padding: 1rem;
}

body.settings-page .settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

body.settings-page .settings-grid .full {
  grid-column: 1 / -1;
}

body.settings-page .msg-ok {
  background: #052e16;
  border: 1px solid #16a34a;
  border-radius: 8px;
  padding: 0.55rem;
  margin-bottom: 0.8rem;
}

body.settings-page .msg-err {
  background: #7f1d1d;
  border: 1px solid #ef4444;
  border-radius: 8px;
  padding: 0.55rem;
  margin-bottom: 0.8rem;
}

body.settings-page .settings-wrap input,
body.settings-page .settings-wrap select,
body.settings-page .settings-wrap textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #020617;
  color: #f8fafc;
  padding: 0.55rem;
}

body.settings-page .settings-wrap textarea {
  min-height: 96px;
  resize: vertical;
}

body.settings-page .settings-wrap button {
  border: 0;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  font-weight: 700;
  margin-top: 0.65rem;
}

body.settings-page .settings-wrap form {
  margin-bottom: 1.1rem;
}

body.settings-page .settings-wrap h2 {
  margin-top: 1.35rem;
  margin-bottom: 0.6rem;
}

body.settings-page .settings-wrap label {
  display: block;
  margin-top: 0.45rem;
  margin-bottom: 0.25rem;
}

body.settings-page .note {
  background: #172554;
  border: 1px solid #3b82f6;
  border-radius: 8px;
  padding: 0.6rem;
  margin-top: 0.8rem;
  color: #dbeafe;
}

/* Setup */
body.setup-page {
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  margin: 0;
  overflow: auto;
  min-height: 100vh;
}

body.setup-locked-page {
  display: grid;
  place-items: center;
}

.setup-locked-card {
  max-width: 760px;
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 1rem;
}

.setup-mig-wrap {
  max-width: 900px;
  margin: 2rem auto;
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 1rem;
}

.setup-main-wrap {
  max-width: 760px;
  margin: 2rem auto;
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 1.25rem;
}

body.setup-page code {
  background: #020617;
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
}

body.setup-page a,
body.setup-page .setup-start-link {
  color: #93c5fd;
}

body.setup-page table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.6rem;
}

body.setup-page th,
body.setup-page td {
  text-align: left;
  border-bottom: 1px solid #223046;
  padding: 0.55rem 0.4rem;
}

body.setup-page .ok {
  color: #86efac;
}

body.setup-page .pending {
  color: #fcd34d;
}

body.setup-page .msg {
  background: #052e16;
  border: 1px solid #22c55e;
  border-radius: 8px;
  padding: 0.6rem;
  margin-bottom: 0.8rem;
}

body.setup-page .err {
  background: #7f1d1d;
  border: 1px solid #ef4444;
  border-radius: 8px;
  padding: 0.6rem;
  margin-bottom: 0.8rem;
}

body.setup-page button {
  margin-top: 1rem;
  border: 0;
  border-radius: 8px;
  padding: 0.7rem 1rem;
  background: #2563eb;
  color: white;
  font-weight: 600;
  cursor: pointer;
}

body.setup-main-page h1 {
  margin-top: 0;
  font-size: 1.5rem;
}

body.setup-main-page h2 {
  font-size: 1.05rem;
  margin-bottom: 0.7rem;
  margin-top: 1.4rem;
  color: #93c5fd;
}

body.setup-main-page .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

body.setup-main-page .full {
  grid-column: 1 / -1;
}

body.setup-main-page label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  color: #cbd5e1;
}

body.setup-main-page input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0b1220;
  color: #f8fafc;
}

.setup-back-link {
  margin-top: 1rem;
}

/* Admin */
body.admin-page {
  margin: 0;
  background: #0f172a;
  color: #e2e8f0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  overflow: auto;
}

body.admin-page .wrap {
  max-width: 980px;
  margin: 2rem auto;
  background: #111827;
  border: 1px solid #243044;
  border-radius: 12px;
  padding: 1rem;
}

body.admin-page h1 {
  margin-top: 0;
}

body.admin-page h2 {
  margin-top: 1.4rem;
  margin-bottom: 0.6rem;
  font-size: 1.05rem;
  color: #93c5fd;
}

body.admin-page label {
  display: block;
  margin-bottom: 0.4rem;
}

body.admin-page input,
body.admin-page .admin-select {
  width: 100%;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #020617;
  color: #f8fafc;
  box-sizing: border-box;
}

body.admin-page button {
  margin-top: 0.8rem;
  border: 0;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  background: #2563eb;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

/* User help */
body.help-page {
  margin: 0;
  min-height: 100vh;
  overflow: auto;
  background: #0f172a;
  color: #e2e8f0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  padding-bottom: var(--footer-h);
}

body.help-page .help-wrap {
  max-width: 920px;
  margin: 1.4rem auto;
  background: #111827;
  border: 1px solid #243044;
  border-radius: 12px;
  padding: 1rem;
}

body.help-page h1 {
  margin-top: 0;
  color: #93c5fd;
}

body.help-page .help-intro {
  color: #cbd5e1;
  margin-bottom: 0.95rem;
}

body.help-page .help-card {
  background: #0b1220;
  border: 1px solid #25364f;
  border-radius: 10px;
  padding: 0.8rem;
  margin-bottom: 0.8rem;
}

body.help-page .help-card h2 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
  color: #93c5fd;
}

body.help-page .help-card ol,
body.help-page .help-card ul {
  margin: 0.25rem 0 0;
  padding-left: 1.2rem;
}

body.help-page .help-card li {
  margin-bottom: 0.3rem;
}

body.help-page .help-actions {
  margin-top: 1rem;
}

body.admin-page table {
  width: 100%;
  border-collapse: collapse;
}

body.admin-page th,
body.admin-page td {
  border-bottom: 1px solid #233047;
  padding: 0.55rem 0.4rem;
  text-align: left;
  font-size: 0.92rem;
}

body.admin-page th {
  color: #93c5fd;
  font-weight: 600;
}

body.admin-page .msg {
  margin-bottom: 0.8rem;
  border-radius: 8px;
  padding: 0.55rem;
}

body.admin-page .ok {
  background: #052e16;
  border: 1px solid #16a34a;
}

body.admin-page .err {
  background: #7f1d1d;
  border: 1px solid #ef4444;
}

body.admin-page .info {
  background: #172554;
  border: 1px solid #3b82f6;
}

body.admin-page .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

body.admin-page .grid .full {
  grid-column: 1 / -1;
}

body.admin-page .mini-btn {
  margin-top: 0;
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
}

body.admin-page .admin-badge {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  background: #0c4a6e;
  color: #bae6fd;
  font-size: 0.78rem;
}

body.admin-page .collapse {
  border: 1px solid #233047;
  border-radius: 10px;
  margin-top: 0.9rem;
  background: #0b1220;
}

body.admin-page .collapse > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.75rem 0.9rem;
  font-weight: 700;
  color: #93c5fd;
  border-bottom: 1px solid #233047;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

body.admin-page .collapse > summary::-webkit-details-marker {
  display: none;
}

body.admin-page .collapse > summary::after {
  content: "▼";
  color: #bfdbfe;
  font-size: 0.82rem;
  line-height: 1;
  transition: transform 0.15s ease;
}

body.admin-page .collapse[open] > summary::after {
  content: "▲";
}

body.admin-page .collapse-content {
  padding: 0.75rem 0.9rem 0.9rem;
}

body.admin-page .table-search {
  max-width: 460px;
  margin-bottom: 0.65rem;
}

body.admin-page .filter-note {
  color: #93c5fd;
  font-size: 0.82rem;
  margin: 0.25rem 0 0.65rem;
}

body.admin-page a {
  color: #93c5fd;
}

body.admin-page .admin-current-upload {
  margin-top: 1rem;
  color: #94a3b8;
}

body.admin-page .admin-traffic-note {
  margin-top: 0.5rem;
  color: #94a3b8;
  font-size: 0.82rem;
}

body.admin-page .admin-stack-form {
  margin-top: 0.35rem;
}

body.admin-page .admin-filter-form {
  margin-bottom: 0.5rem;
}

body.admin-page .admin-filter-reset {
  margin-left: 0.6rem;
}

body.admin-page .admin-inline-form {
  display: inline-block;
}

body.admin-page .admin-pagination {
  margin-top: 0.6rem;
}

body.admin-page .admin-testmail-form {
  margin-top: 0.6rem;
}

body.admin-page .admin-mail-note {
  margin-top: 1rem;
  color: #94a3b8;
}

@media (max-width: 860px) {
  body.admin-page .grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  body.setup-main-page .grid {
    grid-template-columns: 1fr;
  }
  body.settings-page .settings-grid {
    grid-template-columns: 1fr;
  }
}
