/*
 * Outline custom theme — colors only
 * 通过 Nginx sub_filter 注入。
 *
 * 仅覆盖颜色相关属性，不修改字体、尺寸、圆角、阴影、布局、
 * 滚动、动画、代码折叠或其他交互行为。
 */

:root {
    /* 快速配色区 */
    --theme-page-bg: #e8e7d8;
    --theme-content-bg: #f7f4e9;
    --theme-sidebar-bg: #dce2d2;
    --theme-sidebar-hover: #cdd8c5;
    --theme-card-bg: #fbf9f1;
    --theme-input-bg: #fdfbf5;

    --theme-text: #293229;
    --theme-text-secondary: #657064;
    --theme-heading: #29472e;

    --theme-primary: #46784d;
    --theme-primary-hover: #365f3d;
    --theme-primary-soft: #dbe9d8;

    --theme-code-bg: #ece9dc;
    --theme-code-gutter-bg: #ece9dc;
    --theme-code-gutter-text: #71809a;

    --theme-quote-bg: #e4eadc;
    --theme-table-header-bg: #e4e7da;

    --theme-border: #cfd4c7;
    --theme-border-light: #dde1d7;
    --theme-selection: rgba(70, 120, 77, 0.22);
}

/* 全局 */
html,
body,
#root {
    background-color: var(--theme-page-bg) !important;
    color: var(--theme-text);
}

::selection {
    background-color: var(--theme-selection);
}

/* 主内容背景 */
body:has(.ProseMirror),
main:has(.ProseMirror),
[role="main"]:has(.ProseMirror),
main:has(.ProseMirror) > div,
[role="main"]:has(.ProseMirror) > div,
div:has(> .ProseMirror),
section:has(> .ProseMirror),
.sc-izQBue.bPmxGa.jiFQmm,
.sc-izQBue.fVzNGC.jiFQmm,
.sc-fqkvVR.sc-izQBue.bPmxGa.jiFQmm,
.sc-fqkvVR.sc-izQBue.fVzNGC.jiFQmm,
[role="main"].sc-jBeBSR.QkwKh,
[role="main"].juXmzh.QkwKh,
#root > .sc-hmdomO,
#root > .sc-hmdomO > .sc-izQBue {
    background-color: var(--theme-content-bg) !important;
    background-image: none !important;
}

.ProseMirror,
.ProseMirror-focused,
[contenteditable="true"].ProseMirror {
    background-color: transparent !important;
    background-image: none !important;
    color: var(--theme-text) !important;
}

/* 清除正文和标题中 Outline 遗留的白底 */
.ProseMirror > *,
.ProseMirror p,
.ProseMirror div,
.ProseMirror section,
.ProseMirror h1,
.ProseMirror h2,
.ProseMirror h3,
.ProseMirror h4,
.ProseMirror h5,
.ProseMirror h6,
.ProseMirror ul,
.ProseMirror ol,
.ProseMirror li,
h1[contenteditable="true"],
h1[contenteditable="true"] *,
[class*="DocumentTitle"],
[class*="DocumentTitle"] *,
[class*="TitleInput"],
[class*="TitleInput"] *,
[class*="TitleTextarea"],
[class*="TitleTextarea"] *,
textarea[placeholder*="标题"],
input[placeholder*="标题"],
[role="main"] [contenteditable="true"]:not(.ProseMirror),
[role="main"] [contenteditable="true"]:not(.ProseMirror) *,
[role="main"] [role="textbox"]:not(.ProseMirror),
[role="main"] [role="textbox"]:not(.ProseMirror) *,
[role="main"] [data-placeholder*="标题"],
[role="main"] [data-placeholder*="标题"] *,
[role="main"] [placeholder*="标题"],
[role="main"] [placeholder*="标题"] *,
[role="main"] [aria-label*="标题"],
[role="main"] [aria-label*="标题"] *,
[role="main"] > div:first-child span,
[role="main"] > div:first-child mark,
[role="main"] > div:first-child strong {
    background-color: transparent !important;
    background-image: none !important;
}

/* 顶部栏 */
header,
[role="banner"],
[class*="Header"],
[class*="Toolbar"],
[class*="Topbar"],
[class*="TopBar"] {
    background-color: var(--theme-card-bg) !important;
    border-color: var(--theme-border-light) !important;
}

