
/* ------------------------------------------- 
        Fonts
 ---------------------------------------------*/

@font-face {
  font-family: "Averia";
  src: url(../fonts/Averia-Regular.ttf);
}

// ============================================================
// Neo-Tokyo Neon Noir — Palette
// ============================================================
@cde-bg:           #080c14;
@cde-surface:      #101622;
@cde-surface2:     #0d1520;
@cde-border:       #1a2436;
@cde-border-hi:    #263853;
@cde-text:         #e2e8f4;
@cde-muted:        #7d94b8;

// Accents néon par type
@cde-item:         #00d4d4;
@cde-kungfu:       #ff3d5a;
@cde-spell:        #4a9eff;
@cde-supernatural: #cc44ff;
@cde-weapon:       #ff6b35;
@cde-armor:        #4ecdc4;
@cde-sanhei:       #cc44ff;
@cde-ingredient:   #98c379;

@cde-shadow:       0 8px 32px rgba(0, 0, 0, 0.6);
@cde-shadow-sm:    0 2px 12px rgba(0, 0, 0, 0.4);
@cde-radius:       8px;
@cde-radius-sm:    5px;
@cde-gap:          12px;

// Glow helpers
.glow(@color) { box-shadow: 0 0 0 1px fade(@color, 35%), 0 0 12px fade(@color, 20%); }
.glow-text(@color) { text-shadow: 0 0 8px fade(@color, 60%); }

// ============================================================
// CSS Variables (for JS access)
// ============================================================
.fvtt-chroniques-de-l-etrange {
  --cde-bg: @cde-bg;
  --cde-surface: @cde-surface;
  --cde-border: @cde-border;
  --cde-text: @cde-text;
  --cde-muted: @cde-muted;
  --cde-item: @cde-item;
  --cde-kungfu: @cde-kungfu;
  --cde-spell: @cde-spell;
  --cde-supernatural: @cde-supernatural;
  color: @cde-text;
  background: @cde-bg;
}

// ============================================================
// Base sheet
// ============================================================
.cde-sheet {
  background: @cde-bg;
  color: @cde-text;
  font-family: "Averia", sans-serif;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;

  input, textarea {
    font-family: inherit;
    color: @cde-text;
    background: transparent;
  }

  // Selects need an explicit dark background — transparent fails on native dropdowns
  select {
    font-family: inherit;
    color: @cde-text;
    background: @cde-surface;
    border-radius: 2px;
  }

  select option {
    background: @cde-bg;
    color: @cde-text;
  }
}

// ============================================================
// Item-sheet Neon Header
// ============================================================
.cde-neon-header {
  position: relative;
  background: @cde-surface;
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 14px;
  padding: 12px 14px 14px;
  overflow: hidden;
  // Angular clip on bottom-right corner
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%);

  // Top accent line — overridden per type
  &::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: @cde-border-hi;
  }

  // Subtle neon scatter in background
  &::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 0% 0%, fade(@cde-border-hi, 30%) 0%, transparent 50%);
    pointer-events: none;
  }

  // Per-type accent colors
  &.item    { &::before { background: @cde-item; box-shadow: 0 0 10px fade(@cde-item, 50%); } }
  &.kungfu  { &::before { background: @cde-kungfu; box-shadow: 0 0 10px fade(@cde-kungfu, 50%); } }
  &.spell   { &::before { background: @cde-spell; box-shadow: 0 0 10px fade(@cde-spell, 50%); } }
  &.supernatural { &::before { background: @cde-supernatural; box-shadow: 0 0 10px fade(@cde-supernatural, 50%); } }
  &.weapon  { &::before { background: @cde-weapon; box-shadow: 0 0 10px fade(@cde-weapon, 50%); } }
  &.armor   { &::before { background: @cde-armor; box-shadow: 0 0 10px fade(@cde-armor, 50%); } }
  &.sanhei  { &::before { background: @cde-sanhei; box-shadow: 0 0 10px fade(@cde-sanhei, 50%); } }
  &.ingredient { &::before { background: @cde-ingredient; box-shadow: 0 0 10px fade(@cde-ingredient, 50%); } }
}

// Avatar inside neon header — angular clip
.cde-avatar {
  width: 90px;
  height: 90px;
  object-fit: cover;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
  border: 1px solid @cde-border-hi;
  background: @cde-surface2;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

// Header content zone
.cde-header-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

// Item name — flat neon-bottom-border input
.cde-item-name {
  margin: 0;

  input {
    width: 100%;
    border: none;
    border-bottom: 2px solid @cde-border-hi;
    background: transparent;
    color: @cde-text;
    font-size: 18px;
    font-family: "Averia", sans-serif;
    font-weight: 700;
    padding: 4px 0 6px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    outline: none;
    transition: border-color 0.15s;

    &:focus {
      border-bottom-color: @cde-item;
    }
  }
}

// Type-specific focus color on name input
.cde-neon-header.kungfu     .cde-item-name input:focus { border-bottom-color: @cde-kungfu; }
.cde-neon-header.spell      .cde-item-name input:focus { border-bottom-color: @cde-spell; }
.cde-neon-header.supernatural .cde-item-name input:focus { border-bottom-color: @cde-supernatural; }
.cde-neon-header.weapon     .cde-item-name input:focus { border-bottom-color: @cde-weapon; }
.cde-neon-header.armor      .cde-item-name input:focus { border-bottom-color: @cde-armor; }
.cde-neon-header.sanhei     .cde-item-name input:focus { border-bottom-color: @cde-sanhei; }
.cde-neon-header.ingredient .cde-item-name input:focus { border-bottom-color: @cde-ingredient; }

// ============================================================
// Stat Grid (terminal style)
// ============================================================
.cde-stat-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: flex-end;
}

.cde-stat-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 110px;
  flex: 1 1 110px;
  max-width: 200px;

  &--wide {
    flex: 1 1 100%;
    max-width: 100%;
    min-width: 0;
  }
}

.cde-stat-label {
  font-size: 10px;
  font-family: "Averia", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: @cde-muted;
  white-space: nowrap;
}

.cde-stat-value {
  font-size: 15px;
  font-weight: 800;
  color: @cde-text;
  letter-spacing: 0.02em;
}

.cde-stat-cell input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid @cde-border;
  color: @cde-text;
  font-size: 14px;
  padding: 4px 0;
  outline: none;
  transition: border-color 0.15s;

  &:focus { border-bottom-color: @cde-item; }
}

.cde-stat-cell textarea {
  width: 100%;
  background: transparent;
  border: 1px solid @cde-border;
  border-radius: 2px;
  color: @cde-text;
  font-size: 13px;
  font-family: inherit;
  padding: 4px 6px;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s;
  line-height: 1.5;

  &:focus { border-color: @cde-kungfu; }
}

.cde-stat-cell select {
  width: 100%;
  border: none;
  border-bottom: 1px solid @cde-border;
  font-size: 14px;
  padding: 4px 0;
  outline: none;
  transition: border-color 0.15s;

  &:focus { border-bottom-color: @cde-item; }
}

.cde-neon-header.kungfu .cde-stat-cell input:focus,
.cde-neon-header.kungfu .cde-stat-cell select:focus { border-bottom-color: @cde-kungfu; }
.cde-neon-header.spell .cde-stat-cell input:focus,
.cde-neon-header.spell .cde-stat-cell select:focus   { border-bottom-color: @cde-spell; }
.cde-neon-header.supernatural .cde-stat-cell input:focus,
.cde-neon-header.supernatural .cde-stat-cell select:focus { border-bottom-color: @cde-supernatural; }
.cde-neon-header.weapon .cde-stat-cell input:focus,
.cde-neon-header.weapon .cde-stat-cell select:focus { border-bottom-color: @cde-weapon; }
.cde-neon-header.armor .cde-stat-cell input:focus,
.cde-neon-header.armor .cde-stat-cell select:focus  { border-bottom-color: @cde-armor; }
.cde-neon-header.sanhei .cde-stat-cell input:focus,
.cde-neon-header.sanhei .cde-stat-cell select:focus { border-bottom-color: @cde-sanhei; }
.cde-neon-header.ingredient .cde-stat-cell input:focus,
.cde-neon-header.ingredient .cde-stat-cell select:focus { border-bottom-color: @cde-ingredient; }

// ============================================================
// Type Badge — angular clip-path parallelogram
// ============================================================
.cde-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 14px 3px 10px;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: @cde-bg;
  cursor: default;
  white-space: nowrap;

  &.item         { background: @cde-item; }
  &.kungfu       { background: @cde-kungfu; }
  &.spell        { background: @cde-spell; }
  &.supernatural { background: @cde-supernatural; }
  &.character    { background: @cde-item; }
  &.npc          { background: @cde-supernatural; }
  &.weapon       { background: @cde-weapon; }
  &.armor        { background: @cde-armor; }
  &.sanhei       { background: @cde-sanhei; }
  &.ingredient   { background: @cde-ingredient; }
}

// ============================================================
// Neon Tabs
// ============================================================
.cde-neon-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid @cde-border;
  background: transparent;
  margin-top: 8px;
  overflow-x: auto;

  .item {
    padding: 8px 14px;
    font-size: 11px;
    font-family: "Averia", sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: @cde-muted;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
    cursor: pointer;

    &:hover {
      color: @cde-text;
    }

    &.active {
      color: @cde-item;
      border-bottom-color: @cde-item;
      font-weight: 700;
      background: fade(@cde-item, 8%);
    }
  }
}

// Per-type active tab color
.item.kungfu       .cde-neon-tabs .item.active,
form.kungfu        .cde-neon-tabs .item.active,
section.kungfu     .cde-neon-tabs .item.active { color: @cde-kungfu; border-bottom-color: @cde-kungfu; background: fade(@cde-kungfu, 8%); }
form.spell         .cde-neon-tabs .item.active,
section.spell      .cde-neon-tabs .item.active { color: @cde-spell;  border-bottom-color: @cde-spell;  background: fade(@cde-spell, 8%); }
form.supernatural  .cde-neon-tabs .item.active,
section.supernatural .cde-neon-tabs .item.active { color: @cde-supernatural; border-bottom-color: @cde-supernatural; background: fade(@cde-supernatural, 8%); }
form.weapon        .cde-neon-tabs .item.active,
section.weapon     .cde-neon-tabs .item.active { color: @cde-weapon; border-bottom-color: @cde-weapon; background: fade(@cde-weapon, 8%); }
form.armor         .cde-neon-tabs .item.active,
section.armor      .cde-neon-tabs .item.active { color: @cde-armor;  border-bottom-color: @cde-armor;  background: fade(@cde-armor, 8%); }
form.sanhei        .cde-neon-tabs .item.active,
section.sanhei     .cde-neon-tabs .item.active { color: @cde-sanhei; border-bottom-color: @cde-sanhei; background: fade(@cde-sanhei, 8%); }
form.ingredient    .cde-neon-tabs .item.active,
section.ingredient .cde-neon-tabs .item.active { color: @cde-ingredient; border-bottom-color: @cde-ingredient; background: fade(@cde-ingredient, 8%); }
// Actor type accent colors
section.character  .cde-neon-tabs .item.active { color: @cde-item;  border-bottom-color: @cde-item;  background: fade(@cde-item, 8%); }
section.npc        .cde-neon-tabs .item.active { color: @cde-supernatural; border-bottom-color: @cde-supernatural; background: fade(@cde-supernatural, 8%); }

// ============================================================
// Tab body
// ============================================================
.cde-tab-body {
  flex: 1 1 0;
  min-height: 0;
  padding: @cde-gap;
  background: @cde-surface2;
  border: 1px solid @cde-border;
  border-top: none;
  border-radius: 0 0 @cde-radius @cde-radius;
  overflow-y: auto;

  .tab {
    display: none;
    flex-direction: column;
    gap: @cde-gap;
  }

  .tab.active {
    display: flex;
  }
}

