.mgne-chat-card {
  .panel-shell();
  .ornate-frame();
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.68rem;
  color: @iron;
  background:
    radial-gradient(circle at top right, fade(@verdigris, 10%), transparent 22%),
    linear-gradient(135deg, fade(@ember, 10%), transparent 38%),
    linear-gradient(180deg, fade(@bone, 4%), transparent 24%),
    linear-gradient(180deg, fade(@bg-char, 22%), fade(@bg-void, 18%)),
    url("@{page-bg-url}") right bottom / cover no-repeat,
    @bg-panel;
}

.mgne-chat-card .chat-card-header {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.mgne-chat-card .chat-card-header img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid fade(@gold-acid, 38%);
  box-shadow: 0 0 0 2px fade(@parchment, 6%);
}

.mgne-chat-card .chat-eyebrow {
  display: none;
}

.mgne-chat-card h3 {
  .caps-heading();
  margin: 0;
  color: @bone;
  font-size: 0.82rem;
}

.mgne-chat-card .chat-actor,
.mgne-chat-card .chat-subtitle,
.mgne-chat-card .chat-formula,
.mgne-chat-card .chat-special {
  margin: 0;
}

.mgne-chat-card .chat-actor {
  color: @iron;
}

.mgne-chat-card .chat-formula {
  color: @iron;

  code {
    color: @parchment;
    background: fade(@bg-void, 75%);
    padding: 0.1em 0.42em;
    border-radius: 3px;
  }
}

.mgne-chat-card .chat-result-line {
  display: flex;
  justify-content: space-between;
  align-items: end;
  padding: 0.38rem 0.55rem;
  border: 1px solid fade(@gold-acid, 28%);
  border-radius: @radius-sm;
  background: fade(@bg-void, 78%);
}

.mgne-chat-card .chat-result-label {
  .caps-heading();
  font-size: 0.62rem;
  color: @parchment;
}

.mgne-chat-card .chat-result-total {
  font-family: @font-display;
  font-size: 1.08rem;
  color: @parchment;
}

.mgne-chat-card .chat-outcome,
.mgne-chat-card .chat-damage-total {
  &.has-tooltip {
    cursor: pointer;
    user-select: none;
    &:hover { filter: brightness(1.12); }
  }
  .chat-tooltip-icon {
    opacity: 0.55;
    font-size: 0.75em;
    margin-left: 0.3rem;
    vertical-align: middle;
    transition: opacity 0.15s;
  }
  &.tooltip-open .chat-tooltip-icon { opacity: 1; }
}

// Dice tooltip reveal panel
.mgne-chat-card .chat-dice-tooltip {
  margin-top: 0.4rem;
  padding: 0.4rem 0.55rem;
  background: fade(@bg-void, 85%);
  border: 1px solid fade(@bone, 22%);
  border-radius: @radius-sm;

  // Foundry's standard dice-roll markup
  .dice-roll {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
  }
  .dice-formula {
    font-family: "Courier New", monospace;
    font-size: 0.72rem;
    color: fade(@parchment, 78%);
  }
  .dice-tooltip {
    font-size: 0.78rem;
  }
  .dice {
    margin: 0.15rem 0;
  }
  .die-icon, .die-face {
    color: @gold-acid;
    font-size: 0.8rem;
  }
  .part-formula { color: fade(@parchment, 82%); font-size: 0.72rem; }
  .part-total   { color: @parchment; font-weight: 600; }
  .max          { color: lighten(@verdigris, 20%); }
  .min          { color: lighten(@ember-bright, 10%); }
  .dice-total {
    font-family: "CastorTwoMGNE", serif;
    font-size: 1.05rem;
    color: @gold-acid;
    text-align: right;
    border-top: 1px solid fade(@bone, 20%);
    padding-top: 0.2rem;
    margin-top: 0.15rem;
  }
}

.mgne-chat-card .chat-outcome {
  .caps-heading();
  margin: 0;
  padding: 0.3rem 0.55rem;
  border-radius: @radius-sm;
  background: fade(@bg-void, 72%);
  border-left: 3px solid fade(@ember-bright, 70%);
  color: lighten(@ember-bright, 12%);
  font-size: 0.8rem;
}

.mgne-chat-card .chat-special {
  padding: 0.42rem 0.55rem;
  border-left: 3px solid fade(@ember-bright, 55%);
  background: fade(@bg-input, 85%);
  color: @parchment;
}

.mgne-chat-card.outcome-critical-success,
.mgne-chat-card.outcome-success,
.mgne-chat-card.outcome-steady {
  border-color: fade(@verdigris, 42%);

  .chat-outcome {
    color: lighten(@verdigris, 28%);
    border-left-color: fade(@verdigris, 80%);
  }
}

.mgne-chat-card.outcome-failure,
.mgne-chat-card.outcome-broken,
.mgne-chat-card.outcome-fumble {
  border-color: fade(@blood, 48%);

  .chat-outcome {
    color: lighten(@ember-bright, 18%);
    border-left-color: fade(@ember-bright, 80%);
  }
}

.mgne-chat-card.mode-apply-damage .chat-result-total,
.mgne-chat-card.mode-damage .chat-result-total {
  color: lighten(@ember-bright, 8%);
}

.mgne-chat-card .chat-card-actions {
  margin-top: 0.2rem;
}

.mgne-roll-damage-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.38rem 0.7rem;
  border: 1px solid @ember-bright;
  border-radius: @radius-sm;
  background: @ember;
  color: #f8ede0;
  font-family: @font-display;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;

  .dmg-formula {
    color: #fff5e8;
    font-size: 0.75rem;
    font-weight: 700;
  }

  &:hover {
    background: lighten(@ember, 8%);
    border-color: lighten(@ember-bright, 12%);
    color: #fff;
  }

  &.is-critical {
    border: 1px solid @gold-acid;
    background: darken(@gold-acid, 10%);
    color: #fff5d0;
    font-weight: 700;

    .dmg-formula {
      color: #fff;
    }

    &:hover {
      background: @gold-acid;
      color: #fff;
    }
  }
}

.mgne-omen-reroll-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.38rem 0.7rem;
  border: 1px solid @gold-acid;
  border-radius: @radius-sm;
  background: darken(@gold-acid, 15%);
  color: #fff5d0;
  font-family: @font-display;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;

  &:hover {
    background: lighten(darken(@gold-acid, 15%), 8%);
    border-color: lighten(@gold-acid, 12%);
    color: #fff;
  }
}

.chat-apply-actions {
  margin-top: 0.35rem;
}

.mgne-apply-damage-select {
  width: 100%;
  padding: 0.35rem 0.6rem;
  border: 1px solid @ember-bright;
  border-radius: @radius-sm;
  background: @bg-char;
  color: @bone;
  font-family: @font-body;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;

  option {
    background: @bg-char;
    color: @bone;
  }

  &:hover {
    border-color: lighten(@ember-bright, 12%);
    background: rgba(183, 70, 31, 0.18);
  }

  &:focus {
    outline: none;
    border-color: @ember-bright;
  }
}