/* 侧边栏 */
nav,
aside,
[role="navigation"],
[class*="Sidebar"],
[class*="Navigation"],
[role="navigation"] > div,
aside > div,
[class*="Sidebar"] > div,
[class*="Navigation"] > div,
[role="navigation"] [class*="Header"],
[role="navigation"] [class*="Footer"],
[role="navigation"] [class*="Scrollable"],
[role="navigation"] [class*="Scroll"],
aside [class*="Header"],
aside [class*="Footer"],
aside [class*="Scrollable"],
aside [class*="Scroll"],
[class*="Sidebar"] [class*="Header"],
[class*="Sidebar"] [class*="Footer"],
[class*="Sidebar"] [class*="Scrollable"],
[class*="Sidebar"] [class*="Scroll"],
body:has(a[href*="/settings"]) #root > div > div:first-child,
body:has(a[href*="/settings"]) #root > div > div:first-child > div {
    background-color: var(--theme-sidebar-bg) !important;
    background-image: none !important;
}

nav a:hover,
aside a:hover,
aside button:hover,
[role="navigation"] a:hover,
[role="navigation"] button:hover,
[class*="Sidebar"] a:hover,
[class*="Sidebar"] button:hover,
[role="navigation"] a[aria-current="page"],
aside a[aria-current="page"],
[class*="Sidebar"] a[aria-current="page"] {
    background-color: var(--theme-sidebar-hover) !important;
}


/* 文字与链接 */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--theme-heading) !important;
}

[role="main"] p,
[role="main"] li,
article p,
article li,
.ProseMirror p,
.ProseMirror li {
    color: var(--theme-text);
}

[role="main"] a,
.ProseMirror a,
article a {
    color: var(--theme-primary) !important;
    text-decoration-color: rgba(70, 120, 77, 0.45);
}

[role="main"] a:hover,
.ProseMirror a:hover,
article a:hover {
    color: var(--theme-primary-hover) !important;
}

/* 主按钮 */
button[class*="primary"],
button[class*="Primary"],
[class*="Button"][data-variant="primary"] {
    background-color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
    color: #ffffff !important;
}

button[class*="primary"]:hover,
button[class*="Primary"]:hover {
    background-color: var(--theme-primary-hover) !important;
}

/* 输入框与搜索框 */
input,
textarea,
select,
[role="main"] [role="combobox"],
[role="main"] [class*="Select"],
[role="main"] [class*="Input"],
[role="main"] button[role="combobox"],
[role="main"] [aria-haspopup="listbox"] {
    background-color: var(--theme-input-bg) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--theme-primary) !important;
}

input::placeholder,
textarea::placeholder {
    color: #8b9388 !important;
}

[class*="Search"],
[class*="SearchInput"],
[class*="SearchContainer"],
header [class*="Search"],
[role="banner"] [class*="Search"],
[class*="Topbar"] [class*="Search"],
[class*="TopBar"] [class*="Search"] {
    background-color: var(--theme-input-bg) !important;
    background-image: none !important;
}

input[type="search"],
input[placeholder*="搜索"],
[class*="Search"] input,
header input[type="search"],
[role="banner"] input[type="search"] {
    background-color: transparent !important;
}

/* 卡片、弹窗和菜单 */
[class*="Card"],
[role="dialog"],
[class*="Dialog"],
[class*="Modal"],
[role="menu"],
[role="listbox"] {
    background-color: var(--theme-card-bg) !important;
    border-color: var(--theme-border-light) !important;
}

[role="menuitem"]:hover,
[role="option"]:hover {
    background-color: var(--theme-primary-soft) !important;
}

/* 引用、代码和表格 */
blockquote,
.ProseMirror blockquote {
    background-color: var(--theme-quote-bg) !important;
    border-left-color: var(--theme-primary) !important;
    color: #455245;
}

code,
pre,
.ProseMirror pre,
.ProseMirror .code-block.with-line-numbers,
.ProseMirror .code-block.with-line-numbers > pre,
.ProseMirror .code-block.with-line-numbers pre,
.ProseMirror [class*="CodeBlock"],
.ProseMirror [class*="CodeMirror"] {
    background-color: var(--theme-code-bg) !important;
    border-color: var(--theme-border-light) !important;
}

pre code,
.ProseMirror pre > *,
.ProseMirror [class*="CodeBlock"] > *,
.ProseMirror [class*="CodeMirror"] > * {
    background-color: transparent !important;
}

