.dnd5e.sheet .item-buttons button {
  font-size: 10px;
  line-height: 12px;
  margin: 0;
}

.dnd5e.sheet .item-buttons span {
  padding: 0;
}

.local-qol-flavor-text {
  font-size: 12px
}

.dice-total.dmgBtn-mqol {
  transition: color 0.2s ease-in-out 0.7s;
}

.dice-total.dmgBtn-mqol:hover {
  color: transparent;
  transition: color 0.2s ease-in-out 0s;
}

.dmgBtn-container-mqol {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  align-items: center;
  z-index: 1;
}

.dmgBtn-container-mqol button {
  height: 100% !important;
  margin: 1px !important;
  padding: 0;
}

.dmgBtn-container-mqol button > i {
  font-weight: bold;
  margin: 0;
}

.dmgBtn-container-mqol .dice-total-full-button {
  margin-left: 0 !important;
}

.dmgBtn-container-mqol .dice-total-half-button,
.dmgBtn-container-mqol .dice-total-double-button,
.dmgBtn-container-mqol .dice-quarter-button
{
  font-size: 0.8em !important;
}

.dmgBtn-container-mqol .dice-total-double-button {
  font-size: 0.8em !important;
  margin-right: 10px !important;
}

.dmgBtn-container-mqol .dice-total-full-healing-button {
  margin-right: 0 !important;
  margin-left: 10px !important;
}

.column-button-container-mqol {
  text-align: left;
  left: 0;
  right: 0;
  top: -5px;
  bottom: 4px;
  padding: 0 1px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1;
  flex-direction: column;
}

.dmgBtn-container-mqol {
  display: flex !important;
  opacity: 0;
  transition: opacity 0.2s ease-in-out 0.7s;
}

.dmgBtn-container-mqol:hover {
  opacity: 1;
  transition: opacity 0.2s ease-in-out 0s;
}

.midi-qol-enable-damage-button {
  color: green
}
.midi-qol-disable-damage-button {
  color: red
}
.xdice-total-full-damage-button,
.xdice-total-half-damage-button,
.xdice-total-double-damage-button,
.xdice-total-full-damage-healing-button
{
  width: 20%;
  height:80%;
  font-size:24px;
  line-height:8px;
  background-color: 0xffffff;
  color:white;
}

.midi-qol-flex-container {
  display: flex;
  flex-wrap: wrap;
  align-items: left;
  align-items: center;
  font-size: 14px;
  line-height: 16px;
}
.midi-qol-bigger-text {
  font-size: 14px;
  line-height: 16px;
}

.midi-qol-flex-container > div {
  margin: 2px;
}

/*
.midi-qol-target-name:hover {
  text-shadow: 0 0 4px red;
}
*/

.midi-qol-gmonly {
  display: none;
}

.midi-qol-box {
  border: 2px groove var(--color-fieldset-border);
  padding: 3px;
  border-radius: 4px;
}
.midi-qol-nobox {
  padding: 5px;
  border-top: 2px groove var(--color-fieldset-border);
}

.midi-qol-faint {
  color: #606060;
}

.application .midi-qol-faint {
  color: var(--color-form-hint);
}

.midi-qol-very-faint {
  color: #A0A0A0;
}

#midi-qol-settings div.form-group select {
  width: auto;
}

#midi-qol-settings .form-group {
  display: grid;
  grid-template-areas: "label input" "hint hint";
  grid-template-columns: 1fr;
}

#midi-qol-settings .form-group :nth-child(3) {
  grid-area: hint;
}

#midi-qol-settings .form-group:not(:nth-of-type(1)) {
  margin-top: 5px;
}

#midi-qol-settings .form-group > input[type="number"] {
  margin-right: 5px;
  text-align: center;
  width: 40px;
}

#midi-qol-settings .form-group > select {
  margin-right: 5px;
}

#midi-qol-settings .heading {
  text-align: left;
  font-weight: bold;
  margin-bottom: 5px;  
}

#midi-qol-settings #midi-config-mechanics .form-group > div.flexrow > select {
  max-width: 200px;
}

#midi-qol-settings #midi-config-mechanics .midi-qol-box #midi-condition-group {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "label in1 in2 in3";
  column-gap: 5px;
}

.midi-qol-quick-config .window-content {
  overflow-y: scroll;
}

