/* ==========================================================================
   Potato Crew — Gear Planner & Model System
   ========================================================================== */

/* Character profile and standalone gear-set manager */
.modal.gear-create-modal,
.modal.gear-weights-modal {
  width: min(760px, calc(100vw - 2rem));
  max-width: 760px;
}
.gear-create-form,
.gear-weight-editor,
.gear-weight-custom {
  display: grid;
  gap: 1rem;
  min-width: 0;
}
.gear-create-form p,
.gear-weight-editor p {
  margin: 0;
}
.gear-create-form label,
.gear-create-options > summary {
  font-weight: 600;
}
.gear-create-form .input,
.gear-create-form label small {
  font-weight: 400;
}
.gear-create-character {
  font-weight: 600;
}
.gear-create-character span {
  color: var(--text-muted);
  font-weight: 400;
}
.gear-form-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: end;
}
.gear-form-field {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
}
.gear-create-form .input,
.gear-weight-editor .input {
  width: 100%;
  min-width: 0;
}
.gear-weight-label-row,
.gear-weight-toolbar,
.gear-weight-profile-actions,
.gear-weight-suggestion,
.gear-scoring-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.gear-weight-label-row > label,
.gear-weight-label-row > strong,
.gear-weight-add > label {
  font-weight: 600;
}
.gear-weight-toolbar {
  gap: 0.35rem;
}
.gear-weight-profile-picker {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.65rem;
}
.gear-weight-profile-picker select {
  flex: 1 1 15rem;
}
.gear-weight-profile-picker .button {
  flex-shrink: 0;
}
.gear-weight-custom {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.gear-weight-custom[hidden],
.gear-weight-editor [hidden] {
  display: none !important;
}
.gear-weight-columns,
.gear-weight-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 105px 36px;
  gap: 0.65rem;
  align-items: center;
}
.gear-weight-columns {
  color: var(--text-muted);
  font-size: 0.8rem;
}
.gear-weight-columns span:nth-child(2) {
  text-align: right;
}
.gear-weight-rows {
  display: grid;
  gap: 0.1rem;
}
.gear-weight-row {
  padding: 0.6rem 0;
  border-top: 1px solid var(--border);
}
.gear-weight-row:first-child {
  border-top: 0;
}
.gear-weight-row label {
  min-width: 0;
  overflow-wrap: anywhere;
}
.gear-weight-row label small {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 0.15rem;
}
.gear-weight-row input {
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.gear-weight-row .button {
  padding: 0.4rem;
}
.gear-weight-add {
  display: grid;
  gap: 0.55rem;
  padding-block: 1rem;
  border-block: 1px solid var(--border);
}
.gear-weight-add-controls {
  display: flex;
  gap: 0.65rem;
}
.gear-weight-add-controls select {
  flex: 1;
}
.gear-weight-add-controls .button {
  flex-shrink: 0;
}
.gear-weight-profile-actions {
  justify-content: flex-start;
}
.gear-weight-explanation {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.gear-weight-explanation p {
  padding-top: 0.7rem;
}
.gear-weight-feedback {
  font-size: 0.85rem;
}
.gear-weight-preview {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  min-width: 0;
}
.gear-weight-preview .gear-weight-label-row {
  margin-bottom: 0.5rem;
}
.gear-weight-preview [data-preview-slot] {
  width: auto;
  max-width: 45%;
  padding-block: 0.35rem;
}
.gear-weight-preview [aria-busy='true'] {
  opacity: 0.65;
}
.gear-weight-preview-item {
  border-bottom: 1px solid var(--border);
}
.gear-weight-preview-item:last-child {
  border-bottom: 0;
}
.gear-weight-preview-item summary {
  display: grid;
  grid-template-columns: 1.2rem 32px minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.85rem 0;
}
.gear-weight-preview-name {
  overflow-wrap: anywhere;
}
.gear-weight-preview-icon {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-width: 1px;
  border-style: solid;
  border-radius: 4px;
}
.gear-weight-preview-rank {
  color: var(--text-muted);
  font-size: 0.8rem;
}
.gear-weight-preview-score {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.gear-weight-preview-score .gear-ep-badge {
  display: inline-block;
  font-family: inherit;
}
.gear-weight-preview-score small {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}
.gear-weight-contributions {
  padding: 0 0 0.8rem 1.7rem;
  font-size: 0.82rem;
  display: grid;
  gap: 0.4rem;
}
.gear-weight-contributions > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.gear-weight-contributions small {
  display: block;
  color: var(--text-muted);
}
.gear-weight-contributions strong {
  flex-shrink: 0;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.gear-item-score-breakdown {
  padding: 1rem 0;
}
button.gear-ep-badge {
  font-family: inherit;
}
.gear-create-options {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.gear-create-options > div,
.gear-create-options > label {
  margin-top: 1rem;
}
.gear-create-active {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  align-self: end;
  min-height: 42px;
  padding: 10px 0;
  border: 1px solid transparent;
}
.gear-create-active input {
  width: 20px;
  flex-shrink: 0;
  margin: 0;
}
.gear-create-footer {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  margin-top: 0.3rem;
}
.gear-scoring-context {
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
}
.gear-scoring-context > div {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  column-gap: 0.75rem;
  row-gap: 0.25rem;
}
.gear-scoring-context span {
  color: var(--text-muted);
  font-size: 0.85rem;
}
@media (max-width: 520px) {
  .gear-form-columns {
    grid-template-columns: minmax(0, 1fr);
  }
  .gear-weight-columns,
  .gear-weight-row {
    grid-template-columns: minmax(0, 1fr) 82px 32px;
    gap: 0.4rem;
  }
  .gear-weight-row input {
    padding-inline: 0.4rem;
  }
  .gear-weight-add-controls {
    flex-wrap: wrap;
  }
  .gear-weight-add-controls select {
    flex-basis: 100%;
  }
  .gear-create-form .input,
  .gear-weight-editor input,
  .gear-weight-editor select {
    font-size: 16px;
  }
  .gear-weight-row small {
    font-size: 0.75rem;
  }
}

.gear-sets-tab {
  display: grid;
  gap: 1.5rem;
  min-width: 0;
}

.gear-sets-tab .character-tab-header,
.gear-sets-tab .active-build-header,
.gear-sets-tab .saved-build-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.gear-sets-tab h3,
.gear-sets-tab h4,
.gear-sets-tab p {
  margin: 0;
}

.gear-sets-tab .character-tab-header h3 {
  font-size: 1.2rem;
  margin-bottom: 0.3rem;
}

.gear-sets-tab .character-tab-header > div {
  flex: 1 1 18rem;
}

.gear-sets-tab .gear-set-active-card,
.gear-sets-tab .gear-saved-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.gear-sets-tab .gear-set-active-card {
  border-left: 3px solid var(--accent);
}

.gear-sets-tab .active-build-name {
  margin-bottom: 0.5rem;
  font-size: 1.15rem;
  overflow-wrap: anywhere;
}

.gear-sets-tab .active-build-meta,
.gear-sets-tab .saved-build-card-body {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  font-size: 0.9rem;
}

.gear-sets-tab .active-build-desc {
  margin-top: 0.75rem;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.gear-sets-tab .active-build-actions,
.gear-sets-tab .saved-build-card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.gear-sets-tab .saved-builds-section {
  display: grid;
  gap: 0.85rem;
  min-width: 0;
}

.gear-sets-tab .saved-builds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: 1rem;
}

.gear-sets-tab .saved-build-card-header {
  align-items: flex-start;
}

.gear-sets-tab .saved-build-card-header strong {
  flex: 1 1 10rem;
  overflow-wrap: anywhere;
}

.gear-sets-tab .saved-build-card-body span:last-child {
  text-transform: capitalize;
}

.gear-sets-tab .saved-build-card-actions > a {
  margin-right: auto;
}

.gear-planner-page {
  width: 100%;
  min-width: 0;
  padding: 0.5rem 0 3rem;
}

/* --------------------------------------------------------------------------
   Header HUD
   -------------------------------------------------------------------------- */
.gear-planner-header {
  position: relative;
  z-index: 40;
  background: var(--bg-warm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(0, 0, 0, 0.6);
  border-radius: 10px;
  padding: 0.6rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow:
    0 8px 30px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  backdrop-filter: blur(12px);
  box-sizing: border-box;
}

.gear-planner-header-left {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  min-width: 0;
  max-width: 100%;
}

.gear-planner-identity {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  max-width: 100%;
}

.gear-planner-back-btn {
  padding: 0.35rem 0.55rem;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.gear-planner-class-avatar {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  background: var(--bg-secondary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gear-planner-class-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gear-planner-titles {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.gear-planner-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gear-planner-name {
  overflow-wrap: anywhere;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.2;
}

.gear-planner-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
}

.gear-planner-class-label {
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: capitalize;
}

.gear-planner-ilvl-badge {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  padding: 0.1rem 0.55rem;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--warning, #ddb57d);
  white-space: nowrap;
}

/* Center HUD Capsule */
.gear-planner-header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
}

.gear-points-hud {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 1rem;
  gap: 1.15rem;
}

.gear-hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.15rem;
}

.gear-hud-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  line-height: 1;
}

.gear-hud-val {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.gear-hud-val.highlight {
  color: var(--success, #86c9aa);
}

.gear-hud-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.08);
}

/* Right Header Actions */
.gear-planner-header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  min-width: 0;
  max-width: 100%;
}

.gear-planner-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.gear-autosave-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 105px;
  box-sizing: border-box;
  justify-content: center;
  user-select: none;
}

.gear-autosave-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.gear-autosave-status.saved .gear-autosave-dot {
  background: var(--success, #86c9aa);
}

.gear-autosave-status.saving .gear-autosave-dot {
  background: #ffd100;
  box-shadow: 0 0 6px rgba(255, 209, 0, 0.6);
  animation: pulse 1s infinite alternate;
}

.gear-autosave-status.unsaved .gear-autosave-dot {
  background: #ff8000;
  box-shadow: 0 0 6px rgba(255, 128, 0, 0.6);
}

.gear-autosave-status.error .gear-autosave-dot {
  background: #e05252;
  box-shadow: 0 0 6px rgba(224, 82, 82, 0.6);
}

/* --------------------------------------------------------------------------
   Workspace Layout (Top: Paperdoll + Item Picker; Bottom: Live Stat Sheet)
   -------------------------------------------------------------------------- */
.gear-planner-workspace {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
}

.gear-planner-top-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 1.5rem;
  align-items: stretch;
}

.gear-planner-top-row > * {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.gear-planner-top-row > * > :first-child {
  flex: 1;
}

.gear-planner-top-row.gear-planner-readonly {
  grid-template-columns: minmax(0, 1fr);
}

.gear-planner-bottom-row {
  width: 100%;
}

/* --------------------------------------------------------------------------
   Column 1: 19-Slot Paperdoll & Wider Model Viewer
   -------------------------------------------------------------------------- */
.gear-paperdoll-panel {
  container: gear-paperdoll / inline-size;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.15rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.gear-paperdoll-grid {
  display: grid;
  flex: 1;
  grid-template-rows: minmax(min-content, 1fr) auto;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) minmax(0, 1fr);
  grid-template-areas: 'left model right' 'weapons weapons weapons';
  gap: 0.65rem;
  align-items: stretch;
}

.gear-col-left,
.gear-col-right {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.25rem;
  min-width: 0;
}

.gear-col-left {
  grid-area: left;
}

.gear-col-right {
  grid-area: right;
}

.gear-col-center {
  grid-area: model;
  position: relative;
  min-width: 0;
  min-height: 0;
}

/* Distribute side slots over the model's full height, keeping the first and
   last slots aligned with its edges and the weapon row underneath. */
.gear-col-center > .gear-model-viewer-frame {
  position: absolute;
  inset: 0;
  height: 100%;
}

.gear-paperdoll-bottom {
  grid-area: weapons;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Character Model Viewer Frame */
.gear-model-viewer-frame {
  width: 100%;
  height: 480px;
  min-width: 0;
  min-height: 0;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.gear-model-identity {
  padding: 0.5rem 0.6rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-align: center;
}

.gear-model-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
}

.gear-model-char-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.1;
  text-transform: capitalize;
}

.gear-model-equipped-badge {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
}

.gear-model-meta-row {
  display: flex;
  justify-content: center;
}

.gear-model-class-tag {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.gear-model-stage {
  min-width: 0;
  min-height: 0;
  position: relative;
  background: radial-gradient(circle at 50% 40%, var(--bg-warm-elevated) 0%, var(--bg-inset) 80%);
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.gear-model-stage[class*='bg-'] {
  background: radial-gradient(ellipse at 50% 42%, #573219 0%, #2d2119 55%, #181411 100%);
}

.gear-model-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 35%, rgba(0, 0, 0, 0.75) 100%);
  pointer-events: none;
  z-index: 1;
}

.gear-model-faction-crest {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 140px;
  height: 140px;
  opacity: 0.12;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
  z-index: 0;
}

.crest-horde,
.crest-alliance {
  background-image: url('../images/emblem.svg');
}

.gear-model-3d-viewport {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  cursor: grab;
  user-select: none;
}

.gear-model-3d-viewport:active {
  cursor: grabbing;
}

.gear-model-3d-viewport canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  outline: none;
}

.gear-model-loading-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: color-mix(in srgb, var(--bg-secondary) 85%, transparent);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  z-index: 5;
  backdrop-filter: blur(4px);
}

.model-spinner-ring {
  width: 36px;
  height: 36px;
  border: 3px solid color-mix(in srgb, var(--accent) 15%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: modelSpin 0.9s linear infinite;
}

@keyframes modelSpin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.gear-model-avatar-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  padding: 0.25rem 0.5rem;
}

.gear-model-svg {
  width: 100%;
  height: 100%;
  max-height: 380px;
  display: block;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.75));
  transition: transform 0.25s ease;
}

.gear-model-svg:hover {
  transform: scale(1.02);
}

.gear-model-customizer {
  position: relative;
  z-index: 3;
  padding: 0.45rem 0.5rem;
  background: var(--bg-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.gear-model-customizer-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
}

.gear-model-anim-select-wrapper {
  min-width: 0;
}

.gear-model-anim-select,
.gear-model-weapon-select {
  width: 100%;
  min-width: 0;
  height: 32px;
  min-height: 32px;
  padding: 0.22rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  color: var(--text-primary);
  cursor: pointer;
}

.gear-model-gender-toggle {
  display: flex;
  gap: 0.2rem;
}

.gear-gender-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 1rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--bg-elevated);
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
  transition: all 0.15s ease;
}

.gear-gender-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

.gear-gender-btn.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 40%, transparent);
}

