:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #eef0fa;
  background: #10131d;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --panel: #191d2a;
  --panel-soft: #202536;
  --line: #30364a;
  --muted: #a4abc2;
  --accent: #a78bfa;
  --accent-strong: #8b5cf6;
  --danger: #fb7185;
  --success: #6ee7b7;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.auth-page,
.notice-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 18% 10%, rgb(139 92 246 / 18%), transparent 40%),
    radial-gradient(ellipse at 90% 90%, rgb(59 130 246 / 12%), transparent 35%),
    #10131d;
}

.auth-card,
.notice-card {
  width: min(100%, 440px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgb(25 29 42 / 94%);
  box-shadow: 0 24px 80px rgb(0 0 0 / 30%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(135deg, #a78bfa, #6366f1);
  color: #fff;
  font-size: 23px;
  font-weight: 800;
}

.brand h1,
.brand p,
.auth-card h2,
.notice-card h2 {
  margin: 0;
}

.brand p,
.subtitle,
.muted {
  color: var(--muted);
}

.auth-card h2,
.notice-card h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.auth-form,
.field-stack {
  display: grid;
  gap: 14px;
}

.auth-form {
  margin-top: 24px;
}

.field {
  display: grid;
  gap: 7px;
  color: #dce0ef;
  font-size: 14px;
}

.field input,
.message-input,
.search-input {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #111521;
  color: #fff;
}

.primary-button,
.secondary-button,
.quiet-button,
.danger-button {
  min-height: 42px;
  padding: 9px 14px;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 120ms ease, background 120ms ease;
}

.primary-button {
  background: var(--accent-strong);
  color: #fff;
}

.primary-button:hover {
  background: #7c3aed;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.quiet-button {
  min-height: 34px;
  padding: 6px 9px;
  background: transparent;
  color: var(--muted);
}

.quiet-button:hover,
.secondary-button:hover {
  background: #2a3042;
}

.danger-button {
  min-height: 32px;
  padding: 5px 9px;
  background: rgb(251 113 133 / 14%);
  color: #fda4af;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.auth-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
}

.auth-switch button {
  border: 0;
  background: transparent;
  color: #c4b5fd;
  cursor: pointer;
  font-weight: 700;
}

.notice-card p {
  color: var(--muted);
  line-height: 1.6;
}

.notice-card code {
  color: #ddd6fe;
}

.error-box,
.success-box {
  margin-top: 16px;
  padding: 11px 13px;
  border-radius: 11px;
  line-height: 1.45;
}

.error-box {
  border: 1px solid rgb(251 113 133 / 30%);
  background: rgb(251 113 133 / 10%);
  color: #fecdd3;
}

.success-box {
  border: 1px solid rgb(110 231 183 / 30%);
  background: rgb(110 231 183 / 9%);
  color: #a7f3d0;
}

.app-shell {
  display: grid;
  width: min(1500px, 100%);
  min-height: 100vh;
  grid-template: 68px 1fr / 290px minmax(0, 1fr);
  margin: 0 auto;
  background: #141824;
}

.topbar {
  z-index: 2;
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: #191d2a;
}

.topbar .brand {
  margin: 0;
}

.topbar .brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  font-size: 20px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-label {
  color: var(--muted);
  font-size: 14px;
}

.sidebar {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 18px;
  padding: 18px 12px;
  border-right: 1px solid var(--line);
  background: #191d2a;
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.room-list {
  display: grid;
  max-height: 38vh;
  gap: 4px;
  overflow: auto;
}

.room-button {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #c7cce0;
  cursor: pointer;
  text-align: left;
}

.room-button:hover,
.room-button.is-active {
  background: #2b3043;
  color: #fff;
}

.room-symbol {
  width: 20px;
  color: #c4b5fd;
  font-weight: 800;
  text-align: center;
}

.sidebar-footer {
  display: grid;
  gap: 9px;
  margin-top: auto;
}

.sidebar-hint {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.main-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}

.room-header {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
}

.room-header h2 {
  overflow: hidden;
  margin: 0;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.message-list {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding: 20px 22px;
}

.empty-state {
  display: grid;
  flex: 1;
  place-content: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 7px;
  color: #e8e9f3;
  font-size: 18px;
}

.message {
  max-width: min(760px, 92%);
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
}

.message.is-own {
  align-self: flex-end;
  border-color: rgb(167 139 250 / 28%);
  background: #29233d;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.message-meta strong {
  color: #d8ccff;
}

.message-body {
  overflow-wrap: anywhere;
  line-height: 1.5;
  white-space: pre-wrap;
}

.message-actions {
  margin-top: 6px;
  text-align: right;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 20px 20px;
}

.message-input {
  min-height: 48px;
  max-height: 140px;
  resize: vertical;
}

.composer .primary-button {
  flex: 0 0 auto;
}

.moderation-panel {
  max-height: 34vh;
  overflow: auto;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: #191d2a;
}

.moderation-panel h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.report-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.report-row p {
  margin: 4px 0 0;
  color: #e1e4ef;
}

.offline-banner {
  position: fixed;
  right: 12px;
  bottom: 12px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #252a39;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template: 62px minmax(160px, 30vh) minmax(0, 1fr) / minmax(0, 1fr);
  }

  .topbar {
    grid-column: 1;
    padding: 0 12px;
  }

  .topbar .brand h1 {
    font-size: 16px;
  }

  .user-label {
    display: none;
  }

  .sidebar {
    min-height: 0;
    flex-direction: row;
    align-items: stretch;
    overflow: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px;
  }

  .sidebar-section {
    display: flex;
    min-width: 150px;
    flex: 1;
    flex-direction: column;
  }

  .room-list {
    max-height: 20vh;
  }

  .sidebar-footer {
    min-width: 140px;
    margin-top: 0;
  }

  .sidebar-hint {
    display: none;
  }

  .room-header {
    min-height: 58px;
    padding: 10px 14px;
  }

  .message-list {
    padding: 14px;
  }

  .composer {
    padding: 10px 12px 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
