:root,
[data-theme="light"] {
  --cw-accent: #CA8E45;
  --cw-card: #F7FAF8;
  --cw-hover: #E8EAE7;
  --cw-indicator: #8EB19A;
  --cw-line: #D5D6D2;
  --cw-main: #8EB19A;
  --cw-main-hover: #86A58F;
  --cw-muted: #5F574D;
  --cw-on-accent: #24180B;
  --cw-on-main: #24180B;
  --cw-page: #EFF1EF;
  --cw-selected: #E2E3E0;
  --cw-text: #24180B;
}

[data-theme="dark"] {
  --cw-accent: #CA8E45;
  --cw-card: #3A3229;
  --cw-hover: #474037;
  --cw-indicator: #CA8E45;
  --cw-line: #5B544D;
  --cw-main: #8EB19A;
  --cw-main-hover: #86A58F;
  --cw-muted: #BABAB5;
  --cw-on-accent: #24180B;
  --cw-on-main: #24180B;
  --cw-page: #2D241B;
  --cw-selected: #504941;
  --cw-text: #F7FAF8;
}

:root,
[data-theme] {
  --affine-v2-layer-background-primary: var(--cw-card) !important;
  --affine-v2-layer-background-overlayPanel: var(--cw-card) !important;
  --affine-v2-layer-background-linkedDocOnEdgeless: var(--cw-card) !important;
  --affine-v2-layer-background-translucentUI: var(--cw-card) !important;
  --affine-v2-layer-white: var(--cw-card) !important;
  --affine-v2-dialog-background-primary: var(--cw-card) !important;
  --affine-v2-slashMenu-background: var(--cw-card) !important;
  --affine-v2-tableOfContent-background: var(--cw-card) !important;
  --affine-v2-button-secondary: var(--cw-card) !important;
  --affine-v2-button-iconButtonSolid: var(--cw-card) !important;
  --affine-v2-button-signinbutton-background: var(--cw-card) !important;
  --affine-v2-input-background: var(--cw-card) !important;
  --affine-v2-segment-button: var(--cw-card) !important;
  --affine-v2-switch-buttonBackground-active: var(--cw-card) !important;
  --affine-v2-tab-tabBackground-active: var(--cw-card) !important;
  --affine-v2-toggle-foreground: var(--cw-card) !important;
  --affine-v2-edgelessToolbar-others-background: var(--cw-card) !important;
  --affine-v2-centerPeek-background: var(--cw-card) !important;
  --affine-v2-centerPeek-buttonBackground: var(--cw-card) !important;
  --affine-v2-selfhost-layer-background-primary: var(--cw-card) !important;
  --affine-v2-selfhost-button-secondary: var(--cw-card) !important;
  --affine-background-primary-color: var(--cw-card) !important;
  --affine-background-overlay-panel-color: var(--cw-card) !important;
  --affine-v2-layer-background-secondary: var(--cw-page) !important;
  --affine-v2-tab-tabBackground-default: var(--cw-page) !important;
  --affine-v2-selfhost-layer-background-secondary: var(--cw-page) !important;
  --affine-background-secondary-color: var(--cw-page) !important;
  --affine-v2-layer-background-hoverOverlay: var(--cw-hover) !important;
  --affine-v2-layer-background-codeBlock: var(--cw-hover) !important;
  --affine-v2-button-buttonOverHover: var(--cw-hover) !important;
  --affine-v2-button-emptyIconBackground: var(--cw-hover) !important;
  --affine-v2-segment-background: var(--cw-hover) !important;
  --affine-v2-switch-switchBackground-background: var(--cw-hover) !important;
  --affine-v2-switch-buttonBackground-hover: var(--cw-hover) !important;
  --affine-v2-tab-tabBackground-hover: var(--cw-hover) !important;
  --affine-v2-skeleton-skeleton: var(--cw-hover) !important;
  --affine-v2-database-buttonBackground: var(--cw-hover) !important;
  --affine-v2-database-attachment-fileSolidBackground: var(--cw-hover) !important;
  --affine-v2-workspacePicker-secondaryBackground: var(--cw-hover) !important;
  --affine-v2-backlinks-blockBackgroundColor: var(--cw-hover) !important;
  --affine-v2-block-notSupportedBlock-inlineBg-default: var(--cw-hover) !important;
  --affine-v2-toggle-backgroundDisable: var(--cw-hover) !important;
  --affine-v2-selfhost-layer-background-hoverOverlay: var(--cw-hover) !important;
  --affine-v2-selfhost-button-sidebarButton-bg-hover: var(--cw-hover) !important;
  --affine-v2-selfhost-portrait-localPortraitBackground: var(--cw-hover) !important;
  --affine-background-code-block: var(--cw-hover) !important;
  --affine-background-tertiary-color: var(--cw-hover) !important;
  --affine-hover-color: var(--cw-hover) !important;
  --affine-hover-color-filled: var(--cw-hover) !important;
  --affine-v2-layer-background-tertiary: var(--cw-selected) !important;
  --affine-v2-button-actionActive: var(--cw-selected) !important;
  --affine-v2-button-templateLabelBackground: var(--cw-selected) !important;
  --affine-v2-table-headerBackground-default: var(--cw-selected) !important;
  --affine-v2-table-headerBackground-headerColor: var(--cw-selected) !important;
  --affine-v2-table-focusBackground: var(--cw-selected) !important;
  --affine-v2-database-focusBackground: var(--cw-selected) !important;
  --affine-v2-backlinks-blockHover: var(--cw-selected) !important;
  --affine-v2-block-notSupportedBlock-inlineBg-hover: var(--cw-selected) !important;
  --affine-v2-block-footnote-numberBg: var(--cw-selected) !important;
  --affine-v2-block-comment-hanelActive: var(--cw-selected) !important;
  --affine-v2-edgeless-selection-selectionMarqueeBackground: var(--cw-selected) !important;
  --affine-v2-selfhost-button-sidebarButton-bg-select: var(--cw-selected) !important;
  --affine-primary-color-04: var(--cw-selected) !important;
  --affine-tertiary-color: var(--cw-selected) !important;
  --affine-blue-50: var(--cw-selected) !important;
  --affine-blue-100: var(--cw-selected) !important;
  --affine-blue-200: var(--cw-selected) !important;
  --affine-blue-300: var(--cw-selected) !important;
  --affine-blue-950: var(--cw-selected) !important;
  --affine-v2-layer-insideBorder-border: var(--cw-line) !important;
  --affine-v2-layer-insideBorder-blackBorder: var(--cw-line) !important;
  --affine-v2-layer-insideBorder-whiteBorder: var(--cw-line) !important;
  --affine-v2-layer-background-edgelessGrid: var(--cw-line) !important;
  --affine-v2-button-innerBlackBorder: var(--cw-line) !important;
  --affine-v2-button-grabber-default: var(--cw-line) !important;
  --affine-v2-button-grabber-select: var(--cw-line) !important;
  --affine-v2-input-border-default: var(--cw-line) !important;
  --affine-v2-input-scrollBar-handle: var(--cw-line) !important;
  --affine-v2-database-border: var(--cw-line) !important;
  --affine-v2-table-border: var(--cw-line) !important;
  --affine-v2-tab-divider-divider: var(--cw-line) !important;
  --affine-v2-block-divider-divider: var(--cw-line) !important;
  --affine-v2-backlinks-blockBorder: var(--cw-line) !important;
  --affine-v2-edgeless-frame-border-default: var(--cw-line) !important;
  --affine-v2-workspacePicker-border: var(--cw-line) !important;
  --affine-v2-pagelist-hoverBorder: var(--cw-line) !important;
  --affine-v2-loading-background: var(--cw-line) !important;
  --affine-v2-toggle-backgroundOff: var(--cw-line) !important;
  --affine-v2-radio-active-default: var(--cw-line) !important;
  --affine-v2-icon-tertiary: var(--cw-line) !important;
  --affine-v2-icon-disable: var(--cw-line) !important;
  --affine-v2-selfhost-layer-border-border: var(--cw-line) !important;
  --affine-v2-selfhost-toggle-backgroundOff: var(--cw-line) !important;
  --affine-v2-selfhost-toggle-backgroundDisable: var(--cw-line) !important;
  --affine-border-color: var(--cw-line) !important;
  --affine-divider-color: var(--cw-line) !important;
  --affine-edgeless-grid-color: var(--cw-line) !important;
  --affine-v2-text-primary: var(--cw-text) !important;
  --affine-v2-text-link: var(--cw-text) !important;
  --affine-v2-tab-fontColor-active: var(--cw-text) !important;
  --affine-v2-tab-fontColor-hover: var(--cw-text) !important;
  --affine-v2-tab-iconColor-active: var(--cw-text) !important;
  --affine-v2-tab-iconColor-hover: var(--cw-text) !important;
  --affine-v2-switch-fontColor-primary: var(--cw-text) !important;
  --affine-v2-switch-iconColor-active: var(--cw-text) !important;
  --affine-v2-layer-black: var(--cw-text) !important;
  --affine-v2-selfhost-icon-primary: var(--cw-text) !important;
  --affine-text-primary-color: var(--cw-text) !important;
  --affine-link-color: var(--cw-text) !important;
  --affine-v2-text-secondary: var(--cw-muted) !important;
  --affine-v2-text-tertiary: var(--cw-muted) !important;
  --affine-v2-text-placeholder: var(--cw-muted) !important;
  --affine-v2-text-disable: var(--cw-muted) !important;
  --affine-v2-icon-primary: var(--cw-muted) !important;
  --affine-v2-icon-secondary: var(--cw-muted) !important;
  --affine-v2-icon-monotone: var(--cw-muted) !important;
  --affine-v2-icon-transparentBlack: var(--cw-muted) !important;
  --affine-v2-tab-fontColor-default: var(--cw-muted) !important;
  --affine-v2-tab-iconColor-default: var(--cw-muted) !important;
  --affine-v2-switch-fontColor-secondary: var(--cw-muted) !important;
  --affine-v2-switch-fontColor-tertiary: var(--cw-muted) !important;
  --affine-v2-switch-iconColor-default: var(--cw-muted) !important;
  --affine-v2-table-textSecondary: var(--cw-muted) !important;
  --affine-v2-database-textSecondary: var(--cw-muted) !important;
  --affine-v2-block-code-lineNum: var(--cw-muted) !important;
  --affine-v2-edgeless-group-fontColor-default: var(--cw-muted) !important;
  --affine-v2-edgeless-lock-locked: var(--cw-muted) !important;
  --affine-v2-button-disable: var(--cw-muted) !important;
  --affine-v2-radio-disable: var(--cw-muted) !important;
  --affine-v2-toggle-foregroundDisable: var(--cw-muted) !important;
  --affine-v2-centerPeek-icon: var(--cw-muted) !important;
  --affine-v2-selfhost-icon-secondary: var(--cw-muted) !important;
  --affine-v2-selfhost-icon-tertiary: var(--cw-muted) !important;
  --affine-v2-selfhost-icon-disable: var(--cw-muted) !important;
  --affine-v2-selfhost-text-placeholder: var(--cw-muted) !important;
  --affine-v2-selfhost-button-disable: var(--cw-muted) !important;
  --affine-text-secondary-color: var(--cw-muted) !important;
  --affine-text-disable-color: var(--cw-muted) !important;
  --affine-placeholder-color: var(--cw-muted) !important;
  --affine-icon-color: var(--cw-muted) !important;
  --affine-icon-secondary: var(--cw-muted) !important;
  --affine-quote-color: var(--cw-muted) !important;
  --affine-list-color: var(--cw-muted) !important;
  --affine-button-gray-color: var(--cw-muted) !important;
  --affine-v2-layer-insideBorder-primaryBorder: var(--cw-indicator) !important;
  --affine-v2-layer-insideBorder-splitviewActived: var(--cw-indicator) !important;
  --affine-v2-text-emphasis: var(--cw-indicator) !important;
  --affine-v2-text-listDotAndNumber: var(--cw-indicator) !important;
  --affine-v2-icon-activated: var(--cw-indicator) !important;
  --affine-v2-button-checkBox: var(--cw-indicator) !important;
  --affine-v2-input-border-active: var(--cw-indicator) !important;
  --affine-v2-radio-active-chekced: var(--cw-indicator) !important;
  --affine-v2-toggle-background: var(--cw-indicator) !important;
  --affine-v2-tab-divider-indicator: var(--cw-indicator) !important;
  --affine-v2-table-focusBorder: var(--cw-indicator) !important;
  --affine-v2-table-indicator-activated: var(--cw-indicator) !important;
  --affine-v2-edgeless-frame-border-active: var(--cw-indicator) !important;
  --affine-v2-edgeless-group-border-active: var(--cw-indicator) !important;
  --affine-v2-edgeless-group-border-hover: var(--cw-indicator) !important;
  --affine-v2-edgeless-group-border-borderHint: var(--cw-indicator) !important;
  --affine-v2-edgeless-group-fontColor-active: var(--cw-indicator) !important;
  --affine-v2-edgeless-group-fontColor-hover: var(--cw-indicator) !important;
  --affine-v2-edgeless-selection-selectionMarqueeBorder: var(--cw-indicator) !important;
  --affine-v2-loading-foreground: var(--cw-indicator) !important;
  --affine-v2-block-list-header: var(--cw-indicator) !important;
  --affine-v2-block-footnote-numberBgHover: var(--cw-indicator) !important;
  --affine-v2-toast-iconState-regular: var(--cw-indicator) !important;
  --affine-v2-readwise-quoteDivider: var(--cw-indicator) !important;
  --affine-v2-selfhost-toggle-backgroundOn: var(--cw-indicator) !important;
  --affine-v2-selfhost-progress-primary: var(--cw-indicator) !important;
  --affine-primary-color: var(--cw-indicator) !important;
  --affine-secondary-color: var(--cw-indicator) !important;
  --affine-text-emphasis-color: var(--cw-indicator) !important;
  --affine-blue: var(--cw-indicator) !important;
  --affine-blue-400: var(--cw-indicator) !important;
  --affine-blue-500: var(--cw-indicator) !important;
  --affine-blue-600: var(--cw-indicator) !important;
  --affine-blue-700: var(--cw-indicator) !important;
  --affine-blue-800: var(--cw-indicator) !important;
  --affine-blue-900: var(--cw-indicator) !important;
  --affine-v2-button-primary: var(--cw-accent) !important;
  --affine-v2-selfhost-button-primary: var(--cw-accent) !important;
  --affine-brand-color: var(--cw-accent) !important;
  --affine-v2-selfhost-text-button-primary: var(--cw-on-accent) !important;
  --affine-v2-selfhost-icon-buttonIcon: var(--cw-on-accent) !important;
  --affine-v2-tooltips-background: var(--cw-main) !important;
  --affine-tooltip: var(--cw-main) !important;
  --affine-v2-tooltips-foreground: var(--cw-on-main) !important;
  --affine-v2-tooltips-secondaryBackground: var(--cw-main-hover) !important;
  --affine-v2-layer-background-modal: color-mix(in srgb, var(--cw-main) 60%, transparent) !important;
  --affine-background-modal-color: color-mix(in srgb, var(--cw-main) 60%, transparent) !important;
  --affine-v2-centerPeek-overlay: color-mix(in srgb, var(--cw-main) 60%, transparent) !important;
  --affine-active-shadow: 0 0 0 2px color-mix(in srgb, var(--cw-accent) 30%, transparent) !important;
  --affine-large-button-effect: 0 12px 20px 4px color-mix(in srgb, var(--cw-accent) 18%, transparent) !important;
}