.gear-model-reset-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 1rem;
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: all 0.15s ease;
}

.gear-model-reset-btn:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.gear-model-hint {
  position: absolute;
  bottom: 0.3rem;
  left: 0.4rem;
  right: 0.4rem;
  z-index: 3;
  pointer-events: none;
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-shadow: 0 1px 3px #000;
}

.gear-model-weapon-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.gear-model-customizer button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.gear-model-equipment-status {
  position: absolute;
  bottom: 1.8rem;
  z-index: 3;
  left: 0.5rem;
  right: 0.5rem;
  margin: 0;
  padding: 0.3rem 0.4rem;
  border-radius: 4px;
  background: var(--bg-secondary);
  pointer-events: none;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  overflow-wrap: anywhere;
}

.gear-slot-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 0.3rem 0.45rem;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  user-select: none;
}

.gear-tooltip-class-set {
  color: #ff5555;
}

.gear-model-retry-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 4;
  background: var(--bg-secondary);
}

.gear-slot-row:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.15);
}

.gear-slot-row.active-slot {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 25%, transparent);
}

.gear-slot-icon-wrapper {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  border: 2px solid #333;
  position: relative;
  background: var(--bg-inset);
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Let the side slots use more of the model's height instead of leaving large
   gaps, while keeping the weapon row compact. */
:is(.gear-col-left, .gear-col-right) > .gear-slot-row {
  flex: 1 1 64px;
  min-height: 64px;
  max-height: 76px;
  padding: 0.4rem 0.5rem;
}

:is(.gear-col-left, .gear-col-right) .gear-slot-icon-wrapper {
  width: 48px;
  height: 48px;
}

.gear-slot-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gear-slot-placeholder {
  width: 24px;
  height: 24px;
  opacity: 0.3;
  filter: grayscale(100%);
}

.gear-slot-info {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  gap: 0.1rem;
}

.gear-slot-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
}

