[data-chat-interface-theme^="crb"] #sidebar-tabs,
[data-chat-interface-theme^="crb"] #chat-log ~ *,
[data-theme^="crb"] {
  --icon-border-color: var(--tertiary);
  --scrollbar-thumb-background: var(--tertiary);
  --scrollbar-thumb-border-color: color-mix(in srgb, var(--tertiary) 50%, black);
  --color-scrollbar-hover: color-mix(in srgb, var(--tertiary) 50%, white);

  --window-app-border-color: var(--tertiary);
  --window-app-border-width: 1px;
  --box-shadow: var(--glassy);
  --accent-color: var(--tertiary);
  --inline-box-shadow: none;

  --inline-background: #ddd;
  --inline-border-color: black;
  --inline-text-color: black;
  --inline-icon-color: var(--color-text-dark-inactive);

  --input-box-shadow: none;
  --dui-input-border-color: var(--color-text-light-5);
  --dui-input-text-color: var(--color-text-dark-input);
  --dui-input-focus-text-color: var(--color-text-dark-input);
  --dui-input-background: rgba(255, 255, 255, 0.5);
  --dui-input-focus-outline-color: var(--primary-light);
  --dui-input-placeholder-color: rgba(0, 0, 0, 0.5);

  --dui-button-background: var(--app-background);
  --dui-button-border-color: var(--app-border-color);
  --dui-button-text-color: var(--text-color-3);
  --dui-button-focus-outline-color: var(--color-primary-1);
  --button-hover-background: var(--color-primary-2);
  --button-hover-border-color: var(--color-primary-1);
  --dui-button-hover-text-color: var(--text-color-1);
  --button-disabled-background: var(--color-primary-5);
  --button-disabled-border-color: var(--color-primary-4);

  --button-toggle-border-color: var(--secondary-light);
  --button-toggle-background: var(--secondary-dark);
  --button-toggle-hover-background: var(--secondary-light);

  --color-primary-1: var(--tertiary);
  --color-primary-2: var(--primary-light);
  --color-primary-3: var(--primary-dark);
  --color-primary-3-75: color-mix(in srgb, var(--color-primary-3) 75%, transparent); //custom
  --color-primary-4-75: color-mix(in srgb, var(--color-primary-4) 75%, transparent); //custom
  --color-secondary-1: var(--secondary-light);
  --color-secondary-2: var(--secondary);
  --color-secondary-3: var(--secondary-dark);
  --color-secondary-3-75: color-mix(in srgb, var(--color-secondary-3) 75%, transparent); //custom

  --color-border-light-1: #ddd;
  --color-border-light-2: #999;
}

[data-chat-interface-theme^="crb"] #chat-log ~ *,
[data-theme^="crb"]:not([data-color-scheme]) {
  --text-color-2: var(--color-text-light-highlight);
  --text-color-3: var(--color-text-light-heading);
  --dui-input-text-color: black;
  --dui-input-focus-text-color: black;
  --dui-input-focus-outline-color: var(--tertiary);
  --dui-button-background: var(--glass-bg-light);
  --app-background: var(--glass-bg);
  --app-border-color: transparent;
  --app-border-width: 0px;
  --app-backdrop-filter: blur(5px);

  --window-app-background: var(--glass-bg);
  --window-app-box-shadow: var(--glassy), 0px 5px 30px black;
  outline: none !important;

  &#token-hud,
  &#tile-hud {
    --dui-button-background: var(--glass-bg);
    --dui-input-text-color: var(--text-color-2);
  }
}

[data-chat-interface-theme^="crb"] #chat-log ~ * {
  --app-background: var(--glass-bg-light);
}

