/* Dark theme — global overrides for every page loading quiet-ui.css.
   Scoped to html[data-color-scheme="dark"]; follows system by default.
   Layer order: dark-theme sits first so its !important declarations
   outrank quiet-reset / quiet-components (important rules resolve in
   reverse layer order). */
@layer dark-theme, quiet-reset, quiet-components;

@layer dark-theme {
  html[data-color-scheme="dark"] {
    color-scheme: dark !important;
    --bg: #171410 !important;
    --bg-2: #1e1a15 !important;
    --surface: #221e18 !important;
    --surface2: #2a251e !important;
    --panel: #221e18 !important;
    --border: #3a332a !important;
    --border-light: #4a4136 !important;
    --border-strong: #6b5644 !important;
    --line: #3a332a !important;
    --line-hi: #4a4136 !important;
    --text: #ece4d8 !important;
    --text-dim: #a79d8e !important;
    --dim: #a79d8e !important;
    --amber: #d98e66 !important;
    --amber-hi: #e8a884 !important;
    --amber-deep: #b56f4c !important;
    --lime: #7fb98a !important;
    --red: #d9795a !important;
    --cyan: #d98e66 !important;
    --au-glass: #221e18 !important;
    --au-edge: #3a332a !important;
    --v-bg: #171410 !important;
    --v-panel: #221e18 !important;
    --v-line: #3a332a !important;
    --v-text: #ece4d8 !important;
    --v-dim: #a79d8e !important;
    --v-amber: #d98e66 !important;
    scrollbar-color: #4a4136 #171410 !important;
  }

  /* ---- Base ---- */
  html[data-color-scheme="dark"] * { -webkit-text-fill-color: currentColor !important; }

  html[data-color-scheme="dark"] body {
    background: #171410 !important;
    color: #ece4d8 !important;
  }
  html[data-color-scheme="dark"] ::selection { background: #6b5644 !important; color: #ece4d8 !important; }

  /* ---- Navigation ---- */
  html[data-color-scheme="dark"] :is(.fs-nav, .art-nav, .videos-nav, .vd-top, .ct-backbar) {
    background: #1d1914 !important;
    border-bottom: 1px solid #3a332a !important;
    color: #ece4d8 !important;
  }
  html[data-color-scheme="dark"] .fs-brand,
  html[data-color-scheme="dark"] .art-brand,
  html[data-color-scheme="dark"] .videos-brand { color: #ece4d8 !important; }
  html[data-color-scheme="dark"] .fs-brand small { color: #a79d8e !important; }
  html[data-color-scheme="dark"] .fs-links a { color: #b3a99a !important; }
  html[data-color-scheme="dark"] .fs-links a:hover { color: #e8a884 !important; }
  html[data-color-scheme="dark"] .fs-menu-btn { border-color: #4a4136 !important; }
  html[data-color-scheme="dark"] .fs-menu-btn span { background: #ece4d8 !important; }
  html[data-color-scheme="dark"] .ct-backbar a { color: #e8a884 !important; }

  /* ---- Hero / headings ---- */
  html[data-color-scheme="dark"] :is(.fs-id h1, .fs-en, .fs-cn, .fs-card h2, .encrypt-head h1,
    .au-iqtest #start h1, .au-status .subtitle, .cvt-shell h1, .art-post h1, .videos-hero h1, .vd-title) {
    color: #ece4d8 !important;
    -webkit-text-fill-color: #ece4d8 !important;
  }
  html[data-color-scheme="dark"] .fs-alias { color: #a79d8e !important; }
  html[data-color-scheme="dark"] .fs-bio { color: #b3a99a !important; }
  html[data-color-scheme="dark"] .fs-tags span { color: #b3a99a !important; }
  html[data-color-scheme="dark"] .fs-list li { color: #c9c0b1 !important; }
  html[data-color-scheme="dark"] .fs-muted { color: #a79d8e !important; }

  /* ---- Cards / surfaces ---- */
  html[data-color-scheme="dark"] :is(.fs-grid > .fs-card, .encrypt-card, .au-status #mcCard,
    .cvt-start, .cvt-app--result .cvt-card, .art-card, .series-card, .vd-video, .videos-side,
    .videos-main, .fs-friend, .fs-friend-card, .fs-article, .fs-article-item, .panel, .auth-card) {
    background: #221e18 !important;
    border: 1px solid #3a332a !important;
    color: #ece4d8 !important;
  }
  html[data-color-scheme="dark"] .fs-card .site-link,
  html[data-color-scheme="dark"] .social-front,
  html[data-color-scheme="dark"] .social-back {
    background: #262119 !important;
    border: 1px solid #4a4136 !important;
  }
  html[data-color-scheme="dark"] .fs-card .site-link:hover,
  html[data-color-scheme="dark"] .fs-friend-card:hover,
  html[data-color-scheme="dark"] .fs-article-item:hover,
  html[data-color-scheme="dark"] .video-item:hover,
  html[data-color-scheme="dark"] .video-item.active {
    background: #332a20 !important;
    border-color: #6b5644 !important;
  }

  /* ---- Card inner text ---- */
  html[data-color-scheme="dark"] .site-link-name { color: #ece4d8 !important; }
  html[data-color-scheme="dark"] .site-link-desc,
  html[data-color-scheme="dark"] .fs-friend-desc,
  html[data-color-scheme="dark"] .fs-friend-url,
  html[data-color-scheme="dark"] .fs-support-title,
  html[data-color-scheme="dark"] .footer-brand,
  html[data-color-scheme="dark"] .site-footer { color: #b3a99a !important; }
  html[data-color-scheme="dark"] .fs-friend-info strong,
  html[data-color-scheme="dark"] .fs-friend-name { color: #ece4d8 !important; }
  html[data-color-scheme="dark"] .social-icon { color: #e8a884 !important; }
  html[data-color-scheme="dark"] .social-name { color: #ece4d8 !important; }
  html[data-color-scheme="dark"] .site-link-icon {
    background: #332a20 !important;
    border-color: #4a4136 !important;
    color: #e8a884 !important;
  }

  /* ---- Pills / tabs ---- */
  html[data-color-scheme="dark"] .fs-pill {
    background: #262119 !important;
    border-color: #4a4136 !important;
    color: #c9c0b1 !important;
  }
  html[data-color-scheme="dark"] .fs-pill.hot {
    background: #33261d !important;
    border-color: #6b5644 !important;
    color: #e8a884 !important;
  }
  html[data-color-scheme="dark"] .encrypt-tab { color: #c9c0b1 !important; }
  html[data-color-scheme="dark"] .encrypt-tab.on { color: #e8a884 !important; border-bottom-color: #e8a884 !important; }
  html[data-color-scheme="dark"] .encrypt-field label { color: #c9c0b1 !important; }

  /* ---- Forms / controls ---- */
  html[data-color-scheme="dark"] :is(input, textarea, select):not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]) {
    color: #ece4d8 !important;
    background: #262119 !important;
    border: 1px solid #4a4136 !important;
  }
  html[data-color-scheme="dark"] input::placeholder,
  html[data-color-scheme="dark"] textarea::placeholder { color: #817c71 !important; }
  html[data-color-scheme="dark"] :is(.btn-secondary, .light, .encrypt-tab, .cvt-btn--secondary, .cvt-btn--quiet, .secondary) {
    color: #c9c0b1 !important;
    background: #262119 !important;
    border: 1px solid #4a4136 !important;
  }
  html[data-color-scheme="dark"] .file-drop { background: #262119 !important; border-color: #4a4136 !important; }
  html[data-color-scheme="dark"] .file-drop:hover,
  html[data-color-scheme="dark"] .file-drop.over { background: #332a20 !important; border-color: #6b5644 !important; }

  /* ---- Status page ---- */
  html[data-color-scheme="dark"] .au-status .card-title { color: #ece4d8 !important; }
  html[data-color-scheme="dark"] .au-status .card-status,
  html[data-color-scheme="dark"] .au-status .stat-label,
  html[data-color-scheme="dark"] .au-status .ip-label,
  html[data-color-scheme="dark"] .au-status .refresh-time { color: #a79d8e !important; }
  html[data-color-scheme="dark"] .au-status .stat-num,
  html[data-color-scheme="dark"] .au-status .ip-address { color: #ece4d8 !important; }
  html[data-color-scheme="dark"] .au-status .status-address { border-left-color: #3a332a !important; }

  /* ---- Color test ---- */
  html[data-color-scheme="dark"] .cvt-shell {
    --c-ink: #ece4d8 !important; --c-muted: #a79d8e !important; --c-line: #3a332a !important;
    --c-surface: #221e18 !important; --c-canvas: #1e1a15 !important;
  }
  html[data-color-scheme="dark"] .cvt-prep { background: #262119 !important; }
  html[data-color-scheme="dark"] .cvt-prep b { color: #ece4d8 !important; -webkit-text-fill-color: #ece4d8 !important; }

  /* ---- Article / video archive ---- */
  html[data-color-scheme="dark"] .art-content { color: #c9c0b1 !important; }
  html[data-color-scheme="dark"] .art-content :is(pre, code, blockquote, table) {
    color: #c9c0b1 !important; background: #262119 !important; border-color: #3a332a !important;
  }
  html[data-color-scheme="dark"] .video-item { color: #ece4d8 !important; border-color: #3a332a !important; }
  html[data-color-scheme="dark"] .video-item:hover,
  html[data-color-scheme="dark"] .video-item.active { color: #e8a884 !important; }
  html[data-color-scheme="dark"] .videos-side-head,
  html[data-color-scheme="dark"] .video-row { border-color: #3a332a !important; }
  html[data-color-scheme="dark"] .vd-empty,
  html[data-color-scheme="dark"] .art-error,
  html[data-color-scheme="dark"] .art-empty { color: #a79d8e !important; border-color: #3a332a !important; }

  /* ---- Misc ---- */
  html[data-color-scheme="dark"] .au-favorability #num,
  html[data-color-scheme="dark"] .au-iqtest #rIQ { color: #e8a884 !important; }
  html[data-color-scheme="dark"] #gate { background: #171410 !important; }
  html[data-color-scheme="dark"] #resbar { background: #221e18 !important; color: #ece4d8 !important; border-color: #3a332a !important; }
  html[data-color-scheme="dark"] .fs-qr-tile { background: #f5f1ea !important; }

  /* ---- Smooth transition on scheme switch (both themes) ---- */
  body,
  :is(.fs-nav, .art-nav, .videos-nav, .ct-backbar, .fs-card, .site-link,
    .social-card, .fs-friend-card, .encrypt-card, .cvt-start, .cvt-card, .art-card, .series-card,
    .vd-video, .videos-side, .videos-main, .file-drop, .btn-primary, .btn-secondary, .go, .light,
    .dark, .card, .panel, .auth-card, input, textarea, select, .encrypt-tab) {
    transition: background-color .25s cubic-bezier(.2,.8,.2,1), color .25s cubic-bezier(.2,.8,.2,1),
      border-color .25s cubic-bezier(.2,.8,.2,1) !important;
  }
}

/* ---- Scheme toggle button ----
   Lives here, not in an injected <style>, because /admin/ sends
   style-src 'self' and would drop inline styles (button rendered unstyled
   at page bottom). This file is an external sheet, so it always applies. */
.fs-actions { display: inline-flex !important; align-items: center !important; gap: 8px !important; margin-left: auto !important; }
/* The links block already carries an auto margin, so the button must not add
   a second one: two auto margins split the free space and center the links. */
.fs-nav-inner:has(.fs-links) > .fs-actions,
.art-nav-inner:has(.art-links) > .fs-actions { margin-left: 0 !important; }
.ws-theme-fab { position: fixed !important; top: 16px !important; right: 16px !important; z-index: 2147483000 !important; display: inline-flex !important; }

.scheme-btn {
  display: inline-flex !important; align-items: center !important; gap: 7px !important;
  height: 32px !important; padding: 0 12px !important;
  border: 1px solid #dcd3c6 !important; border-radius: 999px !important;
  background: transparent !important; color: #746d62 !important;
  font: 12px/1 "Segoe UI", "Microsoft YaHei", sans-serif !important;
  cursor: pointer !important; text-decoration: none !important;
  transition: color .2s, border-color .2s, background-color .2s !important;
}
.scheme-btn:hover { color: #a55339 !important; border-color: #a55339 !important; }
.scheme-btn svg { width: 14px !important; height: 14px !important; flex: none !important; }

html[data-color-scheme="light"] .icon-sun { display: none !important; }
html[data-color-scheme="dark"] .icon-moon { display: none !important; }
html[data-color-scheme="dark"] .scheme-btn {
  border-color: #4a4136 !important; color: #b3a99a !important; background: #221e18 !important;
}
html[data-color-scheme="dark"] .scheme-btn:hover { color: #e8a884 !important; border-color: #6b5644 !important; }
