/* Document theme picker */
.theme-menu-anchor {
  position: relative;
  display: flex;
  flex: 0 0 auto;
}

.theme-menu-anchor > .icon-button svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.theme-popover {
  position: absolute;
  z-index: 80;
  top: calc(100% + 9px);
  right: -36px;
  width: 286px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow-pop);
  color: var(--text);
  -webkit-backdrop-filter: saturate(150%) blur(20px);
  backdrop-filter: saturate(150%) blur(20px);
}

.theme-popover[hidden] {
  display: none;
}

.theme-popover-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 7px 9px;
}

.theme-popover-heading strong {
  font-size: 12px;
  font-variation-settings: "wght" 680;
  font-weight: 680;
}

.theme-popover-heading small {
  color: var(--text-tertiary);
  font-size: 9px;
}

.theme-option-list {
  display: grid;
  gap: 2px;
}

.theme-option {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 18px;
  min-height: 54px;
  cursor: pointer;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.theme-option:hover {
  background: var(--surface-hover);
}

.theme-option.active {
  background: var(--accent-soft);
}

.theme-option-preview {
  position: relative;
  display: block;
  width: 40px;
  height: 32px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.theme-option-preview::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 9px;
  background: #f0f0f2;
  content: "";
}

.theme-option-preview i {
  position: absolute;
  right: 5px;
  left: 14px;
  height: 2px;
  border-radius: 1px;
  background: #1d1d1f;
}

.theme-option-preview i:nth-child(1) {
  top: 8px;
  height: 3px;
}

.theme-option-preview i:nth-child(2) {
  top: 16px;
  right: 10px;
}

.theme-option-preview i:nth-child(3) {
  top: 23px;
  right: 8px;
  background: #007aff;
}

.theme-option-preview[data-preview-theme="vlook-fancy"] {
  background-color: #fffdf9;
  background-image: linear-gradient(rgba(223, 118, 86, 0.09) 1px, transparent 1px), linear-gradient(90deg, rgba(223, 118, 86, 0.09) 1px, transparent 1px);
  background-size: 7px 7px;
}

.theme-option-preview[data-preview-theme="vlook-fancy"]::before {
  background: #d7e4de;
}

.theme-option-preview[data-preview-theme="vlook-fancy"] i:nth-child(1),
.theme-option-preview[data-preview-theme="vlook-fancy"] i:nth-child(3) {
  background: #df7656;
}

.theme-option-preview[data-preview-theme="esther-inspired"] {
  background: #fefcf6;
}

.theme-option-preview[data-preview-theme="esther-inspired"]::before {
  background: #f5f0df;
}

.theme-option-preview[data-preview-theme="esther-inspired"] i:nth-child(1) {
  background: #18253d;
}

.theme-option-preview[data-preview-theme="esther-inspired"] i:nth-child(2) {
  background: #2b7fd8;
}

.theme-option-preview[data-preview-theme="esther-inspired"] i:nth-child(3) {
  background: #f2cf48;
}

.theme-option-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.theme-option-copy strong,
.theme-option-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-option-copy strong {
  font-size: 12px;
  font-variation-settings: "wght" 620;
  font-weight: 620;
}

.theme-option-copy small {
  color: var(--text-tertiary);
  font-size: 10px;
}

.theme-option-check {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  color: var(--accent);
  opacity: 0;
}

.theme-option.active .theme-option-check {
  opacity: 1;
}

.theme-option-check svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

/* VLOOK Fancy V2: coral controls, mint navigation, graph-paper document. */
:root[data-document-theme="vlook-fancy"] {
  --app-bg: #e8efeb;
  --chrome-bg: #dce8e2;
  --sidebar: #dce8e2;
  --surface: #fffdf9;
  --surface-soft: #f5eee9;
  --surface-hover: rgba(223, 118, 86, 0.1);
  --text: #292725;
  --text-secondary: #66615d;
  --text-tertiary: #97918a;
  --border: rgba(83, 73, 66, 0.2);
  --border-soft: rgba(83, 73, 66, 0.11);
  --accent: #df7656;
  --accent-hover: #cb6548;
  --accent-soft: rgba(223, 118, 86, 0.12);
  --accent-soft-strong: rgba(223, 118, 86, 0.19);
  --code-header: #f1e4de;
  --code-canvas: #fffdfa;
  --quote-bg: #edf3ef;
}

:root[data-document-theme="vlook-fancy"] .document-scroller {
  background: #f1e7e2;
}

:root[data-document-theme="vlook-fancy"] .document-page {
  background-color: #fffdf9;
  background-image: linear-gradient(rgba(223, 118, 86, 0.055) 1px, transparent 1px), linear-gradient(90deg, rgba(223, 118, 86, 0.055) 1px, transparent 1px);
  background-size: 24px 24px;
  box-shadow: 0 0 0 1px rgba(223, 118, 86, 0.08), 0 18px 54px rgba(93, 67, 54, 0.08);
}

:root[data-document-theme="vlook-fancy"] .document-title {
  border-bottom: 4px solid rgba(223, 118, 86, 0.2);
  color: #d96d4e;
  font-family: var(--font-ui);
  font-size: 39px;
}

:root[data-document-theme="vlook-fancy"] .type-heading1 .block-content {
  color: #d96d4e;
  font-family: var(--font-ui);
}

:root[data-document-theme="vlook-fancy"] .type-heading2 .block-content {
  padding-left: 12px;
  border-left: 4px solid #df7656;
  color: #3b3734;
}

:root[data-document-theme="vlook-fancy"] .type-heading3 .block-content {
  color: #c96649;
}

:root[data-document-theme="vlook-fancy"] .block-content {
  font-family: Georgia, "Songti SC", SimSun, serif;
}

:root[data-document-theme="vlook-fancy"] .type-bullet .list-marker,
:root[data-document-theme="vlook-fancy"] .type-numbered .list-marker {
  color: #df7656;
}

:root[data-document-theme="vlook-fancy"] .type-quote {
  padding: 10px 13px 10px 15px;
  border: 1px solid rgba(106, 139, 124, 0.18);
  background: rgba(215, 228, 222, 0.52);
}

:root[data-document-theme="vlook-fancy"] .type-quote::before {
  background: #77a18d;
}

:root[data-document-theme="vlook-fancy"] .note-table-shell th {
  background: #dce8e2;
  color: #3f5f51;
}

:root[data-document-theme="vlook-fancy"] .code-block {
  border-color: rgba(223, 118, 86, 0.22);
}

:root[data-document-theme="vlook-fancy"] .code-block .special-head {
  background: #f1e4de;
}

:root[data-document-theme="vlook-fancy"] .note-item.active,
:root[data-document-theme="vlook-fancy"] .outline-list button.active {
  background: rgba(119, 161, 141, 0.2);
  color: #466c5a;
}

:root[data-document-theme="vlook-fancy"] .format-bar {
  background: #fffaf7;
}

/* Esther Inspired: warm paper, navy editorial type, blue and yellow accents. */
:root[data-document-theme="esther-inspired"] {
  --app-bg: #f0ecdf;
  --chrome-bg: #f5f1e5;
  --sidebar: #f5f1e5;
  --surface: #fefcf6;
  --surface-soft: #f6f2e7;
  --surface-hover: rgba(43, 127, 216, 0.08);
  --text: #18253d;
  --text-secondary: #596274;
  --text-tertiary: #9297a1;
  --border: rgba(24, 37, 61, 0.17);
  --border-soft: rgba(24, 37, 61, 0.09);
  --accent: #2b7fd8;
  --accent-hover: #236dbd;
  --accent-soft: rgba(43, 127, 216, 0.1);
  --accent-soft-strong: rgba(43, 127, 216, 0.15);
  --code-header: #edf1f5;
  --code-canvas: #f7f9fb;
  --quote-bg: #ffffff;
}

:root[data-document-theme="esther-inspired"] .document-scroller {
  background: #f0ecdf;
}

:root[data-document-theme="esther-inspired"] .document-page {
  background: #fefcf6;
  box-shadow: 0 0 0 1px rgba(24, 37, 61, 0.06), 0 18px 52px rgba(38, 45, 58, 0.07);
}

:root[data-document-theme="esther-inspired"] .document-title {
  color: #18253d;
  font-family: Georgia, "Noto Sans SC Variable", serif;
  font-weight: 700;
}

:root[data-document-theme="esther-inspired"] .type-heading1 .block-content,
:root[data-document-theme="esther-inspired"] .type-heading2 .block-content {
  color: #18253d;
  font-family: Georgia, "Noto Sans SC Variable", serif;
}

:root[data-document-theme="esther-inspired"] .type-heading1::after,
:root[data-document-theme="esther-inspired"] .type-heading2::after {
  position: absolute;
  top: 18px;
  left: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2b7fd8;
  box-shadow: 5px 5px 0 #f2cf48;
  content: "";
}

:root[data-document-theme="esther-inspired"] .type-heading2 {
  border-bottom: 1px solid rgba(24, 37, 61, 0.12);
}

:root[data-document-theme="esther-inspired"] .type-heading3 .block-content {
  color: #2b7fd8;
}

:root[data-document-theme="esther-inspired"] .type-quote {
  margin-block: 13px;
  padding: 13px 16px 13px 22px;
  border: 1px solid rgba(24, 37, 61, 0.07);
  background: #ffffff;
  box-shadow: 0 7px 20px rgba(24, 37, 61, 0.08);
}

:root[data-document-theme="esther-inspired"] .type-quote::before {
  width: 5px;
  background: #f2cf48;
}

:root[data-document-theme="esther-inspired"] .block-content code {
  background: rgba(232, 74, 95, 0.08);
  color: #d6465b;
}

:root[data-document-theme="esther-inspired"] .note-table-shell {
  box-shadow: 0 7px 20px rgba(24, 37, 61, 0.05);
}

:root[data-document-theme="esther-inspired"] .note-table-shell th {
  background: #edf3f8;
  color: #2b5989;
}

:root[data-document-theme="esther-inspired"] .code-block {
  border-color: rgba(43, 127, 216, 0.15);
  box-shadow: 0 8px 24px rgba(24, 37, 61, 0.07);
}

:root[data-document-theme="esther-inspired"] .code-block .special-head {
  background: #edf1f5;
}

:root[data-document-theme="esther-inspired"] .format-bar {
  background: #fbfaf5;
}

/* Dark companions keep each theme's identity while honoring the existing mode. */
:root[data-document-theme="vlook-fancy"][data-theme="dark"] {
  --app-bg: #1d2421;
  --chrome-bg: #242e29;
  --sidebar: #242e29;
  --surface: #202421;
  --surface-soft: #292d2a;
  --surface-hover: rgba(235, 138, 106, 0.12);
  --text: #f3eee8;
  --text-secondary: #c3bbb4;
  --text-tertiary: #8e8984;
  --border: rgba(255, 255, 255, 0.16);
  --border-soft: rgba(255, 255, 255, 0.09);
  --accent: #eb8a6a;
  --accent-hover: #f09b7e;
  --accent-soft: rgba(235, 138, 106, 0.14);
  --accent-soft-strong: rgba(235, 138, 106, 0.2);
  --code-header: #332b28;
  --code-canvas: #232321;
}

:root[data-document-theme="vlook-fancy"][data-theme="dark"] .document-scroller,
:root[data-document-theme="vlook-fancy"][data-theme="dark"] .document-page {
  background-color: #202421;
}

:root[data-document-theme="vlook-fancy"][data-theme="dark"] .document-page {
  background-image: linear-gradient(rgba(235, 138, 106, 0.055) 1px, transparent 1px), linear-gradient(90deg, rgba(235, 138, 106, 0.055) 1px, transparent 1px);
}

:root[data-document-theme="vlook-fancy"][data-theme="dark"] .type-heading2 .block-content {
  color: #f3eee8;
}

:root[data-document-theme="vlook-fancy"][data-theme="dark"] .type-quote {
  background: rgba(94, 132, 113, 0.2);
}

:root[data-document-theme="vlook-fancy"][data-theme="dark"] .note-table-shell th,
:root[data-document-theme="vlook-fancy"][data-theme="dark"] .format-bar {
  background: #29332e;
}

:root[data-document-theme="esther-inspired"][data-theme="dark"] {
  --app-bg: #111620;
  --chrome-bg: #181e29;
  --sidebar: #181e29;
  --surface: #151a24;
  --surface-soft: #1d2430;
  --surface-hover: rgba(99, 169, 239, 0.1);
  --text: #eef2f8;
  --text-secondary: #adb8c9;
  --text-tertiary: #747f91;
  --border: rgba(255, 255, 255, 0.16);
  --border-soft: rgba(255, 255, 255, 0.09);
  --accent: #63a9ef;
  --accent-hover: #78b7f4;
  --accent-soft: rgba(99, 169, 239, 0.13);
  --accent-soft-strong: rgba(99, 169, 239, 0.2);
  --code-header: #222a37;
  --code-canvas: #181e28;
}

:root[data-document-theme="esther-inspired"][data-theme="dark"] .document-scroller,
:root[data-document-theme="esther-inspired"][data-theme="dark"] .document-page {
  background: #151a24;
}

:root[data-document-theme="esther-inspired"][data-theme="dark"] .document-title,
:root[data-document-theme="esther-inspired"][data-theme="dark"] .type-heading1 .block-content,
:root[data-document-theme="esther-inspired"][data-theme="dark"] .type-heading2 .block-content {
  color: #f2f5fa;
}

:root[data-document-theme="esther-inspired"][data-theme="dark"] .type-quote {
  border-color: rgba(255, 255, 255, 0.07);
  background: #202735;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}

:root[data-document-theme="esther-inspired"][data-theme="dark"] .note-table-shell th,
:root[data-document-theme="esther-inspired"][data-theme="dark"] .format-bar {
  background: #202837;
}

@media (max-width: 620px) {
  .theme-popover {
    position: fixed;
    top: 48px;
    right: 8px;
    width: min(286px, calc(100vw - 16px));
  }

  .theme-popover-heading small {
    display: none;
  }

  :root[data-document-theme="vlook-fancy"] .document-page,
  :root[data-document-theme="esther-inspired"] .document-page {
    box-shadow: none;
  }

  :root[data-document-theme="vlook-fancy"] .document-title {
    font-size: 30px;
  }
}
