/* Homeworld editor + play shell — corners use site --border-radius (1px). */

.homeworld-page .content-shell.homeworld-shell {
  padding: 0;
  max-width: none;
  min-height: calc(100vh - var(--topbar-height, 56px));
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.homeworld-stage {
  position: absolute;
  inset: 0;
  background: #0c1018;
  touch-action: none;
}

.homeworld-stage canvas {
  display: block;
  image-rendering: pixelated;
}

.homeworld-stage--pixel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  background: #2e3440;
  overflow: hidden;
}

.homeworld-stage--pixel.hw-sprite-workspace--dark {
  background: #2e3440;
}

.homeworld-stage--pixel.hw-sprite-workspace--light {
  background: #e8ebf0;
}

.homeworld-stage--pixel.hw-sprite-workspace--light .homeworld-hud__room,
.homeworld-stage--pixel.hw-sprite-workspace--light .homeworld-hud__hint {
  text-shadow: 0 1px 4px rgba(255, 255, 255, 0.85);
  color: #1a2230;
}

.hw-sprite-chrome {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  z-index: 4;
}

.hw-sprite-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 2.65rem;
  padding: 0.35rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.18);
}

.hw-sprite-tool-options {
  flex: 0 0 auto;
  padding: 0.35rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.22);
}

.homeworld-stage--pixel.hw-sprite-workspace--light .hw-sprite-tool-options {
  border-bottom-color: rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.45);
}

.hw-sprite-tool-options__inner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  max-width: 100%;
}

.hw-sprite-tool-options__row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.hw-sprite-tool-options__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.hw-sprite-tool-options__actions .hw-delete-selection-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.45rem;
}

.hw-sprite-tool-options__actions .hw-delete-selection-btn svg {
  width: 1.1rem;
  height: 1.1rem;
}

.hw-sprite-tool-options__hint {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.35;
}

.hw-sprite-tool-options__steps {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 0.65rem;
  line-height: 1.4;
}

.hw-sprite-tool-options__steps li {
  margin-bottom: 0.15rem;
}

.hw-sprite-tool-options__label {
  font-size: 0.72rem;
  font-weight: 500;
  color: #e8ecf4;
  white-space: nowrap;
}

.homeworld-stage--pixel.hw-sprite-workspace--light .hw-sprite-tool-options__label {
  color: #1a2230;
}

.hw-sprite-tool-options__range {
  flex: 1 1 8rem;
  min-width: 6rem;
  max-width: 14rem;
}

.hw-sprite-tool-options__val {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted, #9aa3b5);
  min-width: 1.5rem;
  text-align: right;
}

.homeworld-stage--pixel.hw-sprite-workspace--light .hw-sprite-toolbar {
  border-bottom-color: rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.55);
}

.hw-sprite-toolbar__main {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: thin;
}

