/* Day / night mode (button added by /js/theme.js).
   Pages: home, info, chat, community, news, admin.
   Day mode = the site as it is. Night mode = the rules below, all under
   html[data-theme="dark"]. To change a night colour, change it here. */

/* ---------- the button (sun / moon), next to the language globe ---------- */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-right: 2px;
  padding: 0;
  border: none;
  border-radius: 50%;
  color: #8e5bd8;
  background: transparent;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.3s ease;
}

.theme-toggle svg {
  width: 21px;
  height: 21px;
}

.theme-toggle:hover {
  background: rgba(255, 116, 178, 0.16);
  transform: rotate(-18deg);
}

.theme-toggle:focus-visible {
  outline: 2px solid #ff74b2;
  outline-offset: 2px;
}

/* home page: the account buttons are a column on the right */
.auth-side .topbar .auth .theme-toggle {
  align-self: center;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 12px rgba(170, 70, 170, 0.18);
}

/* =====================================================================
   NIGHT MODE
   ===================================================================== */
html[data-theme="dark"] {
  --n-bg: #160d1f;
  --n-surface: #241631;
  --n-surface-2: #2f1d3f;
  --n-field: #1c1127;
  --n-line: rgba(212, 115, 212, 0.28);
  --n-text: #f3e6f7;
  --n-muted: #c9aed6;
  --n-pink: #ff8ab8;
  color-scheme: dark; /* dark scrollbars and form controls */
  background: var(--n-bg);
}

html[data-theme="dark"] body {
  color: var(--n-text);
  background: var(--n-bg);
}

html[data-theme="dark"] .theme-toggle {
  color: #ffd27a;
}