// Tab section label — visible inside each tab body
.cde-tab-label {
  font-family: "Averia", sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: @cde-muted;
  padding: 2px 6px;
  border-left: 2px solid @cde-border-hi;
  margin-bottom: 2px;
  flex-shrink: 0;
}

// ============================================================
// Card
// ============================================================
.cde-card {
  background: @cde-surface;
  border: 1px solid @cde-border;
  border-radius: @cde-radius;
  padding: 12px;
  box-shadow: @cde-shadow-sm;
}

.cde-card .tab-sous-titre {
  font-family: "Averia", sans-serif;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: @cde-muted;
  margin-bottom: 6px;
  border-bottom: 1px solid @cde-border;
  padding-bottom: 4px;
}

// ============================================================
// Notes editor
// ============================================================
.cde-notes-editor {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;

  .editor {
    flex: 1 1 0;
    min-height: 200px;
    border-radius: @cde-radius;
    border: 1px solid @cde-border;
    background: @cde-surface;
  }
}

// ============================================================
// Technique card (kungfu)
// ============================================================
.cde-technique-card {
  border-left: 3px solid @cde-kungfu;
  background: fade(@cde-surface, 80%);
}

.cde-technique-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.cde-technique-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 200px;

  input {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 1px solid @cde-border;
    color: @cde-text;
    font-size: 15px;
    font-weight: 700;
    padding: 4px 0;
    outline: none;

    &:focus { border-bottom-color: @cde-kungfu; }
  }
}

.cde-technique-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.cde-technique-body .editor {
  min-height: 180px;
}

// Mini technique checkbox row
.cde-check-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 70px;

  label {
    font-size: 10px;
    font-family: "Averia", sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: @cde-muted;
  }

  input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: @cde-kungfu;
    cursor: pointer;
  }
}

// ============================================================
// Legacy chips (kept for actor sheets)
// ============================================================
.cde-chip {
  background: fade(@cde-surface, 75%);
  border: 1px solid @cde-border;
  border-radius: @cde-radius;
  padding: 8px 10px;
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;

  label {
    font-size: 10px;
    font-family: "Averia", sans-serif;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: @cde-muted;
    margin: 0;
  }

  input {
    width: 100%;
    border: none;
    border-bottom: 1px solid @cde-border;
    background: transparent;
    color: @cde-text;
    padding: 4px 0;
    outline: none;

    &:focus { border-bottom-color: @cde-item; }
  }

  select {
    width: 100%;
    border: none;
    border-bottom: 1px solid @cde-border;
    padding: 4px 0;
    outline: none;

    &:focus { border-bottom-color: @cde-item; }
  }

  input[type="checkbox"] {
    width: auto;
    align-self: flex-start;
    accent-color: @cde-item;
  }

  &.mini { min-width: 100px; padding: 6px 8px; }
}

.cde-meta-row {
  display: flex;
  gap: @cde-gap;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-top: 8px;

  &.compact { gap: 8px; }
}

// Kept for backward compat with actor templates
.cde-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: @cde-bg;

  &.item         { background: @cde-item; }
  &.kungfu       { background: @cde-kungfu; }
  &.spell        { background: @cde-spell; }
  &.supernatural { background: @cde-supernatural; }
  &.character    { background: @cde-item; }
  &.npc          { background: @cde-supernatural; }
  &.weapon       { background: @cde-weapon; }
  &.armor        { background: @cde-armor; }
  &.sanhei       { background: @cde-sanhei; }
  &.ingredient   { background: @cde-ingredient; }
}

// ============================================================
// Actor header (kept, updated for new palette)
// ============================================================
.cde-header {
  background: @cde-surface;
  border: 1px solid @cde-border;
  border-radius: @cde-radius;
  padding: 12px;
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: @cde-gap;
  box-shadow: @cde-shadow;

  .profile-img {
    width: 100%;
    border-radius: @cde-radius;
    border: 1px solid @cde-border;
    box-shadow: @cde-shadow;
    object-fit: cover;
  }

  .header-fields h1.charname input {
    width: 100%;
    border: none;
    border-bottom: 2px solid @cde-border-hi;
    background: transparent;
    color: @cde-text;
    font-size: 20px;
    font-family: "Averia", sans-serif;
    padding: 4px 0 8px;
    outline: none;

    &:focus { border-bottom-color: @cde-item; }
  }
}

.cde-actor-header {
  grid-template-columns: 160px 1fr;
  align-items: start;
}

.cde-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.cde-icon-button {
  border: 1px solid @cde-border;
  background: fade(@cde-surface, 70%);
  color: @cde-text;
  border-radius: 999px;
  padding: 6px 10px;
  box-shadow: @cde-shadow-sm;
  cursor: pointer;

  &:hover { border-color: @cde-border-hi; }
}

.cde-quick-meta {
  display: flex;
  align-items: center;
  gap: @cde-gap;
  flex-wrap: wrap;
}

.cde-initiative-card {
  border: 1px solid @cde-border;
  border-left: 3px solid @cde-spell;
  border-radius: @cde-radius;
  padding: 8px 12px;
  background: fade(@cde-surface, 70%);
  box-shadow: @cde-shadow-sm;
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  min-width: 130px;
}

.cde-initiative-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cde-initiative-title {
  font-size: 10px;
  font-family: "Averia", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: @cde-muted;
}

.cde-initiative-icon {
  font-size: 11px;
  color: @cde-spell;
  text-shadow: 0 0 6px fade(@cde-spell, 70%);
}

.cde-initiative-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  .cde-init-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid @cde-border;
    border-radius: 5px;
    background: fade(@cde-bg, 80%);
    color: @cde-muted;
    font-size: 11px;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s, box-shadow 0.15s, color 0.15s;

    &:hover {
      border-color: @cde-spell;
      color: @cde-spell;
      box-shadow: 0 0 0 2px fade(@cde-spell, 25%);
    }
  }

  .cde-init-btn--roll {
    width: 30px;
    height: 30px;
    font-size: 14px;
    border-color: fade(@cde-spell, 40%);
    color: @cde-spell;
    background: fade(@cde-spell, 10%);
    box-shadow: 0 0 6px fade(@cde-spell, 20%);

    &:hover {
      background: fade(@cde-spell, 20%);
      box-shadow: 0 0 10px fade(@cde-spell, 40%);
    }
  }
}

.cde-initiative-values {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 50px;
}

.cde-initiative-value {
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  color: @cde-spell;
  text-shadow: 0 0 8px fade(@cde-spell, 60%);
  line-height: 1;
}

.cde-anti-initiative-value {
  font-size: 9px;
  font-family: "Averia", sans-serif;
  color: @cde-muted;
  text-align: center;
  white-space: nowrap;

  i {
    font-size: 8px;
    opacity: 0.7;
  }
}

// ============================================================
// Grid, field, table, section — common
// ============================================================
.cde-grid {
  display: grid;
  gap: @cde-gap;

  &.two   { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  &.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.cde-field {
  label {
    display: block;
    margin-bottom: 4px;
    font-size: 10px;
    font-family: "Averia", sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: @cde-muted;
  }

  input, textarea {
    width: 100%;
    border: none;
    border-bottom: 1px solid @cde-border;
    background: transparent;
    color: @cde-text;
    padding: 5px 0;
    outline: none;

    &:focus { border-bottom-color: @cde-item; }
  }

  select {
    width: 100%;
    border: none;
    border-bottom: 1px solid @cde-border;
    padding: 5px 0;
    outline: none;

    &:focus { border-bottom-color: @cde-item; }
  }
}

.cde-section-title {
  font-family: "Averia", sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: @cde-muted;
  margin-bottom: 8px;
  border-bottom: 1px solid @cde-border;
  padding-bottom: 4px;
}

.cde-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: fade(@cde-border, 80%);
  color: @cde-muted;
  border: 1px solid @cde-border;
}

.cde-data-table {
  table {
    width: 100%;
    border-collapse: collapse;
    color: @cde-text;
  }

  td {
    padding: 7px 8px;
    border-bottom: 1px solid @cde-border;
  }

  tr:nth-child(even) { background: fade(@cde-surface, 50%); }
  tr:hover           { background: fade(@cde-border-hi, 20%); }

  input {
    width: 100%;
    border: none;
    border-bottom: 1px solid @cde-border;
    background: transparent;
    color: @cde-text;
    padding: 4px 0;
    outline: none;
  }

  select {
    width: 100%;
    border: none;
    border-bottom: 1px solid @cde-border;
    padding: 4px 0;
    outline: none;
  }
}

.cde-centered-card {
  display: flex;
  gap: @cde-gap;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;

  img {
    max-height: 280px;
    border-radius: @cde-radius;
    border: 1px solid @cde-border;
    box-shadow: @cde-shadow;
  }
}

// ============================================================
// NPC Aptitudes table — modern cde-skills-table layout
// ============================================================
.cde-aptitudes-table {
  // Inherits .cde-skills-table styles; just ensure consistent width
  .cde-spec-cell { flex: 1 1 0; }

  .cde-roll-cell {
    width: 28px;
    flex-shrink: 0;
    text-align: center;

    .cde-roll-trigger {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 24px;
      height: 24px;
      color: @cde-muted;
      border-radius: 4px;
      transition: color 0.15s, background 0.15s;

      &:hover {
        color: @cde-supernatural;
        background: fade(@cde-supernatural, 12%);
      }
    }
  }
}

// Empty list placeholder
.cde-empty-list {
  color: @cde-muted;
  font-style: italic;
  font-size: 11px;
  text-align: center;
  padding: 10px 0;
}

// NPC supernatural item cards
// ── Supernatural abilities card (NPC) ───────────────────────────────────────

.cde-super-add-row {
  display: flex;
  justify-content: flex-end;
  padding: 4px 0 8px;
}

.cde-super-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-family: "Averia", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: @cde-muted;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: @cde-radius;
  border: 1px solid @cde-border;
  transition: color 0.12s, border-color 0.12s, background 0.12s;

  i { font-size: 10px; }

  &:hover { color: @cde-supernatural; border-color: @cde-supernatural; background: fade(@cde-supernatural, 8%); }
}

.cde-super-card {
  border: 1px solid @cde-border;
  border-left: 3px solid @cde-supernatural;
  border-radius: @cde-radius;
  background: fade(@cde-surface, 70%);
  margin-bottom: 10px;
  overflow: hidden;
  transition: box-shadow 0.15s;

  &:hover {
    box-shadow: 0 0 8px fade(@cde-supernatural, 20%);

    .cde-super-controls { opacity: 1; }
  }
}

.cde-super-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
}

.cde-super-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}

.cde-super-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.cde-super-name {
  font-size: 14px;
  font-weight: 700;
  font-family: "Averia", sans-serif;
  color: @cde-text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cde-super-meta {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cde-super-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.12s;
  flex-shrink: 0;

  a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 3px;
    color: @cde-muted;
    cursor: pointer;
    transition: color 0.12s, background 0.12s;

    i { font-size: 11px; }

    &:hover { color: @cde-text; background: fade(@cde-border-hi, 30%); }
  }
}

.cde-super-desc {
  padding: 6px 12px 8px 46px;
  border-top: 1px solid fade(@cde-border, 60%);
  background: fade(@cde-surface, 40%);
  font-size: 11px;
  color: @cde-muted;
  line-height: 1.5;

  p { margin: 0 0 4px; &:last-child { margin-bottom: 0; } }
  em { color: @cde-text; }
  strong { color: @cde-supernatural; }
}

.cde-super-empty {
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: @cde-muted;
  font-style: italic;
}