#midi-qol-item-selector .item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#midi-qol-sound-config table {
  margin: 0;
}

.midi-qol-tooltip {
  position: relative;
  display: inline-block;
  border: 0px;
  padding: 0px;
}

.midi-qol-tooltip .midi-qol-tooltiptext {
  visibility: hidden;
  width: max-content;
  background-color: var(--dnd5e-color-card);
  text-align: center;
  border-radius: 6px;
  padding: 3px ;

  /* Position the tooltip */
  position: absolute;
  z-index: 1;
}

.midi-qol-tooltip:hover .midi-qol-tooltiptext {
  visibility: visible;
}

* ----------------------------------------- */
/* Dialog Window
/* ----------------------------------------- */
.midi-qol .dialog .dialog-content .dialog-buttons {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  justify-content: flex-start;
  justify-content: space-around;
}

.midi-qol .dialog .dialog-buttons button {
  background: rgba(0, 0, 0, 0.1);
  border: 2px groove #f0f0e0;
  margin: 0 5px 0 0;
}
.midi-qol.dialog:not(.reaction,.optional) .dialog-buttons button:last-child {
  margin-right: 0;
}
.midi-qol.dialog.reaction .dialog-buttons button:last-child {
  margin-right: 5px;
}
.midi-qol.dialog.optional .dialog-buttons button:last-child {
  margin-right: 5px;
}
.midi-qol.dialog.optional .dice-tooltip-collapser:has(>.expanded) {
  grid-template-rows: 1fr;
}
.midi-qol .dialog .dialog-buttons button.default {
  background: rgba(0, 0, 0, 0.05);
  border: 2px groove #c9c7b8;
}


/* ----------------------------------------- */
/* On Use Macros
/* ----------------------------------------- */
.column-dialog .column-dialog-buttons {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  justify-content: flex-start;
  justify-content: left;
}
.column-dialog .column-dialog-buttons > * {
  flex: 1;
}
.column-dialog .column-dialog-buttons > .flex0 {
  display: block;
  flex: 0;
}
.column-dialog .column-dialog-buttons > .flex1 {
  flex: 1;
}
.column-dialog .column-dialog-buttons > .flex2 {
  flex: 2;
}
.column-dialog .column-dialog-buttons > .flex3 {
  flex: 3;
}
.column-dialog .column-dialog-buttons button {
  background: rgba(0, 0, 0, 0.1);
  border: 2px groove var(--color-border-light-highlight);
  margin: 0 5px 0 0;
}
.column-dialog .column-dialog-buttons button:last-child {
  margin-right: 0;
}
.column-dialog .column-dialog-buttons button.default {
  background: rgba(0, 0, 0, 0.05);
  border: 2px groove var(--color-border-light-secondary);
}

.active-effect-sheet.midi-qol .effect-controls {
  flex: 0;
  margin: 0 8px 0 5px;
}

.active-effect-sheet.midi-qol .midi-qol-box {
  border: 1px groove var(--color-border-light-tertiary);
  border-top: 0px;
  border-radius: 0;
}

/* ----------------------------------------- */
/* midi-trouble-shooter
/* ----------------------------------------- */
.trouble-shooter-action-label:hover {
  text-shadow: 0 0 4px red;
}
.midi-trouble-shooter .contents .scrollable {
  flex: 1;
  overflow: hidden auto;
}
.midi-trouble-shooter .form-footer {
  display: flex;
}
.midi-qol-import-troubleshooter .notes {
  color: var(--color-text-primary);
}

.midi-qol-blind-select {
  width: 150px;
}

.midi-qol-blind-select .selected{
  background-color: #861b1b;
  color: #fff;
}

.midi-qol .grid {
    display: grid;
    grid-template-columns: auto auto auto;
    gap: 10px;
    width: 300; /* You can adjust the width as needed */
}