.ProseMirror .code-block.with-line-numbers::before,
.ProseMirror .code-block.with-line-numbers::after,
.ProseMirror pre.line-numbers::before,
.ProseMirror pre.line-numbers::after,
.ProseMirror pre[class*="line-numbers"]::before,
.ProseMirror pre[class*="line-numbers"]::after {
    background-color: var(--theme-code-gutter-bg) !important;
    background-image: none !important;
}

.ProseMirror .code-block.with-line-numbers [class*="line-number"],
.ProseMirror .code-block.with-line-numbers [class*="lineNumber"],
.ProseMirror .code-block.with-line-numbers [class*="LineNumber"],
.ProseMirror .code-block.with-line-numbers [class*="line-numbers"],
.ProseMirror .code-block.with-line-numbers [class*="LineNumbers"],
.ProseMirror .code-block.with-line-numbers [class*="gutter"],
.ProseMirror .code-block.with-line-numbers [class*="Gutter"],
.ProseMirror .code-block.with-line-numbers [data-line-number],
.ProseMirror .code-block.with-line-numbers pre > [style*="position: absolute"]:first-child,
.ProseMirror .code-block.with-line-numbers pre > div:first-child[aria-hidden="true"],
.ProseMirror .code-block.with-line-numbers pre > span:first-child[aria-hidden="true"] {
    background-color: var(--theme-code-gutter-bg) !important;
    color: var(--theme-code-gutter-text) !important;
}

.ProseMirror div:has(> table),
.ProseMirror figure:has(> table),
.ProseMirror [class*="TableWrapper"],
.ProseMirror [class*="TableContainer"] {
    background-color: transparent !important;
    background-image: none !important;
}

table,
.ProseMirror table,
[role="main"] table,
[role="main"] [role="table"],
[role="main"] [class*="Table"] {
    background-color: var(--theme-card-bg) !important;
    border-color: var(--theme-border) !important;
}

th,
.ProseMirror thead,
.ProseMirror thead tr,
.ProseMirror th,
[role="main"] thead,
[role="main"] thead tr,
[role="main"] thead th,
[role="main"] [role="columnheader"] {
    background-color: var(--theme-table-header-bg) !important;
    color: var(--theme-heading) !important;
    border-color: var(--theme-border) !important;
}

.ProseMirror tbody,
.ProseMirror tbody tr,
.ProseMirror td {
    background-color: var(--theme-content-bg) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}

.ProseMirror table p,
.ProseMirror table span,
.ProseMirror table div,
.ProseMirror table mark,
.ProseMirror table [class*="Math"],
.ProseMirror table [class*="Katex"] {
    background-color: transparent !important;
}

.ProseMirror tbody tr:hover,
.ProseMirror tbody tr:hover td,
tbody tr:hover {
    background-color: var(--theme-primary-soft) !important;
}

hr,
[role="main"] [class*="Separator"],
[role="main"] [class*="Divider"] {
    border-color: var(--theme-border) !important;
    background-color: var(--theme-border-light) !important;
}

/* 集合页、设置页、首页和列表页 */
body:has([class*="Collection"]) main,
body:has([class*="Collection"]) [role="main"],
body:has([class*="Collection"]) main > div,
body:has([class*="Collection"]) [role="main"] > div,
body:has([class*="Collection"]) [class*="CollectionScene"],
body:has([class*="Collection"]) [class*="CollectionHeader"],
body:has([class*="Collection"]) [class*="CollectionContent"],
body:has([class*="Collection"]) [class*="DocumentList"],
body:has([class*="Collection"]) [class*="ListPage"],
[role="main"]:has(form),
[role="main"]:has(button[type="submit"]),
[role="main"]:has(form) > div,
[role="main"]:has(button[type="submit"]) > div,
[role="main"]:has(form) section,
[role="main"]:has(form) form,
[role="main"]:has([role="tab"]),
[role="main"]:has([role="tablist"]),
[role="main"]:has([role="tab"]) > div,
[role="main"]:has([role="tablist"]) > div,
[role="main"] [class*="CenteredContent"],
[role="main"] [class*="ContentColumn"],
[role="main"] [class*="Home"],
[role="main"] [class*="Empty"],
[role="main"] [class*="EmptyState"],
[role="main"] [class*="NoResults"],
[role="main"] [class*="Placeholder"] {
    background-color: var(--theme-content-bg) !important;
    background-image: none !important;
}

[role="tablist"],
[class*="TabBar"],
[class*="Tabs"],
[role="main"] [role="tablist"],
[role="main"] [class*="TabBar"],
[role="main"] [class*="Tabs"] {
    background-color: var(--theme-sidebar-bg) !important;
    border-color: var(--theme-border-light) !important;
}