[data-testid="app-sidebar-wrapper"] {
  position: relative;
  background: var(--cw-main) !important;
  color: var(--cw-on-main) !important;
  --affine-v2-text-primary: var(--cw-on-main) !important;
  --affine-v2-text-secondary: var(--cw-on-main) !important;
  --affine-v2-text-tertiary: var(--cw-on-main) !important;
  --affine-v2-icon-primary: var(--cw-on-main) !important;
  --affine-v2-icon-secondary: var(--cw-on-main) !important;
  --affine-text-primary-color: var(--cw-on-main) !important;
  --affine-text-secondary-color: var(--cw-on-main) !important;
  --affine-icon-color: var(--cw-on-main) !important;
  --affine-v2-layer-background-hoverOverlay: var(--cw-main-hover) !important;
  --affine-v2-layer-insideBorder-blackBorder: var(--cw-main-hover) !important;
  --affine-v2-layer-insideBorder-border: var(--cw-main-hover) !important;
  --affine-v2-button-iconButtonSolid: var(--cw-main-hover) !important;
  --affine-v2-button-secondary: var(--cw-main-hover) !important;
  --affine-v2-button-innerBlackBorder: var(--cw-main-hover) !important;
  --affine-v2-button-sidebarButton-background: var(--cw-main-hover) !important;
  --affine-v2-button-siderbarPrimary-background: var(--cw-main-hover) !important;
  --affine-hover-color: var(--cw-main-hover) !important;
  --affine-hover-color-filled: var(--cw-main-hover) !important;
  --affine-border-color: var(--cw-main-hover) !important;
  --affine-white-30: var(--cw-main-hover) !important;
  --affine-white-60: var(--cw-main-hover) !important;
  --affine-black-10: var(--cw-main-hover) !important;
}

