:root {
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #161a22;
  --panel-alt: #1d2330;
  --text: #e7ecf5;
  --muted: #98a4b8;
  --accent: #67a2ff;
  --success: #2aa96d;
  --danger: #db5f5f;
  --border: #2b3445;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Segoe UI", -apple-system, system-ui, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

h1, h2, h3, p { margin: 0; }

.muted {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

/* ── Auth ── */

.auth-wrapper {
  height: 100%;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: radial-gradient(circle at top left, #1f2735 0%, var(--bg) 52%);
}

.auth-card {
  width: min(480px, 100%);
  background: rgba(22, 26, 34, 0.96);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: grid;
  gap: 12px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.45);
}

.auth-card h1 {
  font-size: 24px;
  text-align: center;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tab {
  border: 1px solid var(--border);
  background: var(--panel-alt);
  color: var(--text);
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  font-size: 14px;
}

.tab.active {
  border-color: var(--accent);
  background: rgba(103, 162, 255, 0.15);
}

.tab-panel {
  display: none;
  gap: 10px;
}

.tab-panel.active {
  display: grid;
}

label {
  font-size: 13px;
  color: #c3ccdc;
}

small {
  color: var(--muted);
  font-size: 12px;
}

input,
textarea,
button {
  font: inherit;
  font-size: 14px;
}

input,
textarea {
  width: 100%;
  background: #0f131c;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
}

button {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--panel-alt);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.alert {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

.alert.error {
  background: rgba(219, 95, 95, 0.18);
  border: 1px solid rgba(219, 95, 95, 0.4);
}

.alert.success {
  background: rgba(42, 169, 109, 0.16);
  border: 1px solid rgba(42, 169, 109, 0.4);
}

.admin-note {
  color: #bfc7d7;
  font-size: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  line-height: 1.4;
}

/* ── App Shell ── */

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: rgba(20, 24, 33, 0.95);
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-header {
  display: grid;
  gap: 4px;
}

.sidebar-header h2 {
  font-size: 18px;
}

.sidebar-header p {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-section h3 {
  margin-bottom: 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.item-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.side-item {
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  font-size: 14px;
  border-radius: 10px;
}

.side-item.active {
  border-color: var(--accent);
  background: rgba(103, 162, 255, 0.2);
}

.empty-item {
  color: var(--muted);
  font-size: 12px;
}

.pending-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: #141a25;
  display: grid;
  gap: 6px;
}

.pending-item video {
  width: 100%;
  border-radius: 8px;
  background: #000;
  max-height: 220px;
}

.pending-item img {
  width: 100%;
  border-radius: 8px;
  background: #000;
  max-height: 220px;
  object-fit: cover;
}

.pending-date {
  color: var(--muted);
  font-size: 11px;
}

.pending-actions {
  display: flex;
  gap: 6px;
}

.pending-actions .danger {
  border-color: rgba(219, 95, 95, 0.7);
}

/* ── Content (chat area) ── */

.content {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.content-header {
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  background: rgba(15, 17, 22, 0.6);
}

.content-header h2 {
  font-size: 16px;
}

/* ── Messages ── */

.messages {
  padding: 14px 16px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.message {
  border: none;
  border-radius: 18px;
  padding: 8px 12px;
  width: fit-content;
  max-width: min(82%, 640px);
  position: relative;
}

.message.other {
  align-self: flex-start;
  background: #1d2636;
  border-bottom-left-radius: 6px;
}

.message.own {
  align-self: flex-end;
  background: #2759bf;
  border-bottom-right-radius: 6px;
}

.message-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
  font-size: 12px;
}

.message-meta strong {
  font-size: 12px;
}

.message-meta span {
  color: var(--muted);
  font-size: 11px;
}

.message.own .message-meta span {
  color: rgba(210, 225, 255, 0.7);
}

.message-text {
  margin: 0;
  line-height: 1.4;
  white-space: pre-wrap;
  font-size: 14px;
}

.message.own .message-text {
  color: #f5f8ff;
}

.chat-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 12px;
  margin-top: 4px;
  margin-bottom: 4px;
  display: block;
  object-fit: cover;
}

.empty-state {
  color: var(--muted);
  margin: auto;
  font-size: 14px;
}

/* ── Reactions (like / dislike) ── */

.reaction-row {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.reaction-btn {
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.reaction-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.15);
  border-color: transparent;
}

.reaction-btn.active {
  background: rgba(103, 162, 255, 0.22);
  border-color: var(--accent);
}

.message.own .reaction-btn {
  background: rgba(255, 255, 255, 0.12);
}

.message.own .reaction-btn.active {
  background: rgba(255, 255, 255, 0.25);
  border-color: #d2e2ff;
}

.reaction-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  min-width: 10px;
  text-align: center;
}

.message.own .reaction-count {
  color: #e8efff;
}

/* ── Message form ── */

.message-form {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  background: rgba(15, 17, 22, 0.7);
  display: grid;
  gap: 4px;
}

.message-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.message-input-row textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  border-radius: 20px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.35;
}

.attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}

.attach-btn:hover {
  color: var(--accent);
}

.attach-btn input[type="file"] {
  display: none;
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.send-btn:hover {
  background: #5593f0;
  border-color: transparent;
}

.chat-image-info {
  font-size: 12px;
  color: #b8c5dc;
  padding-left: 4px;
}

textarea {
  resize: none;
}

/* ── Mobile ── */

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: none;
    padding: 10px 12px;
    gap: 8px;
    overflow-y: visible;
  }

  .sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .sidebar-header h2 {
    font-size: 16px;
  }

  .sidebar-header p {
    font-size: 11px;
  }

  .sidebar-section h3 {
    font-size: 12px;
    margin-bottom: 4px;
  }

  .item-list.static {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .item-list.static li {
    flex: 0 0 auto;
  }

  .side-item {
    text-align: center;
    padding: 7px 14px;
    font-size: 13px;
    white-space: nowrap;
  }

  .content {
    height: auto;
    min-height: 0;
    flex: 1;
    display: grid;
    grid-template-rows: auto 1fr auto;
  }

  .content-header {
    padding: 10px 12px;
  }

  .content-header h2 {
    font-size: 15px;
  }

  .messages {
    padding: 10px;
  }

  .message {
    max-width: 90%;
    font-size: 13px;
  }

  .message-meta strong {
    font-size: 11px;
  }

  .message-meta span {
    font-size: 10px;
  }

  .message-text {
    font-size: 13px;
  }

  .message-form {
    padding: 8px 10px;
  }

  .message-input-row textarea {
    font-size: 14px;
    min-height: 38px;
    padding: 8px 12px;
  }

  .chat-image {
    max-height: 200px;
  }
}

@media (max-width: 480px) {
  .auth-wrapper {
    padding: 8px;
    align-items: flex-start;
  }

  .auth-card {
    margin-top: 8px;
    border-radius: 14px;
    padding: 16px;
    gap: 10px;
  }

  .auth-card h1 {
    font-size: 20px;
  }

  .auth-card .muted {
    font-size: 13px;
  }

  .tab {
    padding: 8px;
    font-size: 13px;
  }

  .admin-note {
    font-size: 11px;
  }
}