// NPC vitality / hei tracker
.cde-npc-tracks {
  margin-top: @cde-gap;

  .cde-track-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid @cde-border;

    &:last-child { border-bottom: none; }
  }

  .cde-track-label {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 120px;
    flex-shrink: 0;
    font-size: 11px;
    font-family: "Averia", sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: @cde-muted;

    i { font-size: 12px; }
  }

  .cde-track-value {
    display: flex;
    align-items: center;
    gap: 6px;

    input.cde-circle-input {
      width: 48px;
    }
  }

  .cde-track-sep {
    font-size: 14px;
    color: @cde-muted;
    font-weight: 700;
  }

  .cde-track-max {
    font-size: 15px;
    font-weight: 700;
    color: @cde-spell;
    text-shadow: 0 0 6px fade(@cde-spell, 40%);
    min-width: 28px;
    text-align: center;
  }

  .cde-track-note {
    flex: 1;
    input { width: 100%; }
  }
}

// ============================================================
// Loksyu — 5 elemental cards grid
// ============================================================
// ============================================================
// Chat buttons — Loksyu / TinJi quick-access
// ============================================================
.cde-chat-app-buttons {
  display: flex;
  gap: 6px;
  padding: 6px 8px 4px;
  border-top: 1px solid @cde-border;
  pointer-events: auto;  // sidebar has pointer-events:none — must override

  .cde-chat-btn {
    flex: 1 1 0;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 5px 8px;
    font-size: 11px;
    font-family: "Orbitron", "Averia", sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: @cde-surface;
    border: 1px solid @cde-border;
    border-radius: 4px;
    color: @cde-muted;
    cursor: pointer;
    transition: all 0.2s;

    i { font-size: 12px; }

    &:hover {
      background: fade(@cde-spell, 10%);
      border-color: @cde-spell;
      color: @cde-spell;
      box-shadow: 0 0 8px fade(@cde-spell, 30%);
    }

    &--tinji:hover {
      background: fade(@cde-kungfu, 10%);
      border-color: @cde-kungfu;
      color: @cde-kungfu;
      box-shadow: 0 0 8px fade(@cde-kungfu, 30%);
    }
  }
}

// ============================================================
// Loksyu standalone app
// ============================================================
.cde-loksyu-standalone {
  .cde-loksyu-app-body {
    padding: 12px;
  }

  .cde-loksyu-elements {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 10px;
  }

  .cde-lok-card {
    flex: 0 0 calc(33.333% - 6px);
    min-width: 140px;
    max-width: 160px;
    background: fade(@cde-surface, 80%);
    border: 1px solid @cde-border;
    border-radius: 6px;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
    transition: border-color 0.2s;

    &--wood  { &:hover { border-color: #4a9e3f; } .cde-lok-input:focus { border-bottom-color: #4a9e3f; } }
    &--fire  { &:hover { border-color: @cde-kungfu; } .cde-lok-input:focus { border-bottom-color: @cde-kungfu; } }
    &--earth { &:hover { border-color: #c88a3a; } .cde-lok-input:focus { border-bottom-color: #c88a3a; } }
    &--metal { &:hover { border-color: @cde-muted; } .cde-lok-input:focus { border-bottom-color: @cde-muted; } }
    &--water { &:hover { border-color: @cde-spell; } .cde-lok-input:focus { border-bottom-color: @cde-spell; } }
  }

  .cde-lok-header {
    display: flex;
    align-items: center;
    gap: 6px;

    img.cde-lok-icon { border-radius: 4px; flex-shrink: 0; }
  }

  .cde-lok-titles {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;

    .cde-lok-name {
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: @cde-text;
    }

    .cde-lok-qual {
      font-size: 9px;
      color: @cde-muted;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }

  .cde-lok-reset {
    color: @cde-muted;
    font-size: 11px;
    flex-shrink: 0;
    cursor: pointer;
    &:hover { color: @cde-text; }
  }

  .cde-lok-values {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .cde-lok-polarity {
    display: flex;
    align-items: center;
    gap: 4px;

    .cde-lok-pol-label {
      font-size: 9px;
      color: @cde-muted;
      width: 30px;
      flex-shrink: 0;
    }

    &--yang .cde-lok-pol-label { color: @cde-text; }
  }

  .cde-lok-input {
    flex: 1 1 0;
    background: transparent;
    border: none;
    border-bottom: 1px solid @cde-border;
    color: @cde-text;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    padding: 2px 0;
    transition: border-bottom-color 0.2s;
    width: 100%;

    &:focus { outline: none; }
    &[disabled] { opacity: 0.5; cursor: default; }
  }

  .cde-loksyu-visual-row {
    text-align: center;
    margin: 6px 0;

    .cde-lok-visual {
      max-width: 120px;
      max-height: 160px;
      width: auto;
      height: auto;
      opacity: 0.6;
      cursor: zoom-in;
      transition: opacity 0.2s ease, box-shadow 0.2s ease;

      &:hover {
        opacity: 0.9;
        box-shadow: 0 0 10px @cde-border-hi;
      }
    }
  }

  .cde-lok-footer {
    display: flex;
    justify-content: center;
    padding-top: 6px;
    border-top: 1px solid @cde-border;
    margin-top: 6px;
  }

  .cde-lok-reset-all {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    font-size: 11px;
    background: fade(@cde-kungfu, 12%);
    border: 1px solid fade(@cde-kungfu, 30%);
    border-radius: 4px;
    color: @cde-muted;
    cursor: pointer;
    transition: all 0.2s;

    &:hover {
      background: fade(@cde-kungfu, 20%);
      border-color: @cde-kungfu;
      color: @cde-text;
    }
  }
}

// ============================================================
// TinJi standalone app
// ============================================================
.cde-tinji-standalone {
  .cde-tinji-app-body {
    padding: 16px 12px;
    display: flex;
    align-items: center;
    gap: 16px;
  }

  .cde-tinji-display {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  .cde-tinji-chinese-large {
    font-size: 40px;
    color: @cde-kungfu;
    text-shadow: 0 0 20px fade(@cde-kungfu, 60%);
    line-height: 1;
    font-family: serif;
  }

  .cde-tinji-label {
    font-size: 11px;
    font-family: "Orbitron", sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: @cde-text;
    opacity: 0.75;
  }

  .cde-tinji-counter {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
  }

  .cde-tinji-step {
    width: 30px;
    height: 30px;
    background: @cde-surface2;
    border: 1px solid @cde-border-hi;
    border-radius: 50%;
    color: @cde-text;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;

    &:hover {
      background: fade(@cde-kungfu, 25%);
      border-color: @cde-kungfu;
      color: @cde-text;
    }
  }

  .cde-tinji-direct {
    width: 72px;
    background: transparent;
    border: none;
    border-bottom: 2px solid @cde-kungfu;
    color: @cde-kungfu;
    font-size: 36px;
    font-weight: 700;
    text-align: center;
    text-shadow: 0 0 12px fade(@cde-kungfu, 50%);
    padding: 0;

    &:focus { outline: none; }
    &[disabled] { opacity: 0.7; cursor: default; }
  }

  .cde-tinji-hint {
    font-size: 10px;
    color: @cde-muted;
    text-align: center;
  }

  .cde-tinji-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
  }

  .cde-tinji-spend-btn,
  .cde-tinji-reset-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.03em;
  }

  .cde-tinji-spend-btn {
    background: fade(@cde-kungfu, 25%);
    border: 1px solid @cde-kungfu;
    color: @cde-text;

    &:hover { background: fade(@cde-kungfu, 45%); border-color: lighten(@cde-kungfu, 10%); }
    &[disabled] { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
  }

  .cde-tinji-reset-btn {
    background: @cde-surface2;
    border: 1px solid @cde-border-hi;
    color: @cde-text;
    opacity: 0.85;

    &:hover { border-color: @cde-text; opacity: 1; }
  }

  .cde-tinji-visual {
    width: 90px;
    height: auto;
    opacity: 0.85;
    flex-shrink: 0;
  }
}

// Chat Tin Ji spend message
.cde-tinji-spend-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 8px 10px;
  background: fade(@cde-kungfu, 18%);
  border: 1px solid fade(@cde-kungfu, 35%);
  border-left: 4px solid @cde-kungfu;
  border-radius: 4px;
  color: @cde-text;

  .cde-tinji-icon {
    font-size: 18px;
    color: @cde-kungfu;
    text-shadow: 0 0 6px fade(@cde-kungfu, 70%);
    flex-shrink: 0;
    font-weight: 700;
    line-height: 1;
  }

  i {
    color: @cde-kungfu;
    font-size: 15px;
    filter: drop-shadow(0 0 4px fade(@cde-kungfu, 60%));
    flex-shrink: 0;
  }

  strong {
    color: @cde-kungfu;
    font-size: 13px;
    letter-spacing: 0.02em;
  }

  .cde-tinji-remain {
    margin-left: auto;
    font-size: 11px;
    color: fade(@cde-text, 65%);
    font-style: italic;
    white-space: nowrap;
  }
}

// Post-roll Loksyu draw message — rich notification card
.cde-loksyu-draw-msg {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  padding: 9px 11px;
  background: linear-gradient(135deg, fade(@cde-item, 10%) 0%, fade(@cde-surface, 95%) 100%);
  border: 1px solid fade(@cde-item, 40%);
  border-left: 4px solid @cde-item;
  border-radius: 5px;
  color: @cde-text;
  box-shadow: 0 2px 8px fade(@cde-item, 12%);

  .cde-loksyu-draw-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    font-size: 13px;
    line-height: 1.4;
  }

  .cde-loksyu-draw-aspect-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    filter: drop-shadow(0 0 4px fade(@cde-item, 60%));
    flex-shrink: 0;
  }

  .cde-loksyu-draw-user {
    font-weight: 700;
    color: @cde-item;
    letter-spacing: 0.03em;
  }

  .cde-loksyu-draw-action {
    color: fade(@cde-text, 65%);
    font-size: 12px;
    font-style: italic;
  }

  .cde-loksyu-draw-type {
    font-weight: 700;
    font-size: 13px;
    color: #c9a227;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-shadow: 0 0 6px fade(#c9a227, 40%);
  }

  .cde-loksyu-draw-from {
    color: fade(@cde-text, 60%);
    font-size: 11px;

    em {
      color: @cde-item;
      font-style: normal;
      font-weight: 600;
    }
  }

  .cde-loksyu-draw-footer {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: fade(@cde-text, 55%);
    padding-top: 4px;
    border-top: 1px solid fade(@cde-item, 20%);

    i {
      color: @cde-item;
      font-size: 10px;
    }

    .cde-loksyu-remain {
      color: @cde-item;
      font-weight: 700;
    }
  }
}

// Post-roll action buttons section inside a roll-result card
.cde-roll-actions {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid fade(@cde-border, 60%);

  .cde-roll-actions-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: fade(@cde-text, 50%);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;

    i { font-size: 9px; }
  }

  .cde-roll-actions-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
  }

  .cde-roll-action-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    font-size: 11px;
    font-family: "Courier New", Courier, monospace;
    border-radius: 3px;
    border: 1px solid fade(@cde-border, 80%);
    background: fade(@cde-surface, 90%);
    color: @cde-text;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    pointer-events: auto;
    line-height: 1.4;

    &:hover:not(:disabled) {
      border-color: fade(@cde-item, 70%);
      background: fade(@cde-item, 12%);
      box-shadow: 0 0 6px fade(@cde-item, 25%);
      color: @cde-item;
    }

    &:disabled {
      opacity: 0.35;
      cursor: not-allowed;
    }

    .cde-roll-action-icon {
      width: 16px;
      height: 16px;
      object-fit: contain;
      filter: drop-shadow(0 0 2px fade(@cde-item, 40%));
    }

    .cde-roll-action-label {
      flex: 1;
    }

    .cde-roll-action-count {
      background: fade(@cde-border, 60%);
      border-radius: 2px;
      padding: 1px 4px;
      font-size: 10px;
      font-weight: 700;
      min-width: 18px;
      text-align: center;
    }

    .cde-roll-action-tinji-char {
      font-size: 14px;
      line-height: 1;
      color: @cde-kungfu;
      text-shadow: 0 0 4px fade(@cde-kungfu, 60%);
    }

    &.cde-roll-action--success {
      &:hover:not(:disabled) {
        border-color: fade(#c9a227, 70%);
        background: fade(#c9a227, 10%);
        box-shadow: 0 0 6px fade(#c9a227, 25%);
        color: #c9a227;
      }
    }

    &.cde-roll-action--faste {
      &:hover:not(:disabled) {
        border-color: fade(@cde-item, 70%);
        background: fade(@cde-item, 10%);
        box-shadow: 0 0 6px fade(@cde-item, 25%);
        color: @cde-item;
      }
    }

    &.cde-roll-action--tinji {
      &:hover:not(:disabled) {
        border-color: fade(@cde-kungfu, 70%);
        background: fade(@cde-kungfu, 12%);
        box-shadow: 0 0 6px fade(@cde-kungfu, 30%);
        color: @cde-kungfu;

        .cde-roll-action-count {
          background: fade(@cde-kungfu, 25%);
        }
      }
    }
  }
}

.cde-loksyu-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: @cde-gap;
  padding: @cde-gap 0;
}

.cde-element-card {
  background: @cde-surface;
  border: 1px solid @cde-border;
  border-radius: @cde-radius;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: @cde-shadow-sm;
  transition: border-color 0.15s, box-shadow 0.15s;

  &:hover { box-shadow: @cde-shadow; }
}

// Per-element color theming using LESS variables
.cde-element--wood  { border-top: 3px solid @wu-green; .cde-element-name { color: @wu-green; text-shadow: 0 0 6px fade(@wu-green, 50%); } .cde-element-img { filter: drop-shadow(0 0 4px @wu-green); } .cde-element-polarity--yang { border-left: 2px solid fade(@wu-green, 70%); } }
.cde-element--fire  { border-top: 3px solid @wu-red;   .cde-element-name { color: @wu-red;   text-shadow: 0 0 6px fade(@wu-red,   50%); } .cde-element-img { filter: drop-shadow(0 0 4px @wu-red); }   .cde-element-polarity--yang { border-left: 2px solid fade(@wu-red,   70%); } }
.cde-element--earth { border-top: 3px solid @wu-brown; .cde-element-name { color: @wu-brown; text-shadow: 0 0 6px fade(@wu-brown, 50%); } .cde-element-img { filter: drop-shadow(0 0 4px @wu-brown); } .cde-element-polarity--yang { border-left: 2px solid fade(@wu-brown, 70%); } }
.cde-element--metal { border-top: 3px solid @wu-gray;  .cde-element-name { color: @wu-gray;  text-shadow: 0 0 6px fade(@wu-gray,  50%); } .cde-element-img { filter: drop-shadow(0 0 4px @wu-gray); }  .cde-element-polarity--yang { border-left: 2px solid fade(@wu-gray,  70%); } }
.cde-element--water { border-top: 3px solid @wu-blue;  .cde-element-name { color: @wu-blue;  text-shadow: 0 0 6px fade(@wu-blue,  50%); } .cde-element-img { filter: drop-shadow(0 0 4px @wu-blue); }  .cde-element-polarity--yang { border-left: 2px solid fade(@wu-blue,  70%); } }

// Input focus per element
.cde-element--wood  .cde-element-polarity input:focus { border-bottom-color: @wu-green; box-shadow: 0 1px 0 0 @wu-green; }
.cde-element--fire  .cde-element-polarity input:focus { border-bottom-color: @wu-red;   box-shadow: 0 1px 0 0 @wu-red;   }
.cde-element--earth .cde-element-polarity input:focus { border-bottom-color: @wu-brown; box-shadow: 0 1px 0 0 @wu-brown; }
.cde-element--metal .cde-element-polarity input:focus { border-bottom-color: @wu-gray;  box-shadow: 0 1px 0 0 @wu-gray;  }
.cde-element--water .cde-element-polarity input:focus { border-bottom-color: @wu-blue;  box-shadow: 0 1px 0 0 @wu-blue;  }

.cde-element-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.cde-element-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 0 4px var(--el-color));
}