[data-testid="app-sidebar-wrapper"] [data-active="true"] {
  background: var(--cw-accent) !important;
  color: var(--cw-on-accent) !important;
  --affine-v2-text-primary: var(--cw-on-accent) !important;
  --affine-v2-icon-primary: var(--cw-on-accent) !important;
  --affine-text-primary-color: var(--cw-on-accent) !important;
  --affine-icon-color: var(--cw-on-accent) !important;
}

[data-testid="split-view-panel"] div:has(> div > div > [data-testid="header"]) {
  box-shadow: inset 0 -1px 0 var(--cw-line);
}

button[data-variant="primary"],
button[data-variant="primary"] * {
  color: var(--cw-on-accent) !important;
}

.cw-switches {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cw-lang {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--cw-main-hover);
}

.cw-lang button {
  padding: 4px 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--cw-on-main);
  font: 600 12px/1.2 var(--affine-font-family, Inter, sans-serif);
  cursor: pointer;
}

.cw-lang button[aria-pressed="true"] {
  background: var(--cw-on-main);
  color: var(--cw-main);
}

.cw-theme-switch {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--cw-main-hover);
  border-radius: 50%;
  background: transparent;
  color: var(--cw-on-main);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.cw-theme-switch:active {
  transform: scale(0.9);
}

