﻿:root {
  --topbar-height: 74px;
  --footer-height: 56px;
  --bg-dark: #131417;
  --bg-light: #d4d4d4;
  --text-dark: #eceef2;
  --text-light: #141414;
  --surface-dark: rgba(25, 28, 35, 0.9);
  --surface-light: rgba(255, 255, 255, 0.82);
  --border-dark: rgba(255, 255, 255, 0.15);
  --border-light: rgba(0, 0, 0, 0.14);
  --accent: #1f8f5f;
  --accent-hover: #15764d;
  --danger: #b63f3f;
  --font-main: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  height: 100%;
}

body {
  font-family: var(--font-main);
  background: var(--bg-light);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background-color 220ms ease, color 220ms ease;
}

body.theme-dark {
  background: var(--bg-dark);
  color: var(--text-dark);
}

#bgCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  background: var(--bg-light);
}

body.theme-dark #bgCanvas {
  background: var(--bg-dark);
}

/* ─── Loading screen ─────────────────────────────────────────────────────── */

#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d0d10;
  transition: opacity 400ms ease;
}

#loadingCanvas {
  width: 200px;
  height: 200px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
  min-height: var(--topbar-height);
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  padding: 0 16px 0 0;
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--border-light);
  background: rgba(212, 212, 212, 0.45);
}

body.theme-dark .topbar {
  background: rgba(19, 20, 23, 0.45);
  border-bottom: 1px solid var(--border-dark);
}

.logo-link {
  display: inline-flex;
  align-items: center;
  position: relative;
  width: var(--topbar-height);
  height: var(--topbar-height);
  border-radius: 0;
}

.logo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  border: none;
  background: rgba(255, 255, 255, 0.4);
}

body.theme-dark .logo {
  border: none;
  background: rgba(255, 255, 255, 0.06);
}

.logo-light {
  display: block;
}

.logo-dark-static,
.logo-dark-animated {
  display: none;
}

video.logo-dark-animated {
  background: transparent;
}

body.theme-dark .logo-light {
  display: none;
}

body.theme-dark .logo-dark-static {
  display: block;
}

body.theme-dark .logo-link:hover .logo-dark-static,
body.theme-dark .logo-link:focus-visible .logo-dark-static {
  display: none;
}

body.theme-dark .logo-link:hover .logo-dark-animated,
body.theme-dark .logo-link:focus-visible .logo-dark-animated {
  display: block;
}

.topbar-nav {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  color: inherit;
  opacity: 0.7;
  transition: opacity 140ms ease, color 140ms ease, text-shadow 140ms ease;
  border-radius: 0;
}

.nav-link:hover {
  opacity: 1;
  background: none;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(31, 143, 95, 0.6), 0 0 24px rgba(31, 143, 95, 0.25);
}

body.theme-dark .nav-link:hover {
  background: none;
  text-shadow: 0 0 14px rgba(31, 143, 95, 0.75), 0 0 28px rgba(31, 143, 95, 0.35);
}

.nav-link-active {
  opacity: 1;
  background: none;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(31, 143, 95, 0.6), 0 0 24px rgba(31, 143, 95, 0.25);
}

.nav-dropdown:hover .nav-link,
.nav-dropdown:focus-within .nav-link {
  opacity: 1;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(31, 143, 95, 0.6), 0 0 24px rgba(31, 143, 95, 0.25);
}

body.theme-dark .nav-dropdown:hover .nav-link,
body.theme-dark .nav-dropdown:focus-within .nav-link {
  text-shadow: 0 0 14px rgba(31, 143, 95, 0.75), 0 0 28px rgba(31, 143, 95, 0.35);
}

.nav-dropdown {
  position: relative;
  display: flex;
  align-items: stretch;
}

.nav-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nav-dropdown-toggle::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.7px solid currentColor;
  border-bottom: 1.7px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  opacity: 0.9;
}

.nav-dropdown-menu {
  position: absolute;
  left: 0;
  top: 100%;
  min-width: 180px;
  padding-top: 8px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px) scale(0.98);
  transition: opacity 140ms ease, transform 160ms ease, visibility 0s linear 160ms;
  z-index: 1100;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition: opacity 140ms ease, transform 160ms ease;
}

.nav-dropdown.nav-dropdown--just-clicked .nav-dropdown-menu,
.nav-dropdown.nav-dropdown--just-clicked:hover .nav-dropdown-menu,
.nav-dropdown.nav-dropdown--just-clicked:focus-within .nav-dropdown-menu {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-4px) scale(0.98);
}

.nav-dropdown-list {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-light);
  background: var(--surface-light);
}

body.theme-dark .nav-dropdown-list {
  border-color: var(--border-dark);
  background: var(--surface-dark);
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  color: inherit;
  text-decoration: none;
  font-size: 13px;
  opacity: 0.85;
}

.nav-dropdown-item:hover {
  opacity: 1;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.06);
}

body.theme-dark .nav-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

body.theme-dark .nav-link-active {
  background: none;
  text-shadow: 0 0 14px rgba(31, 143, 95, 0.75), 0 0 28px rgba(31, 143, 95, 0.35);
}

/* ─── Commands page ─────────────────────────────────────────────────────── */

.cmd-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.cmd-sidebar {
  flex-shrink: 0;
  width: 180px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: calc(var(--topbar-height) + 12px);
}

.cmd-sidebar-title {
  font-weight: 700;
  font-size: 1rem;
  margin: 0 0 8px 4px;
}

.cmd-cat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  opacity: 0.7;
  transition: opacity 140ms ease, background 140ms ease;
}

.cmd-cat-btn:hover {
  opacity: 1;
  background: rgba(0,0,0,0.07);
}

body.theme-dark .cmd-cat-btn:hover {
  background: rgba(255,255,255,0.08);
}

.cmd-cat-btn.cmd-cat-active {
  opacity: 1;
  background: rgba(0,0,0,0.09);
  font-weight: 600;
}

body.theme-dark .cmd-cat-btn.cmd-cat-active {
  background: rgba(255,255,255,0.11);
}

.cmd-cat-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.cmd-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cmd-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-light);
  background: var(--surface-light);
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: inherit;
  transition: background 140ms ease, border-color 140ms ease;
}

.cmd-item:hover {
  background: rgba(0,0,0,0.06);
}

body.theme-dark .cmd-item {
  border-color: var(--border-dark);
  background: var(--surface-dark);
}

body.theme-dark .cmd-item:hover {
  background: rgba(255,255,255,0.08);
}

.cmd-name {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
}

.cmd-short-desc {
  font-size: 0.82rem;
  opacity: 0.65;
  line-height: 1.4;
}