.cde-element-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cde-element-name {
  font-family: "Averia", sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: @cde-muted;  // overridden per-element below
  white-space: nowrap;
}

.cde-element-qualities {
  font-size: 9px;
  color: @cde-muted;
  font-style: italic;
  line-height: 1.3;
  text-align: center;
  display: none; // hidden on small width, shown via media query if needed
}

.cde-element-values {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cde-element-polarity {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 4px;
  background: fade(@cde-bg, 60%);

  &--yin  { border-left: 2px solid fade(@cde-muted, 40%); }
}

.cde-polarity-label {
  font-size: 9px;
  font-family: "Averia", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: @cde-muted;
  white-space: nowrap;
  min-width: 32px;
}

.cde-element-polarity input {
  width: 40px;
  border: none;
  border-bottom: 1px solid @cde-border;
  background: transparent;
  color: @cde-text;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  padding: 2px 0;
  outline: none;
}

.cde-loksyu-visual-row {
  display: flex;
  justify-content: center;
  padding-top: @cde-gap;

  .loksyu-visual {
    max-width: 100%;
    height: auto;
    opacity: 0.7;
    border-radius: @cde-radius;
    border: 1px solid @cde-border;
  }
}

// ============================================================
// Tin Ji — enhanced display
// ============================================================
.cde-tinji-layout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: @cde-gap * 2;
  padding: @cde-gap;
  flex-wrap: wrap;
}

.cde-tinji-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.cde-tinji-chinese {
  font-size: 48px;
  color: @cde-supernatural;
  text-shadow: 0 0 20px fade(@cde-supernatural, 60%);
  line-height: 1;
  letter-spacing: 0.1em;
}

.cde-tinji-subtitle {
  font-family: "Averia", sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: @cde-muted;
}

.cde-tinji-value-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;

  .cde-tinji-input {
    width: 80px;
    text-align: center;
    font-size: 36px;
    font-weight: 700;
    color: @cde-supernatural;
    text-shadow: 0 0 12px fade(@cde-supernatural, 50%);
    border: none;
    border-bottom: 2px solid @cde-supernatural;
    background: transparent;
    outline: none;
    padding: 4px 0;

    &:focus {
      border-bottom-color: lighten(@cde-supernatural, 15%);
      box-shadow: 0 2px 0 0 fade(@cde-supernatural, 60%);
    }
  }
}

.cde-tinji-hint {
  font-size: 10px;
  font-family: "Averia", sans-serif;
  color: @cde-muted;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-align: center;
}

.tinji-visual {
  max-height: 280px;
  max-width: 200px;
  border-radius: @cde-radius;
  border: 1px solid @cde-border;
  box-shadow: @cde-shadow;
}

// ============================================================
// Weapon roll button + dialog
// ============================================================

.cde-weapon-roll-btn {
  color: @cde-weapon !important;
  &:hover { text-shadow: 0 0 6px fade(@cde-weapon, 60%); }
}

.cde-item-damage {
  color: @cde-weapon;
  font-weight: 700;
}

.cde-weapon-prompt {
  // Weapon info bar at top of dialog
  .cde-weapon-info-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: fade(@cde-weapon, 8%);
    border: 1px solid fade(@cde-weapon, 30%);
    border-radius: @cde-radius;
    margin-bottom: @cde-gap;

    .cde-weapon-aspect-icon {
      width: 36px;
      height: 36px;
      object-fit: contain;
    }

    .cde-weapon-info-text {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 2px;
    }

    .cde-weapon-info-name {
      font-size: 14px;
      font-weight: 700;
      font-family: "Averia", sans-serif;
      color: @cde-text;
    }

    .cde-weapon-info-meta {
      font-size: 10px;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: @cde-muted;
      font-family: "Averia", sans-serif;
    }

    .cde-weapon-info-badge {
      font-size: 20px;
      color: fade(@cde-weapon, 50%);
    }
  }
}

// Weapon damage result in chat card
.cde-rr-weapon-damage {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: fade(@cde-weapon, 10%);
  border-top: 1px solid fade(@cde-weapon, 30%);
  border-bottom: 1px solid fade(@cde-weapon, 30%);
  margin: 4px 0;

  .cde-rr-weapon-icon {
    font-size: 16px;
    color: @cde-weapon;
    text-shadow: 0 0 6px fade(@cde-weapon, 50%);
    flex-shrink: 0;
  }

  .cde-rr-weapon-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .cde-rr-weapon-name {
    font-size: 11px;
    font-family: "Averia", sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: @cde-muted;
  }

  .cde-rr-weapon-calc {
    font-size: 12px;
    color: @cde-text;
  }

  .cde-rr-weapon-total {
    font-size: 16px;
    font-weight: 900;
    color: @cde-weapon;
    text-shadow: 0 0 8px fade(@cde-weapon, 60%);
    margin: 0 2px;
  }

  .cde-rr-weapon-unit {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: @cde-muted;
  }
}

// ============================================================
// Magics tab — components grid + magic cards
// ============================================================

.cde-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-family: "Averia", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: @cde-muted;
  border-bottom: 1px solid @cde-border;
  padding-bottom: 6px;
  margin-bottom: 10px;

  i { font-size: 11px; }

  &--top-margin { margin-top: 18px; }
}

// 2-column grid for the 10 components
.cde-components-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.cde-component-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  background: @cde-surface;
  border: 1px solid @cde-border;
  border-radius: @cde-radius;
  padding: 4px 8px;

  &:hover { border-color: @cde-border-hi; }
}

.cde-component-die {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
  opacity: 0.85;
}

.cde-component-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  color: @cde-text;
  font-size: 12px;
  padding: 2px 0;

  &:focus {
    outline: none;
    border-bottom-color: @cde-spell;
  }

  &::placeholder { color: @cde-muted; font-style: italic; font-size: 11px; }
}

.cde-component-random-row {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}

.cde-btn-random-component {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: fade(@cde-spell, 8%);
  border: 1px solid fade(@cde-spell, 35%);
  border-radius: @cde-radius;
  color: @cde-spell;
  font-family: "Averia", sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;

  i { font-size: 14px; }

  &:hover {
    background: fade(@cde-spell, 16%);
    box-shadow: 0 0 8px fade(@cde-spell, 30%);
  }
}

// === Magic type cards ===
.cde-magic-card {
  background: @cde-surface;
  border: 1px solid @cde-border;
  border-left: 3px solid @cde-border-hi;
  border-radius: @cde-radius;
  margin-bottom: 8px;
  overflow: hidden;
  box-shadow: @cde-shadow-sm;
}

.cde-magic-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

.cde-magic-aspect-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.cde-magic-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.cde-magic-name {
  font-family: "Averia", sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: @cde-text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cde-magic-aspect-name {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: @cde-muted;
  font-family: "Averia", sans-serif;
}

.cde-magic-value-input {
  width: 52px;
  flex-shrink: 0;
}

.cde-magic-roll-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: @cde-radius;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;

  i { font-size: 15px; }

  &:hover { background: fade(@cde-spell, 15%); }
}

.cde-magic-toggle {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: @cde-muted;
  flex-shrink: 0;

  input[type="checkbox"] { display: none; }

  i { font-size: 11px; transition: color 0.15s; }

  &:hover i { color: @cde-text; }
}

// Specialities list
.cde-magic-specialities {
  border-top: 1px solid @cde-border;
  padding: 4px 0;
}

.cde-magic-spec-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 42px; // indent aligned with aspect icon
  opacity: 0.55;
  transition: opacity 0.12s, background 0.12s;

  &:hover { opacity: 1; background: fade(@cde-border-hi, 30%); }
  &--active { opacity: 1; }
}