.hw-sprite-toolbar__group {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.hw-sprite-toolbar__group--tools {
  flex-wrap: nowrap;
}

.hw-sprite-toolbar__sep {
  width: 1px;
  height: 1.65rem;
  margin: 0 0.1rem;
  background: rgba(255, 255, 255, 0.14);
  flex-shrink: 0;
}

.homeworld-stage--pixel.hw-sprite-workspace--light .hw-sprite-toolbar__sep {
  background: rgba(0, 0, 0, 0.12);
}

.hw-sprite-toolbar__btn {
  appearance: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  background: transparent;
  color: var(--text-muted, #9aa3b5);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  flex-shrink: 0;
}

.hw-sprite-toolbar__btn svg {
  width: 17px;
  height: 17px;
}

.hw-sprite-toolbar__btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
  color: #e8ecf4;
}

.hw-sprite-toolbar__btn.is-active {
  background: color-mix(in srgb, var(--page-accent, #e85d4c) 22%, transparent);
  border-color: color-mix(in srgb, var(--page-accent, #e85d4c) 55%, transparent);
  color: #fff;
}

.hw-sprite-toolbar__btn--panel.is-active {
  background: color-mix(in srgb, var(--page-accent, #e85d4c) 14%, transparent);
}

.hw-sprite-toolbar__meta {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  min-width: 0;
  max-width: min(22rem, 42vw);
}

.hw-sprite-toolbar__meta-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  width: 100%;
}

.hw-sprite-toolbar__title {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #e8ecf4;
  white-space: nowrap;
}

.homeworld-stage--pixel.hw-sprite-workspace--light .hw-sprite-toolbar__title {
  color: #1a2230;
}

.hw-sprite-toolbar__status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.hw-sprite-toolbar__tool-icon {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  color: #e8ecf4;
}

.homeworld-stage--pixel.hw-sprite-workspace--light .hw-sprite-toolbar__tool-icon {
  color: #1a2230;
}

.hw-sprite-toolbar__tool-icon svg {
  width: 1.05rem;
  height: 1.05rem;
}

.hw-sprite-toolbar__color-swatch {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  border-radius: var(--border-radius);
  border: 2px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  background-image:
    linear-gradient(45deg, rgba(120, 120, 120, 0.45) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(120, 120, 120, 0.45) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(120, 120, 120, 0.45) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(120, 120, 120, 0.45) 75%);
  background-size: 6px 6px;
  background-position: 0 0, 0 3px, 3px -3px, -3px 0;
}

.hw-sprite-toolbar__hint {
  margin: 0.12rem 0 0;
  font-size: 0.65rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.homeworld-stage--pixel.hw-sprite-workspace--light .hw-sprite-toolbar__hint {
  color: #4a5568;
}

.homeworld-loading {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  color: var(--text-muted, #8b95a8);
  z-index: 1;
  pointer-events: none;
}

/* Title + hint: top-right of stage (all modes — clear of left nav / library list) */
.homeworld-hud {
  position: absolute;
  top: 0.65rem;
  right: 1rem;
  left: auto;
  bottom: auto;
  z-index: 5;
  pointer-events: none;
  max-width: min(26rem, 48vw);
  text-align: right;
}

.homeworld-hud__room {
  margin: 0 0 0.2rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.75);
}

.homeworld-hud__hint {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
}

.homeworld-hud__sprite-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin: 0.3rem 0 0.35rem;
}

.homeworld-hud__tool-icon {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  color: #e8ecf4;
  filter: drop-shadow(0 1px 6px rgba(0, 0, 0, 0.65));
}

.homeworld-hud__tool-icon svg {
  width: 1.2rem;
  height: 1.2rem;
}

.homeworld-hud__color-swatch {
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: var(--border-radius);
  border: 2px solid rgba(255, 255, 255, 0.45);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.45),
    0 1px 6px rgba(0, 0, 0, 0.55);
}

.homeworld-toast {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  z-index: 3;
  padding: 0.55rem 0.85rem;
  border-radius: var(--border-radius);
  background: rgba(12, 16, 24, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
}

/* Mode tools: directly under Play / Sprite / World links */
.homeworld-page .sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  padding: 0 0.4rem 0.45rem !important;
  gap: 0.2rem !important;
}

.homeworld-page .sidebar__nav {
  flex: 0 0 auto;
  margin-bottom: 0;
  gap: 0.15rem;
}

.homeworld-page .sidebar__link {
  padding: 0.35rem 0.4rem;
}

.homeworld-page .sidebar > .sidebar__section-title {
  padding: 0.5rem 0.35rem 0.15rem;
  margin: 0;
}

.homeworld-page .sidebar__resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 5px;
  height: 100%;
  cursor: ew-resize;
  z-index: 20;
  touch-action: none;
  background: transparent;
}

.homeworld-page .sidebar__resize-handle:hover,
.homeworld-page .sidebar__resize-handle.is-dragging {
  background: color-mix(in srgb, var(--page-accent, #e85d4c) 40%, transparent);
}

.homeworld-tools-sep {
  flex: 0 0 auto;
  height: 1px;
  margin: 0.25rem 0.35rem 0.05rem;
  background: rgba(255, 255, 255, 0.14);
  border: 0;
}

.homeworld-tools-sep[hidden] {
  display: none !important;
}

.homeworld-tools {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 0;
  padding: 0.25rem 0.3rem 0.45rem;
  border-top: none;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 0.78rem;
}

.hw-tools-layout {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 0;
}

.hw-tools-main {
  flex: 1 1 auto;
  min-width: 0;
}

.hw-tools-rail {
  flex: 0 0 42px;
  width: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.15rem 0.35rem;
  margin: -0.15rem -0.2rem -0.15rem 0;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.12);
}

.hw-tools-rail__group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.22rem;
  width: 100%;
}

.hw-tools-rail__sep {
  width: 26px;
  height: 1px;
  margin: 0.12rem 0;
  background: rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.hw-tools-rail__btn {
  appearance: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  background: transparent;
  color: var(--text-muted, #9aa3b5);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.hw-tools-rail__btn svg {
  width: 18px;
  height: 18px;
}

.hw-tools-rail__btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
  color: #e8ecf4;
}

.hw-tools-rail__btn.is-active {
  background: color-mix(in srgb, var(--page-accent, #e85d4c) 22%, transparent);
  border-color: color-mix(in srgb, var(--page-accent, #e85d4c) 55%, transparent);
  color: #fff;
}

.hw-tools-rail__btn--panel.is-active {
  background: color-mix(in srgb, var(--page-accent, #e85d4c) 14%, transparent);
}

.homeworld-tools[hidden] {
  display: none !important;
}

.homeworld-tools__mode-label {
  font-size: 0.65rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted, #8b95a8);
  margin: 0 0 0.35rem;
  padding: 0 0.05rem;
}

.hw-tools__section {
  margin-bottom: 0.45rem;
}

.hw-tools__section--sep {
  padding-top: 0.55rem;
  margin-top: 0.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.hw-tools__subsection {
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.hw-tools__subsection--tight {
  margin-top: 0.45rem;
  padding-top: 0.4rem;
}

.hw-tools__label--sub {
  margin-bottom: 0.35rem;
}

.hw-tools__hint {
  font-size: 0.65rem;
  margin: 0.35rem 0 0;
  line-height: 1.35;
}

.hw-tools__status {
  font-size: 0.7rem;
  margin: 0.5rem 0 0;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.hw-tools__section:last-child {
  margin-bottom: 0;
}

/* Sprite editor — floating paint / timeline panels */
.hw-sprite-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hw-sprite-panel__block {
  margin: 0;
}

.hw-sprite-panel__tools {
  margin-bottom: 0.15rem;
}

.hw-sprite-panel__divider {
  height: 1px;
  margin: 0.15rem 0;
  background: rgba(255, 255, 255, 0.1);
}

.hw-sprite-color__rgb {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.hw-sprite-color__channel {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.62rem;
  color: var(--text-muted, #8b95a8);
}

.hw-sprite-color__channel input {
  width: 100%;
  padding: 0.3rem 0.35rem;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: #e8ecf2;
  font-size: 0.72rem;
}

.hw-sprite-color__alpha {
  display: grid;
  grid-template-columns: auto 1fr 2.75rem 2.5rem;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.45rem;
  font-size: 0.62rem;
  color: var(--text-muted, #8b95a8);
}

.hw-sprite-color__alpha-label {
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.62rem;
}

.hw-sprite-color__alpha-range {
  width: 100%;
  margin: 0;
}

.hw-sprite-color__alpha-num {
  width: 100%;
  padding: 0.25rem 0.3rem;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: #e8ecf2;
  font-size: 0.72rem;
}

.hw-sprite-color__alpha-pct {
  font-size: 0.68rem;
  text-align: right;
  color: #c5cdd8;
}

.hw-sprite-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.hw-sprite-swatch {
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--border-radius);
  cursor: pointer;
}

.hw-sprite-swatch {
  position: relative;
}

.hw-sprite-swatch.is-selected {
  outline: 2px solid var(--page-accent, #e85d4c);
  outline-offset: 2px;
}

.hw-sprite-swatch__key {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  padding: 0;
  background: none;
  border: 0;
  color: #fff;
  text-shadow:
    0 0 2px #000,
    0 1px 2px rgba(0, 0, 0, 0.95),
    1px 0 2px rgba(0, 0, 0, 0.85),
    -1px 0 2px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}

.hw-sprite-palette-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.hw-sprite-palette-name {
  font-size: 0.62rem;
}

.hw-sprite-palette-actions {
  margin-top: 0.35rem;
}

.hw-sprite-panel__palette-block kbd {
  font-size: 0.62rem;
  padding: 0.05rem 0.25rem;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.25);
}

.hw-library__palette-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  width: 100%;
  height: 100%;
  padding: 4px;
  box-sizing: border-box;
  align-content: flex-start;
}

.hw-library__palette-chip {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: var(--border-radius);
  border: 1px solid rgba(0, 0, 0, 0.35);
  flex: 0 0 auto;
}

.hw-library__palette-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.5rem;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.25);
  min-height: 3rem;
}

.hw-library__palette-preview .hw-library__palette-chip {
  width: 1.25rem;
  height: 1.25rem;
}

.hw-sprite-swatch:hover {
  outline: 2px solid rgba(255, 255, 255, 0.35);
  outline-offset: 1px;
}

.hw-sprite-brush-range {
  flex: 1;
  min-width: 0;
}

.hw-sprite-brush-val {
  font-size: 0.72rem;
  color: var(--text-muted, #9aa3b5);
  min-width: 2.2rem;
  text-align: right;
}

.hw-brush-shapes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.35rem;
}

.hw-brush-shapes .hw-brush-shape-btn {
  flex: 1;
  min-width: 0;
  padding: 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hw-brush-shapes .hw-brush-shape-btn svg {
  width: 1.1rem;
  height: 1.1rem;
}

.hw-brush-size-row {
  margin-top: 0.15rem;
}

.hw-light-angle-row--disabled {
  opacity: 0.45;
  pointer-events: none;
}

.hw-sprite-lights-list {
  margin: 0.35rem 0 0;
  padding: 0;
  list-style: none;
}

.hw-sprite-light-pick {
  width: 100%;
  justify-content: flex-start;
  margin-bottom: 0.25rem;
}

.hw-sprite-light-pick.is-active {
  outline: 1px solid rgba(255, 140, 60, 0.65);
}

.hw-sprite-dim {
  width: 3.2rem;
  padding: 0.25rem 0.35rem;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.3);
  color: #e8ecf2;
  font-size: 0.75rem;
}

.hw-sprite-zoom,
.hw-sprite-fps {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  margin-top: 0.35rem;
}

.hw-sprite-zoom input,
.hw-sprite-fps input {
  width: 3.2rem;
  padding: 0.25rem 0.35rem;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.3);
  color: #e8ecf2;
}

.hw-sprite-onion {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  margin-left: auto;
}

.hw-sprite-frame-idx {
  font-size: 0.78rem;
  min-width: 4.5rem;
  text-align: center;
}

.hw-sprite-layers {
  max-height: 9rem;
  overflow-y: auto;
  margin-bottom: 0;
}

.hw-sprite-panel__block--layers .hw-tools__label {
  margin-bottom: 0.15rem;
}

.hw-sprite-layer-actions {
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.hw-sprite-open__combo {
  position: relative;
  margin-top: 0.2rem;
}

.hw-sprite-open__trigger {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  min-height: 2rem;
  padding: 0.28rem 0.45rem;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.2);
  color: #e8ecf4;
  font-size: 0.78rem;
  text-align: left;
  cursor: pointer;
}

.hw-sprite-open__trigger:hover,
.hw-sprite-open__trigger.is-open {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
}

.hw-sprite-open__trigger-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hw-sprite-open__chev {
  flex: 0 0 auto;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  opacity: 0.65;
  margin-left: 0.15rem;
}

.hw-sprite-open__menu {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: calc(100% + 0.2rem);
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  max-height: 11rem;
  overflow-y: auto;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #1a1f28;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.hw-sprite-open__empty {
  padding: 0.45rem 0.35rem;
  font-size: 0.72rem;
  line-height: 1.35;
}

.hw-sprite-open__option {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.3rem 0.35rem;
  border: none;
  border-radius: var(--border-radius);
  background: transparent;
  color: inherit;
  font-size: 0.76rem;
  text-align: left;
  cursor: pointer;
}

.hw-sprite-open__option:hover {
  background: rgba(255, 255, 255, 0.07);
}

.hw-sprite-open__option.is-selected {
  background: color-mix(in srgb, var(--page-accent, #e85d4c) 18%, transparent);
}

.hw-sprite-open__option-thumb {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--border-radius);
  overflow: hidden;
  background: repeating-conic-gradient(#2a2e36 0% 25%, #1a1d24 0% 50%) 0 0 / 8px 8px;
}

.hw-sprite-open__option-thumb img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  image-rendering: pixelated;
}

.hw-sprite-open__option-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hw-sprite-open__thumb-wrap {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: repeating-conic-gradient(#2a2e36 0% 25%, #1a1d24 0% 50%) 0 0 / 8px 8px;
  overflow: hidden;
}

.hw-world-sprite-preview.is-draggable {
  cursor: grab;
}
.hw-world-sprite-preview.is-dragging {
  opacity: 0.55;
  cursor: grabbing;
}
.hw-world-sprite-preview {
  margin-top: 0.5rem;
  padding: 0.5rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.22);
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 5.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.hw-world-sprite-preview img {
  max-width: 100%;
  max-height: 7.5rem;
  width: auto;
  height: auto;
  image-rendering: pixelated;
  object-fit: contain;
}

.hw-world-sprite-preview__name {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-muted, #9aa3b5);
  word-break: break-word;
}

.hw-world-sprites-panel .hw-sprite-open__menu {
  max-height: 14rem;
}

.hw-sprite-open__thumb {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
  image-rendering: pixelated;
}


.hw-tools__label {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted, #8b95a8);
  margin-bottom: 0.2rem;
}

.hw-tools__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  margin-bottom: 0.25rem;
}

.hw-collision__enable {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.72rem;
  line-height: 1.35;
  margin: 0;
}

.hw-collision__enable input {
  margin-top: 0.15rem;
}

.hw-collision__dims {
  margin-top: 0.3rem;
  gap: 0.35rem;
}

.hw-collision__box--disabled {
  opacity: 0.45;
  pointer-events: none;
}

.hw-sprite-view-controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.35rem;
  align-items: end;
  width: 100%;
}

.hw-sprite-view-controls__btn {
  width: 100%;
  justify-content: center;
  padding: 0.38rem 0.35rem;
  font-size: 0.72rem;
  line-height: 1.2;
}

.hw-sprite-view-controls__zoom {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.18rem;
  margin: 0;
  min-width: 3.25rem;
}

.hw-sprite-view-controls__zoom-label {
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted, #8b95a8);
  line-height: 1;
}

.hw-sprite-view-controls__zoom .hw-tools__input {
  width: 100%;
  min-width: 0;
  padding: 0.32rem 0.25rem;
  text-align: center;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.hw-tools__panel-btns {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.hw-tools__btn--panel {
  width: 100%;
  justify-content: center;
  text-align: center;
  padding: 0.45rem 0.5rem;
}

.hw-tools__btn--panel.is-active {
  background: color-mix(in srgb, var(--page-accent, #e85d4c) 18%, transparent);
  border-color: color-mix(in srgb, var(--page-accent, #e85d4c) 55%, transparent);
  color: #e8ecf4;
}

.hw-tools__field {
  margin: 0;
}

.hw-tools__btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  border-radius: var(--border-radius);
  padding: 0.28rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.hw-tools__btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.hw-tools__btn.is-active {
  border-color: var(--page-accent, #6b8cae);
  background: color-mix(in srgb, var(--page-accent, #6b8cae) 25%, transparent);
}

.hw-tools__btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.hw-tools__btn--primary {
  background: var(--page-accent, #6b8cae);
  border-color: transparent;
  color: #0c1018;
  font-weight: 600;
}

.hw-tools__btn--danger {
  border-color: color-mix(in srgb, #e85d4c 45%, rgba(255, 255, 255, 0.12));
  color: #f0a89e;
}

.hw-tools__btn--danger:hover {
  background: color-mix(in srgb, #e85d4c 18%, transparent);
  color: #ffd4ce;
}

.hw-tools__input,
.hw-tools__select {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: inherit;
  border-radius: var(--border-radius);
  padding: 0.3rem 0.45rem;
  font-size: 0.75rem;
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}

.hw-tools__color {
  width: 2rem;
  height: 1.6rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--border-radius);
  background: transparent;
  cursor: pointer;
}

.hw-tools__list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 8rem;
  overflow-y: auto;
}

.hw-tools__list li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.3rem;
  border-radius: var(--border-radius);
  cursor: pointer;
}

.hw-tools__list li.is-active {
  background: rgba(255, 255, 255, 0.08);
}

.hw-tools__list li:hover {
  background: rgba(255, 255, 255, 0.05);
}

.hw-pixel-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.hw-pixel-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  image-rendering: pixelated;
  touch-action: none;
}



.homeworld-stage--map {
  overflow: hidden;
  cursor: grab;
}
.homeworld-stage--map:active {
  cursor: grabbing;
}
.hw-map-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  touch-action: none;
}


/* Collapsed rail: mode tools need full width — hide until expanded */
:is(body.sidebar-collapsed, html.rr-sidebar-collapsed body) .homeworld-tools,
:is(body.sidebar-collapsed, html.rr-sidebar-collapsed body) .homeworld-tools-sep {
  display: none !important;
}



.homeworld-shell {
  position: relative;
}

.homeworld-floats {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 30;
}

.hw-float {
  position: absolute;
  pointer-events: auto;
  min-width: 240px;
  max-width: min(420px, 92vw);
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  background: rgba(18, 22, 30, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.hw-float__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: grab;
  user-select: none;
}

.hw-float__head:active {
  cursor: grabbing;
}

.hw-float__title {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hw-float__close {
  border: 0;
  background: transparent;
  color: var(--text-muted, #8b95a8);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
}

.hw-float__close:hover {
  color: #fff;
}

.hw-float__body {
  padding: 0.65rem 0.75rem 0.85rem;
  overflow-y: auto;
  font-size: 0.8rem;
}

.hw-float__section + .hw-float__section {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.hw-float__section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted, #8b95a8);
}

.hw-tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.hw-tile-swatch {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--border-radius);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  background: #222;
  image-rendering: pixelated;
}

.hw-tile-swatch span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.15rem 0.25rem;
  font-size: 0.65rem;
  background: rgba(0, 0, 0, 0.55);
  color: #eee;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hw-tile-swatch.is-active {
  outline: 2px solid var(--page-accent, #e85d4c);
  outline-offset: 1px;
}

.hw-tile-swatch:hover {
  border-color: rgba(255, 255, 255, 0.28);
}


.hw-toolstrip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}

.hw-toolstrip__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: 3.1rem;
  padding: 0.35rem 0.25rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted, #9aa3b5);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.hw-toolstrip__btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #e8ecf4;
  border-color: rgba(255, 255, 255, 0.18);
}

.hw-toolstrip__btn.is-active {
  background: color-mix(in srgb, var(--page-accent, #e85d4c) 22%, transparent);
  border-color: var(--page-accent, #e85d4c);
  color: #fff;
}

.hw-toolstrip__btn--icon {
  min-height: 2.65rem;
  padding: 0.45rem 0.25rem;
}

.hw-toolstrip__icon {
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
}

.hw-toolstrip__icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

.hw-toolstrip__label {
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  line-height: 1;
}


.hw-mat__preview {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  grid-template-rows: 1fr 1fr;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--border-radius);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #12151c;
}

.hw-mat__primary {
  grid-row: 1 / 3;
  grid-column: 1;
}

.hw-mat__secondary {
  grid-row: 1;
  grid-column: 2;
}

.hw-mat__texture {
  grid-row: 2;
  grid-column: 2;
}

.hw-mat__tex-slot {
  grid-row: 2;
  grid-column: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(0, 0, 0, 0.35);
}

.hw-mat__tex-preview {
  position: relative;
  flex: 1;
  min-height: 0;
  image-rendering: pixelated;
}

.hw-mat__tex-select {
  width: 100%;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.45);
  color: #e8ecf2;
  font-size: 0.62rem;
  padding: 0.28rem 0.25rem;
  cursor: pointer;
}

.hw-mat__cell-label {
  position: absolute;
  left: 0.35rem;
  right: 0.3rem;
  bottom: 0.28rem;
  font-size: 0.58rem;
  line-height: 1.1;
  text-align: left;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}

.hw-mat__cell {
  position: relative;
  border: 0;
  border-right: 1px solid rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(0, 0, 0, 0.35);
  padding: 0;
  cursor: pointer;
  min-height: 0;
  image-rendering: pixelated;
}

.hw-mat__cell span {
  position: absolute;
  left: 0.35rem;
  right: 0.3rem;
  bottom: 0.28rem;
  font-size: 0.58rem;
  line-height: 1.1;
  text-align: left;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}

.hw-mat__cell:hover {
  filter: brightness(1.08);
}

.hw-mat__hint {
  margin: 0.45rem 0 0.35rem;
  font-size: 0.68rem;
}

.hw-carousel {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.hw-carousel__track {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  overflow-y: visible;
  scroll-snap-type: x mandatory;
  flex: 1;
  min-width: 0;
  min-height: 48px;
  align-items: center;
  /* Room for selection ring (outline was clipped by overflow-x) */
  padding: 3px 4px;
  scroll-padding-inline: 4px;
  scrollbar-width: thin;
}

.hw-carousel__item {
  position: relative;
  overflow: hidden;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: var(--border-radius);
  border: 2px solid rgba(255, 255, 255, 0.12);
  padding: 0;
  cursor: pointer;
  scroll-snap-align: start;
  background: #222;
  image-rendering: pixelated;
  box-sizing: border-box;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.hw-carousel__item.is-active {
  border-color: var(--page-accent, #e85d4c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.hw-carousel__nav {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 2.4rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius);
  background: rgba(255, 255, 255, 0.04);
  color: #c5ccd8;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.hw-carousel__nav:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}


.hw-mat--compact {
  max-width: none;
}

.hw-mat__row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.hw-mat__row-label {
  flex: 0 0 2.4rem;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted, #8b95a8);
}

.hw-mat__plate {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2px;
  height: 40px;
}

.hw-mat__swatch {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--border-radius);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  background: #12151c;
  min-width: 0;
}

.hw-mat__base {
  position: absolute;
  inset: 0;
}

.hw-mat__overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.45;
  mix-blend-mode: multiply;
}

.hw-mat__overlay--plank.hw-mat__overlay--top {
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 5px,
    rgba(0, 0, 0, 0.38) 5px,
    rgba(0, 0, 0, 0.38) 6px
  );
}

.hw-mat__overlay--plank.hw-mat__overlay--top.hw-mat__overlay--vertical {
  background: repeating-linear-gradient(
    to right,
    transparent 0,
    transparent 4px,
    rgba(0, 0, 0, 0.38) 4px,
    rgba(0, 0, 0, 0.38) 5px
  );
}

.hw-mat__orient {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.35rem 0 0.45rem;
}

.hw-mat__orient-label {
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted, #8b95a8);
}

.hw-mat__orient-toggle {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.hw-mat__orient-btn {
  font-size: 0.68rem;
  padding: 0.22rem 0.45rem;
  min-height: 1.65rem;
}

.hw-mat__overlay--plank.hw-mat__overlay--face {
  background: repeating-linear-gradient(
    to right,
    transparent 0,
    transparent 4px,
    rgba(0, 0, 0, 0.38) 4px,
    rgba(0, 0, 0, 0.38) 5px
  );
}


.hw-mat__tag {
  position: absolute;
  left: 0.2rem;
  bottom: 0.15rem;
  font-size: 0.55rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

.hw-mat__swatch:hover {
  filter: brightness(1.06);
  border-color: rgba(255, 255, 255, 0.28);
}


.hw-carousel__item .hw-mat__base,
.hw-carousel__item .hw-mat__overlay {
  position: absolute;
  inset: 0;
}


.hw-color-dock {
  margin: 0.35rem 0 0.4rem;
  padding: 0.45rem 0.5rem;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.32);
}

.hw-color-dock__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.hw-color-dock__label {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted, #9aa3b5);
}

.hw-color-dock__done {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--border-radius);
  background: rgba(255, 255, 255, 0.06);
  color: #d8dee8;
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  cursor: pointer;
}

.hw-color-dock__done:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.hw-color-dock__controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.hw-color-dock__controls input[type="color"] {
  flex: 1;
  min-width: 0;
  height: 2.25rem;
  padding: 0.1rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--border-radius);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.hw-color-dock__hex {
  width: 4.6rem;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  padding: 0.35rem 0.4rem;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: #e8ecf2;
}

.hw-mat__swatch.is-pick-active {
  outline: 2px solid var(--page-accent, #e85d4c);
  outline-offset: 1px;
}

.hw-mat__planes {
  display: flex;
  gap: 0.65rem;
  margin: 0.5rem 0 0.4rem;
}

.hw-mat__plane {
  flex: 1;
  min-width: 0;
}

.hw-mat__plane-label {
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted, #8b95a8);
  margin-bottom: 0.25rem;
}

.hw-mat__preview--sm {
  aspect-ratio: 1;
  min-height: 132px;
  width: 100%;
}

.hw-mat__cell .hw-mat__overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.48;
  mix-blend-mode: multiply;
  background-size: cover;
}

.hw-mat__name-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.68rem;
  margin-bottom: 0.35rem;
}

.hw-mat__name-row span {
  color: var(--text-muted, #9aa3b5);
  flex: 0 0 auto;
}

.hw-mat__name {
  flex: 1;
  min-width: 0;
  font-size: 0.72rem;
  padding: 0.25rem 0.4rem;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  color: #e8ecf2;
}

.hw-mat__opt {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.65rem;
  margin: 0 0 0.25rem;
}

.hw-mat__cell.is-pick-active {
  outline: 2px solid var(--page-accent, #e85d4c);
  outline-offset: -2px;
  z-index: 1;
}

.hw-mat .hw-carousel {
  margin: 0 -2px;
}

.hw-mat__overlay--stone {
  opacity: 0.62;
  background-image: var(--hw-stone-noise, none);
  background-size: 96px 96px;
  mix-blend-mode: soft-light;
}

.hw-mat__overlay--grass.hw-mat__overlay--top {
  background: repeating-linear-gradient(
    95deg,
    transparent 0,
    transparent 3px,
    rgba(25, 70, 35, 0.45) 3px,
    rgba(25, 70, 35, 0.45) 4px
  );
  opacity: 0.55;
}

.hw-mat__overlay--grass.hw-mat__overlay--face {
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent 4px,
    rgba(20, 55, 30, 0.4) 4px,
    rgba(20, 55, 30, 0.4) 5px
  );
  opacity: 0.5;
}

.hw-mat__overlay--carpet {
  opacity: 0.5;
  background-image:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.2) 0, rgba(0, 0, 0, 0.2) 1px, transparent 1px, transparent 4px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.15) 0, rgba(0, 0, 0, 0.15) 1px, transparent 1px, transparent 4px);
}

.hw-mat__overlay--gloss {
  opacity: 0.85;
  background: linear-gradient(
    165deg,
    rgba(255, 255, 255, 0.5) 0%,
    rgba(255, 255, 255, 0.12) 28%,
    rgba(255, 255, 255, 0.02) 55%,
    rgba(0, 0, 0, 0.15) 100%
  );
  mix-blend-mode: screen;
}


.homeworld-stage--library {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0.65rem;
  overflow: hidden;
}

.hw-library {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(12, 15, 22, 0.92);
  overflow: hidden;
}

.hw-library__nav {
  flex: 0 0 200px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.5rem 0.35rem;
  overflow-y: auto;
}

.hw-library__group {
  margin-bottom: 0.25rem;
}

.hw-library__cat,
.hw-library__sub {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: var(--border-radius);
  background: transparent;
  color: #b8c0d0;
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0.4rem 0.55rem;
}

.hw-library__cat {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.hw-library__cat-label {
  flex: 1;
  min-width: 0;
}

.hw-library__chev {
  flex: 0 0 auto;
  width: 0.4rem;
  height: 0.4rem;
  margin-top: -0.1rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  opacity: 0.65;
  transition: transform 0.12s ease;
}

.hw-library__group.has-subs.is-open > .hw-library__cat .hw-library__chev {
  transform: rotate(45deg);
  margin-top: 0.05rem;
}

.hw-library__group.has-subs:not(.is-open) .hw-library__subs {
  display: none;
}

.hw-library__sub {
  font-size: 0.72rem;
  padding-left: 1.1rem;
  color: #8b95a8;
}

.hw-library__cat:hover,
.hw-library__sub:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.hw-library__cat.is-active,
.hw-library__sub.is-active {
  background: color-mix(in srgb, var(--page-accent, #e85d4c) 20%, transparent);
  color: #fff;
}

.hw-library__subs {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-top: 0.1rem;
}

.hw-library__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 0.65rem 0.85rem;
}

.hw-library__head {
  margin-bottom: 0.65rem;
}

.hw-library__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.hw-library__subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.72rem;
}

.hw-library__split {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.hw-library__split.has-detail .hw-library__grid-wrap {
  flex: 0 0 min(42%, 520px);
  max-width: 52%;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.hw-library__grid-wrap {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.hw-library__detail {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.2);
}

.hw-library__detail[hidden] {
  display: none !important;
}

.hw-library__detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem 0.35rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.hw-library__detail-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.hw-library__detail-close {
  border: 0;
  background: transparent;
  color: var(--text-muted, #8b95a8);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}

.hw-library__detail-close:hover {
  color: #fff;
}

.hw-library__detail-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.55rem 0.65rem 0.85rem;
}

.hw-library__detail-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  margin-bottom: 0.5rem;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.35);
  padding: 0.5rem;
}

.hw-library__detail-preview-img {
  max-width: 100%;
  max-height: 200px;
  image-rendering: pixelated;
}

.hw-mat--library {
  max-width: none;
}

.hw-library__grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 0.55rem;
  align-content: start;
}

.hw-library__card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.3rem;
  padding: 0.45rem;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  color: inherit;
  text-align: left;
}

.hw-library__card:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
}

.hw-library__card.is-selected {
  border-color: var(--page-accent, #e85d4c);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--page-accent, #e85d4c) 35%, transparent);
}

.hw-library__thumb {
  display: block;
  aspect-ratio: 1;
  border-radius: var(--border-radius);
  overflow: hidden;
  background: #1a1f28;
  image-rendering: pixelated;
}

.hw-library__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.hw-library__swatch {
  display: block;
  width: 100%;
  height: 100%;
}

.hw-library__swatch--empty {
  background: repeating-conic-gradient(#2a2e36 0% 25%, #1a1d24 0% 50%) 0 0 / 12px 12px;
}

.hw-library__name {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hw-library__tag {
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8b95a8;
}

.hw-library__empty {
  grid-column: 1 / -1;
  padding: 1rem 0;
  font-size: 0.8rem;
}


.hw-library__card.is-dragging {
  opacity: 0.55;
  outline: 2px dashed var(--page-accent, #e85d4c);
}

.hw-library-ctx {
  position: fixed;
  z-index: 80;
  min-width: 11rem;
  max-width: min(16rem, 92vw);
  max-height: min(70vh, 420px);
  overflow-y: auto;
  padding: 0.35rem 0;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(16, 20, 28, 0.98);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
}

.hw-library-ctx__item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: #e8ecf2;
  font-size: 0.72rem;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
}

.hw-library-ctx__item:hover,
.hw-library-ctx__item.is-active {
  background: rgba(255, 255, 255, 0.08);
}

.hw-library-ctx__item.is-active {
  color: var(--page-accent, #e85d4c);
}

.hw-library-ctx__sep {
  height: 1px;
  margin: 0.25rem 0;
  background: rgba(255, 255, 255, 0.08);
}

.hw-library-ctx__label,
.hw-library-ctx__hint {
  display: block;
  font-size: 0.62rem;
  padding: 0.25rem 0.65rem 0.15rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hw-tools__field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.homeworld-stage--map .hw-map-canvas {
  /* drop target hint when dragging library assets */
}

/* Light theme — Homeworld panels (uses site data-theme) */
html[data-theme="light"] .homeworld-page .homeworld-tools,
html[data-theme="light"] .hw-float,
html[data-theme="light"] .hw-library__detail,
html[data-theme="light"] .hw-library__nav,
html[data-theme="light"] .hw-library-ctx {
  background: color-mix(in srgb, var(--color-surface) 96%, transparent);
  border-color: color-mix(in srgb, var(--page-accent) 12%, rgba(20, 30, 50, 0.12));
  color: var(--color-text);
  box-shadow: var(--glass-shadow);
}

html[data-theme="light"] .hw-library-ctx__item {
  color: var(--color-text);
}

html[data-theme="light"] .hw-tools-rail {
  background: color-mix(in srgb, var(--color-surface-alt) 80%, transparent);
  border-left-color: color-mix(in srgb, var(--page-accent) 10%, rgba(20, 30, 50, 0.12));
}

html[data-theme="light"] .hw-tools__btn,
html[data-theme="light"] .hw-tools__input,
html[data-theme="light"] .hw-tools__select {
  background: var(--color-surface-alt);
  border-color: color-mix(in srgb, var(--page-accent) 10%, rgba(20, 30, 50, 0.14));
  color: var(--color-text);
}


html[data-theme="light"] .muted {
  color: var(--color-text-muted);
}

.hw-facing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  width: 100%;
  height: 100%;
}
.hw-facing-grid--large {
  width: 100%;
  height: 220px;
  gap: 4px;
}
.hw-facing-grid__cell {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 3px;
  overflow: hidden;
}
.hw-facing-grid__cell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: pixelated;
}
.hw-facing-grid__cell em {
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: 0.5rem;
  font-style: normal;
  opacity: 0.45;
  letter-spacing: 0.05em;
}
.hw-facing-grid--large .hw-facing-grid__cell em {
  font-size: 0.6rem;
}

.hw-selbar {
  position: absolute;
  z-index: 6;
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 8px;
  background: rgba(20, 22, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}
.hw-selbar button {
  font: inherit;
  font-size: 0.72rem;
  padding: 0.28rem 0.6rem;
  border: 0;
  border-radius: 6px;
  color: #e8eaf0;
  background: transparent;
  cursor: pointer;
}
.hw-selbar button:hover {
  background: rgba(255, 255, 255, 0.12);
}
.hw-selbar button.is-danger:hover {
  background: rgba(255, 90, 90, 0.35);
}

.hw-selbar[hidden] {
  display: none;
}

.hw-selbar__label {
  align-self: center;
  min-width: 2.2rem;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #ffdc78;
}
.hw-selbar button[data-act='rotl'],
.hw-selbar button[data-act='rotr'] {
  font-size: 1rem;
  line-height: 1;
  padding: 0.2rem 0.5rem;
}

.hw-tray {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: min(880px, calc(100% - 24px));
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px 10px;
  border-radius: 12px;
  background: rgba(18, 20, 26, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.hw-tray[hidden] {
  display: none;
}
.hw-tray__head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hw-tray__chips {
  display: flex;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}
.hw-tray__chip,
.hw-tray__facing button,
.hw-tray__close {
  font: inherit;
  font-size: 0.72rem;
  color: #d9dce4;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  cursor: pointer;
}
.hw-tray__chip:hover,
.hw-tray__facing button:hover,
.hw-tray__close:hover {
  background: rgba(255, 255, 255, 0.14);
}
.hw-tray__chip.is-active {
  color: #1a1408;
  background: #ffdc78;
}
.hw-tray__facing {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: #ffdc78;
}
.hw-tray__facing button {
  font-size: 1rem;
  line-height: 1;
  padding: 0.15rem 0.55rem;
}
.hw-tray__list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.hw-tray__card {
  flex: 0 0 auto;
  width: 92px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 5px;
  font: inherit;
  color: #d9dce4;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
}
.hw-tray__card:hover {
  background: rgba(255, 255, 255, 0.09);
}
.hw-tray__card.is-selected {
  border-color: #ffdc78;
  box-shadow: inset 0 0 0 1px rgba(255, 220, 120, 0.4);
}
.hw-tray__thumb {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 64px;
  overflow: hidden;
  border-radius: 6px;
  background: #151820;
}
.hw-tray__thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: pixelated;
}
.hw-tray__name {
  font-size: 0.66rem;
  line-height: 1.2;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