/* ─── Modal ─────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0);
  backdrop-filter: blur(0px);
  transition: background 180ms ease, backdrop-filter 180ms ease;
}

.modal-overlay.modal-visible {
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
}

.modal-box {
  background: var(--surface-light);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  overflow: hidden;
  max-width: 480px;
  width: calc(100% - 40px);
  display: flex;
  flex-direction: column;
  gap: 0;
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  transition: opacity 180ms ease, transform 180ms ease;
}

.modal-box-body {
  padding: 28px 32px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-overlay.modal-visible .modal-box {
  opacity: 1;
  transform: translateY(0) scale(1);
}

body.theme-dark .modal-box {
  background: var(--surface-dark);
  border-color: var(--border-dark);
}

.modal-cmd-name {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}

.modal-cmd-desc {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.65;
  opacity: 0.9;
}

.modal-close-btn {
  width: 100%;
  border-radius: 0 !important;
  margin: 0;
}

/* ─────────────────────────────────────────────────────────────────────────── */

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

@keyframes topbar-rgb-glow {
  0%   { text-shadow: 0 0 10px #1f8f5f, 0 0 22px #1f8f5faa; color: #1f8f5f; }
  16%  { text-shadow: 0 0 12px #3ab8ff, 0 0 24px #3ab8ffaa; color: #3ab8ff; }
  33%  { text-shadow: 0 0 12px #a855f7, 0 0 24px #a855f7aa; color: #a855f7; }
  50%  { text-shadow: 0 0 12px #f97316, 0 0 24px #f97316aa; color: #f97316; }
  66%  { text-shadow: 0 0 12px #ec4899, 0 0 24px #ec4899aa; color: #ec4899; }
  83%  { text-shadow: 0 0 12px #facc15, 0 0 24px #facc15aa; color: #facc15; }
  100% { text-shadow: 0 0 10px #1f8f5f, 0 0 22px #1f8f5faa; color: #1f8f5f; }
}

.topbar-welcome {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(0.95rem, 3.5vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  pointer-events: none;
  white-space: nowrap;
  user-select: none;
  color: #1f8f5f;
  animation: topbar-rgb-glow 14s ease-in-out infinite;
}

a.topbar-welcome,
.topbar-welcome-link {
  pointer-events: auto;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
}

a.topbar-welcome:hover,
.topbar-welcome-link:hover {
  opacity: 0.78;
}

.auth-actions {
  display: flex;
  gap: 8px;
}

.discord-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 10px;
  background: #5865F2;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 140ms ease;
}

.discord-btn:hover {
  background: #4752c4;
}

.discord-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.secondary {
  background: transparent;
  border: 1px solid var(--border-light);
  color: inherit;
}

.btn.danger {
  background: var(--danger);
  color: #fff;
}

.btn.danger:hover {
  filter: brightness(0.92);
}

body.theme-dark .btn.secondary {
  border-color: var(--border-dark);
}

.btn.link {
  background: transparent;
  color: inherit;
  text-decoration: underline;
}

.user-panel {
  position: relative;
}

.user-menu-btn {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  color: inherit;
  border-radius: 0;
  padding: 6px 0;
  cursor: pointer;
}

body.theme-dark .user-menu-btn {
  border: none;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: #c0c0c0;
}

.avatar-hidden {
  display: none;
}

.user-anon-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0,0,0,0.08);
  color: inherit;
  flex-shrink: 0;
}

body.theme-dark .user-anon-icon {
  background: rgba(255,255,255,0.1);
}

.user-anon-icon.hidden {
  display: none;
}

.user-nickname-text {
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.user-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  border: 1.5px solid transparent;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.role-member {
  color: #fff;
  border-color: #12a06a;
  background: linear-gradient(135deg, #12a06a, #0d7a51);
  box-shadow: 0 1px 6px rgba(18, 160, 106, 0.4);
}

.role-old {
  color: #fff;
  border-color: #c47a14;
  background: linear-gradient(135deg, #e08a18, #c47a14);
  box-shadow: 0 1px 6px rgba(196, 122, 20, 0.4);
}

.role-mod {
  color: #fff;
  border-color: #1a7ec4;
  background: linear-gradient(135deg, #1e8de0, #1a7ec4);
  box-shadow: 0 1px 6px rgba(26, 126, 196, 0.4);
}

.role-admin {
  color: #fff;
  border-color: #c42424;
  background: linear-gradient(135deg, #e02828, #c42424);
  box-shadow: 0 1px 6px rgba(196, 36, 36, 0.4);
}

.role-owner {
  color: #fff;
  border-color: #7c2fd4;
  background: linear-gradient(135deg, #9640f5, #7c2fd4);
  box-shadow: 0 1px 6px rgba(124, 47, 212, 0.4);
}

#userNickname {
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
}

.user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  border-radius: 12px;
  display: grid;
  gap: 0;
  padding: 0;
  min-width: 220px;
  overflow: hidden;
  border: 1px solid var(--border-light);
  background: var(--surface-light);
}

.dropdown-menu {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px) scale(0.98);
  transition: opacity 140ms ease, transform 160ms ease, visibility 0s linear 160ms;
}

.dropdown-menu.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition: opacity 140ms ease, transform 160ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .dropdown-menu,
  .dropdown-menu.is-open {
    transition: none;
    transform: none;
  }
}

body.theme-dark .user-menu {
  border-color: var(--border-dark);
  background: var(--surface-dark);
}

.user-menu button {
  border: 0;
  border-bottom: 1px solid var(--border-light);
  border-radius: 0;
  text-align: left;
  padding: 14px 16px;
  cursor: pointer;
  color: inherit;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  font-size: 15px;
}

.user-menu button:last-child {
  border-bottom: 0;
}

.menu-item-disabled {
  opacity: 0.45;
  cursor: not-allowed !important;
  pointer-events: none;
}

.menu-item-wip {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  opacity: 0.85;
  letter-spacing: 0.02em;
}

.user-menu button:hover {
  background: rgba(0, 0, 0, 0.07);
}

body.theme-dark .user-menu button {
  border-bottom-color: var(--border-dark);
}

body.theme-dark .user-menu button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.menu-btn-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.content {
  width: min(900px, calc(100% - 24px));
  margin: 22px auto;
  flex: 1;
  padding-bottom: 18px;
  position: relative;
  z-index: 1;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

/* ─── Home page ─────────────────────────────────────────────────────────── */

.profile-wrap {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-top: 8px;
}

/* — Hero card */
.profile-hero {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 32px 36px;
  border: 1px solid var(--border-light);
  border-radius: 18px;
  background: var(--surface-light);
  position: relative;
  overflow: hidden;
}

body.theme-dark .profile-hero {
  border-color: var(--border-dark);
  background: var(--surface-dark);
}

.profile-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 0% 0%, rgba(31,143,95,0.13) 0%, transparent 60%),
              radial-gradient(ellipse at 100% 100%, rgba(58,184,255,0.09) 0%, transparent 55%);
  pointer-events: none;
}

.profile-avatar-wrap {
  flex-shrink: 0;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #3ab8ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  box-shadow: 0 4px 20px rgba(31,143,95,0.38);
  position: relative;
  z-index: 1;
}

.profile-hero-text {
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: relative;
  z-index: 1;
}

.profile-name {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0;
  background: linear-gradient(135deg, var(--accent) 0%, #3ab8ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.profile-role {
  font-size: 0.92rem;
  opacity: 0.55;
  font-weight: 500;
  margin: 0;
  letter-spacing: 0.01em;
}

.profile-tagline {
  font-size: 1rem;
  margin: 6px 0 0;
  opacity: 0.82;
  line-height: 1.55;
}

/* — Stats row */
.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.profile-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 20px 12px;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  background: var(--surface-light);
  text-align: center;
  min-width: 0;
  overflow: hidden;
}

body.theme-dark .profile-stat {
  border-color: var(--border-dark);
  background: var(--surface-dark);
}

.profile-stat-value {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent) 0%, #3ab8ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.profile-stat-label {
  font-size: 0.75rem;
  opacity: 0.5;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

/* — Cards grid */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.profile-card {
  padding: 22px 24px;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  background: var(--surface-light);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

body.theme-dark .profile-card {
  border-color: var(--border-dark);
  background: var(--surface-dark);
}

.profile-card-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.42;
  margin: 0;
}

.profile-card-content {
  font-size: 0.95rem;
  line-height: 1.65;
  margin: 0;
  opacity: 0.88;
}

.profile-roles-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.roles-list-wrap {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.role-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: rgba(0,0,0,0.02);
}

body.theme-dark .role-list-item {
  border-color: var(--border-dark);
  background: rgba(255,255,255,0.03);
}

.role-value {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.82rem;
  opacity: 0.6;
}

.profile-edit-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.profile-edit-hero {
  align-items: flex-start;
}

.profile-edit-avatar-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.profile-user-avatar {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-light);
}

body.theme-dark .profile-user-avatar {
  border-color: var(--border-dark);
}

.profile-avatar-fallback {
  width: 108px;
  height: 108px;
  font-size: 2.8rem;
  color: #ffffff;
}

.profile-avatar-fallback .icon-svg {
  width: 52px;
  height: 52px;
}

.profile-avatar-hint {
  font-size: 12px;
  opacity: 0.62;
}

.profile-edit-fields {
  width: 100%;
}

.profile-bio-input {
  min-height: 96px;
  max-height: 220px;
  resize: vertical;
  overflow-y: auto;
}

.profile-panel-card {
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 20px;
  background: var(--surface-light);
}

body.theme-dark .profile-panel-card {
  border-color: var(--border-dark);
  background: var(--surface-dark);
}

.profile-security-summary {
  margin-top: 4px;
  font-size: 0.83rem;
  opacity: 0.7;
}

/* ===== Profile Editor Layout ===== */

.profile-editor-layout {
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.profile-tab-sidebar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 168px;
  padding: 8px 16px 8px 0;
  border-right: 1px solid var(--border-light);
  flex-shrink: 0;
}

body.theme-dark .profile-tab-sidebar {
  border-right-color: var(--border-dark);
}

.profile-tab-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted, #888);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 140ms, color 140ms;
  width: 100%;
}

.profile-tab-btn:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text, inherit);
}

body.theme-dark .profile-tab-btn:hover {
  background: rgba(255,255,255,0.06);
}

.profile-tab-btn.profile-tab-active {
  background: rgba(31, 143, 95, 0.12);
  color: #12a06a;
  font-weight: 600;
}

body.theme-dark .profile-tab-btn.profile-tab-active {
  background: rgba(18, 160, 106, 0.15);
  color: #22c97e;
}

.profile-tab-content {
  flex: 1;
  min-width: 0;
  padding-left: 28px;
}

.profile-tab-panel {
  width: 100%;
}

/* Security sections */

.profile-security-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--border-light);
}