.gear-slot-item-name {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.gear-slot-enchant-text {
  font-size: 0.72rem;
  color: #1eff00;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
}

.gear-slot-enchant-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: var(--text-muted);
  padding: 0.2rem 0.35rem;
  font-size: 0.7rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.gear-slot-enchant-btn[hidden] {
  display: none;
}

.gear-slot-enchant-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent);
  border-color: var(--accent);
}

.gear-slot-enchant-btn.has-enchant {
  color: #1eff00;
  border-color: rgba(30, 255, 0, 0.4);
  background: rgba(30, 255, 0, 0.08);
}

/* Quality borders */
.q-poor {
  color: #9d9d9d;
  border-color: #9d9d9d;
}
.q-common {
  color: #ffffff;
  border-color: #ffffff;
}
.q-uncommon {
  color: #1eff00;
  border-color: #1eff00;
}
.q-rare {
  color: #0070dd;
  border-color: #0070dd;
}
.q-epic {
  color: #a335ee;
  border-color: #a335ee;
}
.q-legendary {
  color: #ff8000;
  border-color: #ff8000;
}

.border-q-poor {
  border-color: #9d9d9d !important;
}
.border-q-common {
  border-color: #ffffff !important;
}
.border-q-uncommon {
  border-color: #1eff00 !important;
}
.border-q-rare {
  border-color: #0070dd !important;
}
.border-q-epic {
  border-color: #a335ee !important;
}
.border-q-legendary {
  border-color: #ff8000 !important;
}

