/* Activation is controlled by the stylesheet link media, with system as the default. */
@media all {
  :root {
    color-scheme: dark;
    --primary:#e7e8e9; --primary-light:#c8cbce; --primary-dark:#ffffff;
    --on-primary:#202224; --text-on-primary:#202224; --success:#8bbf86; --warning:#e7b267; --danger:#f18b81; --error:#f18b81; --info:#a8abad;
    --text-primary:#e7e8e9; --text-strong:#e7e8e9; --text-regular:#c6c9cc; --text-secondary:#a8abad; --text-muted:#93979b;
    --border-base:#484c50; --border-light:#383b3e; --border:#383b3e; --border-strong:#484c50;
    --background:#171819; --background-white:#222426; --surface:#222426; --surface-soft:#2c2e30; --card-bg:#222426;
    --glass-bg:rgba(34,36,38,.96); --accent-soft:rgba(231,232,233,.06); --accent-focus:rgba(231,232,233,.1);
    --login-gradient:linear-gradient(135deg,#171819,#222426);
  }
  body { background-color:#171819; color:#e7e8e9; }
  html:has(.fw-document-preview) { background-color:#222426; }
  .fw-document-preview { background-color:#222426; color:#c6c9cc; }
  .fw-document-preview h1,.fw-document-preview h2,.fw-document-preview h3,.fw-document-preview h4 { color:#e7e8e9; border-color:#484c50; }
  .fw-document-preview pre,.fw-document-preview code,.fw-document-preview th { background-color:#2c2e30; color:#c6c9cc; }
  .fw-document-preview pre code { background-color:transparent; }
  .fw-document-preview blockquote,.fw-document-preview th,.fw-document-preview td { border-color:#484c50; color:#c6c9cc; }
  .fw-document-preview a { color:#82adff; }
  .login-card,.btn,.upload-zone,.toolbar,.file-search,.file-list,.upload-progress-list,.modal,.clipboard-list,.viewer-btn,.help-tab.active,.share-card,
  .fw-image-viewer-toolbar,.fw-image-viewer-btn,.viewer-toolbar,.admin-preview-shell,.bar,
  .sidebar,.preview-area,.preview-header { background-color:#222426; color:var(--text-regular); border-color:var(--border-light); }
  input:not([type=color]):not([type=checkbox]):not([type=radio]),textarea,select {
    background-color:#222426; color:var(--text-primary); border-color:var(--border-base);
  }
  input::placeholder,textarea::placeholder { color:var(--text-muted); }
  input:-webkit-autofill { -webkit-text-fill-color:#e7e8e9; -webkit-box-shadow:0 0 0 1000px #222426 inset; caret-color:#e7e8e9; }
  .btn-primary,.btn-primary:hover,.btn-download { background-color:#e7e8e9; border-color:#e7e8e9; color:#202224; }
  .btn-danger { background-color:#3a2727; border-color:#70413c; color:#f18b81; }
  .btn-danger:hover,.icon-btn.danger:focus-visible { background-color:#f18b81; color:#202224; }
  .btn:hover,.viewer-btn:hover,.fw-image-viewer-btn:hover,.help-tab:hover { background-color:#2c2e30; }
  .btn-primary:hover { background-color:#c8cbce; color:#202224; }
  .toast,.toast.success,.toast.error,.toast.info,.toast.warning,.badge,.header-logo { color:#202224; }
  .share-switch input:checked+span::after { background-color:#202224; }
  .push-switch input:checked+.push-slider::before { background-color:#202224; }
  .share-expire-option input:checked+span,.share-manage-expiry-option input:checked+span { color:#202224; }
  .file-icon,.admin-file-icon { --info:#5d6a77; }
  .bind-status-badge { color:#8bbf86; }
  #headerActionMenu,.mobile-files-menu,#filesTab.mobile-files-selecting .batch-actions { background-color:#222426!important; }
  #sharesList .share-card-meta,#sharesList .share-card-permission,#sharesList .share-card-stats,#sharesList .share-card-stats b { color:#a8abad; }
  #sharesList .share-card-last { color:#93979b; }
  #sharesList .share-card-expiry.is-permanent,.share-card-expiry.is-permanent,.share-success-link { color:#82adff; }
  #sharesList .share-card-expiry.is-upcoming,.preview-only-label { color:#e7b267; }
  #sharesList .share-card-expiry.is-expired { color:#93979b; }
  .share-success-icon,.no-preview-tag,.btn-preview,.file-item:hover { background-color:#2c2e30; color:#c6c9cc; }
  .sidebar .file-item.active { background-color:#2c2e30; border-color:#484c50; }
  .sidebar::after { background-color:#383b3e; }
  .sidebar-header { background:linear-gradient(135deg,#222426,#2c2e30); color:#e7e8e9; }
  .sidebar-footer,.preview-header,.viewer-toolbar,.fw-image-viewer-toolbar { border-color:#383b3e; }
  .preview-title,.sidebar .file-name,.office-preview-fallback strong,.bar a { color:#e7e8e9; }
  .file-size,.preview-loading,.preview-empty,.office-preview-fallback,.office-preview-fallback span,.sidebar-footer { color:#a8abad; }
  .preview-md,.preview-txt { background-color:#222426; color:#c6c9cc; }
  .preview-md h1,.preview-md h2,.preview-md h3,.preview-md h4 { color:#e7e8e9; border-color:#383b3e; }
  .preview-md pre,.preview-md code,.preview-md th { background-color:#2c2e30; color:#c6c9cc; }
  .preview-md pre code { background-color:transparent; }
  .preview-md blockquote,.preview-md th,.preview-md td,.preview-md hr { border-color:#484c50; color:#a8abad; }
  .preview-md a { color:#82adff; }
  .preview-image-container { background-color:#171819; }
  body .viewer-toolbar,.fw-image-viewer .fw-image-viewer-toolbar { background-color:#222426; border-color:#383b3e; }
  .clipboard-content,.help-table tbody tr:hover { background-color:#2c2e30; }
  #officeLoadingOverlay,#officeOverlay { background-color:#222426!important; }
  .admin-secret { background-color:#382f21; color:#e7b267; }
  .content-tab.active,.message-capsule { background-color:#2c2e30; color:#e7e8e9; }
  .message-capsule.error { background-color:#3a2727; border-color:#70413c; color:#f18b81; }
  .message-capsule.success { background-color:#253429; border-color:#48634b; color:#8bbf86; }
  .error-msg:not(:empty) { background-color:#3a2727; border-color:#70413c; }
  .admin-shell .danger { background-color:#f18b81!important; border-color:#f18b81!important; color:#202224!important; }
  /* Authentication gate is rendered by the server without the main stylesheet. */
  body:has(.sub):has(#pwd) .card { background-color:#222426; border-color:#383b3e; }
  body:has(.sub):has(#pwd) .lock { background-color:#2c2e30; color:#a8abad; }
  body:has(.sub):has(#pwd) .sub { color:#a8abad; }
  body:has(.sub):has(#pwd) #btn { background-color:#e7e8e9; color:#202224; }
  /* Preserve the author's actual canvas and rendered assets, not just their dimensions. */
  .canvas-stage { --background:#F8F7F3; --grid-line:#E4E1D9; }
  .text-hotspot { color:#171717; }
  /* Neutral overlay and elevated surfaces; inset outline preserves geometry. */
  .modal-mask,.preview-modal,.canvas-dialog-overlay { background-color:rgba(0,0,0,.6); }
  .modal,.preview-box,.canvas-dialog {
    --background-white:#292b2d; --card-bg:#292b2d; --glass-bg:#292b2d;
    background-color:#292b2d;
    border-color:#414448;
    box-shadow:0 12px 36px rgba(0,0,0,.48),inset 0 0 0 1px #414448;
  }
  .modal-header,.modal-footer { border-color:#414448; }
  .modal input:not([type=color]):not([type=checkbox]):not([type=radio]),.modal textarea,.modal select,
  .canvas-dialog input:not([type=color]):not([type=checkbox]):not([type=radio]),.canvas-dialog textarea,.canvas-dialog select {
    background-color:#202224; border-color:#484c50;
  }
  .modal input:-webkit-autofill,.canvas-dialog input:-webkit-autofill {
    -webkit-box-shadow:0 0 0 1000px #202224 inset;
  }
  /* 分享页悬浮操作栏组件深色（preview-rail.css 无变量环境，hex 覆盖；特异性高于组件浅色规则） */
  .fw-share-page .fw-preview-rail { background-color:#222426; border-color:#383b3e; }
  .fw-share-page .fw-preview-rail-btn { background-color:transparent; color:#e7e8e9; }
  .fw-share-page .fw-preview-rail-level { color:#a8abad; }
  .fw-share-page .fw-preview-rail-nav,
  .fw-share-page .fw-preview-rail-group { border-color:#383b3e; }
  @media (hover:hover) and (pointer:fine) {
    .fw-share-page .fw-preview-rail-btn:not(:disabled):hover { background-color:#2c2e30; }
  }
}