body.theme-dark .profile-security-section {
  border-bottom-color: var(--border-dark);
}

.profile-security-section:last-child {
  border-bottom: none;
}

.profile-security-card {
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 18px;
  background: var(--surface-light);
  margin-bottom: 14px;
}

body.theme-dark .profile-security-card {
  border-color: var(--border-dark);
  background: var(--surface-dark);
}

.profile-password-form {
  max-width: 440px;
}

.profile-compact-field {
  margin-bottom: 12px;
}

.profile-compact-field .auth-input {
  padding: 9px 12px;
  font-size: 0.95rem;
}

.profile-password-code-wrap {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-light);
}

body.theme-dark .profile-password-code-wrap {
  border-top-color: var(--border-dark);
}

.profile-password-code-hint {
  margin-bottom: 10px;
}

.profile-section-header {
  margin-bottom: 16px;
}

.profile-section-title {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
}

.profile-section-hint {
  margin: 0;
  font-size: 0.83rem;
  opacity: 0.65;
}

.profile-edit-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}

.profile-edit-header .profile-name {
  margin: 0;
}

@media (max-width: 600px) {
  .profile-editor-layout {
    flex-direction: column;
  }
  .profile-tab-sidebar {
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
    padding: 0 0 10px;
    width: 100%;
    min-width: unset;
  }
  body.theme-dark .profile-tab-sidebar {
    border-bottom-color: var(--border-dark);
  }
  .profile-tab-content {
    padding-left: 0;
    padding-top: 18px;
  }
}


  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.trusted-filter-btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border-light);
  background: transparent;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 140ms, background 140ms, color 140ms;
  color: inherit;
}

body.theme-dark .trusted-filter-btn {
  border-color: var(--border-dark);
}

.trusted-filter-btn:hover {
  border-color: var(--accent);
  background: rgba(18, 160, 106, 0.08);
}

.trusted-filter-active {
  border-color: var(--accent) !important;
  background: rgba(18, 160, 106, 0.12) !important;
  color: #12a06a;
  font-weight: 600;
}

body.theme-dark .trusted-filter-active {
  color: #22c97e;
  background: rgba(18, 160, 106, 0.18) !important;
}

.trusted-devices-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 12px;
}

.trusted-devices-empty {
  opacity: 0.72;
}

.trusted-device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(0,0,0,0.02);
  transition: border-color 140ms;
}

.trusted-device-item:hover {
  border-color: rgba(0,0,0,0.15);
}

body.theme-dark .trusted-device-item {
  border-color: var(--border-dark);
  background: rgba(255,255,255,0.03);
}

body.theme-dark .trusted-device-item:hover {
  border-color: rgba(255,255,255,0.18);
}

.trusted-device-meta {
  display: grid;
  gap: 2px;
}

.trusted-device-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.trusted-device-line {
  margin: 3px 0 0;
  font-size: 0.8rem;
  opacity: 0.6;
}

.trusted-device-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.trusted-current-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(18, 160, 106, 0.14);
  color: #12a06a;
  border: 1px solid rgba(18, 160, 106, 0.35);
  letter-spacing: 0.02em;
}