/* --------------------------------------------------------------------------
   Column 2: Item Search / Upgrades Drawer
   -------------------------------------------------------------------------- */
.gear-drawer-panel {
  container: gear-upgrades / inline-size;
  min-width: 0;
  min-height: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.gear-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1rem;
  flex-shrink: 0;
}

.gear-drawer-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

.gear-drawer-heading-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
}

.gear-drawer-heading-icon .icon {
  width: 20px;
  height: 20px;
}

.gear-drawer-heading .eyebrow {
  margin: 0 0 4px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.3;
}

.gear-drawer-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-warm);
  line-height: 1.25;
  letter-spacing: 0.01em;
  margin: 0;
}

.gear-drawer-slot-tag {
  display: grid;
  gap: 3px;
  padding: 7px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-warm);
  border-radius: 5px;
  line-height: 1.2;
}

.gear-drawer-slot-tag > span {
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gear-drawer-slot-tag > strong {
  color: var(--text-warm);
  font-size: 13px;
  font-weight: 500;
}

.gear-drawer-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
  flex-shrink: 0;
  align-content: start;
}

.gear-catalog-scope {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.gear-catalog-scope strong {
  color: var(--text-primary);
  font-weight: 500;
}

.gear-search-input {
  grid-column: 1 / -1;
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
  color: var(--text-primary);
  font-size: 0.88rem;
  box-sizing: border-box;
}

.gear-filter-select {
  min-width: 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.5rem;
  color: var(--text-primary);
  font-size: 0.82rem;
  cursor: pointer;
}

.gear-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 540px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding-right: 0.25rem;
}

.gear-item-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  font-size: 0.8rem;
}

.gear-item-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  min-width: 0;
  align-items: start;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  gap: 0.5rem 0.75rem;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
  cursor: pointer;
}

.gear-item-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

.gear-item-card.is-equipped {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.gear-item-card-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1 1 auto;
}

.gear-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  border: 2px solid #333;
  object-fit: cover;
  flex-shrink: 0;
}

.gear-item-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  gap: 0.1rem;
}

.gear-item-name-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.4rem;
}

