/* ---------- Join view overlay ---------- */

.sls-container {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #000;
  display: flex;
  flex-direction: column;
}

.sls-grid {
  flex: 1;
  display: grid;
  gap: 4px;
  padding: 4px;
  min-height: 0;
}

.sls-cut {
  position: relative;
  background-color: #111;
  background-repeat: no-repeat;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  color: #fff;
  font-family: "Signika", sans-serif;
}

.sls-cut:hover {
  border-color: #f0c040;
  box-shadow: 0 0 24px rgba(240, 192, 64, 0.5);
  transform: scale(1.005);
}

.sls-cut.sls-empty {
  background: repeating-linear-gradient(45deg, #222, #222 10px, #1a1a1a 10px, #1a1a1a 20px);
  cursor: default;
}
.sls-cut.sls-empty:hover {
  border-color: transparent;
  box-shadow: none;
  transform: none;
}

.sls-label {
  --sls-name-scale: 1;
  --sls-bg-scale: 1;
  background: rgba(0, 0, 0, 0.65);
  padding: 0.5em 1em;
  margin-bottom: 24px;
  border-radius: 4px;
  font-size: calc(20px * var(--sls-name-scale));
  letter-spacing: 1px;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

.sls-fallback {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 12;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.75);
  color: #eee;
  border: 1px solid #666;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: background-color 120ms ease, border-color 120ms ease;
}
.sls-fallback:hover {
  background: rgba(40, 40, 40, 0.9);
  border-color: #f0c040;
  color: #fff;
}
.sls-fallback i { font-size: 12px; }

/* The real Foundry form sits pinned to the bottom so the user still has a
   password field and submit button. The user select is hidden — we set it via JS. */
form#join-game.sls-custom {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 11;
  background: rgba(0, 0, 0, 0.82);
  border: 1px solid #333;
  border-radius: 6px;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  max-width: 640px;
  pointer-events: auto;
}

form#join-game.sls-custom .form-group:has(select[name="userid"]),
form#join-game.sls-custom select[name="userid"] {
  display: none !important;
}

form#join-game.sls-custom .form-group {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 0;
}

form#join-game.sls-custom label { color: #ddd; font-size: 12px; }

/* Highlight the form once a portrait has been picked so players notice it. */
.sls-container.sls-picked ~ form#join-game.sls-custom,
body:has(.sls-container.sls-picked) form#join-game.sls-custom {
  box-shadow: 0 0 28px rgba(240, 192, 64, 0.55);
  border-color: #f0c040;
}

/* ---------- Config dialog ---------- */

/* Make the whole dialog body a flex column that fills the window so the
   footer can stick to the bottom while the cut list scrolls. */
#stylish-login-config {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#stylish-login-config .window-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.sls-config {
  display: flex;
  flex-direction: row;
  gap: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
}

/* ---------- Preset bar ---------- */

.sls-preset-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 8px;
  background: rgba(240, 192, 64, 0.06);
  border: 1px solid rgba(240, 192, 64, 0.2);
  border-radius: 4px;
  flex: 0 0 auto;
}
.sls-preset-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sls-preset-row > label {
  margin: 0;
  color: #f0c040;
  font-size: 12px;
  font-weight: 600;
  flex: 0 0 auto;
}
.sls-preset-select { flex: 1; min-width: 0; font-size: 11px; height: 24px; }
.sls-preset-name { flex: 1; min-width: 0; font-size: 11px; }
.sls-preset-row button {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 10px;
  line-height: 1;
}
.sls-preset-community-row {
  display: flex;
  gap: 4px;
}
.sls-preset-community-row button {
  flex: 1;
  font-size: 10px;
  padding: 3px 6px;
  height: 24px;
  white-space: nowrap;
}

/* ---------- Community panel ---------- */