body.theme-dark .trusted-current-chip {
  background: rgba(34, 201, 126, 0.15);
  color: #22c97e;
  border-color: rgba(34, 201, 126, 0.3);
}

.trusted-remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1.5px solid var(--border-light);
  background: transparent;
  color: var(--danger, #b63f3f);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 140ms, border-color 140ms, background 140ms;
}

.trusted-remove-btn:hover {
  opacity: 1;
  border-color: var(--danger, #b63f3f);
  background: rgba(182, 63, 63, 0.08);
}

body.theme-dark .trusted-remove-btn {
  border-color: var(--border-dark);
}

.trusted-logout-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 10px;
  border: 1.5px solid rgba(182, 63, 63, 0.5);
  background: transparent;
  color: var(--danger, #b63f3f);
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms, border-color 140ms;
  margin-top: 4px;
}

.trusted-logout-all-btn:hover {
  background: rgba(182, 63, 63, 0.09);
  border-color: var(--danger, #b63f3f);
}

.trusted-logout-all-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hidden-input {
  display: none;
}

@media (max-width: 1100px) {
  .topbar-welcome {
    display: none;
  }
}

@media (max-width: 860px) {
  .user-nickname-text .role-chip {
    display: none;
  }
}

@media (max-width: 760px) {
  .user-nickname-text {
    display: none;
  }
}

.profile-card-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.lib-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 0.82em;
  font-family: "Consolas", "Courier New", monospace;
  font-weight: 600;
  background: rgba(31, 143, 95, 0.12);
  color: var(--accent);
  border: 1px solid rgba(31, 143, 95, 0.28);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* — Links card */
.profile-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border-light);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 140ms ease, border-color 140ms ease;
}

.profile-link:hover {
  background: rgba(0,0,0,0.05);
}

body.theme-dark .profile-link {
  border-color: var(--border-dark);
}

body.theme-dark .profile-link:hover {
  background: rgba(255,255,255,0.07);
}

.profile-link-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

.profile-link-handle {
  margin-left: auto;
  font-size: 0.8rem;
  opacity: 0.45;
}

/* — Vibe banner */
.profile-vibe {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px 24px;
  border: 1px solid rgba(31,143,95,0.3);
  border-radius: 14px;
  background: rgba(31,143,95,0.06);
}

body.theme-dark .profile-vibe {
  background: rgba(31,143,95,0.09);
  border-color: rgba(31,143,95,0.28);
}

.profile-vibe-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.profile-vibe-text {
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
  opacity: 0.88;
}

.profile-vibe-text strong {
  color: var(--accent);
}

@media (max-width: 680px) {
  .profile-hero {
    flex-direction: column;
    align-items: flex-start;
    padding: 22px 20px;
    gap: 16px;
  }
  .profile-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .profile-stat {
    padding: 12px 4px;
  }
  .profile-stat-value {
    font-size: clamp(1rem, 4.5vw, 1.5rem);
  }
  .profile-stat-label {
    font-size: clamp(0.58rem, 1.8vw, 0.72rem);
    letter-spacing: 0.02em;
    word-break: break-word;
    text-align: center;
  }
  .profile-grid {
    grid-template-columns: 1fr;
  }
  .profile-vibe {
    grid-column: auto;
  }
}

/* ─────────────────────────────────────────────────────────────────────────── */

.card {
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 18px;
  background: var(--surface-light);
}

body.theme-dark .card {
  border-color: var(--border-dark);
  background: var(--surface-dark);
}

.form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field input {
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 10px;
  background: #ffffff;
  color: #111;
}

body.theme-dark .field input {
  border-color: var(--border-dark);
  background: #1d1f25;
  color: #f4f6fb;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.switch-text {
  margin: 0;
  opacity: 0.85;
}

/* ─── Toast notifications ─────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  top: calc(var(--topbar-height) + 12px);
  right: 16px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  position: relative;
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px 18px;
  border-radius: 14px;
  min-width: 280px;
  max-width: 380px;
  overflow: hidden;
  border: 1px solid var(--border-light);
  background: var(--surface-light);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.07);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 260ms ease, transform 260ms ease;
}

.toast.toast-visible {
  opacity: 1;
  transform: translateX(0);
}

.toast.toast-hiding {
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 220ms ease, transform 220ms ease;
}

body.theme-dark .toast {
  border-color: var(--border-dark);
  background: var(--surface-dark);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.25);
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.toast-body {
  flex: 1;
  font-size: 14px;
  line-height: 1.55;
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.45;
  padding: 0 0 0 4px;
  font-size: 16px;
  line-height: 1;
  transition: opacity 140ms ease;
}

.toast-close:hover {
  opacity: 1;
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  border-radius: 0 0 14px 14px;
  background: var(--accent);
  transform-origin: left;
  animation: toast-progress-shrink linear forwards;
}

.toast-error .toast-progress {
  background: var(--danger);
}

@keyframes toast-progress-shrink {
  from { width: 100%; }
  to   { width: 0%; }
}

@media (max-width: 480px) {
  .toast-container {
    right: 8px;
    left: 8px;
  }
  .toast {
    min-width: unset;
    max-width: unset;
    width: 100%;
  }
}

@media (max-width: 420px) {
  .footer {
    flex-wrap: wrap;
    justify-content: space-between;
    row-gap: 4px;
    padding: 8px 12px;
  }
  .footer-copy {
    order: 3;
    width: 100%;
    text-align: center;
    font-size: 11px;
  }
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--footer-height);
  z-index: 900;
  text-align: center;
  padding: 8px 16px;
  border-top: 1px solid var(--border-light);
  font-size: 14px;
  background: rgba(255, 255, 255, 0.42);
}

.footer-left-controls {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.footer-control-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  color: inherit;
  padding: 6px 0;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
}

.footer-control-btn:hover {
  opacity: 0.82;
}

.footer-control-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.icon-svg {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
}

.footer-copy {
  white-space: nowrap;
}
.footer-legal-links {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-left: 30px;
  white-space: normal;
}
.footer-legal-link {
  color: inherit;
  text-decoration: none;
  opacity: 0.72;
  font-size: 12px;
  transition: opacity 140ms ease, color 140ms ease;
}
.footer-legal-link:hover {
  opacity: 1;
  color: var(--accent);
}

.footer-ai-disclaimer {
  display: block;
  margin-top: 4px;
  font-size: 0.7rem;
  opacity: 0.4;
}

body.theme-dark .footer {
  border-top: 1px solid var(--border-dark);
  background: rgba(255, 255, 255, 0.04);
}

.footer-theme-text {
  font-size: 13px;
}

.footer-right-controls {
  display: flex;
  align-items: center;
}

.lang-panel {
  position: relative;
}

.lang-menu {
  position: absolute;
  right: -16px;
  bottom: calc(100% + 8px);
  border-radius: 9px;
  display: grid;
  gap: 0;
  padding: 0;
  min-width: 110px;
  overflow: hidden;
  border: 1px solid var(--border-light);
  background: var(--surface-light);
}

.lang-menu.dropdown-menu {
  transform: translateY(6px) scale(0.98);
  transform-origin: bottom right;
}

.lang-menu.dropdown-menu.is-open {
  transform: translateY(0) scale(1);
}

body.theme-dark .lang-menu {
  border-color: var(--border-dark);
  background: var(--surface-dark);
}

.lang-option {
  border: 0;
  border-bottom: 1px solid var(--border-light);
  border-radius: 0;
  text-align: left;
  padding: 7px 11px;
  cursor: pointer;
  color: inherit;
  background: transparent;
  display: flex;
  align-items: center;
  width: 100%;
  font-size: 12px;
}

.lang-option:last-child {
  border-bottom: 0;
}

.lang-option:hover {
  background: rgba(0, 0, 0, 0.07);
}

body.theme-dark .lang-option {
  border-bottom-color: var(--border-dark);
}

body.theme-dark .lang-option:hover {
  background: rgba(255, 255, 255, 0.1);
}

.lang-code-badge,
.lang-name {
  display: none;
}

.hidden {
  display: none !important;
}

body.lang-en .lang-ru {
  display: none !important;
}

body:not(.lang-en) .lang-en {
  display: none !important;
}

@media (max-width: 680px) {
  .topbar {
    min-height: 52px;
    align-items: center;
    text-align: center;
    padding: 0 12px 0 0;
    white-space: normal;
  }
  .footer-legal-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin: 6px 0 0;
    gap: 0;
  }

  .logo-link {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
  }

  .logo {
    width: 100%;
    height: 100%;
  }

  .topbar-right {
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .auth-actions {
    width: auto;
  }

  .auth-actions .btn {
    flex: unset;
  }

  .footer {
    min-height: 64px;
    padding: 8px 10px;
  }

  .footer-left-controls {
    gap: 12px;
  }

  .footer-control-btn {
    gap: 8px;
    font-size: 16px;
  }

  .footer-control-icon {
    font-size: 18px;
  }

  .footer-copy {
    font-size: 12px;
    max-width: none;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
  }

  .nav-link {
    padding: 0 10px;
    font-size: 13px;
  }

  #userNickname {
    font-size: 14px;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .avatar {
    width: 34px;
    height: 34px;
  }
}

/* ─── Auth pages ─────────────────────────────────────────────────────────── */

