/* Theme preference controls */
.hm-header-actions {
  display: flex;
  align-items: center;
  gap: .85rem;
  margin-left: auto;
}
.hm-theme-toggle {
  display: inline-flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  flex: 0 0 42px;
  padding: 0;
  border: 1px solid #e1d1f0;
  border-radius: 999px;
  background: #f3eaff;
  color: #4a2468;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}
.hm-theme-toggle:hover,
.hm-theme-toggle:focus-visible {
  background: #e7d8f7;
  transform: translateY(-1px);
}
.hm-theme-toggle--mobile { display: none; }
.hm-dark-mode-disabled .hm-theme-toggle { display: none !important; }

@media (max-width:781px) {
  .hm-header-actions { display: none; }
  .hm-site-header > .wp-block-group.alignwide {
    display: flex !important;
    width: 100% !important;
    column-gap: .5rem !important;
    justify-content: flex-start !important;
  }
  .hm-theme-toggle:not(.hm-theme-toggle--mobile) { display: none; }
  .hm-theme-toggle--mobile {
    display: inline-flex;
    order: 2;
    margin-left: auto !important;
  }
  .hm-mobile-menu-toggle {
    order: 3;
    margin-left: .5rem !important;
  }
}

/* Dark mode */
html[data-theme="dark"] {
  color-scheme: dark;
  --hm-shadow: 0 16px 45px rgba(0, 0, 0, .30);
  --hm-shadow-hover: 0 22px 55px rgba(0, 0, 0, .42);
}
html[data-theme="dark"] body,
html[data-theme="dark"] .wp-site-blocks {
  background: #17131c !important;
  color: #f4edf9 !important;
}
html[data-theme="dark"] .has-white-background-color.has-background,
html[data-theme="dark"] .has-blush-background-color.has-background,
html[data-theme="dark"] .has-lilac-background-color.has-background {
  background-color: #251d2d !important;
}
html[data-theme="dark"] .has-aubergine-background-color.has-background {
  background-color: #1e1427 !important;
}
html[data-theme="dark"] .has-soft-lilac-gradient-background {
  background: linear-gradient(135deg, #21182a 0%, #30213e 100%) !important;
}
html[data-theme="dark"] .has-purple-yarn-gradient-background {
  background: linear-gradient(135deg, #2c1640 0%, #562b82 50%, #8e63c3 100%) !important;
}
html[data-theme="dark"] .hm-calm-cta { border-color: #59456a; box-shadow: 0 14px 30px rgba(0, 0, 0, .24); }
html[data-theme="dark"] .hm-site-header {
  border-bottom-color: #453653 !important;
}
html[data-theme="dark"] .hm-site-header.has-white-background-color {
  background-color: #17131c !important;
}
html[data-theme="dark"] .hm-brand-logo,
html[data-theme="dark"] .hm-mobile-menu__brand span {
  background-image: url("../images/handmadeby-logo-dark.png");
}
html[data-theme="dark"] .wp-block-heading,
html[data-theme="dark"] .has-ink-color,
html[data-theme="dark"] .has-aubergine-color {
  color: #f4edf9 !important;
}
html[data-theme="dark"] .has-muted-color {
  color: #cdbed8 !important;
}
html[data-theme="dark"] .has-purple-color,
html[data-theme="dark"] .has-violet-color {
  color: #d0b1f5 !important;
}
html[data-theme="dark"] a,
html[data-theme="dark"] .wp-block-navigation a,
html[data-theme="dark"] .wp-block-navigation-item__content {
  color: #d0b1f5;
}
html[data-theme="dark"] a:hover,
html[data-theme="dark"] a:focus-visible,
html[data-theme="dark"] .wp-block-navigation a:hover,
html[data-theme="dark"] .wp-block-navigation a:focus-visible {
  color: #ffffff;
}
html[data-theme="dark"] .wp-block-button:not(.is-style-outline) .wp-block-button__link {
  background-color: #9b6bd0 !important;
  color: var(--hm-button-dark-text) !important;
}
html[data-theme="dark"] .wp-block-post-comments-form input[type="submit"],
html[data-theme="dark"] .comment-form input[type="submit"],
html[data-theme="dark"] footer a[href*="wordpress.com/reader/site/subscription"] { color: var(--hm-button-dark-text) !important; }
html[data-theme="dark"] .is-style-outline .wp-block-button__link {
  border-color: #d0b1f5 !important;
  background: transparent !important;
  color: #eadcf9 !important;
}
html[data-theme="dark"] .hm-hero .is-style-outline .wp-block-button__link { border-color: #d0b1f5; color: var(--hm-button-dark-text) !important; }
html[data-theme="dark"] .wp-block-post-terms a {
  background: #3a284a;
  color: #eadcf9;
}
html[data-theme="dark"] .hm-pattern-archive__header h1,
html[data-theme="dark"] .hm-pattern-card .wp-block-post-title a,
html[data-theme="dark"] .hm-pattern-single__header .wp-block-post-title { color: #eadcf9; }
html[data-theme="dark"] .hm-pattern-archive__eyebrow,
html[data-theme="dark"] .hm-pattern-card__type,
html[data-theme="dark"] .hm-pattern-single__type,
html[data-theme="dark"] .hm-pattern-card__excerpt .wp-block-post-excerpt__more-link { color: #d0b1f5; }
html[data-theme="dark"] .hm-pattern-card { border-color: #59456a; background: #251d2d; box-shadow: 0 10px 26px rgba(0, 0, 0, .22); }
html[data-theme="dark"] .hm-pattern-card__excerpt,
html[data-theme="dark"] .hm-pattern-single__excerpt { color: #cdbed8; }
html[data-theme="dark"] .hm-pattern-instructions__switcher > span::after { border-color: #9d74be; }
html[data-theme="dark"] .hm-stitch-reference__switcher > span::after,
html[data-theme="dark"] .hm-stitch-directory__switcher > span::after { border-color: #9d74be; }
html[data-theme="dark"] .hm-pattern-archive__empty { background: #251d2d; color: #cdbed8; }
html[data-theme="dark"] .hm-pattern-information { border-color: #59456a; background: linear-gradient(135deg, #251d2d 0%, #30213e 100%); box-shadow: 0 10px 26px rgba(0, 0, 0, .2); }
html[data-theme="dark"] .hm-pattern-information__heading,
html[data-theme="dark"] .hm-pattern-information__list dd { color: #eadcf9; }
html[data-theme="dark"] .hm-pattern-information__list > div,
html[data-theme="dark"] .hm-pattern-information__notes { border-color: #59456a; }
html[data-theme="dark"] .hm-pattern-information__list dt { color: #d0b1f5; }
html[data-theme="dark"] .hm-pattern-information__notes { color: #cdbed8; }
html[data-theme="dark"] .hm-pattern-stitches-used { border-color: #59456a; background: linear-gradient(135deg, #251d2d 0%, #30213e 100%); box-shadow: 0 10px 26px rgba(0, 0, 0, .2); }
html[data-theme="dark"] .hm-pattern-stitches-used__heading,
html[data-theme="dark"] .hm-pattern-stitches-used__list a,
html[data-theme="dark"] .hm-pattern-stitches-used__editor-list li { color: #eadcf9; }
html[data-theme="dark"] .hm-pattern-stitches-used__list a,
html[data-theme="dark"] .hm-pattern-stitches-used__editor-list li { border-color: #59456a; background: #30213e; }
html[data-theme="dark"] .hm-pattern-stitches-used__empty { color: #cdbed8; }
html[data-theme="dark"] .hm-pattern-instructions { border-color: #59456a; background: #251d2d; box-shadow: 0 10px 26px rgba(0, 0, 0, .2); }
html[data-theme="dark"] .hm-pattern-instructions__notation { border-color: #59456a; background: #30213e; color: #cdbed8; }
html[data-theme="dark"] .hm-pattern-instructions__notation strong { color: #eadcf9; }
html[data-theme="dark"] .hm-pattern-instructions__notation code { background: #4a3560; color: #e5d2f8; }
html[data-theme="dark"] .hm-pattern-instructions__heading,
html[data-theme="dark"] .hm-pattern-instructions__step-content :is(h3, h4),
html[data-theme="dark"] .hm-pattern-instructions__body { color: #eadcf9; }
html[data-theme="dark"] .hm-pattern-instructions__group-heading { border-color: #59456a; color: #d0b1f5; }
html[data-theme="dark"] .hm-pattern-instructions__intro { color: #cdbed8; }
html[data-theme="dark"] .hm-pattern-instructions__step { border-color: #59456a; background: #30213e; }
html[data-theme="dark"] .hm-pattern-instructions__switcher { border-color: #59456a; background: #30213e; }
html[data-theme="dark"] .hm-pattern-instructions__switcher > span { color: #cdbed8; }
html[data-theme="dark"] .hm-pattern-instructions__switcher button { color: #eadcf9; }
html[data-theme="dark"] .hm-pattern-instructions__switcher button[aria-pressed="true"] { background: #7951a5; color: #fff; }
html[data-theme="dark"] .hm-blog-timeline .wp-block-post::before {
  background: #59456a;
}
html[data-theme="dark"] .hm-blog-timeline .wp-block-post::after {
  border-color: #251d2d;
  background: #b486e8;
  box-shadow: 0 0 0 1px #d0b1f5;
}
html[data-theme="dark"] .hm-blog-timeline__author,
html[data-theme="dark"] .hm-post-meta__author {
  background: #7951a5;
  color: #f7f0ff;
}
html[data-theme="dark"] .hm-linked-pattern__button { background: var(--hm-button-primary); color: var(--hm-button-dark-text); box-shadow: 0 6px 14px rgba(0, 0, 0, .28); }
html[data-theme="dark"] .hm-linked-pattern__button:hover { background: #7b49b4; color: var(--hm-button-dark-text); }
html[data-theme="dark"] .hm-keep-crafting h3 { color: #eadcf9; }
html[data-theme="dark"] .hm-keep-crafting > p { color: #cdbed8; }
html[data-theme="dark"] .hm-pattern-meta {
  border-color: #59456a;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .20);
}
html[data-theme="dark"] .wp-block-query-pagination .current {
  background: #b486e8;
  color: #1d1325;
}
html[data-theme="dark"] .hm-theme-toggle {
  border-color: #665176;
  background: #362642;
  color: #f4edf9;
}
html[data-theme="dark"] .hm-theme-toggle:hover,
html[data-theme="dark"] .hm-theme-toggle:focus-visible {
  background: #4a3560;
}
html[data-theme="dark"] .hm-stitch-reference__header,
html[data-theme="dark"] .hm-stitch-reference__repeat { border-color: #59456a; }
html[data-theme="dark"] .hm-stitch-reference h1,
html[data-theme="dark"] .hm-stitch-reference__terms h2,
html[data-theme="dark"] .hm-stitch-reference__details h2,
html[data-theme="dark"] .hm-stitch-reference__sources h2,
html[data-theme="dark"] .hm-stitch-reference__abbreviation,
html[data-theme="dark"] .hm-stitch-reference__details dd,
html[data-theme="dark"] .hm-stitch-reference__instructions h3,
html[data-theme="dark"] .hm-stitch-reference__repeat h3 { color: #f4edf9; }
html[data-theme="dark"] .hm-stitch-reference__eyebrow,
html[data-theme="dark"] .hm-stitch-reference__system { color: #d0b1f5; }
html[data-theme="dark"] .hm-stitch-reference__switcher,
html[data-theme="dark"] .hm-stitch-reference__terms,
html[data-theme="dark"] .hm-stitch-reference__alternates,
html[data-theme="dark"] .hm-stitch-reference__notes { border-color: #665176; background: #251d2d; }
html[data-theme="dark"] .hm-stitch-reference__switcher > span,
html[data-theme="dark"] .hm-stitch-reference__details dt { color: #cdbed8; }
html[data-theme="dark"] .hm-stitch-reference__switcher button { color: #eadcf9; }
html[data-theme="dark"] .hm-stitch-reference__switcher button[aria-pressed="true"] { background: #b486e8; color: #1d1325; }
html[data-theme="dark"] .hm-stitch-reference__details dl > div { border-color: #59456a; background: #21182a; }
html[data-theme="dark"] .hm-tools-page__intro,
html[data-theme="dark"] .hm-tool-card__description,
html[data-theme="dark"] .hm-row-counter-guide__intro,
html[data-theme="dark"] .hm-row-counter-guide__step p { color: #cdbed8; }
html[data-theme="dark"] .hm-tool-card { border-color: #59456a; background: linear-gradient(135deg, #251d2d 0%, #2d2038 100%); color: #f4edf9; }
html[data-theme="dark"] .hm-tool-card:hover,
html[data-theme="dark"] .hm-tool-card:focus-visible { border-color: #b486e8; color: #ffffff; }
html[data-theme="dark"] .hm-tool-card__icon { background-color: #d3c1df; box-shadow: 0 7px 18px rgba(0, 0, 0, .28); }
html[data-theme="dark"] .hm-row-counter-guide__step { border-color: #59456a; background: #251d2d; }
html[data-theme="dark"] .hm-row-counter-guide__step h2 { color: #f4edf9; }
html[data-theme="dark"] .wp-site-blocks > main > :is(.wp-block-post-title, .wp-block-query-title, h1.wp-block-heading) { color: #eadcf9 !important; }
html[data-theme="dark"] .hm-tool-card__title { color: #f4edf9; }
html[data-theme="dark"] .hm-tool-card__action { color: #d0b1f5; }
html[data-theme="dark"] .hm-stitch-directory__header h1,
html[data-theme="dark"] .hm-stitch-directory__group-title,
html[data-theme="dark"] .hm-stitch-directory__name,
html[data-theme="dark"] .hm-stitch-directory__terms strong,
html[data-theme="dark"] .hm-stitch-directory__search > label,
html[data-theme="dark"] .hm-stitch-directory__results-heading { color: #f4edf9; }
html[data-theme="dark"] .hm-stitch-directory__header p:last-child,
html[data-theme="dark"] .hm-stitch-directory__group-heading span,
html[data-theme="dark"] .hm-stitch-directory__terms { color: #cdbed8; }
html[data-theme="dark"] .hm-stitch-directory__group-heading,
html[data-theme="dark"] .hm-stitch-directory__list,
html[data-theme="dark"] .hm-stitch-directory__list li { border-color: #59456a; }
html[data-theme="dark"] .hm-stitch-directory__list a { color: #f4edf9; }
html[data-theme="dark"] .hm-stitch-directory__list a:hover,
html[data-theme="dark"] .hm-stitch-directory__list a:focus-visible { background: #251d2d; }
html[data-theme="dark"] .hm-stitch-directory__arrow { color: #d0b1f5; }
html[data-theme="dark"] .hm-stitch-directory__search input { border-color: #665176; background: #251d2d; color: #f4edf9; }
html[data-theme="dark"] .hm-stitch-directory__abbreviation { background: #4a3560; color: #f4edf9; }
html[data-theme="dark"] .hm-stitch-directory__switcher { border-color: #665176; background: #251d2d; }
html[data-theme="dark"] .hm-stitch-directory__switcher > span { color: #cdbed8; }
html[data-theme="dark"] .hm-stitch-directory__switcher button { color: #eadcf9; }
html[data-theme="dark"] .hm-stitch-directory__switcher button[aria-pressed="true"] { background: #b486e8; color: #1d1325; }
html[data-theme="dark"] .hm-stitch-directory__search-control button { background: #362642; color: #f4edf9; }
html[data-theme="dark"] .hm-stitch-directory__search-control button:hover,
html[data-theme="dark"] .hm-stitch-directory__search-control button:focus-visible { background: #4a3560; }
html[data-theme="dark"] .hm-stitch-directory__no-results { background: #251d2d; color: #cdbed8; }
html[data-theme="dark"] .hm-row-counter__toggle,
html[data-theme="dark"] .hm-row-counter__panel {
  border-color: #665176;
  background: #251d2d;
  color: #f4edf9;
  box-shadow: 0 14px 36px rgba(0, 0, 0, .38);
}
html[data-theme="dark"] .hm-row-counter__toggle:hover,
html[data-theme="dark"] .hm-row-counter__toggle:focus-visible { background: #362642; }
html[data-theme="dark"] .hm-row-counter__badge { color: #f4edf9; }
html[data-theme="dark"] .hm-row-counter__header p,
html[data-theme="dark"] .hm-row-counter__number,
html[data-theme="dark"] .hm-row-counter__reset { color: #eadcf9; }
html[data-theme="dark"] .hm-row-counter__caption,
html[data-theme="dark"] .hm-row-counter__shortcut,
html[data-theme="dark"] .hm-row-counter__close { color: #cdbed8; }
html[data-theme="dark"] .hm-row-counter__close:hover,
html[data-theme="dark"] .hm-row-counter__close:focus-visible,
html[data-theme="dark"] .hm-row-counter__reset:not(:disabled):hover,
html[data-theme="dark"] .hm-row-counter__reset:not(:disabled):focus-visible { background: #362642; color: #ffffff; }
html[data-theme="dark"] .hm-row-counter__adjust {
  border-color: #665176;
  background: #362642;
  color: #f4edf9;
}
html[data-theme="dark"] .hm-row-counter__adjust:hover,
html[data-theme="dark"] .hm-row-counter__adjust:focus-visible { background: #4a3560; }
html[data-theme="dark"] .hm-row-counter__shortcut kbd {
  border-color: #665176;
  background: #362642;
  color: #eadcf9;
}
html[data-theme="dark"] .hm-row-counter__adjust--increment {
  border-color: #b486e8;
  background: #b486e8;
  color: #1d1325;
}
html[data-theme="dark"] .hm-row-counter__adjust--increment:hover,
html[data-theme="dark"] .hm-row-counter__adjust--increment:focus-visible { background: #d0b1f5; }

@media (max-width:781px) {
  html[data-theme="dark"] .hm-mobile-menu-toggle {
    color: #f4edf9;
  }
  html[data-theme="dark"] .hm-mobile-menu-toggle:hover,
  html[data-theme="dark"] .hm-mobile-menu-toggle:focus-visible {
    background: #362642;
  }
  html[data-theme="dark"] .hm-mobile-menu__panel {
    background: #17131c;
  }
  html[data-theme="dark"] .hm-mobile-menu__close {
    background: #362642;
    color: #f4edf9;
  }
  html[data-theme="dark"] .hm-mobile-menu__close:hover,
  html[data-theme="dark"] .hm-mobile-menu__close:focus-visible,
  html[data-theme="dark"] .hm-mobile-menu__links a:hover,
  html[data-theme="dark"] .hm-mobile-menu__links a:focus-visible {
    background: #362642;
    color: #ffffff;
  }
  html[data-theme="dark"] .hm-mobile-menu__links a {
    color: #eadcf9;
  }
}