@keyframes sls-slide-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes sls-slide-back {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.sls-community-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 4px;
  height: 100%;
  animation: sls-slide-in 250ms ease-out;
}
.sls-community-top-row {
  display: flex;
  gap: 4px;
  align-items: center;
}
.sls-refresh-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: 11px;
  background: #2a2a2a;
  border: 1px solid #555;
  color: #ddd;
  cursor: pointer;
  border-radius: 3px;
}
.sls-refresh-btn:hover:not(:disabled) { background: #333; border-color: #f0c040; }
.sls-refresh-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.sls-community-filters {
  display: flex;
  gap: 4px;
}
.sls-community-filters select {
  flex: 1;
  font-size: 11px;
  height: 24px;
}
.sls-community-meta {
  font-size: 10px;
  color: #888;
  margin-top: 2px;
}
.sls-community-list {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 80px;
  max-height: 340px;
  padding-right: 2px;
}
.sls-community-card {
  padding: 8px 10px;
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.sls-community-card:hover { background: #252525; border-color: #555; }
.sls-community-card.selected {
  border-color: #f0c040;
  background: rgba(240, 192, 64, 0.08);
}
.sls-community-name {
  font-size: 13px;
  font-weight: 600;
  color: #eee;
}
.sls-community-author {
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}
.sls-community-desc {
  font-size: 11px;
  color: #777;
  margin-top: 4px;
  line-height: 1.3;
}
.sls-community-empty {
  font-size: 12px;
  color: #777;
  font-style: italic;
  padding: 12px 4px;
}
.sls-community-import-btn {
  padding: 6px 10px;
  font-size: 12px;
  background: #2a2a2a;
  border: 1px solid #555;
  border-radius: 4px;
  cursor: pointer;
}
.sls-community-import-btn:hover:not(:disabled) {
  background: #333;
  border-color: #f0c040;
}
.sls-community-import-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.sls-community-divider {
  border: none;
  border-top: 1px solid #333;
  margin: 4px 0;
}
.sls-submit-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sls-submit-fields label {
  font-size: 11px;
  color: #ccc;
  margin: 0;
}
.sls-submit-fields input {
  font-size: 11px;
}
.sls-submit-btn {
  padding: 6px 10px;
  font-size: 12px;
  background: #2a2a2a;
  border: 1px solid #555;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 4px;
}
.sls-submit-btn:hover:not(:disabled) { background: #333; border-color: #f0c040; }
.sls-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

@keyframes sls-spin { to { transform: rotate(360deg); } }
.sls-spin { animation: sls-spin 0.7s linear infinite; }

/* ---------- Toolbar ---------- */

.sls-toolbar { flex: 0 0 auto; }

.sls-grid-size {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0;
}
.sls-grid-size label { margin: 0; color: #ccc; font-size: 11px; }
.sls-grid-size input[type="number"] { width: 38px; height: 24px; font-size: 11px; text-align: center; }
.sls-mode-select { font-size: 12px; height: 26px; }
.sls-logo-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}
.sls-logo-toggle input { margin: 0; }
.sls-live-preview .sls-foundry-logo {
  position: absolute;
  top: 0.5em;
  left: 0.5em;
  height: 2em;
  opacity: 0.8;
  pointer-events: none;
  z-index: 100;
}

.sls-fit-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 4px;
}
.sls-fit-row label { margin: 0; color: #ccc; font-size: 12px; }
.sls-fit-row select[name="fit"] {
  height: 26px;
  background: #1a1a1a;
  color: #eee;
  border: 1px solid #444;
  border-radius: 3px;
  padding: 0 4px;
}

.sls-fit-hint {
  margin: 4px 0 0;
  font-size: 11px;
  color: #888;
  font-style: italic;
  line-height: 1.4;
}

.sls-style-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 8px;
  align-items: center;
}
.sls-style-bar label { margin: 0; color: #ccc; font-size: 12px; }
.sls-style-bar select { width: 100%; }
.sls-style-bar input[type="number"] { width: 60px; }
.sls-style-bar input[type="color"] {
  width: 32px;
  height: 24px;
  padding: 0;
  border: 1px solid #444;
  background: #1a1a1a;
  cursor: pointer;
}
/* Reset button spans both columns */
.sls-style-bar button[data-action="resetStyle"] {
  grid-column: 1 / -1;
}

/* ---------- URLs ---------- */

.sls-urls {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* URL rows injected under the "Configure Login" menu on the Settings page.
   The Foundry settings content column is narrow, so everything stays inside
   it: each row is a flex container that can wrap, the URL code truncates
   with ellipsis, and the label sits on its own line above the URL + button. */
.sls-urls-inline .sls-share {
  background: rgba(240, 192, 64, 0.08);
  border: 1px solid rgba(240, 192, 64, 0.4);
  border-radius: 3px;
  padding: 0.2em 0.4em;
  font-size: 0.8em;
}
.sls-urls-inline .sls-share input[readonly] {
  opacity: 0.85;
  cursor: default;
  background: rgba(0, 0, 0, 0.4);
  font-family: monospace;
  height: 1.6em;
}
.sls-urls-inline .sls-share .form-fields {
  flex-wrap: nowrap;
}
.sls-urls-inline .sls-share button {
  flex: 0 0 auto;
  width: 1.5em;
  height: 1.5em;
  padding: 0;
  line-height: 1;
}
.sls-share-hint {
  color: #888;
  font-style: italic;
  margin: 0;
  padding: 0.3em 0;
}

/* ---------- Font management (settings page) ---------- */
.sls-fonts-inline {
  margin-top: 6px;
}
.sls-fonts-inline .sls-share label {
  font-weight: 600;
  font-size: 0.85em;
}
.sls-font-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 4px 0;
}
.sls-font-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 3px;
  font-size: 0.8em;
}
.sls-font-entry-name {
  font-weight: 600;
  min-width: 80px;
}
.sls-font-entry-url {
  flex: 1;
  opacity: 0.6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sls-font-entry .sls-font-remove {
  flex: 0 0 auto;
  width: 1.4em;
  height: 1.4em;
  padding: 0;
  line-height: 1;
  color: #e44;
  background: transparent;
  border: none;
  cursor: pointer;
  opacity: 0.6;
}
.sls-font-entry .sls-font-remove:hover { opacity: 1; }
.sls-font-add-row {
  display: flex;
  gap: 4px;
  align-items: center;
}
.sls-font-add-row input {
  flex: 1;
  height: 1.6em;
  font-size: 0.8em;
  padding: 0 4px;
}
.sls-font-add-row .sls-font-name-input { max-width: 120px; }
.sls-font-add-row button {
  flex: 0 0 auto;
  width: 1.5em;
  height: 1.5em;
  padding: 0;
  line-height: 1;
}

/* ---------- Three-column layout ---------- */

.sls-left {
  flex: 0 0 300px;
  width: 300px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 8px;
  overflow: hidden;
  padding: 8px;
  border-right: 1px solid #333;
}
.sls-left-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #444;
  padding-bottom: 4px;
  flex: 0 0 auto;
}
.sls-left h3 {
  margin: 0;
  font-size: 13px;
  color: #f0c040;
}
.sls-add-cut-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 11px;
  flex: 0 0 auto;
}

.sls-center {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  overflow: hidden;
}

.sls-cut-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 35%;
  overflow-y: auto;
  padding-right: 4px;
  flex: 0 0 auto;
}

.sls-cut-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid #444;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 100ms, border-color 100ms;
}
.sls-cut-row:hover { background: rgba(240, 192, 64, 0.1); }
.sls-cut-row.selected {
  background: rgba(240, 192, 64, 0.18);
  border-color: #f0c040;
}
.sls-cut-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #666;
  flex: 0 0 auto;
}
.sls-cut-row.selected .sls-cut-dot { background: #f0c040; }
.sls-cut-name {
  flex: 1;
  font-size: 12px;
  color: #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sls-cut-name em { color: #888; }
.sls-cut-row button {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  padding: 0;
  font-size: 11px;
}

.sls-cut-forms {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.sls-cut-fieldset {
  display: none;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 14px 14px 10px;
  background: rgba(0, 0, 0, 0.15);
}
.sls-cut-fieldset.active { display: block; }
.sls-cut-fieldset legend {
  font-size: 11px;
  color: #f0c040;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 6px;
}
.sls-cut-fieldset .form-group {
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sls-cut-fieldset .form-group > label {
  font-size: 12px;
  color: #cfcfcf;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sls-cut-fieldset .sls-range-val {
  font-family: monospace;
  color: #f0c040;
  font-size: 10px;
}
.sls-cut-fieldset .sls-image-row {
  flex-direction: row;
  gap: 4px;
  align-items: center;
}
.sls-cut-fieldset .sls-image-row label {
  flex: 0 0 auto;
  margin-right: 4px;
}
.sls-cut-fieldset .sls-image-row input[type="text"] {
  flex: 1;
  min-width: 0;
  font-size: 11px;
}
.sls-cut-fieldset .sls-image-row button {
  flex: 0 0 auto;
  width: 30px;
}
.sls-cut-fieldset input[type="range"] { width: 100%; }

.sls-cut-fieldset .sls-hover-override {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.sls-cut-fieldset .sls-hover-override > label {
  flex: 1 1 auto;
  display: flex;
  gap: 6px;
  align-items: center;
}
.sls-cut-fieldset .sls-hover-override input[type="color"] {
  flex: 0 0 auto;
  width: 34px;
  height: 24px;
  padding: 0;
  border: 1px solid #444;
  background: #1a1a1a;
  cursor: pointer;
}
.sls-cut-fieldset .sls-hover-override input[type="color"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.sls-name-style-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #444;
}
.sls-name-style-title {
  font-size: 11px;
  color: #f0c040;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.sls-empty-msg {
  text-align: center;
  color: #888;
  padding: 14px;
  font-size: 12px;
  font-style: italic;
}

/* ---------- Right: options column ---------- */

.sls-right {
  flex: 0 0 260px;
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px;
  border-left: 1px solid #333;
  overflow-y: auto;
  overflow-x: hidden;
}
.sls-right-group {
  border: 1px solid #555;
  border-radius: 4px;
  padding: 10px 10px 8px;
  background: rgba(0, 0, 0, 0.15);
  margin: 0;
}
.sls-right-group legend {
  font-size: 11px;
  color: #f0c040;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 6px;
}

.sls-live-preview-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}

.sls-entry-preview {
  --ar: 1.78;
  position: relative;
  aspect-ratio: var(--ar);
  width: min(100cqw, 100cqh * var(--ar));
  height: min(100cqh, 100cqw / var(--ar));
  background: #000;
  background-repeat: no-repeat;
  border: 1px solid #444;
  border-radius: 4px;
  overflow: hidden;
  container-type: inline-size;
}
.sls-entry-preview-label {
  color: #eee;
  opacity: 0.85;
  white-space: nowrap;
  pointer-events: none;
  z-index: 1;
}

.sls-live-preview {
  --sls-line-color: #000;
  --sls-line-thick: 3;
  --sls-hover-color: #f0c040;
  --sls-glow-strength: 1;
  --sls-hover-zoom: 4;
  position: relative;
  display: grid;
  gap: calc(var(--sls-line-thick) * 1px);
  background: var(--sls-line-color);
  border: 1px solid #444;
  border-radius: 4px;
  padding: calc(var(--sls-line-thick) * 1px);
  overflow: hidden;
  /* --ar is set from JS to match the real login viewport ratio.
     Fit inside the wrap along whichever axis is the tighter constraint. */
  --ar: 1.78;
  aspect-ratio: var(--ar);
  width: min(100cqw, 100cqh * var(--ar));
  height: min(100cqh, 100cqw / var(--ar));
}

.sls-live-cell {
  position: relative;
  overflow: hidden;
  background: #111;
  border: 2px solid transparent;
  border-radius: var(--sls-corner-radius, 2px);
  cursor: grab;
  user-select: none;
  touch-action: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: border-color 120ms, box-shadow 120ms;
}
.sls-live-cell.sls-dragging { cursor: grabbing; }
.sls-live-cell:hover {
  border-color: var(--sls-hover-color);
}
.sls-live-cell:hover .sls-live-img-wrap,
.sls-live-cell:hover .sls-live-silhouette-wrap {
  transform: scale(calc(1 + var(--sls-hover-zoom) / 100));
}
.sls-live-cell:hover .sls-live-hover-wrap { opacity: 1; }
.sls-live-cell.selected {
  border-color: var(--sls-hover-color, #f0c040);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sls-hover-color, #f0c040) 40%, transparent);
}
.sls-live-img,
.sls-live-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  pointer-events: none;
  transform-origin: center center;
}

/* ---------- Line style variants (grid mode) ---------- */

/* Double — two parallel thin strokes with the gap between them. Grid bg
   shows through the middle; each cell gets a thin outer stroke via
   box-shadow so you see: stroke | bg | stroke. */
.sls-live-preview.sls-line-style-double {
  background: transparent;
}
.sls-live-preview.sls-line-style-double .sls-live-cell {
  box-shadow: 0 0 0 max(1px, calc(var(--sls-line-thick) * 0.33px)) var(--sls-line-color);
}


/* Neon glow — solid lines plus an outward drop-shadow filter on the whole
   preview so every visible bg edge (grid gaps + outer border) glows. */
.sls-live-preview.sls-line-style-neon {
  filter:
    drop-shadow(0 0 calc(var(--sls-line-thick) * 1.2px) var(--sls-line-color))
    drop-shadow(0 0 calc(var(--sls-line-thick) * 2.4px) var(--sls-line-color));
}

.sls-live-label {
  --sls-name-scale: 1;
  --sls-bg-scale: 1;
  position: absolute;
  left: 50%;
  top: 88%;
  transform: translate(-50%, -50%);
  z-index: 7;
  background: rgba(0, 0, 0, 0.65);
  padding: 0.3em 0.75em;
  border-radius: 3px;
  font-size: calc(var(--sls-name-base, 13px) * var(--sls-name-scale));
  color: #fff;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
  max-width: 90%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sls-live-err {
  position: absolute;
  inset: 0;
  z-index: 3;
  padding: 6px;
  font-size: 10px;
  color: #f88;
  background: rgba(40, 0, 0, 0.85);
  word-break: break-all;
  white-space: pre-wrap;
  overflow: auto;
}
.sls-live-hint {
  margin: 0;
  font-size: 10px;
  color: #888;
  font-style: italic;
  text-align: center;
}

.sls-edge-hint {
  margin: 4px 0 0;
  padding: 6px 10px;
  font-size: 12px;
  text-align: center;
  color: #f0c040;
  background: rgba(240, 192, 64, 0.08);
  border: 1px solid rgba(240, 192, 64, 0.5);
  border-radius: 4px;
  text-shadow: 0 0 6px rgba(240, 192, 64, 0.9), 0 0 2px rgba(240, 192, 64, 0.7);
  box-shadow: 0 0 12px rgba(240, 192, 64, 0.35), inset 0 0 8px rgba(240, 192, 64, 0.15);
  animation: sls-edge-glow 2.2s ease-in-out infinite;
  flex: 0 0 auto;
}

@keyframes sls-edge-glow {
  0%, 100% {
    box-shadow: 0 0 8px rgba(240, 192, 64, 0.25), inset 0 0 6px rgba(240, 192, 64, 0.12);
    text-shadow: 0 0 4px rgba(240, 192, 64, 0.7), 0 0 1px rgba(240, 192, 64, 0.6);
  }
  50% {
    box-shadow: 0 0 18px rgba(240, 192, 64, 0.55), inset 0 0 10px rgba(240, 192, 64, 0.2);
    text-shadow: 0 0 8px rgba(240, 192, 64, 1), 0 0 3px rgba(240, 192, 64, 0.8);
  }
}

/* ---------- Custom layout (free-form cells) ---------- */

.sls-live-preview.sls-custom {
  display: block;
}
/* Cells in custom mode are absolute-positioned to their polygon bbox and
   clipped to the polygon. The JS sets left/top/width/height/clip-path. */
.sls-live-preview.sls-custom .sls-live-cell {
  position: absolute;
  border: none;
}
.sls-live-preview.sls-custom .sls-live-cell.selected {
  outline: none;
}
.sls-live-preview.sls-custom .sls-live-cell:hover {
  border-color: transparent;
  box-shadow: none;
}
.sls-live-img-wrap {
  position: absolute;
  inset: 0;
  transition: transform 180ms ease;
  transform-origin: center center;
}

/* Golden outline overlay for custom cells — sits above everything so the
   hover glow lands on the polygon's actual edges. */
.sls-outline-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 11;
  overflow: visible;
}
.sls-outline-svg polygon {
  fill: none;
  stroke: var(--sls-hover-color, #f0c040);
  stroke-width: calc(var(--sls-line-thick, 4) + 1);
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  filter:
    drop-shadow(0 0 calc(var(--sls-line-thick, 4) * 0.75px * var(--sls-glow-strength, 1)) var(--sls-hover-color, #f0c040))
    drop-shadow(0 0 calc(var(--sls-line-thick, 4) * 2px * var(--sls-glow-strength, 1)) var(--sls-hover-color, #f0c040));
  opacity: 0;
  transition: opacity 140ms;
}
.sls-outline-svg polygon.hover,
.sls-outline-svg polygon.selected {
  opacity: 1;
}

.sls-live-preview.sls-editing,
.sls-live-preview.sls-editing .sls-live-cell {
  cursor: crosshair;
}

/* ---------- Background layout ---------- */

.sls-live-preview.sls-background {
  display: block;
  position: relative;
  background-color: #111;
}
.sls-live-preview.sls-background > .sls-bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  z-index: 0;
}
.sls-live-preview.sls-background .sls-live-cell {
  position: absolute;
  border: 2px dashed rgba(240, 192, 64, 0.85);
  background: rgba(240, 192, 64, 0.12);
  cursor: move;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
}
.sls-live-preview.sls-background .sls-live-cell.selected {
  border-color: var(--sls-hover-color, #f0c040);
  background: color-mix(in srgb, var(--sls-hover-color, #f0c040) 22%, transparent);
  outline: none;
}
.sls-live-preview.sls-background .sls-live-cell .sls-live-img-wrap {
  pointer-events: none;
  border-radius: var(--sls-corner-radius, 2px);
  overflow: hidden;
}
.sls-live-preview.sls-background .sls-live-cell .sls-live-img:not([src]) {
  display: none;
}
.sls-live-preview.sls-background .sls-live-cell.sls-cut-border {
  border: calc(var(--sls-line-thick, 4) * 1px) solid var(--sls-line-color, #000);
}
.sls-live-preview.sls-background .sls-live-cell.sls-bg-moving { cursor: grabbing; }

.sls-zoom-box {
  position: absolute;
  border: 2px dashed rgba(120, 190, 255, 0.85);
  background: rgba(120, 190, 255, 0.08);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  cursor: move;
  box-sizing: border-box;
  z-index: 5;
}
.sls-zoom-box-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: rgba(120, 190, 255, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  pointer-events: none;
  user-select: none;
}

.sls-zoom-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: rgba(120, 190, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.5);
  z-index: 6;
}
.sls-zoom-handle[data-corner="tl"] { top: 1px;    left: 1px;  cursor: nwse-resize; }
.sls-zoom-handle[data-corner="tr"] { top: 1px;    right: 1px; cursor: nesw-resize; }
.sls-zoom-handle[data-corner="bl"] { bottom: 1px; left: 1px;  cursor: nesw-resize; }
.sls-zoom-handle[data-corner="br"] { bottom: 1px; right: 1px; cursor: nwse-resize; }

.sls-bg-handle {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 14px;
  height: 14px;
  background: #f0c040;
  border: 1px solid #000;
  cursor: nwse-resize;
  z-index: 3;
}

.sls-bg-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sls-bg-picker label { margin: 0; color: #ccc; font-size: 12px; }
.sls-bg-picker input[type="text"] { width: 100%; font-size: 11px; box-sizing: border-box; }
.sls-bg-picker-btns {
  display: flex;
  gap: 4px;
}
.sls-bg-picker-btns button {
  flex: 1;
  height: 22px;
  padding: 0 6px;
  font-size: 11px;
  line-height: 1;
}

.sls-edit-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  overflow: visible;
}
.sls-ghost-line {
  stroke: #f0c040;
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(240, 192, 64, 0.9));
  display: none;
  vector-effect: non-scaling-stroke;
}
/* Committed segments of an in-progress multi-segment draw, shown while the
   GM is still choosing where the cut will end. Same golden glow as the ghost
   tail so the full path reads as one continuous drawing. */
.sls-draw-seg {
  stroke: #f0c040;
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(240, 192, 64, 0.9));
  vector-effect: non-scaling-stroke;
}
.sls-draw-vertex {
  fill: #f0c040;
  stroke: #000;
  stroke-width: 0.4;
  vector-effect: non-scaling-stroke;
}
.sls-committed-line {
  stroke: var(--sls-line-color, #000);
  stroke-width: var(--sls-line-thick, 4);
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
/* Inner line is hidden by default; only "double" mode reveals it. It sits
   on top of the main line with a thinner bg-colored stroke, which visually
   carves a gap through the middle — producing the double-line effect. */
.sls-committed-line.sls-line-inner {
  stroke: transparent;
  stroke-width: 0;
}

/* ---------- Custom-mode line style variants (SVG) ---------- */

.sls-live-preview.sls-line-style-neon .sls-edit-svg {
  filter:
    drop-shadow(0 0 calc(var(--sls-line-thick, 4) * 1.2px) var(--sls-line-color, #000))
    drop-shadow(0 0 calc(var(--sls-line-thick, 4) * 2.4px) var(--sls-line-color, #000));
}

.sls-live-preview.sls-line-style-double .sls-committed-line.sls-line-main {
  stroke-width: calc(var(--sls-line-thick, 4) * 2.2);
  stroke-linecap: butt;
}
.sls-live-preview.sls-line-style-double .sls-committed-line.sls-line-inner {
  stroke: #fff;
  stroke-width: calc(var(--sls-line-thick, 4) * 0.7);
  stroke-linecap: butt;
  vector-effect: non-scaling-stroke;
  mix-blend-mode: difference;
}

/* Brush style: default SVG lines are hidden and the brush layer takes over.
   Polygon hover outline is also hidden so the wobbly brush is the only thing
   that glows — the outline's straight edges wouldn't match the brush shape. */
.sls-live-preview.sls-line-style-brush .sls-committed-line,
.sls-live-preview.sls-line-style-brushCrossed .sls-committed-line,
.sls-live-preview.sls-line-style-brush2 .sls-committed-line,
.sls-live-preview.sls-line-style-brush2Crossed .sls-committed-line,
.sls-live-preview.sls-line-style-thorns .sls-committed-line,
.sls-live-preview.sls-line-style-torn .sls-committed-line { display: none; }
.sls-live-preview.sls-line-style-brush .sls-outline-svg polygon,
.sls-live-preview.sls-line-style-brushCrossed .sls-outline-svg polygon,
.sls-live-preview.sls-line-style-brush2 .sls-outline-svg polygon,
.sls-live-preview.sls-line-style-brush2Crossed .sls-outline-svg polygon,
.sls-live-preview.sls-line-style-thorns .sls-outline-svg polygon,
.sls-live-preview.sls-line-style-torn .sls-outline-svg polygon { stroke: transparent; filter: none; }
.sls-brush-line {
  fill: var(--sls-brush-fill, #000);
  transition: filter 140ms, fill 140ms;
}
.sls-brush-line.sls-glow {
  fill: var(--sls-hover-color, #f0c040);
  filter:
    drop-shadow(0 0 calc(2px * var(--sls-glow-strength, 1)) var(--sls-hover-color, #f0c040))
    drop-shadow(0 0 calc(6px * var(--sls-glow-strength, 1)) var(--sls-hover-color, #f0c040))
    drop-shadow(0 0 calc(12px * var(--sls-glow-strength, 1)) var(--sls-hover-color, #f0c040));
}
.sls-brush-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 4;
}
.sls-brush-line {
  position: absolute;
  transform-origin: 0 50%;
  display: block;
  overflow: visible;
}


.sls-edit-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  background: rgba(240, 192, 64, 0.1);
  border: 1px solid rgba(240, 192, 64, 0.5);
  border-radius: 4px;
  font-size: 12px;
  flex: 0 0 auto;
}
.sls-edit-bar > span { color: #ccc; font-weight: 600; }
.sls-edit-bar button {
  padding: 4px 10px;
  font-size: 12px;
  background: #2a2a2a;
  color: #eee;
  border: 1px solid #555;
  border-radius: 3px;
  cursor: pointer;
}
.sls-edit-bar button:hover { background: #3a3a3a; }
.sls-edit-bar button.active {
  background: #f0c040;
  color: #111;
  border-color: #c09030;
  font-weight: 600;
}
.sls-edit-bar button.primary {
  background: #f0c040;
  color: #111;
  border-color: #c09030;
  font-weight: 600;
}
.sls-edit-bar .sls-edit-spacer { flex: 1; }

.sls-edit-hint {
  margin: 4px 0 0;
  font-size: 11px;
  color: #888;
  font-style: italic;
  flex: 0 0 auto;
}

.sls-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid #444;
  padding: 10px 6px 4px;
  flex: 0 0 auto;
  background: inherit;
  position: sticky;
  bottom: 0;
}
.sls-footer-hint {
  width: 100%;
  margin: 0;
  font-size: 10px;
  color: #777;
  font-style: italic;
  text-align: right;
}


/* ---------- Per-cut name style ---------- */

/* Preview labels */
.sls-live-label.sls-name-bg-none {
  background: transparent;
  padding: 0;
  text-shadow: 0 1px 3px #000, 0 0 6px rgba(0,0,0,0.9);
  overflow: visible;
  max-width: none;
}
.sls-live-label.sls-name-bg-image {
  background-color: transparent;
  background-repeat: no-repeat;
  background-size: calc(100% * var(--sls-bg-scale)) calc(100% * var(--sls-bg-scale));
  background-position: center;
  padding: 0.6em 1.4em;
  border-radius: 0;
}
.sls-live-label .sls-name-img {
  display: block;
  max-width: calc(180px * var(--sls-name-scale) * var(--sls-bg-scale));
  max-height: calc(60px * var(--sls-name-scale) * var(--sls-bg-scale));
  width: auto;
  height: auto;
  pointer-events: none;
}
.sls-live-label.sls-name-bg-none .sls-name-img,
.sls-live-label.sls-name-bg-image .sls-name-img { background: transparent; }

/* Image-only labels: no box, no padding — the <img> is the label. */
.sls-live-label.sls-name-image-only,
.sls-label.sls-name-image-only {
  background: transparent;
  padding: 0;
  border-radius: 0;
  text-shadow: none;
}

/* Font picker: each option renders in its own typeface. */
.sls-font-select option { padding: 4px 6px; font-size: 14px; }

/* Login labels — same class hooks. */
.sls-label.sls-name-bg-none {
  background: transparent;
  padding: 0;
  text-shadow: 0 2px 4px #000, 0 0 8px rgba(0,0,0,0.9);
}
.sls-label.sls-name-bg-image {
  background-color: transparent;
  background-repeat: no-repeat;
  background-size: calc(100% * var(--sls-bg-scale, 1)) calc(100% * var(--sls-bg-scale, 1));
  background-position: center;
  padding: 0.6em 1.4em;
  border-radius: 0;
}
.sls-label .sls-name-img {
  display: block;
  max-width: calc(320px * var(--sls-name-scale, 1) * var(--sls-bg-scale, 1));
  max-height: calc(110px * var(--sls-name-scale, 1) * var(--sls-bg-scale, 1));
  width: auto;
  height: auto;
  pointer-events: none;
}

/* Inline question-mark tooltip */
.sls-hint-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #444;
  color: #aaa;
  font-size: 9px;
  font-weight: 700;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
  flex-shrink: 0;
  user-select: none;
}
.sls-hint-bubble {
  display: none;
  position: fixed;
  width: 260px;
  background: #1c1c1c;
  color: #bbb;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
  padding: 8px 10px;
  border: 1px solid #444;
  border-radius: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
  white-space: normal;
  z-index: 9999;
  pointer-events: none;
}
.sls-hint-bubble.sls-hint-visible { display: block; }

/* Section header used in the right column */
.sls-section-header {
  font-size: 12px;
  font-weight: 600;
  color: #f0c040;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(240, 192, 64, 0.3);
  padding-bottom: 4px;
  margin-top: 4px;
}

/* Music picker + entry screen (right column) */
.sls-music-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sls-music-row > label {
  font-size: 12px;
  color: #ccc;
}
.sls-music-row .sls-image-row {
  display: flex;
  gap: 4px;
}
.sls-music-row input[type="text"] {
  flex: 1;
  font-size: 11px;
}
.sls-music-row button {
  height: 22px;
  padding: 0 6px;
  font-size: 11px;
}
.sls-volume-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
}
.sls-volume-row label {
  font-size: 11px;
  color: #ccc;
  display: flex;
  justify-content: space-between;
}
.sls-volume-row input[type="range"] { width: 100%; }
.sls-entry-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sls-entry-hint {
  margin: 0;
  font-size: 10px;
  color: #888;
  font-style: italic;
  line-height: 1.4;
}
.sls-entry-sub {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  padding: 8px 10px;
  border-left: 2px solid #444;
  background: rgba(255, 255, 255, 0.02);
}
.sls-customize-entry-btn {
  margin-top: 8px;
  padding: 6px 10px;
  font-size: 12px;
  background: #2a2a2a;
  border: 1px solid #555;
  color: #ddd;
  cursor: pointer;
  border-radius: 3px;
}
.sls-customize-entry-btn:hover { background: #333; border-color: #f0c040; }
.sls-edit-entry-bg-btn {
  margin-top: 4px;
  padding: 6px 10px;
  font-size: 12px;
  background: #2a2a2a;
  border: 1px solid #555;
  color: #ddd;
  cursor: pointer;
  border-radius: 3px;
}
.sls-edit-entry-bg-btn:hover { background: #333; border-color: #f0c040; }
.sls-entry-bg-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 0 2px;
}
.sls-entry-bg-controls label {
  font-size: 11px;
  color: #ccc;
  display: flex;
  justify-content: space-between;
}
.sls-entry-bg-controls select { font-size: 11px; height: 24px; }
.sls-entry-bg-controls input[type="range"] { width: 100%; }
.sls-entry-bg-controls .sls-image-row { display: flex; gap: 4px; }
.sls-entry-bg-controls .sls-image-row input[type="text"] {
  flex: 1; min-width: 0; font-size: 11px; height: 24px;
  background: #1a1a1a; border: 1px solid #555; color: #ddd; border-radius: 3px; padding: 0 4px;
}
.sls-entry-bg-controls .sls-image-row button {
  padding: 2px 6px; font-size: 11px; background: #2a2a2a;
  border: 1px solid #555; color: #ddd; cursor: pointer; border-radius: 3px;
}
.sls-entry-editor-divider {
  border: none; border-top: 1px solid #444; margin: 4px 0;
}
.sls-entry-text-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 4px;
  animation: sls-slide-in 250ms ease-out;
}
.sls-entry-text-panel .form-group label { font-size: 12px; color: #ccc; }
.sls-back-btn {
  align-self: flex-start;
  padding: 6px 12px;
  font-size: 12px;
  background: #2a2a2a;
  border: 1px solid #555;
  color: #ddd;
  cursor: pointer;
  border-radius: 3px;
  margin-bottom: 4px;
}
.sls-back-btn:hover { background: #333; border-color: #f0c040; }
.sls-entry-sub > label {
  font-size: 11px;
  color: #ccc;
  margin-top: 2px;
}
.sls-entry-sub .sls-image-row {
  display: flex;
  gap: 4px;
}
.sls-entry-sub input[type="text"] {
  flex: 1;
  font-size: 11px;
}
.sls-entry-sub button {
  height: 22px;
  padding: 0 6px;
  font-size: 11px;
}
.sls-entry-sub select {
  font-size: 12px;
}

/* Glow on hover — the parent cell's :hover state triggers it. Uses the
   cell's current --sls-hover-color, so it inherits per-cut overrides. */
.sls-live-cell:hover .sls-live-label.sls-name-glow,
.sls-cut:hover .sls-label.sls-name-glow {
  filter:
    drop-shadow(0 0 calc(4px * var(--sls-glow-strength, 1)) var(--sls-hover-color, #f0c040))
    drop-shadow(0 0 calc(10px * var(--sls-glow-strength, 1)) var(--sls-hover-color, #f0c040));
  transition: filter 140ms;
}
.sls-live-label.sls-name-glow,
.sls-label.sls-name-glow {
  transition: filter 140ms;
}
/* Custom-mode labels live in a detached layer, so .sls-cut:hover can't reach
   them. login.html toggles .sls-hovered manually. */
.sls-label-layer .sls-label.sls-name-glow.sls-hovered {
  filter:
    drop-shadow(0 0 calc(4px * var(--sls-glow-strength, 1)) var(--sls-hover-color, #f0c040))
    drop-shadow(0 0 calc(10px * var(--sls-glow-strength, 1)) var(--sls-hover-color, #f0c040));
}

/* Kill all hover effects on cells with noHover set. */
.sls-live-cell.sls-no-hover:hover {
  border-color: transparent;
  box-shadow: none;
}