.auth-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px 64px;
  min-height: calc(100vh - var(--topbar-height) - var(--footer-height));
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface-light);
  border: 1px solid var(--border-light);
  border-radius: 18px;
  padding: 36px 32px;
}

body.theme-dark .auth-card {
  background: var(--surface-dark);
  border-color: var(--border-dark);
}

.auth-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 28px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.auth-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.55;
}

.auth-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-light);
  background: rgba(0,0,0,0.04);
  color: inherit;
  font: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 150ms;
}

.auth-input:focus {
  border-color: var(--accent);
}

body.theme-dark .auth-input {
  border-color: var(--border-dark);
  background: rgba(255,255,255,0.05);
}

body.theme-dark .auth-input:focus {
  border-color: var(--accent);
}

.auth-code-input {
  font-size: 1.5rem;
  letter-spacing: 0.25em;
  text-align: center;
  font-weight: 700;
}

.auth-btn {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  font-size: 1rem;
}

.auth-remember-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 10px;
  font-size: 0.92rem;
  opacity: 0.9;
}

.auth-remember-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.auth-btn-secondary {
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  font-size: 0.9rem;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  color: inherit;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 120ms;
}

.auth-btn-secondary:hover {
  opacity: 1;
}

body.theme-dark .auth-btn-secondary {
  border-color: var(--border-dark);
}

.auth-hint {
  font-size: 0.9rem;
  opacity: 0.7;
  margin: 0 0 20px;
  line-height: 1.5;
}

.auth-resend-note {
  margin: 8px 2px 0;
  font-size: 0.82rem;
  opacity: 0.72;
}

@media (max-width: 480px) {
  .auth-card {
    padding: 24px 18px;
  }
}


/* ─── AI pages ─────────────────────────────────────────────────────────────── */
.ai-page {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 20px 56px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.ai-header { text-align: center; margin-bottom: 4px; }

.ai-title {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
  margin: 0 0 8px;
  background: linear-gradient(135deg, var(--accent) 0%, #4fb88c 60%, #7c4dff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.ai-subtitle {
  font-size: 14px;
  margin: 0;
  opacity: 0.7;
}

.ai-card {
  background: var(--surface-light);
  border: 1px solid var(--border-light);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(8px);
  transition: border-color .2s ease, box-shadow .2s ease;
}
body.theme-dark .ai-card {
  background: var(--surface-dark);
  border-color: var(--border-dark);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.32);
}
.ai-card:focus-within { border-color: var(--accent); }

.ai-form { display: flex; flex-direction: column; gap: 14px; }

.ai-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }

.ai-prompt {
  resize: vertical;
  min-height: 120px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
}

.ai-charcount { font-size: 12px; opacity: 0.6; text-align: right; }

/* Select styling */
.ai-form select.auth-input {
  -webkit-appearance: none;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
  cursor: pointer;
}
.ai-form select.auth-input option {
  background-color: #f7f7fa;
  color: #141414;
}
body.theme-dark .ai-form select.auth-input option {
  background-color: #1b1d22;
  color: #eceef2;
}

.ai-controls-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.ai-controls-row .ai-field { flex: 1 1 200px; }
.ai-controls-row-3 .ai-field { flex: 1 1 160px; }

.ai-submit {
  flex: 0 0 auto;
  min-width: 180px;
  height: 44px;
  padding: 0 22px;
  font-weight: 600;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, #166b47 100%);
  border: none;
  color: #fff;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, opacity .2s ease;
}
.ai-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(31, 143, 95, .35);
}
.ai-submit:disabled { opacity: .6; cursor: progress; }

/* Disclaimer */
.ai-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 4px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.10), rgba(245, 158, 11, 0.04));
  border: 1px solid rgba(245, 158, 11, 0.35);
  font-size: 13px;
  line-height: 1.45;
}
.ai-disclaimer-icon {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  color: #d97706;
  margin-top: 1px;
}
body.theme-dark .ai-disclaimer-icon { color: #fbbf24; }
.ai-disclaimer-text { flex: 1; }
.ai-disclaimer-title {
  display: block;
  font-weight: 600;
  margin-bottom: 2px;
  color: #92400e;
}
body.theme-dark .ai-disclaimer-title { color: #fde68a; }
.ai-disclaimer-body { opacity: 0.85; }

/* Output card */
.ai-output-card { padding: 0; overflow: hidden; }
.ai-output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-light);
  background: rgba(0,0,0,0.025);
}
body.theme-dark .ai-output-head {
  border-bottom-color: var(--border-dark);
  background: rgba(255,255,255,0.025);
}
.ai-output-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
}