.cw-switches button:focus-visible {
  outline: 2px solid var(--cw-on-main);
  outline-offset: 2px;
}

.cw-theme-icon {
  width: 17px;
  height: 17px;
  overflow: visible;
  transition: transform 0.7s cubic-bezier(0.65, 0, 0.35, 1);
}

.cw-theme-icon .cw-sun-core,
.cw-theme-icon .cw-sun-rays {
  transform-box: fill-box;
  transform-origin: center;
}

.cw-theme-icon .cw-sun-rays path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.cw-theme-icon .cw-moon-bite {
  transition: transform 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}

.cw-theme-icon .cw-sun-core {
  transition: transform 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) 0.05s;
}

.cw-theme-icon .cw-sun-rays {
  transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.12s, opacity 0.25s ease 0.12s;
}

:root:not([data-theme="dark"]) .cw-theme-icon {
  transform: rotate(180deg);
}

:root:not([data-theme="dark"]) .cw-theme-icon .cw-sun-rays {
  transform: rotate(-120deg) scale(0.2);
  opacity: 0;
}

:root:not([data-theme="dark"]) .cw-theme-icon .cw-sun-core {
  transform: scale(2.05);
}

:root:not([data-theme="dark"]) .cw-theme-icon .cw-moon-bite {
  transform: translate(7.4px, -7.4px);
}

@media (prefers-reduced-motion: reduce) {
  .cw-theme-icon,
  .cw-theme-icon * {
    transition: none !important;
  }
}