.cde-magic-spec-check-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;

  input[type="checkbox"] { display: none; }

  .cde-spec-checkbox-ui {
    width: 14px;
    height: 14px;
    border: 1px solid @cde-muted;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.12s, background 0.12s;
  }

  input:checked + .cde-spec-checkbox-ui {
    background: @cde-spell;
    border-color: @cde-spell;

    &::after {
      content: "✓";
      font-size: 9px;
      color: @cde-bg;
      line-height: 1;
    }
  }
}

.cde-magic-spec-element {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
}

.cde-magic-spec-polarity {
  font-size: 10px;
  font-family: "Averia", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: @cde-muted;
  width: 42px;
  flex-shrink: 0;

  &.icon-yin    { color: @cde-supernatural; }
  &.icon-yang   { color: @cde-item; }
  &.icon-yinyang { color: @cde-spell; }
}

.cde-magic-spec-name {
  flex: 1;
  font-size: 12px;
  color: @cde-text;
  font-family: "Averia", sans-serif;
}

.cde-magic-spec-roll-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: @cde-radius;
  cursor: pointer;
  color: @cde-muted;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;

  i { font-size: 12px; }

  &:hover { color: @cde-spell; background: fade(@cde-spell, 12%); }
}

// Per-magic accent colors using direct Wu Xing LESS variables
.cde-magic--internalcinnabar {
  border-left-color: @wu-gray;
  .cde-magic-name { color: lighten(@wu-gray, 20%); }
  .cde-magic-roll-btn i { color: @wu-gray; }
}
.cde-magic--alchemy {
  border-left-color: @wu-blue;
  .cde-magic-name { color: lighten(@wu-blue, 15%); }
  .cde-magic-roll-btn i { color: @wu-blue; }
}
.cde-magic--masteryoftheway {
  border-left-color: @wu-brown;
  .cde-magic-name { color: lighten(@wu-brown, 20%); }
  .cde-magic-roll-btn i { color: lighten(@wu-brown, 10%); }
}
.cde-magic--exorcism {
  border-left-color: @wu-red;
  .cde-magic-name { color: lighten(@wu-red, 20%); }
  .cde-magic-roll-btn i { color: @wu-red; }
}
.cde-magic--geomancy {
  border-left-color: @wu-green;
  .cde-magic-name { color: lighten(@wu-green, 15%); }
  .cde-magic-roll-btn i { color: @wu-green; }
}

// =====================================================================
// GRIMOIRE (spell list integrated in magic discipline cards)
// =====================================================================

.cde-grimoire-section {
  border-top: 1px dashed fade(@cde-border, 60%);
  margin-top: 6px;
  padding-top: 6px;
}

.cde-grimoire-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 10px;
  font-family: "Averia", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: @cde-muted;

  i { font-size: 10px; color: @cde-spell; }

  span { flex: 1; }
}

.cde-grimoire-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  cursor: pointer;
  color: @cde-muted;
  transition: color 0.12s, background 0.12s;

  i { font-size: 10px; }

  &:hover { color: @cde-spell; background: fade(@cde-spell, 15%); }
}

.cde-grimoire-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cde-grimoire-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 14px;
  border-bottom: 1px solid fade(@cde-border, 40%);
  transition: background 0.1s;

  &:last-child { border-bottom: none; }

  &:hover {
    background: fade(@cde-border, 25%);

    .cde-grimoire-controls { opacity: 1; }
  }
}

.cde-grimoire-img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  border-radius: 2px;
  flex-shrink: 0;
}

.cde-grimoire-name {
  flex: 1;
  font-size: 12px;
  color: @cde-text;
  font-family: "Averia", sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cde-grimoire-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: @cde-muted;
  flex-shrink: 0;

  em {
    color: @cde-spell;
    font-style: normal;
    font-size: 10px;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.cde-grimoire-diff, .cde-grimoire-hei {
  display: flex;
  align-items: center;
  gap: 3px;

  i { font-size: 9px; }
}

.cde-grimoire-diff { color: @cde-muted; }
.cde-grimoire-hei  { color: @cde-kungfu; }

.cde-grimoire-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.12s;
  flex-shrink: 0;

  a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    color: @cde-muted;
    cursor: pointer;
    transition: color 0.12s, background 0.12s;

    i { font-size: 10px; }

    &:hover { color: @cde-text; background: fade(@cde-border-hi, 30%); }
  }
}

.cde-grimoire-empty {
  padding: 4px 14px 8px;
  font-size: 11px;
  color: @cde-muted;
  font-style: italic;
  margin: 0;
}

// =====================================================================
// KUNG-FU CARDS (actor tab redesign)
// =====================================================================

.cde-kf-add-row {
  display: flex;
  justify-content: flex-end;
  padding: 4px 0 8px;
}

.cde-kf-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-family: "Averia", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: @cde-muted;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: @cde-radius;
  border: 1px solid @cde-border;
  transition: color 0.12s, border-color 0.12s, background 0.12s;

  i { font-size: 10px; }

  &:hover { color: @cde-kungfu; border-color: @cde-kungfu; background: fade(@cde-kungfu, 8%); }
}

.cde-kf-card {
  border: 1px solid @cde-border;
  border-left: 3px solid @cde-kungfu;
  border-radius: @cde-radius;
  background: fade(@cde-surface, 70%);
  margin-bottom: 10px;
  overflow: hidden;
  transition: box-shadow 0.15s;

  &:hover { box-shadow: 0 0 8px fade(@cde-kungfu, 20%); }

  &.cde-kf--metal  { border-left-color: @wu-gray; }
  &.cde-kf--eau    { border-left-color: @wu-blue; }
  &.cde-kf--terre  { border-left-color: lighten(@wu-brown, 10%); }
  &.cde-kf--feu    { border-left-color: @wu-red; }
  &.cde-kf--bois   { border-left-color: @wu-green; }
}

.cde-kf-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;

  &:hover .cde-kf-controls { opacity: 1; }
}

.cde-kf-aspect-icon {
  width: 26px;
  height: 26px;
  object-fit: contain;
  flex-shrink: 0;
}

.cde-kf-orient-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
  opacity: 0.75;
}

.cde-kf-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cde-kf-name {
  font-size: 14px;
  font-weight: 700;
  font-family: "Averia", sans-serif;
  color: @cde-text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cde-kf-meta {
  font-size: 10px;
  color: @cde-muted;
  font-family: "Averia", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;

  em { color: @cde-text; font-style: normal; }
}

.cde-kf-roll-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: @cde-radius;
  cursor: pointer;
  color: @cde-muted;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;

  i { font-size: 14px; }

  &:hover { color: @cde-kungfu; background: fade(@cde-kungfu, 15%); }
}

.cde-kf-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.12s;
  flex-shrink: 0;

  a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 3px;
    color: @cde-muted;
    cursor: pointer;
    transition: color 0.12s, background 0.12s;

    i { font-size: 11px; }

    &:hover { color: @cde-text; background: fade(@cde-border-hi, 30%); }
  }
}

.cde-kf-style-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 12px 6px 44px;
  border-top: 1px solid fade(@cde-border, 60%);
  background: fade(@cde-surface, 40%);
}

.cde-kf-style-label {
  font-size: 10px;
  font-family: "Averia", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: @cde-kungfu;
  flex-shrink: 0;

  i { font-size: 9px; }
}

.cde-kf-style-text {
  font-size: 11px;
  color: @cde-text;
  font-family: "Averia", sans-serif;
  font-style: italic;
}

.cde-kf-techniques {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid fade(@cde-border, 50%);
}

.cde-kf-tech {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 44px;
  border-bottom: 1px solid fade(@cde-border, 30%);
  opacity: 0.5;
  transition: opacity 0.1s, background 0.1s;

  &:last-child { border-bottom: none; }
  &--mastered { opacity: 1; }
  &:hover { background: fade(@cde-border, 20%); opacity: 1; }
}

.cde-kf-tech-mastered {
  font-size: 11px;
  flex-shrink: 0;
  width: 14px;
  text-align: center;

  .cde-kf-tech--mastered & { color: @cde-kungfu; }
  .cde-kf-tech:not(.cde-kf-tech--mastered) & { color: @cde-muted; }
}

.cde-act-badge {
  font-size: 9px;
  font-family: "Averia", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 5px;
  border-radius: 3px;
  flex-shrink: 0;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid currentColor;

  &.cde-act--action-attack         { color: @wu-red;    background: fade(@wu-red, 10%); }
  &.cde-act--action-defense        { color: @wu-blue;   background: fade(@wu-blue, 10%); }
  &.cde-act--action-aid            { color: @wu-green;  background: fade(@wu-green, 10%); }
  &.cde-act--action-attack-defense { color: @wu-gray;   background: fade(@wu-gray, 12%); }
  &.cde-act--reaction              { color: @wu-brown;  background: fade(@wu-brown, 12%); }
  &.cde-act--dice                  { color: @cde-spell; background: fade(@cde-spell, 10%); }
  &.cde-act--damage-inflicted      { color: @cde-weapon; background: fade(@cde-weapon, 10%); }
  &.cde-act--damage-received       { color: @cde-muted; background: fade(@cde-border, 20%); }
}

.cde-kf-tech-name {
  flex: 1;
  font-size: 12px;
  color: @cde-text;
  font-family: "Averia", sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  em { color: @cde-muted; }
}

.cde-kf-empty {
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: @cde-muted;
  font-style: italic;
}

// Random component chat message
.cde-chat-random-component {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
}

.cde-chat-component-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: @cde-muted;
  font-family: "Averia", sans-serif;
}

.cde-chat-component-value {
  font-size: 16px;
  font-weight: 700;
  color: @cde-spell;
  text-shadow: 0 0 8px fade(@cde-spell, 50%);
}

// Legacy tabs (actor sheets still use cde-tabs)
.cde-tabs {
  margin-top: @cde-gap;
  border-bottom: 1px solid @cde-border;

  .item {
    color: @cde-muted;
    padding: 8px 12px;
    font-size: 11px;
    font-family: "Averia", sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;

    &:hover { color: @cde-text; }

    &.active {
      color: @cde-item;
      background: @cde-surface;
      border: 1px solid @cde-border;
      border-bottom: 1px solid @cde-surface;
      border-radius: @cde-radius @cde-radius 0 0;
    }
  }
}


/* =============================================
   Global UI Rules
   =============================================*/

#logo {
  content: url("/systems/fvtt-chroniques-de-l-etrange/images/logo_jeu.webp");
  width: 100px;
  height: 100px;
  margin-left: 7px;
  margin-top: -2px;
}

#pause > img {
  content: url("/systems/fvtt-chroniques-de-l-etrange/images/wheel.webp");
  height: 192px;
  width: 192px;
  top: -45px;
  left: calc(50% - 96px);
}

#pause.paused {
  animation: none;
}

a.compendium-name,
a.entry-name,
strong.ellipsis {
  font-family: "Averia";
}



/* concerne les pages de journaux */

.journal-header input {
  font-family: "Averia";
}

.journal-entry-page h1 {
  font-family: "Averia";
  text-align: center;
  color:hsla(249, 66%, 58%, 0.874);
  border-bottom: 1px solid orange;
  border-top: 1px solid orange;
  border-top: 1px solid orange;

}

.journal-entry-page h2 {
  font-family: "Averia";
  color:orange;
  border-bottom: 0px;
  border-top: 1px solid orange;
}

.journal-entry-page h3,
.journal-entry-page h4,
.journal-entry-page h5,
.journal-entry-page h6 {
  font-family: "Averia";
  color:hsla(249, 66%, 58%, 0.874);
  border-bottom: 0px;
}

/* concerne le Tchat */

#interface .chat-message .message-header img {
  max-width: 80px;
  border-radius: 5px;
  border: 0.5px solid black;
  /* max-width: 50px; */
  /* max-height: 50px; */
  margin-right: 4px;
}

#interface .chat-message .message-header .message-sender {
  width: 100px;
}