.gear-item-name {
  min-width: 0;
  flex: 0 1 auto;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gear-item-source {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
}

.gear-item-source > span {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gear-item-card-right {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}

.gear-item-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: stretch;
  width: 100%;
  gap: 0.3rem;
}

.gear-crafter-btn {
  margin-inline-end: auto;
}

.gear-wishlist-btn {
  min-width: 154px;
  font-size: 0.78rem;
  padding: 0.25rem 0.65rem;
  white-space: nowrap;
}

.gear-wishlist-btn.is-saved {
  color: var(--accent);
  border-color: var(--border-warm);
  background: var(--accent-soft);
}

.gear-ep-badge {
  justify-self: end;
  align-self: start;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.gear-ep-badge.positive {
  color: #1eff00;
  border-color: rgba(30, 255, 0, 0.3);
  background: rgba(30, 255, 0, 0.08);
}

.gear-equip-btn {
  min-width: 82px;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  height: 28px;
}

/* --------------------------------------------------------------------------
   Live Stat Sheet (Full-Width Multi-Card Bottom Panel)
   -------------------------------------------------------------------------- */
.gear-stats-panel {
  --gear-stats-columns: 4;
  --gear-stats-gap: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: var(--gear-stats-gap);
}

.gear-stats-section {
  flex: 1 1 calc((100% - (var(--gear-stats-columns) - 1) * var(--gear-stats-gap)) / var(--gear-stats-columns));
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.gear-stats-section-set-bonuses {
  flex-basis: 100%;
}
.gear-talent-link.build-context {
  margin-top: 0;
}
.gear-talent-build-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.build-context-intro > .gear-talent-link-actions {
  flex: 0 1 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.gear-legacy-benefits,
.gear-talent-benefits,
.gear-racial-passives {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 0.25rem 1.25rem;
}
.gear-legacy-benefits > .gear-set-bonus-item,
.gear-talent-benefits > .gear-set-bonus-item,
.gear-racial-passives > .gear-set-bonus-item {
  border-top: 0;
}
.gear-other-talents,
.gear-other-racials {
  grid-column: 1 / -1;
  margin-top: 0.5rem;
}
.gear-other-talents summary,
.gear-other-racials summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 0.5rem 0;
}
.gear-talent-note,
.gear-racial-note {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0.65rem 0 0;
}

.gear-stats-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
  margin: 0 0 0.35rem;
}
.gear-stats-section-title .icon {
  width: 17px;
  height: 17px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.gear-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  width: 100%;
  min-width: 0;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0.45rem 0.35rem;
  border: 0;
  border-radius: 5px;
  background: transparent;
  font-family: inherit;
  text-align: left;
  cursor: help;
}

.gear-stat-name {
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}
.gear-stat-row + .gear-stat-row {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}
.gear-stat-row[data-stat-key^='resistances.'] .gear-stat-name {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}
.gear-resistance-icon {
  width: 32px;
  height: 29px;
  flex-shrink: 0;
  /* Original WoW character-panel sprite: five 32 × 29 icons. */
  background: url('/images/wow/resistance-icons.png') no-repeat 0 0;
}
.gear-stat-row[data-stat-key='resistances.nature'] .gear-resistance-icon {
  background-position-y: -29px;
}
.gear-stat-row[data-stat-key='resistances.arcane'] .gear-resistance-icon {
  background-position-y: -58px;
}
.gear-stat-row[data-stat-key='resistances.frost'] .gear-resistance-icon {
  background-position-y: -87px;
}
.gear-stat-row[data-stat-key='resistances.shadow'] .gear-resistance-icon {
  background-position-y: -116px;
}

.gear-stat-val {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.gear-set-bonus-item {
  min-width: 0;
  padding: 0.75rem 0.35rem;
  font-size: 0.9rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.gear-set-bonus-item + .gear-set-bonus-item {
  border-top: 1px solid var(--border);
}
.gear-set-bonus-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.3rem 0.75rem;
}
.gear-set-bonus-heading strong {
  color: var(--text-primary);
  font-weight: 600;
}

.gear-legacy-benefit-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.gear-legacy-benefit-name img {
  flex-shrink: 0;
  border-radius: 4px;
}
.gear-set-piece-badge {
  flex-shrink: 0;
  color: var(--success);
  font-size: 0.72rem;
  font-weight: 600;
}
.gear-set-bonus-item p {
  margin: 0.3rem 0 0;
  color: var(--text-secondary);
}

.gear-diff-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
}

.gear-diff-row.positive .gear-diff-val {
  color: #1eff00;
  font-weight: 700;
}

.gear-diff-row.negative .gear-diff-val {
  color: #e05252;
  font-weight: 700;
}

.gear-diff-empty {
  font-size: 0.78rem;
}

.gear-crafters-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 350px;
  overflow-y: auto;
}

.gear-crafter-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.gear-crafter-name {
  color: var(--text-primary);
}

.gear-crafter-discord {
  background: rgba(88, 101, 242, 0.2);
  color: #7289da;
  font-size: 0.75rem;
}

.gear-loading-box {
  padding: 2rem;
  text-align: center;
}

.gear-empty-items {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

.gear-share-section {
  margin-bottom: 1.25rem;
}

.gear-share-desc {
  margin: 0 0 0.5rem 0;
}

.gear-share-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.gear-share-input {
  flex: 1 1 auto;
}

.gear-share-box {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.gear-modal-actions {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.gear-modal-desc-row {
  margin-bottom: 1rem;
}

.gear-modal-desc {
  margin: 0;
}

.gear-ilvl-sub {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 0.75rem;
}
.gear-enchant-modal-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
}

.gear-enchant-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.gear-enchant-card.active-enchant {
  border-color: #1eff00;
  background: rgba(30, 255, 0, 0.08);
}

.gear-enchant-card.remove-enchant {
  border-color: rgba(224, 82, 82, 0.4);
}

.gear-enchant-card.remove-enchant .gear-enchant-card-title {
  color: #e05252;
}

.gear-enchant-modal-header {
  margin-bottom: 1rem;
}

.gear-enchant-modal-sub {
  margin: 0;
}

.gear-enchant-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.gear-enchant-card-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1eff00;
}

.gear-enchant-card-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   WoW: Forever Item Tooltips
   -------------------------------------------------------------------------- */
.gear-tooltip {
  position: absolute;
  overflow-wrap: anywhere;
  z-index: 1000;
  max-width: min(320px, calc(100vw - 24px));
  min-width: min(250px, calc(100vw - 24px));
  padding: 0.75rem 0.85rem;
  background: color-mix(in srgb, var(--bg-secondary) 97%, transparent);
  border: 1px solid var(--border-warm);
  border-radius: 6px;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.9),
    inset 0 0 12px rgba(0, 0, 0, 0.6);
  font-size: 0.8rem;
  line-height: 1.35;
  color: #ffffff;
  pointer-events: none;
  backdrop-filter: blur(8px);
  box-sizing: border-box;
}

.gear-tooltip-header {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.35rem;
}

.gear-tooltip-name {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
}

.gear-tooltip-ilvl {
  font-size: 0.72rem;
  color: #ffd100;
}

.gear-tooltip-binding {
  color: #ffffff;
  font-size: 0.75rem;
}

.gear-tooltip-slot-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #ffffff;
}

