.application.mgne .mgne-sheet {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.application.mgne.character .mgne-sheet-header {
  flex: 0 0 auto;
}

.application.mgne .sheet-header {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 0.8rem;
  align-items: start;
}

.application.mgne.item-sheet .sheet-header {
  grid-template-columns: 111px 1fr;
}

.application.mgne .actor-portrait,
.application.mgne .item-portrait {
  width: 100%;
  max-width: 148px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: @radius-lg;
  border: 1px solid fade(@gold-acid, 40%);
  box-shadow:
    0 12px 24px fade(black, 34%),
    inset 0 0 0 2px fade(@parchment, 8%);
  background:
    radial-gradient(circle at 30% 20%, fade(@bone, 8%), transparent 30%),
    @bg-input;
}

.application.mgne.item-sheet .item-portrait {
  max-width: 111px;
}

.application.mgne .header-fields,
.application.mgne .resource-bar,
.application.mgne .ability-grid,
.application.mgne .inventory-section,
.application.mgne .daily-resources-panel,
.application.mgne .tab-panel {
  .panel-shell();
  .ornate-frame();
  padding: 0.65rem;
}

.application.mgne .resource-bar,
.application.mgne .ability-grid,
.application.mgne .grid.two,
.application.mgne .grid.three,
.application.mgne .condition-value-grid,
.application.mgne .condition-flag-grid {
  display: grid;
  gap: 0.5rem;
}

.application.mgne .resource-bar {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.application.mgne .resource-bar-core {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.application.mgne .resource-bar-daily {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.application.mgne .resource-bar-equipment {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.application.mgne .ability-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.application.mgne .grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.application.mgne .grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.application.mgne.item-sheet .item-form-grid {
  display: grid;
  gap: 0.65rem 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

.application.mgne.item-sheet .item-form-grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.application.mgne.item-sheet .item-form-grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.application.mgne.item-sheet .item-form-row {
  display: grid;
  grid-template-columns: minmax(6rem, max-content) minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem;
  min-width: 0;

  > label {
    margin: 0;
    line-height: 1.1;
    min-width: 0;
  }

  > input,
  > select {
    width: 100%;
    min-width: 0;
  }
}

.application.mgne .condition-value-grid {
  grid-template-columns: max-content 1fr;
  align-items: center;
  margin-bottom: 0.6rem;
}

.application.mgne .condition-flag-grid {
  grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
  gap: 0.3rem 0.6rem;
}

.application.mgne .resource-box,
.application.mgne .ability-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  padding: 0.52rem;
  border-radius: @radius-md;
  border: 1px solid fade(@iron, 30%);
  background:
    linear-gradient(180deg, fade(@bone, 4%), transparent 30%),
    linear-gradient(180deg, fade(@ember, 7%), transparent 80%),
    @bg-panel-soft;
}

.application.mgne .ability-card {
  min-height: 0;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0.38rem 0.46rem;
}

.application.mgne .resource-box-track,
.application.mgne .resource-box-single {
  justify-content: space-between;
}

.application.mgne .resource-box-compact {
  gap: 0.18rem;
  padding: 0.36rem 0.42rem;

  > label {
    font-size: 0.68rem;
    letter-spacing: 0.11em;
  }
}

.application.mgne .resource-box-inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;

  > label {
    flex: 0 0 auto;
    margin: 0;
  }
}

.application.mgne .resource-box-inline .resource-track,
.application.mgne .resource-box-inline .numeric-pill {
  flex: 1 1 auto;
}

.application.mgne .resource-box-inline-track {
  align-items: flex-start;

  > label {
    padding-top: 1rem;
  }
}

.application.mgne .resource-box-inline-track .numeric-caption {
  color: @label-ink;
}

.application.mgne .resource-box-inline-track .numeric-caption-strong {
  padding: 0.08rem 0.34rem;
  border-radius: 999px;
  background: fade(@gold-acid, 18%);
  border: 1px solid fade(@label-ink, 28%);
  color: darken(@label-ink, 4%);
  font-size: 0.6rem;
  letter-spacing: 0.11em;
}

.application.mgne .resource-box-inline-track .numeric-cluster {
  align-items: center;
}

.application.mgne .resource-box-inline-track .numeric-input {
  width: 3.4rem;
  min-width: 3.4rem;
}

.application.mgne .resource-box-inline-single .numeric-pill {
  flex: 0 0 auto;
}

.application.mgne .resource-box-inline-single .numeric-input {
  width: 3.2rem;
  min-width: 3.2rem;
}

.application.mgne .header-resource {
  align-self: stretch;
}

.application.mgne .header-resource .resource-box {
  height: 100%;
}

.application.mgne .resource-track {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.32rem;
  align-items: end;
}

.application.mgne .resource-track-die {
  grid-template-columns: 1fr 1fr;
}

.application.mgne .numeric-cluster {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.application.mgne .numeric-caption {
  .caps-heading();
  color: fade(@label-soft, 94%);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
}

.application.mgne .resource-box-compact .numeric-caption {
  font-size: 0.52rem;
  letter-spacing: 0.09em;
}

.application.mgne .track-separator {
  align-self: center;
  color: fade(@gold-acid, 72%);
  font-family: @font-display;
  font-size: 1rem;
  line-height: 1;
}

.application.mgne .numeric-input {
  min-width: 0;
  text-align: center;
  text-align-last: center;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1rem;
  padding-inline: 0.2rem;
}

.application.mgne .resource-box-compact .numeric-input,
.application.mgne .resource-box-compact .compact-select {
  min-height: 30px;
  padding: 0.18rem 0.16rem;
  font-size: 0.9rem;
}

.application.mgne .numeric-input-readonly {
  color: @bone;
}

.application.mgne .compact-select {
  text-align: center;
  text-align-last: center;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  padding-inline: 0.35rem;
}

.application.mgne .numeric-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.18rem;
  border-radius: @radius-md;
  border: 1px solid fade(@gold-acid, 18%);
  background: fade(@bg-input, 64%);
}

.application.mgne .resource-box-compact .numeric-pill {
  padding: 0.1rem;
}

.application.mgne .numeric-pill-suffix {
  gap: 0.35rem;
  justify-content: space-between;
}

.application.mgne .numeric-suffix {
  flex: 0 0 auto;
  color: @gold-acid;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
}

.application.mgne .resource-meta {
  display: inline-flex;
  align-self: flex-start;
  margin-top: 0.12rem;
  padding: 0.16rem 0.44rem;
  border-radius: 999px;
  border: 1px solid fade(@verdigris, 20%);
  color: lighten(@verdigris, 18%);
  background: fade(@verdigris, 10%);
  font-size: 0.72rem;
}

.application.mgne .resource-box-compact .resource-track {
  gap: 0.22rem;
}

.application.mgne .resource-box-compact .numeric-cluster {
  gap: 0.1rem;
}

.application.mgne .resource-box-compact .track-separator {
  font-size: 0.88rem;
}

.application.mgne .resource-box-compact .resource-meta {
  margin-top: 0.06rem;
  padding: 0.1rem 0.34rem;
  font-size: 0.64rem;
}

.application.mgne .resource-inline {
  display: flex;
  gap: 0.32rem;
  align-items: center;

  span {
    color: @dust;
  }
}

.application.mgne .sheet-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex: 0 0 auto;
  justify-content: center;
}

.application.mgne .tab-button {
  min-width: 110px;
}

.application.mgne .tab-button.active {
  border-color: fade(@ember-bright, 70%);
  background:
    linear-gradient(180deg, fade(@ember-bright, 26%), fade(@blood, 12%)),
    linear-gradient(135deg, fade(@parchment, 12%), transparent 45%),
    @bg-input;
  color: lighten(@parchment, 6%);
}

.application.mgne .tab-panel:not(.active) {
  display: none;
}

.application.mgne.character .tab-panel.active {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.application.mgne .inventory-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.application.mgne .daily-resources-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.application.mgne .section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.application.mgne .section-heading h2 {
  .caps-heading();
  margin: 0;
  color: @bone;
  font-size: 0.9rem;
}

.application.mgne .section-heading small {
  display: inline-block;
  margin-top: 0.12rem;
  color: @dust;
  font-size: 0.72rem;
}

.application.mgne .inventory-header,
.application.mgne .inline-buttons,
.application.mgne .item-actions,
.application.mgne .sheet-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}

.application.mgne .resource-box-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 0.12rem;
}

.application.mgne .resource-box-actions-rest {
  gap: 0.32rem;
  flex-wrap: wrap;

  > button {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 0.5rem;
    white-space: nowrap;
  }
}

.application.mgne .inventory-header {
  justify-content: space-between;
}

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

.application.mgne .item-row {
  position: relative;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 0.45rem;
  align-items: center;
  padding: 0.48rem 0.2rem 0.48rem 0.55rem;
  border-radius: @radius-sm;
  border: 1px solid transparent;
  background:
    linear-gradient(90deg, fade(@ember, 9%), transparent 35%),
    linear-gradient(180deg, fade(@parchment, 2%), fade(@bg-void, 12%)),
    fade(@bg-input, 80%);

  &:hover {
    border-color: fade(@gold-acid, 28%);
    background:
      linear-gradient(90deg, fade(@ember, 12%), transparent 35%),
      linear-gradient(180deg, fade(@parchment, 4%), fade(@bg-void, 12%)),
      fade(@bg-input, 88%);
  }
}

.application.mgne .item-name {
  color: @parchment;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 0.95rem;
}

.application.mgne .check-grid {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.application.mgne.item-sheet .item-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.45rem 0.9rem;
  align-items: center;
}

.application.mgne.item-sheet .check-grid > label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  width: fit-content;
  margin: 0;
}

.application.mgne .checkbox-line {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  width: fit-content;

  &.active {
    color: @ember-bright;
    font-weight: 600;
  }
}

.application.mgne .check-grid input[type="checkbox"],
.application.mgne .checkbox-line input[type="checkbox"] {
  --checkbox-size: 0.9rem;
  flex: 0 0 0.9rem;
  width: 0.9rem;
  height: 0.9rem;
  min-width: 0.9rem;
  padding: 0;
  margin: 0;
  position: relative;
}

@media (max-width: 820px) {
  .application.mgne.item-sheet .item-form-grid-two,
  .application.mgne.item-sheet .item-form-grid-three {
    grid-template-columns: minmax(0, 1fr);
  }
}

.application.mgne .ability-label {
  display: inline-flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
}

.application.mgne .resource-label-accent {
  color: @ember-bright;
  text-shadow: 0 0 12px fade(@ember, 18%);
}

.application.mgne .ability-score {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 58px;
  min-height: 32px;
  padding: 0.08rem;
  border-radius: @radius-sm;
  border: 1px solid fade(@gold-acid, 14%);
  background: fade(@bg-input, 54%);
}

.application.mgne .ability-input {
  font-family: @font-display;
  font-size: 1.05rem;
  line-height: 1;
  color: @bone;
  padding: 0.12rem;
}

.application.mgne select.ability-input {
  flex: 1 1 auto;
  width: 100%;
}

.application.mgne .ability-score-text {
  flex-direction: column;
  gap: 0.02rem;
}

.application.mgne .ability-defense-main {
  .caps-heading();
  color: @bone;
  font-size: 0.8rem;
}

.application.mgne .ability-defense-sub {
  color: @dust;
  font-size: 0.62rem;
}

.application.mgne .character .ability-card:nth-child(odd),
.application.mgne .character .resource-box:nth-child(odd) {
  background:
    linear-gradient(180deg, fade(@verdigris, 10%), transparent 55%),
    linear-gradient(180deg, fade(@parchment, 4%), transparent 35%),
    @bg-panel-soft;
}

.application.mgne .creature .resource-box,
.application.mgne .companion .resource-box,
.application.mgne .creature .ability-card,
.application.mgne .companion .ability-card {
  background:
    linear-gradient(180deg, fade(@blood, 11%), transparent 60%),
    linear-gradient(180deg, fade(@parchment, 4%), transparent 35%),
    @bg-panel-soft;
}

@media (max-width: 960px) {
  .application.mgne .sheet-header,
  .application.mgne .resource-bar,
  .application.mgne .ability-grid,
  .application.mgne .grid.two,
  .application.mgne .grid.three {
    grid-template-columns: 1fr;
  }

  .application.mgne .item-row {
    grid-template-columns: 1fr;
  }
}