// ============================================================
// Three Treasures partial layout
// ============================================================
.cde-flex-center-text {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.cde-flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

// ============================================================
// Circle input — replaces cercle.webp overlay approach
// ============================================================
.cde-circle-input {
  width: 44px !important;
  height: 44px !important;
  border-radius: 50%;
  border: 2px solid @cde-border-hi;
  background: @cde-surface;
  color: @cde-text;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0;
  flex-shrink: 0;
  display: inline-block !important;
  line-height: 40px;
  vertical-align: middle;
  box-sizing: border-box;

  &:focus {
    outline: none;
    border-color: @cde-item;
    box-shadow: 0 0 8px fade(@cde-item, 40%);
  }

  &.cde-circle-sm {
    width: 32px !important;
    height: 32px !important;
    font-size: 0.85rem;
    line-height: 28px;
  }
}

// ============================================================
// Skills table
// ============================================================
.cde-skills-table {
  width: 100%;
  border-collapse: collapse;

  tr { border-bottom: 1px solid @cde-border; }
  tr:last-child { border-bottom: none; }

  td {
    padding: 3px 4px;
    vertical-align: middle;
  }

  td.click, td.noclick {
    width: 30px;
    min-width: 30px;
    text-align: center;
    cursor: pointer;

    &:hover img { filter: drop-shadow(0 0 5px @cde-item); }
  }

  td.noclick { cursor: default; opacity: 0.4; }

  .cde-skill-label {
    white-space: nowrap;
    font-size: 0.8rem;
    padding-right: 8px;
  }

  .cde-val-cell {
    width: 52px;
    min-width: 52px;
    text-align: center;
    padding: 4px;
  }

  .cde-spec-cell {
    width: 100%;
    input[type="text"] { width: 100%; }
  }

  .cde-bonus-cell {
    white-space: nowrap;
    font-family: monospace;
    font-size: 0.65rem;
    color: @cde-muted;
    padding: 0 6px;
  }

  .cde-check-cell { width: 22px; text-align: center; }
}

// ============================================================
// Three Treasures layout (HEI / SAN-ZING / PTAO)
// ============================================================
.cde-tt-block {
  margin-bottom: 12px;

  .cde-tt-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
  }

  .cde-tt-labels {
    margin-bottom: 4px;
    span {
      width: 52px;
      text-align: center;
      font-family: "Averia", sans-serif;
      font-size: 0.6rem;
      text-transform: uppercase;
      color: @cde-muted;
    }
    .cde-tt-center { width: 44px; }
  }

  .cde-tt-yinyang {
    width: 44px;
    height: 44px;
    opacity: 0.8;
  }
}

.cde-tt-sanzing {
  margin-bottom: 12px;

  .cde-tt-sz-header,
  .cde-tt-sz-row {
    display: grid;
    grid-template-columns: 36px 48px 1fr 48px 36px;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
  }

  .cde-tt-sz-header {
    font-family: "Averia", sans-serif;
    font-size: 0.6rem;
    text-transform: uppercase;
    color: @cde-muted;
    text-align: center;
  }

  .cde-tt-sz-row {
    border-top: 1px solid @cde-border;

    .cde-circle-input { justify-self: center; }
  }

  .cde-tt-level {
    text-align: center;
    font-family: monospace;
    font-size: 0.75rem;
    font-weight: 700;
    color: @cde-muted;
  }
}

// ============================================================
// Ng Hang — Aspects grid
// ============================================================
.cde-aspects-header {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;

  .cde-aspects-logo {
    max-height: 48px;
    opacity: 0.7;
  }
}

.cde-aspects-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}

.cde-aspect-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px;
  border-radius: 4px;
  background: @cde-surface;
  border: 1px solid @cde-border;
  min-width: 88px;
  flex: 1 1 88px;
  max-width: 120px;

  .cde-aspect-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
  }

  .cde-aspect-gif { width: 36px; height: 36px; }

  .cde-aspect-name {
    font-family: "Averia";
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }

  .cde-aspect-roll {
    display: flex;
    align-items: center;
    gap: 6px;

    .cde-roll-trigger {
      cursor: pointer;
      display: flex;
      align-items: center;

      &:hover img { filter: drop-shadow(0 0 5px currentColor); }
    }
  }

  .cde-aspect-qual {
    font-size: 0.6rem;
    color: @cde-muted;
    text-align: center;
    line-height: 1.3;
  }

  &.cde-aspect--fire {
    border-color: @cde-kungfu;
    .cde-aspect-name { color: @cde-kungfu; }
    .cde-circle-input:focus { border-color: @cde-kungfu; box-shadow: 0 0 6px @cde-kungfu; }
  }

  &.cde-aspect--wood {
    border-color: #44bb44;
    .cde-aspect-name { color: #55cc55; }
    .cde-circle-input:focus { border-color: #55cc55; box-shadow: 0 0 6px #55cc55; }
  }

  &.cde-aspect--earth {
    border-color: #aa7722;
    .cde-aspect-name { color: #cc9933; }
    .cde-circle-input:focus { border-color: #cc9933; box-shadow: 0 0 6px #cc9933; }
  }

  &.cde-aspect--water {
    border-color: @cde-spell;
    .cde-aspect-name { color: @cde-spell; }
    .cde-circle-input:focus { border-color: @cde-spell; box-shadow: 0 0 6px @cde-spell; }
  }

  &.cde-aspect--metal {
    border-color: @cde-muted;
    .cde-aspect-name { color: @cde-text; }
    .cde-circle-input:focus { border-color: @cde-item; box-shadow: 0 0 6px @cde-item; }
  }
}

.cde-nghang-diagram {
  display: flex;
  justify-content: center;
  margin-top: 8px;

  img {
    max-width: 100%;
    max-height: 180px;
    opacity: 0.45;
    border-radius: 4px;
    cursor: zoom-in;
    transition: opacity 0.2s ease, box-shadow 0.2s ease;

    &:hover {
      opacity: 0.85;
      box-shadow: 0 0 12px @cde-border-hi;
    }
  }
}

.img-die-sm {
  width: 27px !important;
  height: 27px !important;
  flex-shrink: 0;
}

// ============================================================
// Magics partial layout
// ============================================================
.cde-magics-table {
  td.image {
    width: 2.2%;
    &.td-die { width: 2%; }
  }
  td.value { width: 25%; }
  td.td-spacer { width: 2.2%; }
}

.chancethrow {
  display: flex;
  justify-content: center;
  align-items: center;
}

// ============================================================
// Actor sheet item lists
// ============================================================
.cde-item-group-label {
  font-family: "Averia", sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: @cde-muted;
  padding: 2px 6px;
  border-left: 2px solid @cde-border-hi;
  margin: 8px 0 2px;
  flex-shrink: 0;
}

ol.item-list {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;

  li.item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 6px;
    border-radius: 4px;
    background: @cde-surface;
    border: 1px solid @cde-border;
    margin-bottom: 2px;

    img { border: none; border-radius: 3px; flex-shrink: 0; }

    h4.item-name { flex: 1 1 0; margin: 0; font-size: 13px; color: @cde-text; }

    .cde-item-stat {
      font-family: monospace;
      font-size: 11px;
      color: @cde-muted;
    }

    .item-controls {
      display: flex;
      gap: 4px;
      flex-shrink: 0;

      a.item-control {
        color: @cde-muted;
        &:hover { color: @cde-text; }
      }
    }
  }
}

// ============================================================
// Roll Prompt Dialogs (.cde-roll-prompt)
// ============================================================

.cde-roll-prompt {
  background: @cde-bg;
  color: @cde-text;
  font-family: "Averia", sans-serif;
  padding: 12px 14px;

  &.cde-roll-prompt--magic {
    min-width: 340px;
  }

  .cde-roll-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    margin-bottom: 10px;
    border-bottom: 1px solid @cde-border;
  }

  .cde-roll-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: @cde-text;
  }

  .cde-roll-dice-count {
    font-size: 36px;
    font-weight: 900;
    color: @cde-item;
    line-height: 1;
    text-align: center;
    margin: 4px 0 8px;
    text-shadow: 0 0 12px fade(@cde-item, 60%);

    .cde-roll-dice-label {
      font-size: 14px;
      font-weight: 600;
      color: @cde-muted;
      margin-left: 4px;
    }
  }

  .cde-roll-section {
    margin-bottom: 8px;

    &.cde-roll-section--separator {
      padding-bottom: 10px;
      margin-bottom: 10px;
      border-bottom: 1px dashed @cde-border;
    }
  }

  .cde-roll-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: @cde-muted;
    margin: 0 0 6px;
  }

  .cde-roll-fields {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .cde-roll-field {
    display: flex;
    align-items: center;
    gap: 8px;

    label {
      flex: 0 0 160px;
      font-size: 11px;
      color: @cde-muted;
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }

    select,
    .cde-roll-input {
      flex: 1;
      background: @cde-surface;
      border: none;
      border-bottom: 1px solid @cde-border;
      color: @cde-text;
      font-family: monospace;
      font-size: 13px;
      padding: 3px 6px;
      border-radius: 2px;

      &:focus {
        outline: none;
        border-bottom-color: @cde-item;
        box-shadow: 0 1px 0 0 @cde-item;
      }
    }

    select option {
      background: @cde-surface;
      color: @cde-text;
    }
  }

  .cde-roll-hint {
    font-size: 10px;
    color: @cde-muted;
    margin: 4px 0 0;
    font-style: italic;
  }
}

// ============================================================
// Dice Roll Result in Chat (.cde-roll-result)
// ============================================================

// Wu Xing aspect color + icon custom properties
// Row order: [successes, auspicious, noxious, loksyu, tinji]
// Colors: wood=#41a436 fire=#cd171a earth=#a85747 metal=#70706e water=#009fe2

@wu-green:  #41a436;
@wu-red:    #cd171a;
@wu-brown:  #a85747;
@wu-gray:   #70706e;
@wu-blue:   #009fe2;

@wu-img-bois:  ~"url(/systems/fvtt-chroniques-de-l-etrange/images/cde_bois.webp)";
@wu-img-feu:   ~"url(/systems/fvtt-chroniques-de-l-etrange/images/cde_feu.webp)";
@wu-img-terre: ~"url(/systems/fvtt-chroniques-de-l-etrange/images/cde_terre.webp)";
@wu-img-metal: ~"url(/systems/fvtt-chroniques-de-l-etrange/images/cde_metal.webp)";
@wu-img-eau:   ~"url(/systems/fvtt-chroniques-de-l-etrange/images/cde_eau.webp)";