.ai-icon-btn {
  background: transparent;
  border: 1px solid var(--border-light);
  color: inherit;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .15s ease, border-color .15s ease;
}
body.theme-dark .ai-icon-btn { border-color: var(--border-dark); }
.ai-icon-btn:hover {
  background: rgba(31, 143, 95, .10);
  border-color: var(--accent);
}
.ai-icon-btn:disabled { opacity: .6; cursor: progress; }

.ai-output { padding: 20px; min-height: 120px; }

.ai-empty {
  margin: 0;
  text-align: center;
  padding: 20px 0;
  opacity: 0.6;
}
.ai-error { color: var(--danger); opacity: 1; }

.ai-text-result {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  max-height: 70vh;
  overflow: auto;
}

.ai-image-output {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  padding: 18px;
}
.ai-image-preview {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 78vh;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  object-fit: contain;
}

.ai-image-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 30px 0;
}
.ai-spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(31, 143, 95, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: aiSpin .9s linear infinite;
}
@keyframes aiSpin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .ai-page { padding: 20px 14px 40px; }
  .ai-card { padding: 18px; border-radius: 14px; }
  .ai-submit { width: 100%; min-width: 0; }
  .ai-controls-row { gap: 12px; }
}

/* ─── Nav dropdown: cascading submenu ───────────────────────────────────── */

.nav-dropdown-sub-group {
  padding: 4px 0;
}

.nav-dropdown-sub-label {
  display: block;
  padding: 6px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.5;
  user-select: none;
}

.nav-dropdown-sub-list {
  padding-left: 8px;
}

/* ─── News Hub ──────────────────────────────────────────────────────────── */

.news-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
  margin-top: 32px;
}

.news-hub-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 32px 28px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(31,143,95,0.12) 0%, rgba(31,143,95,0.04) 100%);
  border: 1px solid rgba(31,143,95,0.25);
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  cursor: pointer;
}
.news-hub-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(31,143,95,0.18);
  border-color: rgba(31,143,95,0.4);
}

.news-hub-card-icon {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: rgba(31,143,95,0.15);
}
.news-hub-card-icon svg {
  stroke: var(--accent);
}

.news-hub-card-body {
  flex: 1;
  min-width: 0;
}

.news-hub-card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 6px;
}

.news-hub-card-desc {
  font-size: 0.9rem;
  opacity: 0.7;
  margin: 0;
  line-height: 1.4;
}

.news-hub-card-arrow {
  font-size: 1.5rem;
  opacity: 0.4;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.2s;
}
.news-hub-card:hover .news-hub-card-arrow {
  opacity: 0.8;
  transform: translateX(4px);
}

/* Light theme hub cards */
html:not(.dark-init) .news-hub-card {
  background: linear-gradient(135deg, rgba(31,143,95,0.08) 0%, rgba(31,143,95,0.02) 100%);
  border-color: rgba(31,143,95,0.2);
}
html:not(.dark-init) .news-hub-card:hover {
  box-shadow: 0 16px 40px rgba(31,143,95,0.12);
  border-color: rgba(31,143,95,0.35);
}

.news-hub-intro {
  max-width: 720px;
  margin: 0 auto 12px;
  text-align: center;
}

.news-hub-intro-text {
  font-size: 1.02rem;
  line-height: 1.65;
  opacity: 0.72;
  margin: 0;
}

.news-hub-section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 36px 0 4px;
}

.news-hub-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.news-hub-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  opacity: 0.7;
}
html:not(.dark-init) .news-hub-tag {
  background: rgba(0,0,0,0.05);
  border-color: rgba(0,0,0,0.1);
}

.news-hub-features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 48px;
}

.news-hub-feature {
  text-align: center;
  padding: 28px 20px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
}
.news-hub-feature h4 {
  margin: 10px 0 6px;
  font-size: 1rem;
  font-weight: 700;
}
.news-hub-feature p {
  margin: 0;
  font-size: 0.88rem;
  opacity: 0.65;
  line-height: 1.45;
}
html:not(.dark-init) .news-hub-feature {
  background: rgba(0,0,0,0.025);
  border-color: rgba(0,0,0,0.06);
}

.news-hub-feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(31,143,95,0.1);
}
.news-hub-feature-icon svg {
  stroke: var(--accent);
}
html:not(.dark-init) .news-hub-feature-icon {
  background: rgba(31,143,95,0.08);
}

/* ─── Fixed back navigation button (left side) ────────────────────────── */

.news-nav-fixed {
  position: fixed;
  left: 16px;
  top: calc(var(--topbar-height) + 16px);
  z-index: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-dark);
  background: transparent;
  color: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.2s, border-color 0.2s;
}
.news-nav-fixed:hover {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
}
.news-nav-fixed svg {
  stroke: currentColor;
  flex-shrink: 0;
}
html:not(.dark-init) .news-nav-fixed {
  border-color: var(--border-light);
}

/* ─── Sticky toolbar (search + filter) ─────────────────────────────────── */

.news-sticky-toolbar {
  position: sticky;
  top: var(--topbar-height);
  z-index: 400;
  padding: 10px 20px;
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  background: transparent;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
body.theme-dark .news-sticky-toolbar {
  border-bottom-color: rgba(255,255,255,0.06);
}

.news-sticky-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.news-search-compact {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.12);
  background: transparent;
  transition: border-color 0.2s;
}
.news-search-compact:focus-within {
  border-color: var(--accent);
}
.news-search-compact svg {
  opacity: 0.4;
  flex-shrink: 0;
}
body.theme-dark .news-search-compact {
  border-color: rgba(255,255,255,0.1);
}

.news-search-input-compact {
  flex: 1;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
}
.news-search-input-compact::placeholder {
  opacity: 0.4;
}

.news-page-with-toolbar {
  padding-top: 20px;
}

/* ─── Filter dropdown ──────────────────────────────────────────────────── */

.news-filter-dropdown {
  position: relative;
}

.news-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.12);
  background: transparent;
  color: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s, background 0.2s;
}
.news-filter-toggle:hover {
  border-color: var(--accent);
  background: rgba(31,143,95,0.08);
}
.news-filter-toggle svg {
  opacity: 0.6;
}
body.theme-dark .news-filter-toggle {
  border-color: rgba(255,255,255,0.1);
}

.news-filter-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(250,250,252,0.97);
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  z-index: 600;
}
body.theme-dark .news-filter-panel {
  border-color: rgba(255,255,255,0.12);
  background: rgba(22,23,27,0.95);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.news-filter-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}
body.theme-dark .news-filter-actions {
  border-bottom-color: var(--border-dark);
}