html.auth-side[data-theme="dark"] .topbar .auth .theme-toggle,
html.auth-side[data-theme="dark"] .topbar .auth .lang-picker {
  background: var(--n-surface);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ---------- menu ---------- */
html[data-theme="dark"] .topbar .nav-link,
html[data-theme="dark"] .topbar .logo {
  color: #eadcf2;
}

html[data-theme="dark"] .topbar .nav-link:hover,
html[data-theme="dark"] .topbar .nav-link.active {
  color: #ff9fd0;
}

html[data-theme="dark"] .topbar .nav-link::after {
  background: #ff9fd0;
}

html[data-theme="dark"] .account-link {
  color: var(--n-text);
}

/* ---------- home ---------- */
html[data-theme="dark"] .hero {
  background: linear-gradient(220deg, #3b2352, #2e1d40, #4a2140, #53203f, #1f2c4c, #1c3150);
}

html[data-theme="dark"] .hero h1 {
  color: #c9b8ff;
}

html[data-theme="dark"] .hero p {
  color: #e8cdee;
}

html[data-theme="dark"] .hero .cta {
  color: #3a1d47;
}

html[data-theme="dark"] .thumb {
  background: var(--n-surface);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .section-header {
  color: #ff6fae;
}

html[data-theme="dark"] .recent-section-panel {
  color: #d58cff;
}

html[data-theme="dark"] .dot {
  background: #5a4068;
}

html[data-theme="dark"] .dot.active {
  background: #ff74b2;
}

/* ---------- info page (the default two-tone look; the special looks of
   Callisto, Derrick, Reynold, Eclise, Yvonne and Siyeon keep their picture) ---------- */
html[data-theme="dark"] .detail-page:not([class*="theme-"]) .detail-hero {
  background: linear-gradient(112deg, #4a2157 0 49.95%, #5b2141 50.05% 100%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .detail-page:not([class*="theme-"]) .detail-info {
  color: var(--n-text);
}

html[data-theme="dark"] .detail-page:not([class*="theme-"]) .detail-role {
  color: #ff9fc7;
}

html[data-theme="dark"] .detail-page:not([class*="theme-"]) .detail-title {
  color: rgba(255, 255, 255, 0.22);
}

html[data-theme="dark"] .detail-page:not([class*="theme-"]) .detail-back,
html[data-theme="dark"] .detail-page:not([class*="theme-"]) .detail-nav-link {
  color: var(--n-text);
  background: rgba(36, 22, 49, 0.78);
}

html[data-theme="dark"] .detail-page:not([class*="theme-"]) .detail-nav-link small {
  color: var(--n-muted);
}

/* ---------- account pages (chat, community, news, admin) ---------- */
html[data-theme="dark"] .page-head {
  color: var(--n-text);
  background: linear-gradient(110deg, #233a5c 0%, #4a1f45 45%, #3a2252 100%);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .page-head p,
html[data-theme="dark"] .muted {
  color: var(--n-muted);
}

html[data-theme="dark"] .page-head .head-link,
html[data-theme="dark"] .link-button {
  color: var(--n-pink);
}

html[data-theme="dark"] .card {
  color: var(--n-text);
  background: var(--n-surface);
  border-color: var(--n-line);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] :is(.card h2, .who-name, .news-body, .backup-list, .legal li, .db-table-btn) {
  color: var(--n-text);
}

html[data-theme="dark"] .field > span {
  color: #e3c9ea;
}

html[data-theme="dark"] .app-page :is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea),
html[data-theme="dark"] :is(.app-select, .app-input, .app-textarea) {
  color: var(--n-text);
  background: var(--n-field);
  border-color: #4a3058;
}

html[data-theme="dark"] .app-page :is(input, textarea)::placeholder {
  color: #9c82a8;
}

html[data-theme="dark"] :is(.btn-app.light, .badge-role, .persona-tabs) {
  color: #f3d6ff;
  background: #3a2550;
}

html[data-theme="dark"] :is(.comment-box, .codes li, .stat, .review-box .news-item) {
  background: var(--n-surface-2);
}

html[data-theme="dark"] .comments {
  border-top-color: #4a3058;
}

html[data-theme="dark"] .stat b {
  color: var(--n-pink);
}

html[data-theme="dark"] .stat.alert {
  background: #8f1240;
}

html[data-theme="dark"] :is(.filters button, .admin-tabs button) {
  color: #f3d6ff;
  background: var(--n-surface);
  border-color: #4a3058;
}

html[data-theme="dark"] .admin-tabs button:hover {
  background: var(--n-surface-2);
}

html[data-theme="dark"] :is(.filters button[aria-pressed="true"], .admin-tabs button[aria-selected="true"]) {
  color: #fff;
  background: linear-gradient(90deg, #ff74b2, #c77dff);
}

html[data-theme="dark"] .app-table td {
  border-bottom-color: #3a2550;
}

html[data-theme="dark"] :is(.app-table th, .app-table code) {
  color: #e3c9ea;
}

html[data-theme="dark"] .app-table .row-alert td {
  background: #3d1426;
}

html[data-theme="dark"] .pill.ok {
  color: #b9f3d3;
  background: #1f4a35;
}

html[data-theme="dark"] .state-on {
  color: #6fe0a7;
}

html[data-theme="dark"] .state-off {
  color: var(--n-pink);
}

html[data-theme="dark"] .db-table-btn {
  background: var(--n-surface-2);
  border-color: #4a3058;
}

html[data-theme="dark"] .db-table-btn:hover {
  background: #3a2550;
}

html[data-theme="dark"] .db-table td.secret {
  color: #9c82a8;
}

/* the QR code of the two-step verification stays black on white */
html[data-theme="dark"] .qr {
  background: #fff;
}

/* ---------- chat ---------- */
html[data-theme="dark"] :is(.char-card, .persona, .persona-form) {
  color: var(--n-text);
  background: var(--n-surface-2);
}

html[data-theme="dark"] .persona-form {
  border-color: #5a3a6a;
}

html[data-theme="dark"] :is(.char-card.is-on, .persona.is-on) {
  background: #3d1f3a;
}

html[data-theme="dark"] :is(.char-card img, .msg-hello img) {
  border-color: var(--n-surface);
}

html[data-theme="dark"] :is(.char-role, .typing .msg-text) {
  color: var(--n-muted);
}

html[data-theme="dark"] :is(.conv-open, .persona-pick, .room-name, .tab) {
  color: var(--n-text);
}

html[data-theme="dark"] .tab.is-on {
  color: #fff;
}

html[data-theme="dark"] .conv.is-on {
  background: #34203f;
}

html[data-theme="dark"] .conv-delete {
  color: var(--n-pink);
}

html[data-theme="dark"] .conv-delete:hover {
  background: #4a1f35;
}

html[data-theme="dark"] :is(.conv-avatar, .room-avatar, .msg-avatar) {
  background: #3a2550;
}

html[data-theme="dark"] .room-head {
  border-bottom-color: #3a2550;
}

html[data-theme="dark"] .from-character .msg-text {
  color: var(--n-text);
  background: var(--n-surface-2);
}

html[data-theme="dark"] .typing .msg-text {
  background: var(--n-surface);
}

/* ---------- news ---------- */
html[data-theme="dark"] .news-hero {
  --ink: #f3e6f7;
  --pk-soft: #4a1f3d;
  --lav: #43357a;
  --lav-soft: #2c2245;
  background: linear-gradient(120deg, #2a1534 0%, #1b1026 45%, #24163a 100%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .nh-fav {
  background: var(--n-surface);
}

html[data-theme="dark"] .news-page .topbar {
  background: linear-gradient(90deg, #3b1d36, #2c2252);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .news-page .topbar .logo {
  color: var(--n-text);
}

html[data-theme="dark"] .news-page .topbar .nav-link {
  color: #cdb6ff;
}

html[data-theme="dark"] .news-page .topbar .nav-link:hover,
html[data-theme="dark"] .news-page .topbar .nav-link.active {
  color: #ff8ab8;
}

/* home: the pastel cards on the right keep their dark text */
html[data-theme="dark"] .info {
  color: #2a1036;
}

/* "Log in" (pastel button): dark text, as in day mode */
html[data-theme="dark"] .btn:not(.primary) {
  color: #3a1d47;
}