.gear-tooltip-damage-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #ffffff;
}

.gear-tooltip-dps {
  font-size: 0.75rem;
  color: #ffffff;
}

.gear-tooltip-armor,
.gear-tooltip-block,
.gear-tooltip-stat,
.gear-tooltip-resist {
  color: #ffffff;
  font-size: 0.78rem;
}

.gear-tooltip-durability,
.gear-tooltip-req-level,
.gear-tooltip-profession {
  font-size: 0.72rem;
  color: #ffffff;
}

.gear-tooltip-enchant {
  color: #00ccff;
  margin: 0.25rem 0;
  font-size: 0.75rem;
  font-weight: 600;
}

.gear-tooltip-equip {
  color: #1eff00;
  margin: 0.2rem 0;
  font-size: 0.75rem;
  line-height: 1.3;
}

.gear-tooltip-set-container {
  margin-top: 0.4rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.gear-tooltip-set-title {
  color: #ffd100;
  font-weight: 700;
  font-size: 0.78rem;
}

.gear-tooltip-set-bonus {
  font-size: 0.72rem;
  margin-top: 0.15rem;
}

.gear-tooltip-set-bonus.active {
  color: #1eff00;
}

.gear-tooltip-set-bonus.inactive {
  color: #888888;
}

.gear-tooltip-set-pieces {
  margin: 0.2rem 0 0.35rem 0.7rem;
  color: #888888;
  font-size: 0.72rem;
}

.gear-tooltip-source {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  padding-top: 0.25rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.gear-tooltip-upgrade-badge {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
}

.gear-tooltip-upgrade-badge.positive {
  background: rgba(30, 255, 0, 0.15);
  color: #1eff00;
  border: 1px solid rgba(30, 255, 0, 0.3);
}

.gear-tooltip-upgrade-badge.negative {
  background: rgba(224, 82, 82, 0.15);
  color: #e05252;
  border: 1px solid rgba(224, 82, 82, 0.3);
}

/* --------------------------------------------------------------------------
   Responsive Design
   -------------------------------------------------------------------------- */
@media (max-width: 1200px) {
  .gear-planner-top-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .gear-stats-panel {
    --gear-stats-columns: 3;
  }
}

@media (max-width: 900px) {
  .gear-planner-header {
    position: static;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .gear-stats-panel {
    --gear-stats-columns: 2;
  }
}

@media (max-width: 560px) {
  .gear-stats-panel {
    --gear-stats-columns: 1;
  }
}

@container gear-upgrades (max-width: 360px) {
  .gear-item-card {
    padding-inline: 0.5rem;
    gap: 0.5rem;
  }

  .gear-item-card-left {
    gap: 0.5rem;
  }

  .gear-item-name-row {
    flex-wrap: wrap;
  }

  .gear-item-name {
    flex: 1 1 90px;
  }

  .gear-ep-badge {
    width: 3.75rem;
    padding-inline: 0.3rem;
    line-height: 1.2;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: right;
  }
}

@container gear-paperdoll (max-width: 620px) {
  .gear-paperdoll-grid {
    grid-template-rows: auto minmax(min-content, 1fr) auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: 'model model' 'left right' 'weapons weapons';
  }
  .gear-col-center {
    height: 480px;
  }
}

@container gear-paperdoll (max-width: 460px) {
  .gear-paperdoll-bottom {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem;
  }
}

@container gear-paperdoll (max-width: 260px) {
  .gear-paperdoll-grid {
    grid-template-rows: auto auto auto auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'model' 'left' 'right' 'weapons';
  }
  .gear-model-name-row {
    flex-direction: column;
    gap: 0.15rem;
  }
  .gear-model-char-name {
    max-width: 100%;
  }
}
.gear-model-identity-empty {
  display: grid;
  place-content: center;
  text-align: center;
  padding: 2rem;
  min-height: 300px;
  color: var(--text-secondary);
}

/* Stat explanations share the planner's neutral panel surfaces. */
.gear-stats-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.8rem;
}
.gear-stats-heading h2 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}
.gear-stats-heading p,
.gear-stats-update {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.78rem;
}
.gear-stat-values {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
  gap: 0.1rem;
}
.gear-stat-gear-bonus {
  color: var(--success);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.gear-stat-gear-bonus.negative,
.gear-stat-last-change.negative {
  color: var(--danger, #e05252);
}
.gear-stat-row:hover,
.gear-stat-row[aria-describedby] {
  background: var(--bg-elevated);
}
.gear-stat-row:focus-visible,
.gear-hud-item:focus-visible,
.gear-stat-tooltip:focus-visible {
  outline: 2px solid var(--text-secondary);
  outline-offset: 3px;
}
.gear-hud-item[data-stat-key] {
  padding: 0;
  border: 0;
  background: transparent;
  font-family: inherit;
  cursor: help;
}
.gear-stats-method {
  flex-basis: 100%;
  color: var(--text-secondary);
  font-size: 0.76rem;
  line-height: 1.5;
}
.gear-stats-method summary {
  cursor: pointer;
}
.gear-stats-method p {
  max-width: 85ch;
  margin: 0.5rem 0 0;
}
.gear-stat-tooltip {
  position: fixed;
  z-index: 10000;
  width: 360px;
  max-width: calc(100vw - 24px);
  max-height: min(620px, calc(100dvh - 24px));
  overflow: auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: 10px;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.45);
  color: var(--text-secondary);
  font-size: 0.78rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.gear-stat-tooltip[hidden] {
  display: none;
}
.gear-stat-tooltip-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  color: var(--text-primary);
  font-size: 0.96rem;
}
.gear-stat-tooltip-title > span {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.gear-stat-benefit {
  margin: 0.55rem 0 0.8rem;
}
.gear-stat-breakdown {
  margin: 0;
  padding: 0.65rem;
  background: var(--bg-elevated);
  border-radius: 6px;
}
.gear-stat-breakdown > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.15rem 0;
}
.gear-stat-breakdown dt span {
  display: block;
  font-size: 0.68rem;
  color: var(--text-secondary);
}
.gear-stat-breakdown dd {
  margin: 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.gear-stat-breakdown .gear-stat-breakdown-total {
  border-top: 1px solid var(--border-hover);
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  font-weight: 700;
  color: var(--text-primary);
}
.gear-stat-last-change {
  color: var(--success);
  margin: 0.75rem 0;
}
.gear-stat-formula {
  margin: 0.75rem 0;
}
.gear-stat-sources {
  border-top: 1px solid var(--border);
  padding-top: 0.65rem;
}
.gear-stat-sources h4 {
  margin: 0 0 0.4rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.gear-stat-source {
  margin: 0.5rem 0;
}
.gear-stat-source > strong {
  color: var(--text-primary);
  font-weight: 500;
}
.gear-stat-source-slot {
  color: var(--text-secondary);
  font-size: 0.68rem;
  text-transform: capitalize;
  margin-left: 0.4rem;
}
.gear-stat-source-detail {
  display: block;
  color: var(--success);
  font-size: 0.73rem;
}
.gear-stat-tooltip-note {
  margin: 0.7rem 0 0;
  font-size: 0.68rem;
  color: var(--text-secondary);
}

.gear-tooltip-faction {
  margin-top: 0.25rem;
  color: var(--warning, #ddb57d);
}
.gear-loadout-issues {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--warning);
  border-radius: 8px;
  color: var(--warning);
  font-size: 0.82rem;
}
.gear-loadout-issues > span {
  flex: 1 1 320px;
}
.gear-loadout-issues[hidden] {
  display: none;
}

.gear-planner-top-row[hidden],
[data-gear-equipment][hidden] {
  display: none;
}
.gear-equipment-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 0;
  overflow: hidden;
}
.gear-equipment-panel > header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.gear-equipment-panel > header h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 18px;
}
.gear-equipment-panel > header p {
  margin: 0;
  font-size: 13px;
}
.gear-equipment-panel table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  table-layout: fixed;
}
.gear-equipment-panel :is(th, td) {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  overflow-wrap: anywhere;
}
.gear-equipment-panel thead th {
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.gear-equipment-panel thead th:first-child {
  width: 120px;
}
.gear-equipment-panel thead th:nth-child(2) {
  width: 36%;
}
.gear-equipment-panel thead th:last-child {
  width: 132px;
}
.gear-equipment-panel tbody th {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
}
.gear-equipment-panel tbody tr:last-child > * {
  border-bottom: 0;
}
.gear-equipment-slot-label {
  display: flex;
  align-items: center;
  min-height: 22px;
}
.gear-equipment-reference .button {
  margin-top: 4px;
}
.gear-equipment-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border-radius: 6px;
  cursor: pointer;
}
.gear-equipment-item > span {
  min-width: 0;
  padding-top: 2px;
  font-size: 13px;
  line-height: 1.5;
}
.gear-equipment-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 2px;
  border: 2px solid;
  border-radius: 7px;
  background: var(--bg-secondary);
  object-fit: cover;
}
.gear-equipment-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
.gear-equipment-panel small {
  display: block;
  color: var(--text-muted);
  margin-top: 5px;
  font-size: 11px;
}
.gear-equipment-enchant {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  align-items: start;
  gap: 6px;
  margin: 6px 0 0 54px;
  padding: 6px 8px;
  border: 1px solid color-mix(in srgb, var(--success) 22%, var(--border));
  border-radius: 6px;
  background: color-mix(in srgb, var(--success) 4%, var(--bg-secondary));
  font-size: 11px;
  line-height: 1.5;
}
.gear-equipment-enchant-icon {
  display: flex;
  align-items: center;
  height: 16px;
  color: var(--success);
}
.gear-equipment-enchant-icon .icon {
  width: 14px;
  height: 14px;
}
.gear-equipment-enchant strong {
  font-weight: 500;
}
.gear-equipment-source,
.gear-source-heading,
.gear-reputation-requirement {
  display: grid;
  grid-template-columns: 106px minmax(0, 1fr);
  align-items: start;
  gap: 6px 10px;
  font-size: 12px;
  line-height: 1.6;
}
.gear-source-content {
  min-width: 0;
}
.gear-source-name {
  line-height: 22px;
}
.gear-equipment-enchant p {
  margin: 2px 0 0;
  color: var(--success);
}
.gear-equipment-panel a:not(.button) {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--border-warm);
  text-underline-offset: 3px;
}
.gear-equipment-panel a:not(.button):hover {
  color: var(--accent);
}
.gear-equipment-panel a > .icon {
  width: 12px;
  height: 12px;
  margin-left: 4px;
  vertical-align: -1px;
}
.gear-source-tag {
  --gear-source-color: var(--text-muted);
  display: inline-flex;
  justify-self: start;
  align-items: center;
  flex-shrink: 0;
  gap: 5px;
  padding: 3px 7px;
  border: 1px solid color-mix(in srgb, var(--gear-source-color) 40%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--gear-source-color) 10%, transparent);
  color: color-mix(in srgb, var(--gear-source-color) 80%, white);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.gear-source-tag .icon {
  width: 12px;
  height: 12px;
}
.gear-source-raid,
.gear-source-pvp {
  --gear-source-color: #de8c83;
}
.gear-source-dungeon,
.gear-source-reputation {
  --gear-source-color: #b59ce6;
}
.gear-source-quest {
  --gear-source-color: #e9c26b;
}
.gear-source-crafted {
  --gear-source-color: #7fc8a0;
}
.gear-source-vendor {
  --gear-source-color: #84b7e2;
}
.gear-source-drop,
.gear-source-container {
  --gear-source-color: #c8ae8e;
}
.gear-source-world {
  --gear-source-color: #7cbfc1;
}
.gear-equipment-sources {
  padding: 0;
  margin: 0;
  list-style: none;
}
.gear-equipment-sources > li + li {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.gear-source-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 3px 0 0;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.gear-source-meta > .icon {
  align-self: start;
  flex-shrink: 0;
  width: 13px;
  height: 13px;
  margin-top: 2px;
}
.gear-source-cost-label {
  color: var(--text-muted);
  flex-shrink: 0;
}
.gear-source-alternative {
  display: block;
  color: var(--text-muted);
}
.gear-source-details {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.6;
}
.gear-source-details > summary {
  color: var(--accent);
  cursor: pointer;
}
.gear-source-details > ul {
  padding: 6px 0 0 16px;
  margin: 0;
}
.gear-source-details > .gear-equipment-sources {
  padding-left: 0;
}
.gear-source-details li + li {
  margin-top: 4px;
}
.gear-reputation-requirement,
.gear-source-note {
  margin-top: 10px;
}
.gear-source-note {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
}
.gear-acquisition-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
}
.gear-equipment-enchant-sources {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.gear-equipment-panel .table-scroll {
  overflow: auto;
}
@media (max-width: 800px) {
  .gear-equipment-panel > header {
    padding: 16px;
  }
  .gear-equipment-panel table,
  .gear-equipment-panel tbody {
    display: block;
  }
  .gear-equipment-panel thead {
    position: absolute;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
    overflow: hidden;
  }
  .gear-equipment-panel tbody tr {
    display: grid;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
  }
  .gear-equipment-panel tbody :is(th, td) {
    padding: 0;
    border: 0;
  }
  .gear-equipment-panel tbody th {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 10px;
  }
  .gear-equipment-slot-label {
    min-height: 0;
  }
  .gear-equipment-reference .button {
    margin-top: 0;
    width: 100%;
    justify-content: center;
  }
  .gear-equipment-panel tbody .gear-equipment-empty {
    grid-template-columns: 90px minmax(0, 1fr);
    gap: 12px;
  }
  .gear-talent-link-actions {
    width: 100%;
  }
  .gear-talent-link-actions .button {
    flex: 1;
    justify-content: center;
  }
}
@media (max-width: 480px) {
  .gear-equipment-enchant {
    margin-left: 0;
  }
  .gear-equipment-source,
  .gear-source-heading,
  .gear-reputation-requirement {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }
}
.gear-planner-top-row .gear-items-list {
  scrollbar-gutter: stable;
  overflow-anchor: none;
}
.gear-drawer-slot-tag {
  min-width: 108px;
}
@media (min-width: 1201px) {
  /* The paperdoll determines the shared height; results scroll within it. */
  #gear-picker-col {
    contain: size;
    min-height: 0;
  }
  .gear-planner-top-row .gear-items-list {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow: auto;
  }
}