.news-filter-action-btn {
  flex: 1;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.12);
  background: transparent;
  color: rgba(0,0,0,0.6);
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.news-filter-action-btn:hover {
  background: rgba(31,143,95,0.15);
  color: var(--accent);
}
body.theme-dark .news-filter-action-btn {
  border-color: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.7);
}

.news-filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  transition: background 0.15s;
  color: rgba(0,0,0,0.8);
}
.news-filter-item:hover {
  background: rgba(31,143,95,0.1);
}
body.theme-dark .news-filter-item {
  color: rgba(255,255,255,0.85);
}
body.theme-dark .news-filter-item:hover {
  background: rgba(31,143,95,0.15);
}

.news-filter-cb {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.news-filter-apply-btn {
  width: 100%;
  margin-top: 8px;
  padding: 6px 0;
  font-size: 0.82rem;
  border-radius: 8px;
}

/* ─── Load more button ─────────────────────────────────────────────────── */

.news-load-more-wrap {
  text-align: center;
  padding: 12px 0 20px;
}

.news-load-more-btn {
  padding: 10px 40px;
  border-radius: 10px;
  font-size: 0.9rem;
}

/* ─── Reactions (likes/dislikes) ───────────────────────────────────────── */

.news-post-reactions {
  display: flex;
  gap: 12px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
html:not(.dark-init) .news-post-reactions {
  border-top-color: rgba(0,0,0,0.08);
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  user-select: none;
}
.reaction-btn:hover {
  background: rgba(255,255,255,0.08);
  transform: scale(1.05);
}
.reaction-btn svg {
  opacity: 0.6;
  transition: opacity 0.2s;
}
.reaction-btn:hover svg {
  opacity: 1;
}

.reaction-btn.reaction-active.reaction-like {
  background: rgba(76, 175, 80, 0.15);
  border-color: rgba(76, 175, 80, 0.4);
  color: #4caf50;
}
.reaction-btn.reaction-active.reaction-like svg {
  opacity: 1;
  stroke: #4caf50;
}

.reaction-btn.reaction-active.reaction-dislike {
  background: rgba(244, 67, 54, 0.15);
  border-color: rgba(244, 67, 54, 0.4);
  color: #f44336;
}
.reaction-btn.reaction-active.reaction-dislike svg {
  opacity: 1;
  stroke: #f44336;
}

html:not(.dark-init) .reaction-btn {
  border-color: rgba(0,0,0,0.12);
  background: rgba(0,0,0,0.03);
}
html:not(.dark-init) .reaction-btn:hover {
  background: rgba(0,0,0,0.06);
}

.reaction-num {
  font-weight: 600;
}

/* Reactions in news cards */
.news-card-reactions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.reaction-count {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.82rem;
}
.reaction-count svg {
  opacity: 0.5;
}

/* ─── News page ────────────────────────────────────────────────────────── */

.news-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.news-header {
  text-align: center;
  margin-bottom: 28px;
}

.news-title {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 6px;
}

.news-subtitle {
  font-size: 0.95rem;
  opacity: 0.65;
  margin: 0;
}

.news-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

.news-search-bar {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 220px;
}

.news-search-input {
  flex: 1;
  min-width: 0;
}

.news-search-btn {
  white-space: nowrap;
  padding: 8px 16px;
}

.news-cat-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.news-cat-btn {
  padding: 6px 14px;
  border: 1px solid var(--border-light);
  border-radius: 20px;
  background: transparent;
  color: inherit;
  font-size: 13px;
  cursor: pointer;
  opacity: 0.7;
  transition: all 160ms ease;
}

body.theme-dark .news-cat-btn {
  border-color: var(--border-dark);
}

.news-cat-btn:hover {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
}

.news-cat-btn.news-cat-active {
  opacity: 1;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* .news-back-btn removed — replaced by .news-nav-fixed */

/* News grid */
.news-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.news-card {
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-light);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

body.theme-dark .news-card {
  background: var(--surface-dark);
  border-color: var(--border-dark);
}

.news-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}

body.theme-dark .news-card:hover {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.news-card-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.05);
}

body.theme-dark .news-card-image {
  background: rgba(255, 255, 255, 0.04);
}

.news-card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.news-card-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  opacity: 0.3;
}

.news-card-body {
  padding: 16px;
}

.news-card-cat {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--accent);
  margin-bottom: 6px;
}

.news-card-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 8px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-card-summary {
  font-size: 0.85rem;
  opacity: 0.65;
  margin: 0 0 10px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-card-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  opacity: 0.5;
  flex-wrap: wrap;
}

.news-empty {
  grid-column: 1 / -1;
  text-align: center;
  opacity: 0.5;
  padding: 40px 0;
  font-size: 0.95rem;
}

.news-loading {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  padding: 60px 0;
}

/* Pagination */
.news-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 0;
}

.news-page-btn {
  padding: 8px 18px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 13px;
  transition: all 160ms ease;
}

body.theme-dark .news-page-btn {
  border-color: var(--border-dark);
}

.news-page-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.news-page-info {
  font-size: 13px;
  opacity: 0.6;
}

/* Admin panel */
.news-admin-panel {
  margin-bottom: 20px;
  padding: 16px;
  border: 1px dashed var(--border-light);
  border-radius: 12px;
  background: rgba(31, 143, 95, 0.04);
}

body.theme-dark .news-admin-panel {
  border-color: var(--border-dark);
  background: rgba(31, 143, 95, 0.06);
}

.news-admin-btn {
  margin-bottom: 8px;
}

.news-gen-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

body.theme-dark .news-gen-form {
  border-top-color: var(--border-dark);
}

.news-gen-status {
  font-size: 13px;
  opacity: 0.7;
  margin: 4px 0 0;
}

/* ─── News Post Page ────────────────────────────────────────────────────── */

.news-post-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.news-post-hero {
  width: 100%;
  border-radius: 14px;
  margin: 16px 0 24px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.news-post-article {
  margin-top: 8px;
}

.news-post-title {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 12px;
}

.news-post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  opacity: 0.6;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

body.theme-dark .news-post-meta {
  border-bottom-color: var(--border-dark);
}

.news-post-author {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  opacity: 1;
}

.news-post-author-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.news-post-content {
  font-size: 0.95rem;
  line-height: 1.75;
}

.news-post-content h2 {
  font-size: 1.35rem;
  margin: 28px 0 12px;
}

.news-post-content h3 {
  font-size: 1.15rem;
  margin: 22px 0 10px;
}

.news-post-content p {
  margin: 0 0 16px;
}

.news-post-content blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: rgba(31, 143, 95, 0.05);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  opacity: 0.85;
}

body.theme-dark .news-post-content blockquote {
  background: rgba(31, 143, 95, 0.08);
}

.news-post-content ul,
.news-post-content ol {
  padding-left: 20px;
  margin: 0 0 16px;
}

.news-post-content li {
  margin-bottom: 6px;
}