[data-theme^="crb"] {
  button {
    --text-color-1: white;
    --text-color-2: var(--color-text-light-highlight);
    --text-color-3: var(--color-text-light-heading);
  }

  &.app.window-app {
    outline: 1px solid var(--gold-brown);
    &.sidebar-popout {
      outline: none;
    }
  }

  &.app.window-app.journal-sheet.journal-entry {
    --window-app-background: var(--glass-bg);
  }

  &#controls,
  &#navigation {
    --dui-button-background: var(--glass-bg);
  }

  &.sheet.journal-entry .journal-entry-content {
    background-image: var(--sheet);
    background-size: cover;
    border: var(--window-app-border-width) solid;
    border-color: var(--window-app-border-color);
    box-shadow: 0px 0px 0px 1px var(--gold-brown);
    border-bottom: unset;
    border-right: unset;
    margin: unset;
  }

  &.spellcasting-entry.preparation ol.spell-list > li .item-name .item-image,
  &.actor.sheet .item-image {
    --box-shadow: 0px 0px 0px 1px var(--gold-brown);
  }

  &.actor.sheet section.window-content .item-summary .description .addendum {
    border-image-source: var(--ornamentation);
  }
  &.actor.sheet[data-color-scheme="dark"] section.window-content .item-summary .description .addendum {
    color: var(--text-color-3);
  }

  &.chat-message {
    outline: 1px solid var(--gold-brown);
    &[data-has-header] {
      .message-header {
        background-image: var(--sheet-light);
        background-size: cover;
        background-color: var(--header-color);
        background-blend-mode: multiply;
        border-bottom: 1px solid var(--tertiary);
        box-shadow: 0px 1px 0px 0px var(--gold-brown);
        margin-bottom: 5px;
        padding-bottom: 5px;
      }
      &[data-header-text-color-scheme="light"] .message-header {
        color: white !important;
        text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.5) !important;
        .message-sender:not([data-visibility="gm"]) {
          color: white !important;
        }
        .header-meta {
          background: rgba(255, 255, 255, 0.2);
          border-color: rgba(255, 255, 255, 0.5);
          text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.5);
        }
      }
      &[data-header-text-color-scheme="dark"] .message-header {
        color: black !important;
        text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.5) !important;
        .header-meta {
          background: rgba(0, 0, 0, 0.2);
          border-color: rgba(0, 0, 0, 0.5);
        }
      }
    }
    .message-header .header-meta {
      &.whisper {
        background-color: var(--dnd5e-color-blue) !important;
        border-color: color-mix(in srgb, var(--dnd5e-color-groove) 100%, rgba(255, 255, 255, 0.5)) !important;
        color: white !important;
      }
      &.blind {
        background-color: var(--dnd5e-color-sc-2) !important;
        border-color: color-mix(in srgb, var(--dnd5e-color-groove) 100%, rgba(255, 255, 255, 0.5)) !important;
        color: white !important;
      }
    }
    .card-content {
      --app-border-color: var(--tertiary);
      border-image-repeat: repeat;
      border-image-slice: 11;
      border-image-source: var(--ornamentation);
      border-image-width: 14px;
      border-style: double;
      padding: 3px 10px;
      font-weight: 500;
      margin: 0px;
      margin-top: 5px;

      hr {
        margin: 0px -10px;
        border-bottom: none;
      }
    }
    .card-footer {
      border: none;

      span {
        border-right: 1px solid gray;
        padding-right: 5px; // Undoes 0px set by system
      }
    }
  }

  hr {
    border-top: none;
    --app-border-color: rgba(125, 125, 125, 0.5);
  }

  &#hotbar .macro {
    border: 1px solid black;
  }

  &.sidebar-popout {
    background: var(--app-background) !important;
  }

  &.message.chat-message {
    background: var(--window-app-background);
    background-position: top;
    background-size: cover;
    &.whisper {
      background: var(--window-app-background);
      background-color: var(--whisper-bg);
      background-blend-mode: luminosity;
      background-size: cover;
      border-color: var(--tertiary);
      &.blind {
        background: var(--window-app-background);
        background-color: var(--blind-bg);
        background-blend-mode: luminosity;
        background-size: cover;
        border-color: var(--tertiary);
      }
    }
  }

  &#effects-panel .effect-item > .icon {
    --box-shadow: var(--gold-and-glow);
    --border-radius: 50%;
    &.aura {
      border-radius: 33%;
      transform: scale(0.8);
    }
  }
}

/* ----------------------------------------- */
/* Modules                                   */
/* ----------------------------------------- */
[data-theme^="crb"] {
  &#token-action-hud-app #token-action-hud {
    button {
      --dui-button-background: var(--glass-bg-dark);
    }
    .hover > button {
      --dui-button-background: var(--button-hover-background);
    }
  }

  &#pf2e-token-hud {
    --color-primary-2: var(--tertiary);
    --color-secondary-4: var(--glass-bg-light);

    hr {
      display: none;
    }
  }
}

[data-theme^="crb"] {
  &[id^="pf2e-hud-sidebar"] .inner,
  &[id^="pf2e-hud-persistent"].app,
  &[id^="pf2e-hud-persistent"] .app {
    --app-background: var(--glass-bg-dark);
  }
}

/* ----------------------------------------- */
/* Navigation                                */
/* ----------------------------------------- */
[data-dorako-ui-scope="navigation"][data-theme^="crb"] {
  .scene {
    --button-toggle-focus-outline-color: #d3b87c;
  }

  .scene:not(.gm) {
    --button-toggle-background: var(--app-background);
    --button-toggle-hover-background: var(--primary-light);
  }

  .scene.gm {
    &.active:not(.view) {
      --button-toggle-focus-outline-color: transparent;
    }
  }
}

/* ----------------------------------------- */
/* Chatlog                                   */
/* ----------------------------------------- */
[data-chat-interface-theme^="crb"] {
  --scrollbar-thumb-background: var(--tertiary);
  --scrollbar-thumb-border-color: color-mix(in srgb, var(--tertiary) 50%, black);
  --color-scrollbar-hover: color-mix(in srgb, var(--tertiary) 50%, white);
}

/* ----------------------------------------- */
/* Placeable HUD                             */
/* ----------------------------------------- */
[data-theme^="crb"] [data-dorako-ui-scope="placeable-hud"] {
  // Space is intentional
  --dui-button-background: var(--glass-bg);
}