.midi-qol .grid-item {
    width: 50px;
    height: 50px;
    margin: 10px;
    background-color: grey;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.midi-qol .grid-item.selected {
    background-color: green;
}

.midi-scrollable-list {
  list-style: none;
  margin: 0.5em 0;
  padding: 0;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid var(--color-border-dark-5);
  border-radius: 2px;
  max-height: 600px;
  overflow: hidden auto;
  scrollbar-width: thin;
}

.dice-result .dice-tooltip .dice .total {
    flex: 50%;
    max-width: 62.66px;
}

.dice-result .dice-tooltip .dice .dice-rolls {
    flex: 50%;
}

.dice-result .dice-tooltip .dice .total .label {
    white-space: normal;
}

.dice-result .midi-dice-tooltip {
  flex: auto;
  order: unset;
  display: block;
  overflow: hidden;
  transition: all 250ms ease;
}
.dice-result .midi-dice-tooltip .tooltip-part {
  border-bottom: 1px solid var(--color-border-light-1);
  padding: 0.125rem 0;
}
.dice-result .midi-dice-tooltip .tooltip-part:last-child {
  border: none;
  padding-bottom: 0;
}
.dice-result .midi-dice-tooltip .tooltip-part.constant {
  padding-right: 6px;
  min-height: 40px;
  display: grid;
}
.dice-result .midi-dice-tooltip .dice {
  display: flex;
  align-items: center;
}
.dice-result .midi-dice-tooltip .dice .dice-rolls {
  flex: 1;
  margin: 5px 0 5px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
}
.dice-result .midi-dice-tooltip .dice .dice-rolls .roll {
  position: unset;
  float: unset;
  margin: 0;
}
.dice-result .midi-dice-tooltip .dice .dice-rolls .constant {
  font-family: var(--font-primary);
  font-weight: bold;
  font-size: var(--font-size-18);
  margin-left: 0.25rem;
}
.dice-result .midi-dice-tooltip .dice .dice-rolls .constant .sign {
  font-weight: normal;
  color: var(--color-text-light-6);
  margin-right: 2px;
}
.dice-result .midi-dice-tooltip .dice .total {
  flex-basis: 25%;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.dice-result .midi-dice-tooltip .dice .total > img {
  top: 6px;
  position: absolute;
  width: 32px;
  border: none;
  opacity: 0.1;
}
.dice-result .midi-dice-tooltip .dice .total .label {
  font-family: var(--dnd5e-font-roboto-condensed);
  font-size: var(--font-size-10);
  color: var(--color-text-dark-5);
  text-transform: uppercase;
  text-align: center;
}
.dice-result .midi-dice-tooltip .dice .total .value {
  font-family: var(--font-primary);
  font-weight: bold;
  font-size: var(--font-size-20);
}
.dice-result .midi-dice-tooltip .dice .total .sign {
  color: var(--color-text-light-6);
  font-weight: normal;
  margin-right: 2px;
}
.dice-result .dice-total {
  font-weight: bold;
  font-size: var(--font-size-20);
  padding: 0.125rem;
  margin-top: 0.25rem;
  font-family: var(--font-primary);
  position: relative;
}
.midi-bonus-damage-flavor {
  text-align: center;
}
.dnd5e2 .midi-buttons button {
  background: var(--dnd5e-color-card);
  font-family: var(--dnd5e-font-roboto);
  font-weight: bold;
  font-size: var(--font-size-11);
  text-transform: uppercase;
  padding: 0.05rem;
  border: 1px solid var(--color-border-light-2);
  box-shadow: 0 0 8px var(--dnd5e-shadow-15);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
}

.dnd5e2.chat-card.midi-chat-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  /* Effects Tray */
}
.dnd5e.chat-card.midi-chat-card .card-buttons {
  margin: 2px 0;
  height: 18px;
  line-height: 14px;
}

.dnd5e.chat-card.midi-chat-card.card-buttons button {
  color: red;
  font-size: var(--font-size-12);
  height: 18px;
  line-height: 12px;
  margin: 2px 0;
}
.dnd5e.chat-card.midi-chat-card .card-buttons span {
  display: block;
  line-height: 18px;
  text-align: center;
  border: 1px solid var(--dnd5e-border-light);
}

:is(.chat-popout, #chat-log) .message .dnd5e2.evaluation .midi-qol.target > img {
  width: 22px !important;
  height: 22px !important;
  object-fit: cover;
  object-position: top;
  margin: 0px 0 !important;
  border-radius: 100%;
  border: 1px solid var(--dnd5e-color-gold) !important;
  box-shadow: 0 0 2px var(--dnd5e-shadow-45) !important;
  background: var(--dnd5e-color-light-gray);
}

/* CHAT - DND5E 3 AND MIDI */

:root {

  --dnd5e-color-failure-background: rgb(245,221,221);
  --dnd5e-color-success-background: rgb(204,215,197);
    
  }
  
  /* Chat message borders */
  
  :is(.chat-popout, #chat-log) .message {
    border-width: 0;	
    border-left: 0.2rem solid;
    border-color: var(--user-color);
  }
  
  /* Fix chat message corners */
  
  :is(.chat-popout, #chat-log) .message.whisper::before {
      border-radius: 6px !important;
  }
  
  /* Condensed Item description */
  
  .dnd5e2.chat-card .description {
      padding: 0.4rem;
    margin-bottom: 0.4rem;
  }
  
  .dnd5e2.chat-card .description:not(:has(p),.collapsed) .details { 
    margin-top: 0.4rem; /* fix for badly imported details */
  }
  
  /* Chat card spacing */
  
  .dnd5e2.chat-card.midi-chat-card {
      gap: 0;
  }
  
  /* Condensed hits, misses and saves evaluation */
  
  :is(.chat-popout, #chat-log) .message .dnd5e2.evaluation {
      gap: 0.15rem;
    margin-bottom: 0.25rem;
  }
  
  :is(.chat-popout, #chat-log) .message .dnd5e2.evaluation .target {
    padding: 0.2rem 0.3rem;
  }
  
  :is(.chat-popout, #chat-log) .message .dnd5e2.evaluation .target .name-stacked {
    min-height: auto;
  }
  
  :is(.chat-popout, #chat-log) .message .dnd5e2.evaluation .target .name-stacked .title {
    font-size: var(--font-size-14);
    margin-bottom: 0.1rem;
  }
  
  :is(.chat-popout, #chat-log) .message .dnd5e2.evaluation .target.failure {
      border-color: rgba(110,0,0,0.4);
    background-color: var(--dnd5e-color-failure-background);
  }
  
  :is(.chat-popout, #chat-log) .message .dnd5e2.evaluation .target.success {
      border-color: rgba(0,108,0,0.4);
    background-color: var(--dnd5e-color-success-background);
  }
  
  .midi-qol-tooltiptext.midi-qol-save-tooltip {
    width: 65%;
  }
  
  .midi-qol-saves-display {
    padding-top: 0.2rem;
    font-size: 12px;
  }
  
  /* Condensed footer pills */
  .card-footer.pills.unlist li.pill.pill-sm {
      font-size: 9px;
    padding: 0.2rem 0.3rem;
  }
  .card-footer.pills.unlist {
      gap: 0.2rem;
    margin-top: 0.1rem;
  }
  
  /* Midi Attack and Damage buttons */
  
  .dnd5e2.chat-card .card-buttons.midi-buttons:has(button) {
      gap: 0.2rem;
    padding-bottom: 0.4rem;
  }
  
  .midi-qol-attack-buttons button, 
  .midi-qol-damage-buttons button,
  .dnd5e2 .midi-buttons button {
      height: 1.75rem;
    margin: 0;
  }
  
  /* Midi Attack and Damage results */
  .midi-qol-attack-roll, .midi-qol-damage-roll {
      white-space: nowrap;
  }
  
  .midi-results .flexrow {
      gap: 0.15rem; 
  }
  
  
  .dice-result .dice-tooltip .tooltip-part {
      padding: 0;
  }
  
  .dice-result .dice-tooltip .tooltip-part .dice {
    margin: 0.2rem 0;
  }
  
  .dice-result .dice-total {
    margin-top: 0;
  }
  
  .dice-result .dice-tooltip-collapser {
    margin-top: 0.1rem;
  }
  
  .midi-qol-attack-roll > div:nth-child(1), .midi-qol-damage-roll > div:nth-child(1), .midi-qol-other-damage-roll > div:nth-child(1), .midi-qol-utility-roll > div:nth-child(1){
    text-transform: uppercase;
    font-size: 10px;
    font-weight: bold;
  }
  
  .dice-roll .dice-result {
      margin-bottom: 0.2rem;
  }
  
  /* Midi Damage application card (tested with DnD5E damage application OFF)  */
  
  :is(.chat-popout, #chat-log) .message:has(.xmidi-qol-flex-container) {
      padding: 0 ;
    border: none;
    border-left: 0.2rem solid var(--user-color);
  }
  
  /* Hides the header  */
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) .message-header {
      display: none; 
  }
  
  /* Table Adjustments */
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) table {
      margin: 0;
    border: none;
  }
  
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) th {
    line-height: normal;
    padding: 7px 3px 5px 3px;
    text-align: left !important;
  }
  
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) thead > tr > th:nth-child(1)::before {
      font-family: "Font Awesome 6 Pro";
    content: "\f7a9";
    margin-right: 3px;
    color: var(--color-text-light-7);
  }
  
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) td {
    font-size: 13px;
    line-height: normal;
    padding: 0.15rem;
  }
  
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) th:last-child, 
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) td:last-child {
    padding-right: 0.5rem;
  }
  
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) th:first-child,
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) td:first-child {
    padding-left: 8px;
    width: 100%;
  }
  
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) thead {
    background: rgba(0, 0, 0, 0.05);
    font-size: 10px;
    color: var(--color-text-dark-secondary);
    text-shadow: none;
    text-transform: uppercase;
    border: none;
    text-wrap: nowrap;
    
  }
  
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) tfoot td {
    padding-top: 5px;
    padding-bottom: 7px;
  }
  
  :is(.chat-popout, #chat-log) .message.whisper::before {
      border-radius: 0px;
  }
  
  .midi-qol-tooltiptext {
      width: max-content;
    font-size: 14px;
  }
  
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) table > tbody > tr > td:nth-child(1) > div:nth-child(1) > div:nth-child(1) {
    min-width: 32px;
  }
  
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container):has(button) table > tbody > tr > td:nth-child(1) > div:nth-child(2) > span > div {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 12px;
    max-width: 95px;
  }
  
  /* Select and buttons */
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) select,
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) button {
    border-radius: 3px;
    border: 1px solid var(--color-border-light-2);
    background: rgba(255, 255, 255, 0.4);
    width: auto !important;
    height: 26px !important;
    padding: 0 4px 0 2px;
    font-size: 12px;
  }
  
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) button {
    padding: 0 5px 0 9px;
  }
  
  /* row colors */
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) table tbody tr:nth-child(even) {
      background-color: rgba(255, 255, 255, 0.1);
  }
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) table tbody tr:nth-child(odd) {
      background-color: rgba(255, 255, 255, 0.1);
  }
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) table tbody tr:hover {
      background-color: rgba(150, 150, 200, 0.2);
  }
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) table tbody tr {
      border-bottom: 1px solid rgba(150, 150, 200, 0.2);
  }
  
  /* Attempt to fix alignment in the damage display. Might break with DnD5e damage application as Midi outputs text differently with it on */
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) td:first-child {
      display: flex;
      align-items: center;
  }
  /* Attempt to fix the image too */
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) .midi-qol-target-name {
      width: 30px;
      height: 30px;
      margin-right: 0.25rem;
      vertical-align: middle;
  }
  
  /* Hacky way to improve "All" positioning */
  .chat-message.message.flexcol:has(.xmidi-qol-flex-container) tfoot td:first-child {
      position: relative;
    top: 0.25rem;
    left: 0.25rem;
  }

  /* Item sheet midi tab */
  .midi-qol-tab .form-header {
    color: var(--color-text-dark-primary);
  }
  .midi-qol-tab textarea {
    color: var(--color-text-dark-primary);
  }
  .midi-qol-tab .midi-properties {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .midi-qol-tab .form-group {
    margin-bottom: 5px;
  }
  .midi-qol-tab .midi-properties label.checkbox {
    align-items: baseline;
  }
  .theme-dark .midi-qol-tab textarea {
    background: var(--dnd5e-background-card);
  }
  .midi-qol-tab .midi-activation-conditions h3 {
    border-bottom-color: var(--color-border-light-primary)
  }

  #midi-qol-undo-workflow .midi-qol-box {
    margin-right: -1px;
  }

  #midi-qol-target-confirmation-config h4 {
    text-shadow: none;
    color: var(--color-text-primary);
  }
  .midi-qol-target-confirmation-list {
      overflow-y: scroll;
      max-height: 600px;
  }
  .midi-targeting dl .midi-qol-box dd {
    margin: 1rem;
  }