.news-post-admin {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.danger-text {
  color: var(--danger) !important;
}

/* ─── Comments ──────────────────────────────────────────────────────────── */

.news-comments-section {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
}

body.theme-dark .news-comments-section {
  border-top-color: var(--border-dark);
}

.comments-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 16px;
}

.news-comments-disabled {
  opacity: 0.5;
  font-style: italic;
}

.comment-form {
  margin-bottom: 24px;
}

.comment-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-dark);
  border: 1px solid var(--border-dark);
  border-radius: 12px;
  padding: 6px 6px 6px 14px;
  transition: border-color 0.2s;
}
body:not(.theme-dark) .comment-input-wrap {
  background: var(--surface-light);
  border-color: var(--border-light);
}
.comment-input-wrap:focus-within {
  border-color: var(--accent);
}

.comment-textarea {
  flex: 1;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  resize: none;
  outline: none;
  padding: 0;
  min-height: 22px;
  max-height: 120px;
  overflow-y: auto;
}
.comment-textarea::placeholder {
  opacity: 0.4;
}

.comment-input-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.comment-emoji-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 2px;
  opacity: 0.4;
  transition: opacity 150ms, transform 150ms;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}
.comment-emoji-btn:hover {
  opacity: 1;
  transform: scale(1.15);
}

.comment-char-count {
  font-size: 10px;
  opacity: 0.35;
  white-space: nowrap;
  line-height: 1;
}

.comment-send-btn {
  flex-shrink: 0;
  border: none;
  background: var(--accent);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.15s;
}
.comment-send-btn:hover {
  background: var(--accent-hover, #1a8a5a);
  transform: scale(1.08);
}
.comment-send-btn:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

.comment-login-hint {
  font-size: 0.9rem;
  opacity: 0.55;
  text-align: center;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px dashed var(--border-light);
  border-radius: 10px;
}

body.theme-dark .comment-login-hint {
  border-color: var(--border-dark);
}

/* Emoji popup picker */
.emoji-popup {
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 9000;
  width: 230px;
  max-height: 260px;
  border-radius: 14px;
  border: 1px solid var(--border-dark);
  background: var(--surface-dark);
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.emoji-popup.emoji-popup-visible {
  display: flex;
}
body:not(.theme-dark) .emoji-popup {
  border-color: var(--border-light);
  background: var(--surface-light);
  box-shadow: 0 12px 40px rgba(0,0,0,0.12);
}

.emoji-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--border-dark);
}
body:not(.theme-dark) .emoji-tabs {
  border-bottom-color: var(--border-light);
}

.emoji-tab {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1.2rem;
  padding: 6px 4px 8px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  border-radius: 6px 6px 0 0;
  transition: background 0.15s, border-color 0.15s;
}
.emoji-tab:hover {
  background: rgba(255,255,255,0.06);
}
.emoji-tab-active {
  border-bottom-color: var(--accent);
  background: rgba(31,143,95,0.08);
}
body:not(.theme-dark) .emoji-tab:hover {
  background: rgba(0,0,0,0.04);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
}

.emoji-btn {
  border: none;
  background: transparent;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 5px;
  border-radius: 6px;
  transition: background 120ms, transform 120ms;
  line-height: 1;
  text-align: center;
}
.emoji-btn:hover {
  background: rgba(255,255,255,0.1);
  transform: scale(1.2);
}
body:not(.theme-dark) .emoji-btn:hover {
  background: rgba(0,0,0,0.07);
}

/* Twemoji sizing */
img.emoji {
  height: 1.2em;
  width: 1.2em;
  margin: 0 0.05em;
  vertical-align: -0.15em;
  display: inline-block;
}
.emoji-btn img.emoji {
  height: 1.3em;
  width: 1.3em;
  vertical-align: -0.1em;
}
.emoji-tab img.emoji {
  height: 1.15em;
  width: 1.15em;
}

/* Comments list */
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.comment-item {
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-light);
  border: 1px solid var(--border-light);
}

body.theme-dark .comment-item {
  background: var(--surface-dark);
  border-color: var(--border-dark);
}

.comment-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.comment-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.06);
  color: inherit;
  opacity: 0.4;
}

body.theme-dark .comment-avatar-fallback {
  background: rgba(255, 255, 255, 0.06);
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}

.comment-nickname {
  font-weight: 600;
  font-size: 0.9rem;
}

.role-chip-sm {
  font-size: 10px;
  padding: 1px 6px;
}

.comment-date {
  font-size: 12px;
  opacity: 0.45;
}

.comment-admin-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.comment-delete-btn,
.comment-ban-btn {
  border: none;
  background: transparent;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
  opacity: 0.5;
  transition: opacity 120ms;
}

.comment-delete-btn:hover,
.comment-ban-btn:hover {
  opacity: 1;
}

.comment-body {
  font-size: 0.9rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-item-pending {
  opacity: 0.75;
}
.comment-pending {
  font-style: italic;
  color: rgba(31,143,95,0.7);
}
body.theme-dark .comment-pending {
  color: rgba(31,143,95,0.9);
}
.comment-pending-icon {
  margin-right: 4px;
}

/* Responsive */
@media (max-width: 1024px) {
  .news-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 768px) {
  .news-grid {
    grid-template-columns: 1fr;
  }
  .news-post-title {
    font-size: 1.4rem;
  }
  .news-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 480px) {
  .news-page { padding: 20px 14px 40px; }
  .news-post-page { padding: 16px 14px 40px; }
  .news-card-body { padding: 12px; }
}

/* ── Custom scrollbars ── */

/* Webkit (Chrome, Edge, Safari) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 100px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.22);
}
::-webkit-scrollbar-corner {
  background: transparent;
}

body:not(.theme-dark) ::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.13);
}
body:not(.theme-dark) ::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.25);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}
body:not(.theme-dark) * {
  scrollbar-color: rgba(0,0,0,0.13) transparent;
}

/* Thin scrollbars inside compact widgets */
.emoji-grid::-webkit-scrollbar,
.comment-textarea::-webkit-scrollbar,
.comments-list::-webkit-scrollbar {
  width: 5px;
}
.emoji-grid::-webkit-scrollbar-thumb,
.comment-textarea::-webkit-scrollbar-thumb,
.comments-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 100px;
}
.emoji-grid::-webkit-scrollbar-thumb:hover,
.comment-textarea::-webkit-scrollbar-thumb:hover,
.comments-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.28);
}
body:not(.theme-dark) .emoji-grid::-webkit-scrollbar-thumb,
body:not(.theme-dark) .comment-textarea::-webkit-scrollbar-thumb,
body:not(.theme-dark) .comments-list::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.12);
}
body:not(.theme-dark) .emoji-grid::-webkit-scrollbar-thumb:hover,
body:not(.theme-dark) .comment-textarea::-webkit-scrollbar-thumb:hover,
body:not(.theme-dark) .comments-list::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.24);
}