// Wu Xing aspect custom properties (accent color + icon per aspect)
// Sets --rr-accent on the card root, plus per-row --rr-color/--rr-icon
[data-aspect="wood"] {
  --rr-accent: @wu-green;
  --rr-accent-bg: fade(@wu-green, 12%);
  .cde-rr-row--auspicious { --rr-color: @wu-red;    --rr-icon: @wu-img-feu;   }
  .cde-rr-row--noxious    { --rr-color: @wu-blue;   --rr-icon: @wu-img-eau;   }
  .cde-rr-row--loksyu     { --rr-color: @wu-brown;  --rr-icon: @wu-img-terre; }
  .cde-rr-row--tinji      { --rr-color: @wu-gray;   --rr-icon: @wu-img-metal; }
}
[data-aspect="fire"] {
  --rr-accent: @wu-red;
  --rr-accent-bg: fade(@wu-red, 12%);
  .cde-rr-row--auspicious { --rr-color: @wu-brown;  --rr-icon: @wu-img-terre; }
  .cde-rr-row--noxious    { --rr-color: @wu-green;  --rr-icon: @wu-img-bois;  }
  .cde-rr-row--loksyu     { --rr-color: @wu-gray;   --rr-icon: @wu-img-metal; }
  .cde-rr-row--tinji      { --rr-color: @wu-blue;   --rr-icon: @wu-img-eau;   }
}
[data-aspect="earth"] {
  --rr-accent: @wu-brown;
  --rr-accent-bg: fade(@wu-brown, 12%);
  .cde-rr-row--auspicious { --rr-color: @wu-gray;   --rr-icon: @wu-img-metal; }
  .cde-rr-row--noxious    { --rr-color: @wu-red;    --rr-icon: @wu-img-feu;   }
  .cde-rr-row--loksyu     { --rr-color: @wu-blue;   --rr-icon: @wu-img-eau;   }
  .cde-rr-row--tinji      { --rr-color: @wu-green;  --rr-icon: @wu-img-bois;  }
}
[data-aspect="metal"] {
  --rr-accent: @wu-gray;
  --rr-accent-bg: fade(@wu-gray, 16%);
  .cde-rr-row--auspicious { --rr-color: @wu-blue;   --rr-icon: @wu-img-eau;   }
  .cde-rr-row--noxious    { --rr-color: @wu-brown;  --rr-icon: @wu-img-terre; }
  .cde-rr-row--loksyu     { --rr-color: @wu-green;  --rr-icon: @wu-img-bois;  }
  .cde-rr-row--tinji      { --rr-color: @wu-red;    --rr-icon: @wu-img-feu;   }
}
[data-aspect="water"] {
  --rr-accent: @wu-blue;
  --rr-accent-bg: fade(@wu-blue, 12%);
  .cde-rr-row--auspicious { --rr-color: @wu-green;  --rr-icon: @wu-img-bois;  }
  .cde-rr-row--noxious    { --rr-color: @wu-gray;   --rr-icon: @wu-img-metal; }
  .cde-rr-row--loksyu     { --rr-color: @wu-red;    --rr-icon: @wu-img-feu;   }
  .cde-rr-row--tinji      { --rr-color: @wu-brown;  --rr-icon: @wu-img-terre; }
}

.cde-roll-result {
  background: @cde-bg;
  color: @cde-text;
  font-family: 'Share Tech Mono', monospace;
  border-radius: 4px;
  border: 1px solid @cde-border;
  overflow: hidden;

  // ---- Header ----
  .cde-rr-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--rr-accent-bg, fade(@cde-surface, 80%));
    border-left: 4px solid var(--rr-accent, @cde-border);
    border-bottom: 1px solid @cde-border;
    gap: 8px;

    .cde-rr-header-left {
      display: flex;
      align-items: center;
      gap: 10px;
      flex: 1;
    }

    .cde-rr-aspect-icon {
      width: 32px;
      height: 32px;
      object-fit: contain;
      filter: drop-shadow(0 0 4px var(--rr-accent, @cde-border));
      border: none;
    }

    .cde-rr-header-text {
      display: flex;
      flex-direction: column;
    }

    .cde-rr-aspect-label {
      font-size: 11px;
      font-weight: 900;
      text-transform: uppercase;
      letter-spacing: 0.12em;
      color: var(--rr-accent, @cde-text);
      text-shadow: 0 0 6px var(--rr-accent, transparent);
    }

    .cde-rr-roll-label {
      font-size: 13px;
      font-weight: 600;
      color: @cde-text;
    }

    .cde-rr-header-right {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 2px;
    }

    .cde-rr-actor-avatar {
      width: 28px;
      height: 28px;
      border-radius: 50%;
      border: 1px solid var(--rr-accent, @cde-border);
      object-fit: cover;
    }

    .cde-rr-actor-name {
      font-size: 9px;
      color: @cde-muted;
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }
  }

  // ---- Hero: successes count ----
  .cde-rr-hero {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: fade(@cde-surface, 40%);

    .cde-rr-hero-count {
      font-size: 48px;
      font-weight: 900;
      line-height: 1;
      color: var(--rr-accent, @cde-text);
      text-shadow: 0 0 16px var(--rr-accent, transparent), 0 0 32px var(--rr-accent, transparent);
    }

    .cde-rr-hero-right {
      display: flex;
      flex-direction: column;
    }

    .cde-rr-hero-label {
      font-size: 11px;
      font-weight: 900;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      color: var(--rr-accent, @cde-text);
    }

    .cde-rr-hero-dice {
      font-size: 13px;
      color: @cde-muted;
      margin-top: 2px;
    }

    .cde-rr-hero-dice-label {
      font-size: 10px;
    }

    .cde-rr-spell-power {
      margin-left: auto;
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      border-left: 2px solid var(--rr-accent, @cde-border);
      padding-left: 10px;

      .cde-rr-spell-power-count {
        font-size: 32px;
        font-weight: 900;
        line-height: 1;
        color: var(--rr-accent, @cde-text);
        text-shadow: 0 0 12px var(--rr-accent, transparent);
      }

      .cde-rr-spell-power-label {
        font-size: 9px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        color: @cde-muted;
      }
    }

    // Loksyu bonus badge (shown when dice drawn from Loksyu)
    .cde-rr-loksyu-bonus {
      display: inline-flex;
      align-items: center;
      gap: 3px;
      font-size: 13px;
      font-weight: 700;
      padding: 2px 6px;
      border-radius: 3px;
      animation: cde-pulse-in 0.3s ease;

      &.cde-rr-loksyu-bonus--success {
        background: fade(#c9a227, 20%);
        border: 1px solid fade(#c9a227, 50%);
        color: #c9a227;
        text-shadow: 0 0 6px fade(#c9a227, 60%);
      }

      &.cde-rr-loksyu-bonus--faste {
        background: fade(@cde-item, 15%);
        border: 1px solid fade(@cde-item, 40%);
        color: @cde-item;
        text-shadow: 0 0 6px fade(@cde-item, 50%);
      }
    }
  }

  @keyframes cde-pulse-in {
    from { opacity: 0; transform: scale(0.7); }
    to   { opacity: 1; transform: scale(1); }
  }

  // ---- Detail rows ----
  .cde-rr-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 10px;
  }

  .cde-rr-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 6px;
    border-radius: 3px;
    background: fade(@cde-surface, 60%);
    color: var(--rr-color, @cde-muted);

    .cde-rr-count {
      font-size: 18px;
      font-weight: 900;
      line-height: 1;
      min-width: 26px;
      text-align: center;
      text-shadow: 0 0 6px currentColor;
    }

    // Inline Loksyu bonus badge in detail rows
    .cde-rr-loksyu-bonus {
      font-size: 10px;
      font-weight: 700;
      padding: 1px 4px;
      border-radius: 2px;
      background: fade(@cde-item, 15%);
      border: 1px solid fade(@cde-item, 40%);
      color: @cde-item;
      text-shadow: 0 0 4px fade(@cde-item, 50%);
      flex-shrink: 0;
    }

    .cde-rr-icon {
      width: 22px;
      height: 22px;
      background-image: var(--rr-icon);
      background-size: contain;
      background-repeat: no-repeat;
      background-position: center;
      flex-shrink: 0;
      opacity: 0.85;
    }

    .cde-rr-label {
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.07em;
      flex: 1;
    }

    .cde-rr-partition {
      font-size: 9px;
      color: @cde-muted;
      margin-left: 4px;
    }
  }

  // ---- Footer modifiers ----
  .cde-rr-footer {
    padding: 5px 12px;
    border-top: 1px solid @cde-border;
    background: fade(@cde-surface, 30%);
    display: flex;
    align-items: baseline;
    gap: 6px;

    .cde-rr-footer-label {
      font-size: 9px;
      font-weight: 700;
      text-transform: uppercase;
      color: @cde-muted;
      letter-spacing: 0.08em;
    }

    .cde-rr-footer-text {
      font-size: 10px;
      color: @cde-muted;
      font-family: "Averia", sans-serif;
    }
  }

  // ---- Dice face grid ----
  .cde-dice-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 3px;
    padding: 8px 8px 6px;
    border-top: 1px solid @cde-border;

    .cde-dice-cell {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 1px;

      .cde-dice-count {
        font-size: 12px;
        font-weight: 700;
        color: @cde-text;
        line-height: 1;
      }

      .cde-dice-plate {
        width: 100%;
        border: none;
        opacity: 0.65;
      }
    }
  }
}


// ============================================================
// Initiative prompt dialog
// ============================================================
.cde-initiative-prompt {
  // Override: fields use vertical layout (label on top, control below)
  // to avoid the fixed 160px label squeezing the select to 12px.
  .cde-roll-field {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;

    label {
      flex: none;
      font-size: 10px;
      color: @cde-muted;
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }

    select, .cde-roll-input {
      flex: none;
      width: 100%;
    }
  }

  .cde-initiative-base-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: nowrap;
  }

  .cde-initiative-base-field {
    flex-shrink: 0;
    min-width: 70px;
  }

  .cde-initiative-base-value {
    display: block;
    font-size: 22px;
    font-weight: 800;
    color: @cde-spell;
    text-shadow: 0 0 8px fade(@cde-spell, 50%);
    text-align: center;
    line-height: 1;
    padding: 4px 0;
  }

  .cde-initiative-op {
    font-size: 18px;
    font-weight: 700;
    color: @cde-muted;
    padding-bottom: 6px;
    flex-shrink: 0;
    align-self: flex-end;
  }

  .cde-initiative-action-field {
    flex: 1;
    min-width: 0;
  }

  .cde-initiative-select {
    width: 100%;
  }

  .cde-initiative-hint {
    font-size: 10px;
    font-family: "Averia", sans-serif;
    color: @cde-muted;
    text-align: center;
    letter-spacing: 0.05em;
    padding: 4px 0 0;
    border-top: 1px solid @cde-border;
    margin-top: 4px;
  }

  .cde-initiative-icon {
    font-size: 20px;
    color: @cde-spell;
  }
}

// ============================================================
// Initiative chat result card
// ============================================================
.cde-initiative-result {
  background: @cde-surface;
  border: 1px solid @cde-border;
  border-left: 4px solid @cde-spell;
  border-radius: @cde-radius;
  overflow: hidden;
  color: @cde-text;

  .cde-ir-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: fade(@cde-spell, 8%);
    border-bottom: 1px solid @cde-border;
  }

  .cde-ir-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid @cde-border;
    object-fit: cover;
    flex-shrink: 0;
  }

  .cde-ir-actor-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .cde-ir-actor-name {
    font-size: 13px;
    font-weight: 700;
    color: @cde-text;
  }

  .cde-ir-roll-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: @cde-muted;
    font-family: "Averia", sans-serif;
  }

  .cde-ir-formula {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
    padding: 8px 12px;
    background: fade(@cde-bg, 60%);
    border-bottom: 1px solid @cde-border;
    font-family: monospace;
    font-size: 12px;
  }

  .cde-ir-formula-base {
    color: @cde-muted;
    font-size: 11px;
  }

  .cde-ir-formula-val {
    font-weight: 700;
    color: @cde-text;
    font-size: 13px;
  }

  .cde-ir-formula-mod {
    color: @cde-kungfu;
  }

  .cde-ir-formula-sep {
    color: @cde-muted;
  }

  .cde-ir-formula-eq {
    color: @cde-muted;
    font-size: 14px;
  }

  .cde-ir-formula-total {
    font-size: 16px;
    font-weight: 800;
    color: @cde-spell;
    text-shadow: 0 0 6px fade(@cde-spell, 50%);
  }

  .cde-ir-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 14px 12px;
  }

  .cde-ir-init-value {
    font-size: 48px;
    font-weight: 900;
    color: @cde-spell;
    text-shadow: 0 0 12px fade(@cde-spell, 70%), 0 0 24px fade(@cde-spell, 35%);
    line-height: 1;
    font-family: 'Averia Regular', sans-serif;
  }

  .cde-ir-hero-right {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .cde-ir-init-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: @cde-muted;
    font-family: "Averia", sans-serif;
  }

  .cde-ir-anti {
    display: flex;
    gap: 5px;
    align-items: baseline;
  }

  .cde-ir-anti-label {
    font-size: 10px;
    color: @cde-muted;
    font-family: "Averia", sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .cde-ir-anti-value {
    font-size: 14px;
    font-weight: 700;
    color: @cde-kungfu;
    text-shadow: 0 0 5px fade(@cde-kungfu, 40%);
  }
}