[role="main"] [role="tab"],
[role="main"] [role="tab"] *,
[role="main"] [class*="Tab"] > a,
[role="main"] [class*="Tab"] > button {
    background-color: transparent !important;
}

/* 文档列表与页面背景统一，不再使用独立卡片白底 */
[role="main"] [role="list"],
[role="main"] [class*="DocumentList"],
[role="main"] [class*="PaginatedList"],
[role="main"] div:has(> [role="list"]),
[role="main"] div:has(> [class*="DocumentList"]),
[role="main"] div:has(> [class*="PaginatedList"]),
[role="main"] [role="listitem"],
[role="main"] [class*="DocumentList"] > *,
[role="main"] [class*="PaginatedList"] > *,
[role="main"] [class*="ListItem"],
[role="main"] a[class*="Document"],
[role="main"] a[class*="ListItem"],
[role="main"] div[class*="DocumentRow"] {
    background-color: var(--theme-content-bg) !important;
    background-image: none !important;
    border-color: var(--theme-border-light) !important;
}

/* 其他普通卡片和面板仍使用卡片背景 */
[role="main"] [class*="Card"],
[role="main"] [class*="Panel"] {
    background-color: var(--theme-card-bg) !important;
    border-color: var(--theme-border-light) !important;
}

[role="main"] [role="listitem"] *,
[role="main"] [class*="ListItem"] * {
    background-color: transparent !important;
}

[role="main"] [role="listitem"]:hover,
[role="main"] [class*="DocumentList"] > *:hover,
[role="main"] [class*="PaginatedList"] > *:hover,
[role="main"] [class*="ListItem"]:hover,
[role="main"] a[class*="Document"]:hover,
[role="main"] a[class*="ListItem"]:hover,
[role="main"] div[class*="DocumentRow"]:hover {
    background-color: var(--theme-primary-soft) !important;
}

/* 登录页 */
[class*="Auth"],
[class*="Login"],
[class*="Authentication"] {
    background-color: var(--theme-page-bg) !important;
}

[class*="Auth"] [class*="Card"],
[class*="Login"] [class*="Card"] {
    background-color: var(--theme-card-bg) !important;
}


/* =========================================================
   文档集列表最终颜色覆盖
   仅改变主内容区列表背景，不修改侧边栏文字或图标颜色。
   ========================================================= */
body:has([class*="Collection"]) [role="main"] [role="list"],
body:has([class*="Collection"]) [role="main"] [class*="DocumentList"],
body:has([class*="Collection"]) [role="main"] [class*="PaginatedList"],
body:has([class*="Collection"]) [role="main"] [class*="ListItem"],
body:has([class*="Collection"]) [role="main"] [class*="DocumentRow"],
body:has([class*="Collection"]) [role="main"] div:has(> [role="list"]),
body:has([class*="Collection"]) [role="main"] div:has(> [class*="DocumentList"]),
body:has([class*="Collection"]) [role="main"] div:has(> [class*="PaginatedList"]) {
    background-color: var(--theme-content-bg) !important;
    background-image: none !important;
}

/* =========================================================
   文档集列表实际 DOM 精确覆盖
   .iIuajs 与 .bccALK 为当前 Outline 版本中的列表白色容器。
   仅限主内容区，避免影响侧边栏原有文字颜色。
   ========================================================= */
[role="main"] .iIuajs,
[role="main"] .bccALK,
main .iIuajs,
main .bccALK {
    background: var(--theme-content-bg) !important;
    background-color: var(--theme-content-bg) !important;
    background-image: none !important;
}

/* 两层容器嵌套时保持一致 */
[role="main"] .iIuajs .bccALK,
[role="main"] .bccALK .iIuajs,
main .iIuajs .bccALK,
main .bccALK .iIuajs {
    background: var(--theme-content-bg) !important;
    background-color: var(--theme-content-bg) !important;
    background-image: none !important;
}


/* 覆盖磨砂背景 */
.fNtFGO {
    background: var(--custom-content-bg) !important;
    background-color: var(--custom-content-bg) !important;
    background-image: none !important;
}

/* Safari / Chrome backdrop-filter */
@supports ((-webkit-backdrop-filter: blur(20px)) or (backdrop-filter: blur(20px))) {
    .fNtFGO {
        background: var(--custom-content-bg) !important;
        background-color: var(--custom-content-bg) !important;
    }
}