/* ============================================================
   ROUE D'INITIATIVE — CDEWheelApp
   ============================================================ */

// Wu Xing segment colours (match JS constants)
@wu-metal:     #b8c4cc;
@wu-water:     #3a7bd5;
@wu-earth:     #c8a84b;
@wu-fire:      #d94f3d;
@wu-wood:      #4a9b5a;
@wu-reference: #2c1f6b;

.cde-wheel-app {
  color: @cde-text;
  background: @cde-bg;
  font-family: "Averia", "Averia Regular", sans-serif;

  .window-content {
    padding: 0;
    overflow: hidden;
  }
}

/* Two-column layout: SVG wheel left, panel right */
.cde-wheel-layout {
  display: flex;
  height: 100%;
  min-height: 520px;
}

/* ---- Left: SVG wheel ---- */
.cde-wheel-svg-container {
  flex: 0 0 480px;
  width: 480px;
  padding: 12px 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: @cde-surface2;
  border-right: 1px solid @cde-border;

  svg {
    flex: 1 1 auto;
    width: 100%;
    max-width: 456px;
    max-height: 456px;
    overflow: visible;
  }

  .cde-wheel-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0 2px;
    font-size: 11px;
    color: rgba(255,255,255,0.55);
    flex-shrink: 0;
  }

  .cde-wheel-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .cde-wheel-segment {
    stroke: @cde-bg;
    stroke-width: 1.5;
    transition: opacity 0.2s;
  }

  .cde-wheel-cran-label {
    font-family: "Averia Regular", sans-serif;
    font-size: 12px;
    fill: rgba(255,255,255,0.55);
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
    user-select: none;
  }

  // Combatant token circle on the wheel
  .cde-wheel-fighter-circle {
    stroke-width: 2;
    cursor: pointer;
    transition: r 0.2s, stroke-width 0.2s;

    &:hover {
      stroke-width: 3;
    }

    &.is-active {
      r: 18;
      stroke-width: 3;
      filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.7));
    }

    &.is-turn {
      stroke-dasharray: 3 2;
      animation: cde-spin 4s linear infinite;
    }
  }

  .cde-wheel-fighter-initial {
    font-size: 13px;
    font-weight: 700;
    fill: #fff;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
  }
}

/* ---- Right: panel ---- */
.cde-wheel-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  min-width: 0;
}

.cde-wheel-section-title {
  padding: 7px 12px 6px;
  border-bottom: 1px solid @cde-border;
  background: @cde-surface2;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: @cde-muted;
  border-left: 3px solid @cde-spell;
  flex-shrink: 0;

  em {
    font-style: normal;
    color: @cde-text;
    text-transform: none;
    letter-spacing: 0;
    font-size: 11px;
  }
}

/* Combatant list */
.cde-wheel-combatants {
  flex: 0 0 auto;
  max-height: 130px;
  overflow-y: auto;
  border-bottom: 1px solid @cde-border;
}

.cde-wheel-combatant {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 9px;
  cursor: pointer;
  border-bottom: 1px solid fade(@cde-border, 50%);
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s;

  &:last-child { border-bottom: none; }

  &:hover {
    background: @cde-surface;
  }

  &.cde-wheel-combatant--selected {
    background: fade(@cde-spell, 10%);
    border-left-color: @cde-spell;

    .cde-wheel-combatant-name {
      color: @cde-text;
      font-weight: 600;
    }
  }

  &.cde-wheel-combatant--active {
    .cde-wheel-active-marker {
      color: #f0c040;
      filter: drop-shadow(0 0 3px #f0c040);
    }
  }
}

.cde-wheel-combatant-img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid @cde-border-hi;
  flex-shrink: 0;
}

.cde-wheel-combatant-name {
  flex: 1 1 auto;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: @cde-muted;
}

.cde-wheel-combatant-cran {
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 22px;
  text-align: center;
  padding: 2px 6px;
  border-radius: 12px;
  line-height: 1.3;
}

.cde-wheel-active-marker {
  font-size: 10px;
  color: @cde-muted;
  flex-shrink: 0;
}

/* Action area */
.cde-wheel-actions {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 8px 10px 10px;
  gap: 6px;

  &.cde-wheel-actions--hint {
    justify-content: center;
    align-items: center;
  }
}

.cde-wheel-hint {
  color: @cde-muted;
  font-size: 12px;
  text-align: center;
  font-style: italic;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;

  i {
    font-size: 22px;
    opacity: 0.4;
  }
}

.cde-wheel-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.cde-wheel-action-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  background: @cde-surface;
  border: 1px solid @cde-border-hi;
  border-radius: @cde-radius-sm;
  color: @cde-muted;
  font-size: 11px;
  padding: 5px 7px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  font-family: inherit;

  &:hover {
    color: @cde-text;
    background: @cde-border;
    border-color: @cde-border-hi;
  }

  .cde-wheel-action-name {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .cde-wheel-action-cost {
    flex-shrink: 0;
    font-weight: 700;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 10px;
    background: @cde-border-hi;
    color: @cde-muted;
    line-height: 1.4;
  }

  &[data-cost="1"] {
    &:hover { box-shadow: 0 0 6px fade(@cde-spell, 22%); }
    .cde-wheel-action-cost { background: #1a3d6a; color: #6aadff; }
  }
  &[data-cost="2"] {
    &:hover { box-shadow: 0 0 6px fade(#d4a050, 25%); }
    .cde-wheel-action-cost { background: #4a3200; color: #d4a050; }
  }
  &[data-cost="3"] {
    &:hover { box-shadow: 0 0 6px fade(#e06030, 28%); }
    .cde-wheel-action-cost { background: #4a1800; color: #e07840; }
  }
  &[data-cost="6"] {
    border-color: fade(#cc2040, 40%);
    &:hover { box-shadow: 0 0 6px fade(#cc2040, 35%); }
    .cde-wheel-action-cost { background: #4a0814; color: #e03050; }
  }
}

/* Special action buttons */
.cde-wheel-special-actions {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.cde-wheel-btn-roll,
.cde-wheel-btn-surprise {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: @cde-radius-sm;
  font-size: 11px;
  font-weight: 600;
  padding: 7px 8px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, box-shadow 0.15s;
  border: 1px solid;
}

.cde-wheel-btn-roll {
  background: fade(#c08a00, 14%);
  border-color: fade(#c08a00, 50%);
  color: #e0b030;

  &:hover {
    background: fade(#c08a00, 26%);
    box-shadow: 0 0 8px fade(#c08a00, 40%);
  }
}

.cde-wheel-btn-surprise {
  background: fade(@cde-kungfu, 12%);
  border-color: fade(@cde-kungfu, 45%);
  color: @cde-kungfu;

  &:hover {
    background: fade(@cde-kungfu, 24%);
    box-shadow: 0 0 8px fade(@cde-kungfu, 35%);
  }
}

/* No-combat empty state */
.cde-wheel-no-combat {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: @cde-muted;
  gap: 8px;
  padding: 20px;
  text-align: center;
  font-size: 12px;

  i {
    font-size: 28px;
    opacity: 0.4;
  }
}

/* Spin animation for active-turn token */
@keyframes cde-spin {
  from { transform-origin: var(--fx) var(--fy); transform: rotate(0deg); }
  to   { transform-origin: var(--fx) var(--fy); transform: rotate(360deg); }
}

/* ===================================================================
   Migration App
   =================================================================== */

.cde-migration-app {
  .window-content {
    padding: 0;
    overflow-y: auto;
  }
}

.cde-migration-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

/* Drop zone */
.cde-migration-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 20px;
  border: 2px dashed @cde-border;
  border-radius: 8px;
  background: fadeout(@cde-surface2, 40%);
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;

  &.is-dragover {
    border-color: @cde-spell;
    background: fadeout(@cde-spell, 85%);
  }
}

.cde-migration-drop-icon {
  font-size: 36px;
  color: @cde-spell;
  opacity: 0.7;
}

.cde-migration-drop-hint {
  margin: 0;
  font-size: 12px;
  color: @cde-muted;
}

.cde-migration-file-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid @cde-spell;
  border-radius: 4px;
  color: @cde-spell;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;

  &:hover {
    background: fadeout(@cde-spell, 80%);
  }
}

/* Preview section */
.cde-migration-preview {
  border: 1px solid @cde-border;
  border-radius: 6px;
  overflow: hidden;
}

.cde-migration-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: fadeout(@cde-surface2, 20%);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: @cde-muted;
}

.cde-migration-clear-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid @cde-border;
  border-radius: 4px;
  font-size: 11px;
  color: @cde-muted;
  background: none;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;

  &:hover {
    color: #e04444;
    border-color: #e04444;
  }
}

/* Preview table */
.cde-migration-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;

  th {
    padding: 5px 8px;
    background: fadeout(@cde-surface2, 10%);
    color: @cde-muted;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    text-align: left;
    border-bottom: 1px solid @cde-border;
  }

  td {
    padding: 5px 8px;
    border-bottom: 1px solid fadeout(@cde-border, 60%);
    vertical-align: middle;
  }

  tr:last-child td {
    border-bottom: none;
  }
}

.cde-migration-thumb {
  width: 28px;
  height: 28px;
  border-radius: 3px;
  object-fit: cover;
}

.cde-migration-name {
  font-weight: 600;
  color: @cde-text;
}

.cde-migration-items-count {
  text-align: center;
  color: @cde-muted;
}

.cde-migration-srcfile {
  font-size: 10px;
  color: @cde-muted;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Type badge */
.cde-migration-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;

  &.cde-migration-type-character {
    background: fadeout(@cde-spell, 80%);
    color: @cde-spell;
    border: 1px solid fadeout(@cde-spell, 60%);
  }

  &.cde-migration-type-npc {
    background: fadeout(#9c4dcc, 80%);
    color: #c97ae0;
    border: 1px solid fadeout(#9c4dcc, 60%);
  }
}

/* Errors */
.cde-migration-errors {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;

  li {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid fadeout(#e04444, 40%);
    border-radius: 4px;
    background: fadeout(#e04444, 90%);
    color: #e07070;
    font-size: 11px;

    i { margin-top: 2px; flex-shrink: 0; }
  }
}

/* Bottom action bar */
.cde-migration-actions {
  display: flex;
  justify-content: center;
  padding-top: 4px;
}

.cde-migration-import-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 24px;
  border: none;
  border-radius: 6px;
  background: @cde-spell;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;

  &:hover {
    filter: brightness(1.15);
  }
}

.cde-migration-hint {
  margin: 0;
  font-size: 12px;
  color: @cde-muted;
  text-align: center;
}

// ============================================================
// Welcome message
// ============================================================

.cde-welcome-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: @cde-surface;
  border: 1px solid @cde-border-hi;
  border-radius: 8px;
  text-align: center;
}

.cde-welcome-logo {
  width: 120px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 8px fade(@cde-spell, 40%));
}

.cde-welcome-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: @cde-spell;
  text-shadow: 0 0 8px fade(@cde-spell, 50%);
}

.cde-welcome-links {
  margin: 0;
  font-size: 12px;
  color: @cde-muted;

  a {
    color: @cde-item;
    text-decoration: none;
    border-bottom: 1px solid fade(@cde-item, 40%);

    &:hover {
      color: #fff;
      border-bottom-color: #fff;
    }
  }
}

.cde-welcome-help-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 7px 18px;
  background: @cde-spell;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;

  &:hover {
    filter: brightness(1.2);
  }
}
