* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  color-scheme: dark;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background:
    radial-gradient(circle at top, rgba(82, 111, 165, 0.25), transparent 35%),
    linear-gradient(180deg, #13131c 0%, #0b0b11 100%);
  color: #e8edf5;
}

body {
  min-height: 100vh;
  background: inherit;
  color: inherit;
}

button {
  font: inherit;
}

#root {
  width: 100%;
}

.app-shell {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 32px 20px;
}

.app-header {
  text-align: center;
  margin-bottom: 24px;
}

.app-kicker {
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #88a5d6;
  font-size: 0.75rem;
  margin-bottom: 10px;
}

.app-header h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  color: #f7ead0;
  margin-bottom: 10px;
}

.app-description {
  max-width: 640px;
  margin: 0 auto;
  color: #b7c0d3;
  line-height: 1.5;
}

.character-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}

.character-selector label {
  font-size: 0.85rem;
  color: #8ca2c9;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.character-dropdown {
  appearance: none;
  background: rgba(30, 37, 56, 0.9);
  color: #f5e8ca;
  border: 1px solid rgba(126, 151, 194, 0.28);
  border-radius: 10px;
  padding: 10px 36px 10px 14px;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238ca2c9' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.character-dropdown:focus {
  outline: 2px solid #6888c0;
  outline-offset: 2px;
}

.viewer-card {
  background: rgba(18, 22, 34, 0.84);
  border: 1px solid rgba(140, 168, 219, 0.18);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.canvas-frame {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  aspect-ratio: 1 / 1;
  min-height: 0;
  max-height: none;
  padding: 8px;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01)),
    rgba(9, 11, 18, 0.95);
  border: 1px solid rgba(126, 151, 194, 0.14);
  overflow: hidden;
}

.viewer-canvas {
  max-width: 100%;
  max-height: 100%;
  height: auto;
  object-fit: contain;
}

.viewer-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #c8d6ed;
  font-size: 1.5rem;
  line-height: 1;
  width: 28px;
  height: 40px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  transition: opacity 0.15s;
  z-index: 2;
  padding: 0;
}

.viewer-arrow:hover {
  opacity: 1;
  background: transparent;
}

.viewer-arrow:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.viewer-arrow-left {
  left: 4px;
}

.viewer-arrow-right {
  right: 4px;
}

.viewer-expression-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  color: #c8d6ed;
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  padding: 4px 8px 6px;
  background: linear-gradient(to top, rgba(9, 11, 18, 0.75), transparent);
  pointer-events: none;
}

.viewer-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  background: rgba(10, 13, 21, 0.5);
  backdrop-filter: blur(3px);
  border-radius: 18px;
  color: #f5e8ca;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

.viewer-spinner {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 3px solid rgba(245, 232, 202, 0.18);
  border-top-color: #88a5d6;
  animation: viewer-spin 0.9s linear infinite;
}

@keyframes viewer-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* ── Spine Viewer ─────────────────────────────────────────── */
.spine-viewer-panel {
  min-width: 0;
  align-self: flex-start;
}

.spine-viewer-row {
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: flex-start;
}

.spine-canvas-col {
  flex: 0 0 360px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.spine-canvas-wrap {
  position: relative;
}

.spine-sound-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-direction: row;
  gap: 4px;
  z-index: 10;
}

.spine-canvas-frame {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(126, 151, 194, 0.14);
  background: rgba(9, 11, 18, 0.95);
  aspect-ratio: 1 / 1;
  line-height: 0;
}

.spine-canvas-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.spine-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: 10px;
  border: 1px solid rgba(126, 151, 194, 0.14);
  background: rgba(9, 11, 18, 0.95);
  color: rgba(200, 214, 237, 0.35);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.spine-placeholder--error { color: rgba(220, 80, 80, 0.6); }

.spine-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.spine-audio-editor {
  flex: 0 0 300px;
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(9, 11, 18, 0.72);
  border: 1px solid rgba(90, 130, 200, 0.22);
}

.spine-edit-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(14, 19, 31, 0.7);
  border: 1px solid rgba(120, 149, 201, 0.18);
}

.spine-audio-editor-title {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(190, 210, 242, 0.66);
}

.spine-audio-empty {
  font-size: 0.74rem;
  color: rgba(168, 189, 224, 0.35);
  padding: 2px 0;
}

.spine-audio-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  align-items: end;
  gap: 8px;
}

.spine-audio-name {
  flex: 1;
  min-width: 0;
  font-size: 0.73rem;
  color: #a8bde0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spine-audio-metric {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.spine-audio-metric span {
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(168, 189, 224, 0.62);
}

.spine-audio-master-row {
  display: flex;
}

.spine-audio-metric--master {
  width: 100%;
  max-width: 180px;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.spine-audio-metric--master span {
  white-space: nowrap;
}

.spine-audio-remove {
  background: none;
  border: none;
  color: rgba(168, 189, 224, 0.4);
  cursor: pointer;
  font-size: 1.06rem;
  line-height: 1;
  padding: 0;
  transition: color 0.15s;
}

.spine-audio-remove:hover {
  color: #e87878;
}

.spine-audio-footer {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}

.spine-audio-msg {
  font-size: 0.72rem;
  color: #7ec87e;
  line-height: 1.3;
}

.spine-audio-msg.is-error {
  color: #e87878;
}

.spine-transform-slot {
  font-size: 0.72rem;
  color: rgba(196, 214, 246, 0.92);
  background: rgba(104, 136, 192, 0.2);
  border: 1px solid rgba(123, 149, 195, 0.26);
  border-radius: 6px;
  padding: 4px 7px;
  width: fit-content;
}

.spine-transform-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.spine-transform-field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
}

.spine-transform-field span {
  font-size: 0.67rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(168, 189, 224, 0.66);
}

.drag-axis-input-field {
  width: 100% !important;
  min-width: 0;
  text-align: right;
  cursor: ew-resize;
  padding: 4px 7px;
  font-size: 0.74rem;
}

@media (max-width: 760px) {
  .spine-viewer-row {
    flex-direction: column;
  }

  .spine-canvas-col,
  .spine-audio-editor {
    flex: 1 1 auto;
    width: 100%;
    max-width: 360px;
  }

  .spine-transform-grid {
    grid-template-columns: 1fr;
  }
}

.cms-layout input[type="number"],
.spine-viewer-panel input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.cms-layout input[type="number"]::-webkit-outer-spin-button,
.cms-layout input[type="number"]::-webkit-inner-spin-button,
.spine-viewer-panel input[type="number"]::-webkit-outer-spin-button,
.spine-viewer-panel input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.spine-sound-btn {
  background: rgba(90, 130, 200, 0.1);
  border: 1px solid rgba(90, 130, 200, 0.25);
  color: #a8bde0;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.spine-sound-btn:hover {
  background: rgba(90, 130, 200, 0.28);
  color: #e8f0ff;
}

.spine-topright-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: row;
  gap: 6px;
  z-index: 10;
}

.spine-icon-btn {
  padding: 2px;
  border: none;
  border-radius: 0;
  background: none;
  color: #a8bde0;
  font-size: 0.82rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.spine-icon-btn:hover {
  color: #e8f0ff;
}

.spine-icon-btn.is-active {
  color: #7ec87e;
}

.spine-mute-btn.is-muted {
  color: rgba(168, 189, 224, 0.35);
}

.controls-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.primary-button {
  border: none;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.72rem;
  background: linear-gradient(135deg, #6789c2, #426091);
  color: #f9fbff;
  cursor: pointer;
}

.primary-button:disabled,
.expression-chip:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.expression-badge {
  min-width: 0;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(80, 96, 134, 0.28);
  border: 1px solid rgba(123, 149, 195, 0.2);
  text-align: center;
  color: #f5e8ca;
  font-size: 0.7rem;
}

.expression-grid {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  max-height: 90px;
  overflow-y: auto;
  padding: 2px;
}

.expression-chip {
  border: 1px solid rgba(126, 151, 194, 0.22);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.68rem;
  background: rgba(30, 37, 56, 0.8);
  color: #c8d1e3;
  cursor: pointer;
}

.expression-chip-active {
  background: #6888c0;
  color: #ffffff;
}

.status-message {
  padding: 40px;
  text-align: center;
  font-size: 1.1rem;
}

.status-message-error {
  color: #ff8c8c;
}

/* Test page styles */

.upload-card {
  background: rgba(18, 22, 34, 0.84);
  border: 1px solid rgba(140, 168, 219, 0.18);
  border-radius: 24px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.mode-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 18px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(126, 151, 194, 0.22);
  background: rgba(20, 25, 40, 0.6);
}

.mode-toggle-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: #8ca2c9;
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mode-toggle-btn:hover:not(.mode-toggle-active) {
  background: rgba(126, 151, 194, 0.08);
}

.mode-toggle-active {
  background: linear-gradient(135deg, #6789c2, #426091);
  color: #f9fbff;
}

.mode-panel {
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.upload-title {
  color: #f7ead0;
  font-size: 1.1rem;
  margin: 0 0 6px;
}

.step-title {
  margin: 24px 0 12px;
}

.upload-desc {
  color: #b7c0d3;
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0 0 14px;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.upload-row label:first-child {
  font-size: 0.85rem;
  color: #8ca2c9;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.upload-file-label {
  display: inline-flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(30, 37, 56, 0.9);
  border: 1px solid rgba(126, 151, 194, 0.28);
  color: #b7c0d3;
  font-size: 0.9rem;
  cursor: pointer;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-file-label:hover {
  border-color: rgba(126, 151, 194, 0.5);
}

.upload-file-input {
  display: none;
}

.upload-success {
  color: #7ecc8e;
  margin: 12px 0 0;
  font-size: 0.95rem;
}

.plist-upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.plist-upload-btn {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.plist-toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
}

.plist-upload-row .upload-success {
  margin: 0;
}

.danger-button {
  border-color: rgba(198, 94, 94, 0.35);
  color: #f2b3b3;
}

.danger-button:hover:not(:disabled) {
  background: rgba(198, 94, 94, 0.14);
}

.test-id-input {
  background-image: none;
  padding-right: 14px;
}

.test-plist-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.test-plist-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 220px;
  padding: 10px 18px;
  border-radius: 12px;
  background: rgba(80, 96, 134, 0.28);
  border: 1px solid rgba(123, 149, 195, 0.2);
}

.test-plist-filename {
  color: #f5e8ca;
  font-size: 1rem;
  word-break: break-all;
}

.test-plist-count {
  color: #8ca2c9;
  font-size: 0.8rem;
}

.test-back-link {
  color: #88a5d6;
}

.test-help {
  margin-top: 24px;
  text-align: center;
  color: #6a7a9b;
  font-size: 0.85rem;
}

.test-help p {
  margin-top: 4px;
}

.nav-link {
  color: #88a5d6;
  font-size: 0.85rem;
  text-decoration: none;
  letter-spacing: 0.06em;
}

.nav-link-button {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.nav-link-active {
  color: #f5e8ca;
}

.nav-link:hover {
  text-decoration: underline;
}

/* CMS Layout */

.cms-layout {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

.cms-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: rgba(12, 15, 24, 0.95);
  border-right: 1px solid rgba(126, 151, 194, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cms-sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(126, 151, 194, 0.1);
}

.cms-sidebar-brand {
  font-size: 1.05rem;
  font-weight: 600;
  color: #f7ead0;
  letter-spacing: 0.03em;
}

.cms-sidebar-subtitle {
  font-size: 0.7rem;
  color: #6a7a9b;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-top: 2px;
}

.cms-sidebar-search {
  padding: 14px 14px 6px;
}

.cms-search-input {
  width: 100%;
  background: rgba(30, 37, 56, 0.7);
  border: 1px solid rgba(126, 151, 194, 0.18);
  border-radius: 8px;
  padding: 8px 12px;
  color: #e8edf5;
  font: inherit;
  font-size: 0.85rem;
}

.cms-search-input::placeholder {
  color: #5a6a85;
}

.cms-search-input:focus {
  outline: 2px solid #6888c0;
  outline-offset: -2px;
}

.cms-sidebar-section-title {
  padding: 14px 16px 6px;
  font-size: 0.68rem;
  font-weight: 600;
  color: #5a6a85;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.cms-sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 10px;
}

.cms-sidebar-section-header .cms-sidebar-section-title {
  flex: 1 1 0;
}

.cms-sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cms-sidebar-add-btn {
  border: 1px solid rgba(126, 151, 194, 0.24);
  background: rgba(30, 37, 56, 0.6);
  color: #88a5d6;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cms-sidebar-add-btn:hover {
  background: rgba(126, 151, 194, 0.14);
}

.cms-sidebar-addcol-btn {
  border: 1px solid rgba(126, 151, 194, 0.18);
  background: transparent;
  color: #6a87b8;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cms-sidebar-addcol-btn:hover {
  background: rgba(126, 151, 194, 0.1);
  color: #a8c0e8;
}

.cms-sidebar-sort-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px 8px;
}

.cms-sort-select {
  flex: 1;
  background: rgba(30, 37, 56, 0.7);
  border: 1px solid rgba(126, 151, 194, 0.18);
  border-radius: 6px;
  padding: 4px 8px;
  color: #e8edf5;
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.cms-sort-select:focus {
  outline: none;
  border-color: rgba(126, 151, 194, 0.4);
}

.cms-sort-dir-btn {
  background: rgba(30, 37, 56, 0.7);
  border: 1px solid rgba(126, 151, 194, 0.18);
  border-radius: 6px;
  padding: 4px 8px;
  color: #e8edf5;
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}

.cms-sort-dir-btn:hover {
  background: rgba(80, 100, 150, 0.3);
}

.cms-create-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, 0.55);
  backdrop-filter: blur(2px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.cms-create-panel {
  width: min(420px, 100%);
  background: rgba(18, 22, 34, 0.96);
  border: 1px solid rgba(126, 151, 194, 0.22);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cms-create-panel h3 {
  color: #f5e8ca;
  font-size: 0.95rem;
  margin: 0;
}

.cms-character-list {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px;
}

.cms-character-list::-webkit-scrollbar {
  width: 4px;
}

.cms-character-list::-webkit-scrollbar-thumb {
  background: rgba(126, 151, 194, 0.2);
  border-radius: 4px;
}

.cms-content,
.cms-character-list,
.cms-item-list,
.cms-editor-panel,
.expression-grid,
.app-shell {
  scrollbar-width: thin;
  scrollbar-color: rgba(102, 136, 192, 0.55) rgba(14, 17, 28, 0.7);
}

.cms-content::-webkit-scrollbar,
.cms-character-list::-webkit-scrollbar,
.cms-item-list::-webkit-scrollbar,
.cms-editor-panel::-webkit-scrollbar,
.expression-grid::-webkit-scrollbar,
.app-shell::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.cms-content::-webkit-scrollbar-track,
.cms-character-list::-webkit-scrollbar-track,
.cms-item-list::-webkit-scrollbar-track,
.cms-editor-panel::-webkit-scrollbar-track,
.expression-grid::-webkit-scrollbar-track,
.app-shell::-webkit-scrollbar-track {
  background: rgba(14, 17, 28, 0.7);
  border-radius: 999px;
}

.cms-content::-webkit-scrollbar-thumb,
.cms-character-list::-webkit-scrollbar-thumb,
.cms-item-list::-webkit-scrollbar-thumb,
.cms-editor-panel::-webkit-scrollbar-thumb,
.expression-grid::-webkit-scrollbar-thumb,
.app-shell::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(126, 151, 194, 0.72), rgba(82, 111, 165, 0.72));
  border: 2px solid rgba(14, 17, 28, 0.7);
  border-radius: 999px;
}

.cms-content::-webkit-scrollbar-thumb:hover,
.cms-character-list::-webkit-scrollbar-thumb:hover,
.cms-item-list::-webkit-scrollbar-thumb:hover,
.cms-editor-panel::-webkit-scrollbar-thumb:hover,
.expression-grid::-webkit-scrollbar-thumb:hover,
.app-shell::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(136, 165, 214, 0.86), rgba(103, 137, 194, 0.86));
}

.cms-character-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: #8e9ab3;
  font-size: 0.88rem;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font: inherit;
  transition: background 0.1s;
}

.cms-character-item:hover {
  background: rgba(126, 151, 194, 0.07);
  color: #c8d1e3;
}

.cms-character-item-active {
  background: rgba(103, 137, 194, 0.15);
  color: #f5e8ca;
}

.cms-character-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3a4560;
  flex-shrink: 0;
}

.cms-character-item-active .cms-character-dot {
  background: #88a5d6;
}

.cms-no-results {
  padding: 16px 12px;
  color: #5a6a85;
  font-size: 0.85rem;
  text-align: center;
}

.cms-sidebar-sprites {
  border-top: 1px solid rgba(126, 151, 194, 0.1);
}

.cms-sprite-tabs {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  padding: 2px 8px 8px;
  gap: 4px;
}

.cms-sprite-tab {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: #8e9ab3;
  font-size: 0.85rem;
  border: none;
  background: none;
  text-align: left;
  font: inherit;
  transition: background 0.1s;
}

.cms-sprite-tab:hover {
  background: rgba(126, 151, 194, 0.07);
}

.cms-sprite-tab-active {
  background: rgba(103, 137, 194, 0.15);
  color: #f5e8ca;
}

.cms-sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(126, 151, 194, 0.1);
}

.cms-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.cms-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 52px;
  background: rgba(14, 17, 28, 0.5);
  border-bottom: 1px solid rgba(126, 151, 194, 0.1);
  flex-shrink: 0;
}

.cms-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.cms-topbar-title {
  font-size: 0.95rem;
  color: #c8d1e3;
  font-weight: 500;
  margin: 0;
}

.cms-topbar-title span {
  color: #88a5d6;
}

.cms-topbar-meta {
  font-size: 0.82rem;
  color: #6a7a9b;
  display: flex;
  align-items: center;
  gap: 12px;
}

.viewer-toggle-btn {
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 4px;
  border: 1px solid #3a4a6b;
  background: transparent;
  color: #6a7a9b;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.viewer-toggle-btn:hover {
  background: #1e2a3f;
  color: #88a5d6;
}
.viewer-toggle-btn-active {
  background: #1a2d50;
  color: #88a5d6;
  border-color: #4a6fa5;
}

.topbar-save-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 5px;
  border: 1px solid #3a4a6b;
  background: transparent;
  color: #6a7a9b;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  padding: 0;
}
.topbar-save-btn:hover:not(:disabled) {
  background: #1e2a3f;
  color: #88a5d6;
  border-color: #4a6fa5;
}
.topbar-save-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.topbar-save-btn svg {
  display: block;
}

.topbar-save-btn--saving {
  cursor: not-allowed;
}

@keyframes topbar-spin {
  to { transform: rotate(360deg); }
}
.topbar-save-spinner {
  display: block;
  width: 13px;
  height: 13px;
  border: 2px solid #3a4a6b;
  border-top-color: #88a5d6;
  border-radius: 50%;
  animation: topbar-spin 0.7s linear infinite;
}

.cms-save-toast {
  position: sticky;
  top: 0;
  z-index: 200;
  padding: 7px 18px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  background: #1e3a1e;
  color: #6fcf6f;
  border-bottom: 1px solid #2e5a2e;
  animation: toast-fadein 0.18s ease;
}
.cms-save-toast--error {
  background: #3a1e1e;
  color: #cf6f6f;
  border-bottom-color: #5a2e2e;
}
@keyframes toast-fadein {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cms-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cms-content--fullbleed {
  padding: 0;
  overflow: hidden;
  gap: 0;
}

.editor-top-row {
  display: flex;
  gap: 16px;
  align-items: stretch;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.cms-viewer-panel {
  min-width: 0;
  flex: 0 0 360px;
  align-self: flex-start;
}

.viewer-fullart-frame {
  display: flex;
  justify-content: center;
  align-items: center;
  aspect-ratio: 1 / 1;
  padding: 8px;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01)),
    rgba(9, 11, 18, 0.95);
  border: 1px solid rgba(126, 151, 194, 0.14);
  overflow: hidden;
}

.viewer-fullart-img {
  max-width: 100%;
  max-height: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.editor-identity-fields {
  flex: 1 1 0;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (max-width: 1280px) {
  .editor-identity-fields {
    flex: 1 0 100%;
    width: 100%;
  }
}

.cms-content label {
  color: #8ca2c9;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  position: relative;
}

.cms-content label.has-tip {
  cursor: help;
}

.cms-content label.has-tip::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #0d1221;
  color: #c8d4ec;
  border: 1px solid rgba(126, 151, 194, 0.22);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.75rem;
  font-weight: normal;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.55;
  white-space: normal;
  width: max-content;
  max-width: 260px;
  z-index: 200;
  pointer-events: none;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.12s ease;
}

.cms-content label.has-tip:hover::after {
  opacity: 1;
}

.editor-input {
  background: rgba(20, 25, 40, 0.9);
  color: #f5e8ca;
  border: 1px solid rgba(126, 151, 194, 0.28);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 0.9rem;
  width: 100%;
}

.editor-input:focus {
  outline: 2px solid #6888c0;
  outline-offset: 2px;
}

.editor-sprite-names {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

@media (max-width: 480px) {
  .editor-sprite-names {
    grid-template-columns: 1fr 1fr;
  }
}

.editor-sprite-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.editor-sprite-index {
  color: #6a7a9b;
  font-size: 0.8rem;
  min-width: 22px;
}

.event-image-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  overflow-x: auto;
}

.event-image-row .editor-section {
  min-width: 0;
  flex: 1 1 200px;
}

.event-image-upload {
  width: 100%;
  max-width: 380px;
  height: auto;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
}

.editor-save-button {
  margin-top: 6px;
  width: 100%;
}

.editor-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.editor-actions .editor-save-button,
.editor-delete-button {
  margin-top: 0;
  width: 100%;
}

.editor-message {
  text-align: center;
  font-size: 0.85rem;
  margin: 0;
}

.editor-message-ok {
  color: #7ecc8e;
}

.editor-message-error {
  color: #ff8c8c;
}

.editor-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.editor-section-title {
  color: #d4b87a;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 8px 0 2px;
  padding-top: 8px;
  border-top: 1px solid rgba(126, 151, 194, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.editor-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.editor-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.editor-row-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.editor-row-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}

.editor-row-inline > .editor-section {
  flex: 1 1 120px;
}

.editor-row-inline--weapons {
  flex: 2 1 220px;
}

.editor-row-inline--weapons > .editor-section {
  flex: 1 1 100px;
}

.weapon-top-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.weapon-icon-column {
  width: 180px;
  flex: 0 0 180px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.character-basicinfo-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.character-icon-viewer {
  display: flex;
  align-items: center;
  gap: 4px;
}

.character-icon-viewer .viewer-arrow {
  position: static;
  transform: none;
}

.character-basicinfo-fields {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 1100px) {
  .character-meta-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .character-meta-row {
    grid-template-columns: 1fr;
  }

  .character-meta-release {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .character-meta-event {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .character-meta-acquirable {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .character-meta-base {
    grid-column: 1 / -1;
    grid-row: 4;
  }
}

.weapon-top-fields {
  flex: 1 1 520px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 320px;
}

.weapon-icon-upload {
  width: 180px;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  border: 1px dashed rgba(126, 151, 194, 0.35);
  background: rgba(20, 25, 40, 0.85);
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.weapon-icon-upload:hover:not(:disabled) {
  border-color: rgba(136, 165, 214, 0.55);
  background: rgba(24, 31, 48, 0.95);
}

.weapon-icon-upload:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.weapon-icon-upload.event-image-upload {
  width: 100%;
  max-width: 380px;
  height: auto;
  aspect-ratio: 2 / 3;
}

.event-editor-section {
  margin-top: 10px;
}

.event-editor-block {
  margin-top: 16px;
}

.event-editor-block-header,
.event-subtitle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.event-editor-block-header .editor-section-title {
  margin: 0;
}

.compact-button {
  width: auto;
  min-height: 30px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.event-editor-card,
.event-editor-sub-card {
  margin-top: 10px;
}

.event-nested-row,
.event-special-row {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) minmax(120px, 1fr) minmax(120px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}

.event-reward-ref-row {
  grid-template-columns: minmax(180px, 1fr) auto;
}

.event-score-modifier-row {
  grid-template-columns: minmax(220px, 2fr) minmax(120px, 1fr) auto;
}

.event-special-row {
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(100px, 1fr)) auto;
}

.event-special-character-cell {
  min-width: 0;
}

.event-multi-select {
  min-height: 94px;
}

.event-inline-remove {
  align-self: end;
  white-space: nowrap;
}

.event-toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #c9d1d9;
  font-weight: 700;
}

.event-toggle-row input {
  width: 16px;
  height: 16px;
}

@media (max-width: 900px) {
  .event-nested-row,
  .event-special-row,
  .event-reward-ref-row,
  .event-score-modifier-row {
    grid-template-columns: 1fr;
  }
}

.weapon-icon-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: rgba(10, 13, 21, 0.65);
}

.weapon-icon-placeholder {
  padding: 12px;
  text-align: center;
  color: #8ca2c9;
  font-size: 0.8rem;
  line-height: 1.35;
}

.editor-textarea {
  resize: vertical;
  min-height: 42px;
  font-family: inherit;
}

/* ── CmsHtmlEditor ─────────────────────────────────────────────────────── */
.cms-html-editor {
  width: 100%;
  border: 1px solid rgba(126, 151, 194, 0.28);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(20, 25, 40, 0.9);
}

.cms-html-editor:focus-within {
  outline: 2px solid #6888c0;
  outline-offset: 2px;
}

.cms-html-editor--disabled {
  opacity: 0.5;
  pointer-events: none;
}

.cms-html-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  background: rgba(30, 38, 58, 0.95);
  border-bottom: 1px solid rgba(126, 151, 194, 0.18);
}

.cms-html-editor-tool {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #b8c8e8;
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1;
  min-width: 24px;
  padding: 3px 5px;
  transition: background 0.12s, border-color 0.12s;
}

.cms-html-editor-tool:hover:not(:disabled) {
  background: rgba(88, 130, 200, 0.18);
  border-color: rgba(88, 130, 200, 0.35);
  color: #e2edff;
}

.cms-html-editor-tool:active:not(:disabled) {
  background: rgba(88, 130, 200, 0.32);
}

.cms-html-editor-sep {
  width: 1px;
  height: 16px;
  background: rgba(126, 151, 194, 0.28);
  margin: 0 4px;
  flex-shrink: 0;
}

.cms-html-editor-content {
  padding: 8px 10px;
  color: #f5e8ca;
  font-size: 0.9rem;
  line-height: 1.5;
  outline: none;
  overflow-y: auto;
}

.cms-html-editor-content:empty::before {
  content: attr(data-placeholder);
  color: rgba(245, 232, 202, 0.35);
  pointer-events: none;
}

.cms-html-editor-content ul,
.cms-html-editor-content ol {
  padding-left: 1.4em;
  margin: 0.25em 0;
}

.cms-html-editor-content li {
  margin: 0.1em 0;
}
/* ─────────────────────────────────────────────────────────────────────── */

.editor-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.editor-stat-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.editor-stat-cell label {
  font-size: 0.7rem;
  text-align: center;
}

.editor-stat-cell .editor-input {
  text-align: center;
  padding: 5px 4px;
  font-size: 0.82rem;
}

.editor-card {
  background: rgba(15, 20, 35, 0.5);
  border: 1px solid rgba(126, 151, 194, 0.12);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-card-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-card-row-item {
  flex: 1 1 200px;
  min-width: 0;
}

.editor-passives-4 > .editor-card-row-item {
  flex: 1 1 calc(50% - 4px);
}

.editor-passives-5 > .editor-card-row-item {
  flex: 1 1 calc(33.33% - 6px);
}

.editor-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #a8bde0;
  font-size: 0.82rem;
  font-weight: 600;
}

.unlock-badge {
  font-size: 0.72rem;
  font-weight: 500;
  color: #6a9fd8;
  background: rgba(74, 111, 165, 0.15);
  border: 1px solid rgba(74, 111, 165, 0.35);
  border-radius: 4px;
  padding: 1px 7px;
  white-space: nowrap;
}

.unlock-badge--inline {
  display: inline-block;
  margin-top: 3px;
}

.editor-card-header-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.editor-card-header-field label {
  color: #a8bde0;
  font-size: 0.82rem;
  font-weight: 600;
}

.editor-card-header-field .editor-input {
  width: 84px;
}

.editor-sub-card {
  background: rgba(10, 14, 26, 0.4);
  border: 1px solid rgba(126, 151, 194, 0.08);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.editor-sub-label {
  color: #7a90b4;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.editor-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.editor-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(90, 130, 200, 0.15);
  border: 1px solid rgba(90, 130, 200, 0.35);
  border-radius: 4px;
  padding: 2px 8px 2px 10px;
  font-size: 0.8rem;
  color: #a8bde0;
}

.editor-tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #7a90b4;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
}

.editor-tag-remove:hover {
  color: #e88;
}

.editor-add-btn {
  display: block;
  width: 100%;
  background: transparent;
  color: #6aaa7e;
  border: 1px dashed rgba(90, 158, 111, 0.45);
  border-radius: 6px;
  padding: 7px 0;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-align: center;
  margin-top: 4px;
}

.editor-add-btn:hover {
  background: rgba(90, 158, 111, 0.12);
  color: #8dcc9f;
  border-color: rgba(90, 158, 111, 0.7);
}

.editor-add-btn--inline {
  width: auto;
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.73rem;
  border-style: solid;
  margin-top: 2px;
  opacity: 0.75;
}

.editor-add-btn--inline:hover {
  opacity: 1;
}

.editor-remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(200, 80, 80, 0.2);
  color: #ff8c8c;
  border: 1px solid rgba(200, 80, 80, 0.3);
  border-radius: 5px;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}

.editor-remove-btn:hover {
  background: rgba(200, 80, 80, 0.4);
}

.editor-grid-5x4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.editor-grid-cell {
  background: rgba(15, 20, 35, 0.4);
  border: 1px solid rgba(126, 151, 194, 0.08);
  border-radius: 6px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.editor-grid-cell-filled {
  border-color: rgba(212, 184, 122, 0.3);
  background: rgba(25, 30, 50, 0.5);
}

.editor-grid-check {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: #7a90b4;
  cursor: pointer;
}

.editor-grid-check input[type="checkbox"] {
  margin: 0;
}

.editor-grid-type {
  padding: 3px 4px;
  font-size: 0.72rem;
}

.editor-grid-cell .editor-row-2 {
  gap: 3px;
}

.editor-grid-cell .editor-input {
  padding: 3px 4px;
  font-size: 0.72rem;
}

.editor-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

select.editor-input {
  cursor: pointer;
}

/* Autocomplete */
.ac-wrap {
  position: relative;
  width: 100%;
}

.ac-dropdown {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  z-index: 200;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: rgba(20, 25, 40, 0.97);
  border: 1px solid rgba(126, 151, 194, 0.28);
  border-radius: 8px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}

.ac-option {
  padding: 7px 12px;
  font-size: 0.9rem;
  color: #f5e8ca;
  cursor: pointer;
}

.ac-option:hover,
.ac-option--active {
  background: rgba(90, 130, 200, 0.25);
  color: #fff;
}

/* Assign panel */

.assign-row {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.assign-button {
  background: linear-gradient(135deg, #5a9e6f, #3a7a4f);
  padding: 12px 32px;
  font-size: 1rem;
}

.assign-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #6ab87f, #4a8a5f);
}

.assign-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.assign-panel {
  background: #1a1f30;
  border: 1px solid rgba(140, 168, 219, 0.25);
  border-radius: 18px;
  padding: 32px;
  width: min(440px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.assign-panel h2 {
  color: #f7ead0;
  font-size: 1.3rem;
  margin: 0;
}

.assign-panel p {
  color: #b7c0d3;
  line-height: 1.5;
  margin: 0;
}

.assign-note {
  color: #88a5d6 !important;
  font-size: 0.9rem;
  font-style: italic;
}

.assign-panel label {
  color: #8ca2c9;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.assign-panel input {
  background: rgba(30, 37, 56, 0.9);
  color: #f5e8ca;
  border: 1px solid rgba(126, 151, 194, 0.28);
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-size: 1rem;
  width: 100%;
}

.assign-panel input:focus,
.assign-panel select:focus {
  outline: 2px solid #6888c0;
  outline-offset: 2px;
}

.assign-panel select {
  background: rgba(30, 37, 56, 0.9);
  color: #f5e8ca;
  border: 1px solid rgba(126, 151, 194, 0.28);
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-size: 1rem;
  width: 100%;
}

.assign-action-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}

.assign-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.secondary-button {
  border: 1px solid rgba(126, 151, 194, 0.28);
  border-radius: 999px;
  padding: 12px 22px;
  background: transparent;
  color: #b7c0d3;
  cursor: pointer;
  font: inherit;
}

.secondary-button:hover:not(:disabled) {
  background: rgba(126, 151, 194, 0.1);
}

.secondary-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.assign-success {
  color: #7ecc8e !important;
}

/* --- Mobile sprite tabs (shown inline next to viewer on small screens) --- */
.cms-mobile-sprite-tabs {
  display: none;
}

.viewer-sprite-select {
  margin-top: 10px;
}

.cms-hamburger {
  display: none;
  flex-shrink: 0;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
}
.cms-hamburger:hover { background: rgba(126, 151, 194, 0.1); }
.cms-hamburger span {
  display: block;
  height: 2px;
  width: 100%;
  background: #8e9ab3;
  border-radius: 2px;
}

/* --- Sidebar backdrop overlay --- */
.cms-sidebar-backdrop {
  display: none;
}

/* --- Page Navigation --- */
.cms-topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cms-page-nav {
  display: flex;
  gap: 4px;
  background: rgba(20, 25, 40, 0.5);
  border-radius: 8px;
  padding: 2px;
  border: 1px solid rgba(126, 151, 194, 0.18);
}

.cms-nav-btn {
  padding: 6px 12px;
  background: transparent;
  color: #a8b5cc;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  transition: all 0.15s ease;
}

.cms-nav-btn:hover {
  background: rgba(126, 151, 194, 0.12);
  color: #d4dce8;
}

.cms-nav-btn-active {
  background: rgba(82, 111, 165, 0.35);
  color: #6888c0;
  border: 1px solid rgba(102, 136, 192, 0.22);
}

.nav-label-short { display: inline; }
.nav-label-full  { display: none; }

.cms-page-nav { display: none; }
.cms-page-nav-select {
  display: block;
  background: rgba(20, 25, 40, 0.85);
  color: #a8b5cc;
  border: 1px solid rgba(126, 151, 194, 0.3);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
}
.cms-page-nav-select option { background: #141928; }
.lang-select-dropdown { display: none; }

@media (max-width: 900px) {
  .cms-topbar-title { display: none; }
  .cms-topbar { justify-content: flex-start; }
  .cms-topbar-meta { margin-left: auto; }
  .cms-topbar-left { margin-left: 8px; }
}

@media (max-width: 600px) {
  .lang-toggle { display: none !important; }
  .lang-select-dropdown {
    display: block;
    background: rgba(20, 25, 40, 0.85);
    color: #a8b5cc;
    border: 1px solid rgba(126, 151, 194, 0.3);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.8rem;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
  }
  .lang-select-dropdown option { background: #141928; }
}

/* --- CMS Page Content Layout --- */
.cms-page-content {
  display: flex;
  gap: 16px;
  height: 100%;
  min-height: calc(100vh - 200px);
}

.cms-list-panel {
  flex: 0 0 240px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-right: 1px solid rgba(126, 151, 194, 0.12);
  padding-right: 12px;
}

.cms-search-box {
  display: flex;
  gap: 6px;
}

.cms-search-box input {
  flex: 1;
}

.cms-item-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cms-list-item {
  padding: 8px 10px;
  background: rgba(20, 25, 40, 0.7);
  border: 1px solid rgba(126, 151, 194, 0.14);
  border-radius: 6px;
  color: #a8b5cc;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.85rem;
}

.cms-list-item:hover {
  background: rgba(20, 25, 40, 0.9);
  border-color: rgba(126, 151, 194, 0.25);
  color: #d4dce8;
}

.cms-list-item-active {
  background: rgba(82, 111, 165, 0.25);
  border-color: rgba(102, 136, 192, 0.35);
  color: #6888c0;
  font-weight: 500;
}

.cms-editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-right: 8px;
}

.cms-editor-panel textarea {
  resize: vertical;
  font-family: "Segoe UI", monospace;
  font-size: 0.85rem;
}

@media (max-width: 900px) {
  .cms-layout {
    flex-direction: row;
    height: 100vh;
    overflow: hidden;
    position: relative;
  }

  .cms-hamburger {
    display: flex;
  }

  .cms-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    border-right: 1px solid rgba(126, 151, 194, 0.18);
    border-bottom: none;
  }

  .cms-sidebar-open {
    transform: translateX(0);
  }

  .cms-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(0, 0, 0, 0.45);
  }

  .cms-viewer-panel {
    flex: none;
    width: 100%;
  }

  .cms-content {
    padding: 16px;
    gap: 6px;
  }

  .editor-top-row {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 8px;
    margin-bottom: 0;
  }

  .editor-identity-fields {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 20px 14px;
  }

  .viewer-card {
    padding: 8px;
    border-radius: 10px;
  }

  .canvas-frame {
    min-height: 0;
    max-height: none;
    align-items: flex-start;
  }

  .expression-badge {
    min-width: 0;
    width: 100%;
  }

  .primary-button {
    width: 100%;
  }

  .cms-topbar {
    padding: 0 16px;
    height: 44px;
  }
}

/* ── Reusable Structured Section System ── */
.cms-structured-panel {
  display: flow-root;
  position: relative;
  width: 100%;
  margin: 0 0 28px;
  padding: 0 0 18px;
  box-sizing: border-box;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.cms-structured-panel--spaced {
  margin-top: 8px;
}

.cms-structured-panel .editor-section-title {
  margin-top: 0;
}

.cms-structured-meta-row {
  margin-bottom: 12px;
}

.cms-structured-effect-section {
  display: flex;
  flex-direction: column;
}

.cms-structured-effect-section .editor-textarea {
  min-height: 74px;
}

.cms-structured-table {
  margin-top: 10px;
  margin-bottom: 0;
  padding-bottom: 0;
  width: 100%;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid rgba(76, 98, 142, 0.34);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(19, 28, 48, 0.94), rgba(13, 20, 35, 0.95));
  box-shadow: inset 0 1px 0 rgba(130, 165, 220, 0.08), 0 8px 22px rgba(0, 0, 0, 0.14);
}

.cms-structured-grid {
  display: grid;
  width: 100%;
  min-width: 100%;
  font-size: 0.82rem;
  color: #c8d8f0;
}

.cms-structured-grid--exceed {
  grid-template-columns: 88px minmax(0, 1fr) minmax(0, 1.45fr) minmax(0, 1fr);
}

.cms-structured-grid--participation {
  grid-template-columns: 88px minmax(140px, 0.9fr) minmax(0, 1.35fr) minmax(0, 1.35fr);
}

.cms-structured-grid--stats {
  grid-template-columns: 88px repeat(8, minmax(0, 1fr)) 44px;
}

.cms-structured-grid--missions {
  grid-template-columns: minmax(200px, 1fr) repeat(3, minmax(160px, 220px)) 44px;
}

.cms-missions-scroller {
  overflow-x: auto;
}

.cms-missions-scroller .cms-structured-table {
  overflow: visible;
}

/* ── Event Box tabs ─────────────────────────────────────────────────────── */
.event-box-tabs-wrap {
  overflow-x: auto;
  border-bottom: 2px solid rgba(76, 98, 142, 0.45);
  margin-bottom: 0;
}

.event-box-tabs {
  display: flex;
  gap: 2px;
  min-width: max-content;
  padding: 0 2px;
}

.event-box-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px 6px 12px;
  background: rgba(22, 32, 54, 0.7);
  border: 1px solid rgba(76, 98, 142, 0.35);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  color: #8ca5cc;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.event-box-tab:hover {
  background: rgba(40, 58, 96, 0.8);
  color: #b8cce8;
}

.event-box-tab--active {
  background: rgba(50, 72, 118, 0.95);
  color: #e0ecff;
  border-color: rgba(100, 140, 210, 0.55);
}

.event-box-tab-input {
  background: transparent;
  border: none;
  outline: none;
  color: inherit;
  font: inherit;
  width: 72px;
  min-width: 40px;
  cursor: text;
  padding: 0;
}

.event-box-tab-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 0.78rem;
  line-height: 1;
  color: #7a90b8;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}

.event-box-tab-remove:hover {
  background: rgba(200, 60, 60, 0.35);
  color: #ff9999;
}

.cms-box-table-wrap .cms-structured-table {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  overflow: visible;
  margin-top: 0;
}

.cms-box-table-wrap .cms-structured-grid--header {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.cms-reward-table-wrap .cms-structured-table {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  overflow: visible;
  margin-top: 0;
}

.cms-reward-table-wrap .cms-structured-grid--header {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.cms-box-table-wrap {
  overflow-x: auto;
}

.cms-reward-table-wrap {
  overflow-x: auto;
}

.cms-structured-grid--box {
  grid-template-columns: minmax(200px, 2fr) minmax(100px, 1fr) minmax(100px, 1fr) 44px;
}

.cms-structured-grid--rewards {
  grid-template-columns: minmax(140px, 1.5fr) repeat(2, minmax(160px, 1fr)) 44px;
}

.cms-structured-grid--ticket {
  grid-template-columns: minmax(160px, 1.5fr) minmax(220px, 2fr) 44px;
}

.cms-structured-grid--modifier {
  grid-template-columns: minmax(200px, 3fr) minmax(100px, 1fr) 44px;
}

.cms-exchange-table-wrap {
  overflow-x: auto;
}

.cms-exchange-table-wrap .cms-structured-table {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  overflow: visible;
  margin-top: 0;
}

.cms-exchange-table-wrap .cms-structured-grid--header {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.cms-structured-grid--exchange {
  grid-template-columns: minmax(180px, 2fr) minmax(100px, 1fr) minmax(180px, 2fr) minmax(100px, 1fr) 44px;
}

.event-type-flags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px 16px;
}

.cms-structured-grid--header {
  background: linear-gradient(180deg, rgba(31, 45, 74, 0.96), rgba(22, 33, 55, 0.96));
  color: #8eb8f0;
  font-weight: 600;
  text-align: center;
  border-bottom: 1px solid rgba(76, 98, 142, 0.38);
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
}

.cms-structured-grid--header > div,
.cms-structured-cell {
  padding: 10px 12px;
  min-height: 58px;
  border-right: 1px solid rgba(49, 68, 104, 0.42);
  border-bottom: 1px solid rgba(49, 68, 104, 0.34);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
}

.cms-structured-grid--header > div {
  min-height: 52px;
  padding: 12px 10px;
  white-space: normal;
  line-height: 1.35;
}

.cms-structured-grid--row:nth-child(odd) .cms-structured-cell {
  background: rgba(17, 28, 51, 0.82);
}

.cms-structured-grid--row:nth-child(even) .cms-structured-cell {
  background: rgba(13, 21, 37, 0.68);
}

.cms-structured-grid > :last-child {
  border-right: none;
}

.cms-structured-grid--row:last-child .cms-structured-cell {
  border-bottom: none;
}

.cms-structured-cell .editor-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  text-align: center;
}

.cms-structured-cell--action {
  padding: 6px 4px;
}

.cms-structured-cell--left {
  justify-content: flex-start;
  text-align: left;
}

.cms-mission-reward-cell {
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: 6px;
  padding: 8px 10px;
}

.cms-mission-reward-cell .editor-input {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.cms-special-item-header {
  display: flex;
  align-items: center;
  padding: 4px 10px;
  width: 100%;
}

.cms-special-item-header .ac-wrap {
  width: 100%;
}

.cms-special-char-cell {
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  padding: 8px 10px;
  min-height: 60px;
}

.cms-special-char-cell .ac-wrap {
  width: 100%;
}

.cms-structured-empty-row {
  padding: 16px 20px;
  color: #6a80a8;
  font-size: 0.82rem;
  font-style: italic;
}

.cms-structured-cell--action .editor-remove-btn {
  margin: 0;
}

.cms-structured-textarea {
  min-height: 74px;
  resize: vertical;
  text-align: left;
}

.cms-structured-level-header,
.cms-structured-level-cell {
  justify-content: center;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.cms-structured-level-cell {
  color: #e7c56b;
  font-size: 0.92rem;
  background: linear-gradient(180deg, rgba(62, 45, 15, 0.18), rgba(44, 31, 10, 0.12));
}

.cms-structured-na {
  color: #6b7fa6;
  font-size: 0.82rem;
  font-style: italic;
  user-select: none;
}

@media (max-width: 1200px) {
  .cms-structured-grid--stats {
    grid-template-columns: 76px repeat(8, minmax(0, 1fr)) 40px;
  }

  .cms-structured-grid--exceed {
    grid-template-columns: 78px minmax(0, 0.95fr) minmax(0, 1.2fr) minmax(0, 0.95fr);
  }

  .cms-structured-grid--participation {
    grid-template-columns: 78px minmax(120px, 0.85fr) minmax(0, 1.2fr) minmax(0, 1.2fr);
  }
}

@media (max-width: 1100px) {
  .cms-structured-grid--stats {
    min-width: 980px;
  }

  .cms-structured-grid--exceed {
    min-width: 760px;
  }

  .cms-structured-grid--participation {
    min-width: 900px;
  }
}

/* ===== Tier List CMS ===== */

.tl-cms-root {
  display: flex;
  flex-direction: column;
  gap: 0;
  height: 100%;
  overflow: hidden;
}

.tl-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #8b949e;
}
.tl-empty-text { font-size: 0.95rem; text-align: center; }

.tl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid #21262d;
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
}
.tl-header-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-header-actions { display: flex; align-items: center; gap: 6px; }
.tl-dirty { font-size: 0.78rem; color: #f0a030; font-style: italic; }

.tl-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  background: #21262d;
  border: 1px solid #30363d;
  font-size: 0.72rem;
  color: #8b949e;
  text-transform: capitalize;
}
.tl-type-badge-full {
  background: #1f3a5f;
  border-color: #58a6ff;
  color: #58a6ff;
  font-weight: 700;
}

/* Tier grid */
.tl-grid-area {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding-bottom: 4px;
}
.tl-grid {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid #21262d;
}

.tl-row {
  display: flex;
  align-items: stretch;
  border-bottom: 2px solid #444c56;
  min-height: 68px;
}
.tl-row:last-child { border-bottom: none; }

.tl-row-label {
  width: 56px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.5px;
  position: relative;
  gap: 2px;
}

.tl-remove-tier-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}
.tl-remove-tier-btn:hover { color: #fff; }

.tl-row-label-text {
  cursor: pointer;
  flex: 1;
  text-align: center;
  user-select: none;
  border-bottom: 1px dashed transparent;
  transition: border-color 0.15s;
}
.tl-row-label-text:hover { border-bottom-color: rgba(255,255,255,0.6); }

.tl-tier-rename-input {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 3px;
  color: #fff;
  font-size: inherit;
  font-weight: bold;
  text-align: center;
  width: 100%;
  padding: 1px 4px;
  outline: none;
}

.tl-row-entities {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  flex: 1;
  min-height: 68px;
}

.tl-row-placeholder {
  color: #3d444d;
  font-size: 0.85rem;
  font-style: italic;
  padding: 4px 4px;
}

/* Entity button (in tiers and in pool) */
.tl-entity-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  padding: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: border-color 0.15s, background 0.15s;
  color: #c9d1d9;
}
.tl-entity-btn:hover {
  border-color: #58a6ff;
  background: #1c2333;
}

.tl-entity-icon {
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}

.tl-entity-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #21262d;
  border-radius: 4px;
  color: #8b949e;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.tl-entity-name {
  font-size: 0.62rem;
  color: #8b949e;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

/* Add tier */
.tl-add-tier-row {
  padding: 8px 12px;
  display: flex;
  align-items: center;
}
.tl-add-tier-btn {
  border-style: dashed;
}
.tl-add-tier-btn:hover { border-color: #58a6ff; background: #1c2333; }
.tl-add-tier-form { display: flex; align-items: center; gap: 6px; }
.tl-tier-input { width: 72px !important; text-align: center; font-weight: 700; }

.tl-danger-btn {
  background: none;
  border: 1px solid #da3633;
  border-radius: 999px;
  color: #f85149;
  cursor: pointer;
  font-size: 0.72rem;
  padding: 4px 12px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.tl-danger-btn:hover { background: rgba(248, 81, 73, 0.15); color: #ff7b72; border-color: #f85149; }

/* Pool — fixed-height panel pinned at the bottom */
.tl-pool {
  flex-shrink: 0;
  height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  border-top: 2px solid #30363d;
}

.tl-pool-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid #21262d;
  background: #0d1117;
  position: sticky;
  top: 0;
  z-index: 1;
  flex-shrink: 0;
}
.tl-pool-title { font-size: 0.82rem; color: #8b949e; font-weight: 600; flex-shrink: 0; }
.tl-pool-search { width: 200px; }

.tl-filter-toggle {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  cursor: pointer;
  font-size: 0.78rem;
  padding: 3px 9px;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.tl-filter-toggle:hover { border-color: #58a6ff; color: #c9d1d9; }
.tl-filter-toggle.active { border-color: #58a6ff; color: #58a6ff; }
.tl-filter-toggle.has-active { border-color: #f78166; color: #f78166; }
.tl-filter-toggle.active.has-active { border-color: #f78166; color: #f78166; }

.tl-filter-clear {
  background: none;
  border: none;
  color: #6e7681;
  cursor: pointer;
  font-size: 0.78rem;
  padding: 2px 6px;
  white-space: nowrap;
}
.tl-filter-clear:hover { color: #f78166; }

.tl-filter-panel {
  background: #0d1117;
  border-bottom: 1px solid #21262d;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tl-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tl-filter-label {
  font-size: 0.72rem;
  color: #6e7681;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  width: 52px;
  flex-shrink: 0;
}
.tl-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tl-filter-chip {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #8b949e;
  cursor: pointer;
  font-size: 0.73rem;
  padding: 2px 7px;
  text-transform: capitalize;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.tl-filter-chip:hover { border-color: #58a6ff; color: #c9d1d9; }
.tl-filter-chip.active { background: #1f3a5f; border-color: #58a6ff; color: #58a6ff; font-weight: 600; }

.tl-pool-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px;
  align-content: flex-start;
}

.tl-pool-entity { opacity: 0.85; }
.tl-pool-entity:hover { opacity: 1; }

@keyframes tl-placeholder-pulse {
  from { border-color: #58a6ff; background: rgba(88,166,255,0.06); }
  to   { border-color: #79c0ff; background: rgba(88,166,255,0.16); }
}
.tl-drag-placeholder {
  border: 2px dashed #58a6ff;
  border-radius: 8px;
  animation: tl-placeholder-pulse 1s ease-in-out infinite alternate;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-shrink: 0;
}
.tl-drag-placeholder--entity {
  width: 68px;
  height: 68px;
}
.tl-drag-placeholder--cell {
  width: 64px;
  height: 64px;
  margin: 2px;
}
.tl-ph-tier {
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.tl-ph-rank {
  font-size: 9px;
  color: #8b949e;
  line-height: 1;
}
.tl-ph-icons {
  display: flex;
  gap: 2px;
  align-items: center;
}
.tl-ph-icon {
  width: 14px;
  height: 14px;
  image-rendering: pixelated;
}

.tl-drop-target {
  outline: 2px dashed #58a6ff;
  outline-offset: -2px;
  background: rgba(88, 166, 255, 0.07);
}
.tl-entity-btn[draggable] { cursor: grab; }
.tl-entity-btn[draggable]:active { cursor: grabbing; }

.tl-entity-btn.tl-insert-before {
  box-shadow: -3px 0 0 0 #58a6ff;
  border-radius: 4px;
}
.tl-entity-btn.tl-insert-after {
  box-shadow: 3px 0 0 0 #58a6ff;
  border-radius: 4px;
}

.tl-pool-empty {
  color: #3d444d;
  font-size: 0.85rem;
  font-style: italic;
  padding: 4px 0;
}

/* Popup */
.tl-popup {
  position: fixed;
  z-index: 9999;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  min-width: 192px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tl-popup-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: #c9d1d9;
  padding: 0 2px 4px;
  border-bottom: 1px solid #21262d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-popup-section-label {
  font-size: 0.7rem;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 2px 0;
}
.tl-popup-tiers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tl-popup-tier-btn {
  background: var(--tc);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 4px 12px;
  cursor: pointer;
  min-width: 36px;
  transition: filter 0.15s;
}
.tl-popup-tier-btn:hover { filter: brightness(1.2); }
.tl-popup-remove-btn {
  background: none;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #f85149;
  font-size: 0.8rem;
  padding: 4px 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.tl-popup-remove-btn:hover { border-color: #f85149; background: #1c2333; }
.tl-popup-notes-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 2px;
  border-top: 1px solid #21262d;
}
.tl-popup-notes-label {
  font-size: 0.7rem;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tl-popup-notes-input {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #c9d1d9;
  font-size: 0.8rem;
  font-family: inherit;
  padding: 5px 7px;
  resize: vertical;
  min-height: 52px;
  transition: border-color 0.15s;
}
.tl-popup-notes-input:focus {
  outline: none;
  border-color: #58a6ff;
}
.tl-popup-notes-save-btn {
  background: #1f6feb;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  align-self: flex-end;
  transition: background 0.15s;
}
.tl-popup-notes-save-btn:hover { background: #388bfd; }

/* Create dialog — entity type checkboxes */
.tl-entity-type-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.tl-entity-type-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid #30363d;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.tl-entity-type-option:hover { border-color: #58a6ff; background: #1c2333; }
.tl-entity-type-option input[type="checkbox"] { width: 16px; height: 16px; accent-color: #58a6ff; cursor: pointer; }
.tl-entity-type-option span { font-size: 0.9rem; color: #c9d1d9; }

/* ---- Create dialog — tier list type picker ---- */
.tl-type-picker {
  display: flex;
  gap: 12px;
  margin-top: 6px;
}
.tl-type-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  background: #0d1117;
  border: 2px solid #30363d;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.tl-type-card:hover { border-color: #58a6ff; background: #1c2333; }
.tl-type-card.active { border-color: #58a6ff; background: #1f3a5f; }
.tl-type-card-title { font-size: 1rem; font-weight: 700; color: #c9d1d9; }
.tl-type-card.active .tl-type-card-title { color: #58a6ff; }
.tl-type-card-desc { font-size: 0.78rem; color: #8b949e; line-height: 1.4; }

/* ---- Full multi-dimensional grid ---- */
.tl-full-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid #21262d;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0 0 4px 0;
}
.tl-full-header-row {
  display: grid;
  grid-template-columns: 54px 40px repeat(6, minmax(72px, 1fr));
  background: #161b22;
  border-bottom: 2px solid #21262d;
  min-width: 600px;
}
.tl-full-tier-spacer { grid-column: 1; background: #161b22; }
.tl-full-atk-spacer  { grid-column: 2; background: #161b22; }
.tl-attr-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  display: block;
  image-rendering: pixelated;
}
.tl-full-col-hdr {
  padding: 5px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid #21262d;
}
.tl-full-atk-label {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid #21262d;
  background: #0d1117;
  padding: 4px 2px;
}
.tl-popup-full-col-hdr {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
}
.tl-popup-full-cell-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 4px;
  cursor: pointer;
  padding: 3px;
  transition: background 0.12s, border-color 0.12s;
}
.tl-popup-full-cell-btn:hover { background: #1f3a5f; border-color: #58a6ff; }
.tl-popup-full-cell-btn .tl-attr-icon { width: 24px; height: 24px; }
.tl-full-tier-block {
  display: grid;
  grid-template-columns: 54px 1fr;
  border-bottom: 3px solid #444c56;
  min-width: 600px;
}
.tl-full-tier-block:last-child { border-bottom: none; }
.tl-full-tier-label {
  grid-row: 1 / span 2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  border-right: 2px solid rgba(255,255,255,0.12);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.tl-full-tier-rows {
  display: flex;
  flex-direction: column;
}
.tl-full-atk-row {
  display: grid;
  grid-template-columns: 40px repeat(6, minmax(72px, 1fr));
  border-bottom: 1px solid #21262d;
  min-height: 76px;
}
.tl-full-atk-row:last-child { border-bottom: none; }
.tl-full-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 4px;
  min-height: 76px;
  border-left: 1px solid #21262d;
  transition: background 0.12s;
}
.tl-full-cell.tl-drop-target {
  background: rgba(88, 166, 255, 0.08);
}
.tl-full-entity {
  width: 64px;
  height: 64px;
  padding: 0;
  border-radius: 4px;
}
.tl-full-entity .tl-entity-name { display: none; }

/* Full-mode popup grid */
.tl-popup-back-btn {
  background: none;
  border: none;
  color: #58a6ff;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0 4px 0 0;
}
.tl-popup-back-btn:hover { text-decoration: underline; }
.tl-popup-full-grid {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.tl-popup-full-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

/* ================================================================
   Relationship Graph CMS
   ================================================================ */
.rg-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #0d1117;
  position: relative;
  overflow: hidden;
  /* Cancel cms-content padding so the graph fills edge-to-edge */
  margin: -24px -28px;
  flex: 1;
}

/* Toolbar */
.rg-toolbar {
  display: flex;
  gap: 8px;
  padding: 8px 14px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.rg-toolbar-input {
  flex: 1;
  min-width: 140px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  font-size: 0.82rem;
  padding: 5px 10px;
}
.rg-toolbar-input:focus { outline: none; border-color: #58a6ff; }
.rg-toolbar-select {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  font-size: 0.82rem;
  padding: 5px 10px;
  cursor: pointer;
}
.rg-checkbox-label {
  font-size: 0.8rem;
  color: #8b949e;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.rg-add-btn {
  background: #1f6feb;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.rg-add-btn:hover { background: #388bfd; }

.rg-save-layout-btn {
  background: #238636;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.rg-save-layout-btn:hover { background: #2ea043; }
.rg-save-layout-btn:disabled { opacity: 0.6; cursor: default; }

.rg-label-toggle-btn {
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.rg-label-toggle-btn:hover { background: #30363d; color: #c9d1d9; }
.rg-label-toggle-btn.active {
  background: #1f6feb22;
  border-color: #58a6ff;
  color: #58a6ff;
}

/* Canvas */
.rg-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
  height: 100%;
}
.rg-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #8b949e;
  font-size: 0.9rem;
  z-index: 5;
}

/* Character node */
.rg-node {
  background: #161b22;
  border: 2px solid #30363d;
  border-radius: 12px;
  padding: 0;
  width: 64px;
  height: 64px;
  cursor: default;
  transition: border-color 0.2s, box-shadow 0.2s;
  overflow: visible;
  position: relative;
}
.rg-node:hover,
.rg-node--selected { border-color: #58a6ff; box-shadow: 0 0 0 2px rgba(88,166,255,0.2); }
.rg-node-icon {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #21262d;
  pointer-events: none;
}
.rg-node-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.rg-node-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: #58a6ff;
  letter-spacing: 0.05em;
}
.rg-handle {
  width: 8px !important;
  height: 8px !important;
  background: #58a6ff !important;
  border: 2px solid #0d1117 !important;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10 !important;
}
.rg-node:hover .rg-handle { opacity: 1; }
.rg-group:hover .rg-handle { opacity: 1; }

/* Group / container node */
.rg-group {
  width: 100%;
  height: 100%;
  background: rgba(88,166,255,0.04);
  border: 2px dashed rgba(88,166,255,0.3);
  border-radius: 14px;
  position: relative;
  box-sizing: border-box;
  transition: border-color 0.2s, background 0.2s;
}
.rg-group--selected {
  border-color: rgba(88,166,255,0.7);
  background: rgba(88,166,255,0.08);
  box-shadow: 0 0 0 3px rgba(88,166,255,0.45);
}
.rg-group-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 26px 5px 10px;
  border-bottom: 1px solid rgba(88,166,255,0.12);
  user-select: none;
}
.rg-group-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #6e7681;
  cursor: default;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rg-group-color-picker {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 3px;
  padding: 0;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}
.rg-group-color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.rg-group-color-picker::-webkit-color-swatch { border: 1px solid #30363d; border-radius: 3px; }
.rg-group-color-clear {
  background: none;
  border: none;
  color: #6e7681;
  font-size: 0.65rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}
.rg-group-color-clear:hover { color: #f85149; }
.rg-group-label-input {
  font-size: 0.72rem;
  font-weight: 600;
  background: transparent;
  border: none;
  border-bottom: 1px solid #58a6ff;
  color: #e6edf3;
  outline: none;
  width: 100%;
}
.rg-ctx-group-btn {
  display: block;
  width: 100%;
  padding: 7px 10px;
  background: rgba(88,166,255,0.1);
  border: 1px solid rgba(88,166,255,0.25);
  border-radius: 6px;
  color: #58a6ff;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}
.rg-ctx-group-btn:hover { background: rgba(88,166,255,0.2); }
.rg-ctx-divider {
  height: 1px;
  background: #30363d;
  margin: 6px 0;
}

/* Edge label */
.rg-edge-label {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 0.68rem;
  font-weight: 600;
  color: #c9d1d9;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}
.rg-edge-label:hover { background: #1f2937; }
.rg-edge-oneway {
  margin-left: 4px;
  font-size: 0.6rem;
  opacity: 0.7;
}

/* Legend */
.rg-legend {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  z-index: 5;
  pointer-events: all;
  max-width: 600px;
}
.rg-legend-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 20px;
  padding: 3px 10px 3px 7px;
  font-size: 0.7rem;
  color: #c9d1d9;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.rg-legend-chip:hover,
.rg-legend-chip.active {
  border-color: var(--lc, #58a6ff);
  background: #1c2333;
}
.rg-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Side panel */
.rg-panel {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 270px;
  max-height: calc(100% - 16px);
  overflow-y: auto;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.6);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  z-index: 20;
}
.rg-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #21262d;
  padding-bottom: 8px;
  margin-bottom: 2px;
}
.rg-panel-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #e6edf3;
}
.rg-panel-close {
  background: none;
  border: none;
  color: #8b949e;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 2px;
  line-height: 1;
}
.rg-panel-close:hover { color: #e6edf3; }
.rg-field-label {
  font-size: 0.7rem;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}
.rg-field-input {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  font-size: 0.82rem;
  padding: 5px 8px;
  width: 100%;
  font-family: inherit;
  transition: border-color 0.15s;
}
.rg-field-input:focus { outline: none; border-color: #58a6ff; }
.rg-field-static {
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 6px;
  color: #8b949e;
  font-size: 0.82rem;
  padding: 5px 8px;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
}
.rg-field-textarea {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  font-size: 0.8rem;
  padding: 6px 8px;
  width: 100%;
  font-family: inherit;
  resize: vertical;
  min-height: 50px;
  transition: border-color 0.15s;
}
.rg-field-textarea:focus { outline: none; border-color: #58a6ff; }
.rg-checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}
.rg-optional {
  color: #8b949e;
  font-size: 0.65rem;
  text-transform: none;
  letter-spacing: 0;
}
.rg-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.rg-color-picker {
  width: 36px;
  height: 28px;
  border: 1px solid #30363d;
  border-radius: 5px;
  padding: 2px;
  background: #21262d;
  cursor: pointer;
  flex-shrink: 0;
}
.rg-color-hint {
  font-size: 0.72rem;
  color: #8b949e;
  flex: 1;
}
.rg-type-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.rg-type-chip {
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #c9d1d9;
  font-size: 0.72rem;
  padding: 3px 9px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.rg-type-chip.active, .rg-type-chip:hover {
  border-color: var(--lc, #58a6ff);
  color: var(--lc, #58a6ff);
  background: #161b22;
}
.rg-panel-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid #21262d;
}
.rg-save-btn {
  background: #1f6feb;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.rg-save-btn:hover:not(:disabled) { background: #388bfd; }
.rg-save-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.rg-delete-btn {
  background: none;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #f85149;
  font-size: 0.8rem;
  padding: 5px 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.rg-delete-btn:hover { border-color: #f85149; background: #1c2333; }
.rg-cancel-btn {
  background: none;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  font-size: 0.8rem;
  padding: 5px 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.rg-cancel-btn:hover { border-color: #8b949e; color: #e6edf3; }

/* Node remove button */
.rg-node-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(248,81,73,0.0);
  color: #8b949e;
  font-size: 13px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  z-index: 10;
}
.rg-node-remove:hover { background: #f85149; color: #fff; }

/* Right-click context menu */
.rg-ctx-menu {
  position: fixed;
  z-index: 1000;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 6px;
  min-width: 200px;
  max-width: 260px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.rg-ctx-title {
  font-size: 0.72rem;
  color: #8b949e;
  padding: 2px 6px 6px;
  border-bottom: 1px solid #21262d;
  margin-bottom: 4px;
}
.rg-ctx-search {
  width: 100%;
  box-sizing: border-box;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  font-size: 0.8rem;
  padding: 5px 8px;
  margin-bottom: 4px;
  outline: none;
}
.rg-ctx-search:focus { border-color: #58a6ff; }
.rg-ctx-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.rg-ctx-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  border-radius: 5px;
  color: #c9d1d9;
  font-size: 0.82rem;
  padding: 5px 8px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.1s;
}
.rg-ctx-item:hover { background: #21262d; color: #e6edf3; }
.rg-ctx-item--active { background: #1f3a5f; color: #58a6ff; }
.rg-ctx-item--active:hover { background: #1f3a5f; }
.rg-char-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 0.82rem;
  color: #e6edf3;
}
.rg-ctx-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.rg-ctx-empty {
  font-size: 0.78rem;
  color: #8b949e;
  padding: 6px 8px;
  text-align: center;
}
.rg-toolbar-hint {
  font-size: 0.75rem;
  color: #8b949e;
  margin-left: 4px;
  white-space: nowrap;
}

/* ---- Admin CMS layout ---- */
.admin-cms-layout {
  display: flex;
  flex: 1;
  height: 100%;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}
.admin-cms-sidebar {
  width: 160px;
  flex-shrink: 0;
  background: rgba(12, 15, 24, 0.95);
  border-right: 1px solid rgba(126, 151, 194, 0.12);
  display: flex;
  flex-direction: column;
  padding: 20px 0 16px;
  gap: 2px;
  overflow-y: auto;
}
.admin-cms-sidebar-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #8b949e;
  padding: 0 16px 10px;
}
.admin-cms-tab {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 0;
  color: #8b949e;
  font-size: 0.875rem;
  padding: 8px 16px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  position: relative;
}
.admin-cms-tab:hover { color: #e6edf3; background: rgba(255,255,255,0.04); }
.admin-cms-tab-active {
  color: #e6edf3;
  font-weight: 500;
  background: rgba(255,255,255,0.06);
}
.admin-cms-tab-active::before {
  content: "";
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: #58a6ff;
  border-radius: 0 2px 2px 0;
}
.admin-cms-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}

.admin-cms-burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: none;
  border: 1px solid rgba(126, 151, 194, 0.18);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
  margin-bottom: 16px;
}
.admin-cms-burger:hover { background: rgba(126, 151, 194, 0.1); }
.admin-cms-burger span {
  display: block;
  height: 2px;
  width: 100%;
  background: #8e9ab3;
  border-radius: 2px;
}

.admin-cms-backdrop {
  display: none;
}

@media (max-width: 900px) {
  .admin-cms-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 200px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    border-right: 1px solid rgba(126, 151, 194, 0.18);
  }
  .admin-cms-sidebar-open {
    transform: translateX(0);
  }
  .admin-cms-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(0, 0, 0, 0.45);
  }
  .admin-cms-burger {
    display: flex;
  }
  .admin-cms-content {
    padding: 20px 16px;
  }
}

.admin-tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.admin-tab-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #e6edf3;
}
.admin-tab-accounts {
  max-width: 740px;
}
.admin-tab-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 280px;
  gap: 10px;
  color: #8b949e;
  text-align: center;
}
.admin-tab-placeholder-icon { opacity: 0.35; }
.admin-tab-placeholder-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: #c9d1d9;
  margin-top: 4px;
}
.admin-tab-placeholder-sub { font-size: 0.82rem; }

/* ---- Account table ---- */
.account-table-wrap {
  overflow-x: auto;
  border: 1px solid #30363d;
  border-radius: 10px;
  background: #0d1117;
}
.account-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.account-table th {
  background: #161b22;
  color: #8b949e;
  text-align: left;
  padding: 10px 16px;
  font-weight: 500;
  border-bottom: 1px solid #30363d;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.account-table td {
  padding: 11px 16px;
  border-bottom: 1px solid #161b22;
  vertical-align: middle;
}
.account-table tbody tr:last-child td { border-bottom: none; }
.account-table tbody tr:hover td { background: rgba(255,255,255,0.025); }
.account-row-self .account-username { font-weight: 600; }
.account-user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.account-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0;
}
.account-username { color: #e6edf3; }
.account-self-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  background: rgba(56, 139, 253, 0.15);
  border: 1px solid rgba(56, 139, 253, 0.4);
  border-radius: 20px;
  font-size: 0.68rem;
  color: #58a6ff;
  vertical-align: middle;
  font-weight: 400;
}
.account-role-select {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #30363d;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b949e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}
.account-role-select:focus { outline: none; }
.account-role-select option { background: #161b22; color: #e6edf3; }
.account-created-at {
  color: #8b949e;
  font-size: 0.8rem;
  white-space: nowrap;
}
.account-empty {
  text-align: center;
  opacity: 0.4;
  padding: 28px;
}
.account-actions {
  display: flex;
  gap: 5px;
  justify-content: flex-end;
}
.account-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: rgba(255,255,255,0.04);
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.account-icon-btn:hover { background: rgba(255,255,255,0.08); border-color: #8b949e; color: #e6edf3; }
.account-icon-btn--danger { color: #8b949e; }
.account-icon-btn--danger:hover { background: rgba(248,81,73,0.12); border-color: #f85149; color: #f85149; }

/* Readonly mode: disable text inputs/selects for roles where canEdit=false (e.g. uploader) */
.cms-readonly input:not([type="file"]):not(.upload-file-input),
.cms-readonly textarea,
.cms-readonly select {
  pointer-events: none;
  opacity: 0.5;
  cursor: not-allowed;
}
/* Upload buttons remain fully interactive inside a readonly panel */
.cms-readonly .weapon-icon-upload {
  pointer-events: auto !important;
  opacity: 1 !important;
  cursor: pointer !important;
}
/* Hide structural mutation buttons (add/remove rows, add difficulty, save audio/transform) */
.cms-readonly .editor-add-btn,
.cms-readonly .editor-remove-btn,
.cms-readonly .cms-sidebar-add-btn,
.cms-readonly .spine-audio-footer {
  display: none;
}

/* Spritesheet Manager grid */
.spritesheet-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.spritesheet-back-row {
  padding: 8px 0 4px;
}

.spritesheet-thumb-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  max-width: 130px;
  word-break: break-all;
}

.spritesheet-thumb-btn:hover {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.1);
}

.spritesheet-thumb-selected {
  border-color: #5a9e6f !important;
  background: rgba(90, 158, 111, 0.18) !important;
}

.spritesheet-thumb-img {
  width: 100px;
  height: 100px;
  object-fit: contain;
  image-rendering: pixelated;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
}

.spritesheet-thumb-label {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.65);
  text-align: center;
  line-height: 1.3;
}

.spritesheet-thumb-selected .spritesheet-thumb-label {
  color: #a0d8b0;
}

.sprite-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 8px 14px;
  background: rgba(198, 94, 94, 0.07);
  border: 1px solid rgba(198, 94, 94, 0.22);
  border-radius: 8px;
}

.sprite-action-label {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.6);
}

.sprite-action-label strong {
  color: #f5e8ca;
}

.assign-hint {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.55);
  margin-left: 12px;
  align-self: center;
}

/* ── Logs Page ──────────────────────────────────────────────────── */
.logs-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Audit toolbar ─── */
.audit-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(126,151,194,0.14);
  border-radius: 10px;
}

.audit-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.audit-filter-select {
  min-width: 140px;
  max-width: 180px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.audit-id-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.audit-id-input {
  width: 170px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.audit-toolbar-btn {
  padding: 6px 12px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.audit-clear-btn {
  padding: 6px 9px;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.45);
}

/* ── Section headers ─── */
.audit-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.audit-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
}

.audit-section-scope {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: rgba(200,218,255,0.7);
  font-weight: 500;
}

.audit-scope-id {
  color: rgba(255,255,255,0.35);
  font-size: 0.74rem;
}

.audit-count {
  margin-left: auto;
  font-size: 0.74rem;
  color: rgba(255,255,255,0.28);
}

/* ── Audit entry cards ─── */
.audit-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.logs-scroll {
  max-height: calc(100vh - 240px);
  overflow-y: auto;
  padding-right: 2px;
}

.audit-entry {
  display: flex;
  align-items: stretch;
  border: 1px solid rgba(126,151,194,0.12);
  border-left: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  transition: background 0.15s;
}

.audit-entry:hover {
  background: rgba(255,255,255,0.055);
}

.audit-entry-accent {
  width: 3px;
  flex-shrink: 0;
  background: var(--action-border, rgba(126,151,194,0.35));
  border-radius: 8px 0 0 8px;
}

.audit-entry-body {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* Top row: pill + summary + restore */
.audit-entry-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  row-gap: 4px;
}

.audit-action-pill {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.6;
}

.audit-summary {
  flex: 1;
  min-width: 120px;
  font-size: 0.84rem;
  color: rgba(255,255,255,0.85);
  line-height: 1.5;
  word-break: break-word;
}

.audit-restore-btn {
  flex-shrink: 0;
  margin-left: auto;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid rgba(227,179,65,0.4);
  background: rgba(227,179,65,0.08);
  color: #e3b341;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.audit-restore-btn:hover:not(:disabled) {
  background: rgba(227,179,65,0.16);
  border-color: rgba(227,179,65,0.65);
}

.audit-restore-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Meta row: entity + user + time */
.audit-entry-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.audit-entity-badge {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(126,151,194,0.15);
  color: rgba(200,218,255,0.7);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.audit-entity-id {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.32);
  font-family: monospace;
}

.audit-meta-sep {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.2);
}

.audit-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 0.62rem;
  font-weight: 700;
  flex-shrink: 0;
}

.audit-username {
  font-size: 0.76rem;
  color: rgba(255,255,255,0.55);
  font-weight: 500;
}

.audit-time {
  font-size: 0.73rem;
  color: rgba(255,255,255,0.32);
  white-space: nowrap;
}

/* Fields row */
.audit-fields-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.audit-fields-label {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.3);
}

.audit-field-chip {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(88,166,255,0.1);
  border: 1px solid rgba(88,166,255,0.22);
  color: rgba(88,166,255,0.75);
  font-size: 0.68rem;
  font-family: monospace;
  white-space: nowrap;
}

/* Revision entry extras */
.audit-revision-entry .audit-entry-top {
  align-items: center;
}

.audit-rev-number {
  font-size: 0.8rem;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
  font-family: monospace;
  flex-shrink: 0;
}

.audit-empty {
  padding: 24px 0;
  text-align: center;
  color: rgba(255,255,255,0.3);
  font-size: 0.84rem;
}

/* Legacy (used elsewhere) */
.logs-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.logs-id-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logs-id-input {
  width: 200px;
}

.logs-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.logs-columns--split {
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
}

.logs-audit-section,
.logs-revisions-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-right: 4px;
}

.history-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 9px 10px;
  border: 1px solid rgba(126, 151, 194, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.82rem;
}

.history-revision-row {
  justify-content: space-between;
  align-items: center;
}

.history-time,
.history-meta {
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.74rem;
}

.history-meta {
  display: block;
  margin-top: 2px;
}

.history-empty,
.history-error {
  margin: 0;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.82rem;
}

.history-error {
  margin-bottom: 10px;
  color: #f2b3b3;
}

@media (max-width: 900px) {
  .logs-columns--split {
    grid-template-columns: 1fr;
  }
}

/* ── Entity Reference Editor ─────────────────────────────────────── */
.entity-ref-editor-wrap {
  position: relative;
  width: 100%;
  min-width: 0;
}
.entity-ref-editor-wrap textarea {
  width: 100%;
  box-sizing: border-box;
}
.entity-ref-popup {
  position: absolute;
  z-index: 300;
  top: calc(100% + 2px);
  left: 0;
  min-width: 280px;
  max-width: 420px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.entity-ref-popup-hint {
  font-size: 0.7rem;
  color: rgba(201, 209, 217, 0.45);
  padding: 3px 8px 5px;
}
.entity-ref-item {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 5px 8px;
  border: none;
  border-radius: 5px;
  background: none;
  color: #c9d1d9;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
}
.entity-ref-item:hover,
.entity-ref-item--active {
  background: #1f6feb33;
  color: #e6edf3;
}
.entity-ref-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 3px;
}
.entity-ref-icon--empty {
  display: inline-block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  background: #21262d;
  border-radius: 3px;
}
.entity-ref-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entity-ref-type-badge {
  font-size: 0.68rem;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
  background: #21262d;
  color: #8b949e;
}
.entity-ref-type-badge--se     { background: #1a3a2a; color: #56d364; }
.entity-ref-type-badge--char   { background: #1a2a3a; color: #79c0ff; }
.entity-ref-type-badge--weapon { background: #3a2a1a; color: #e3b341; }
.entity-ref-type-badge--item   { background: #2a1a3a; color: #d2a8ff; }

/* ── Team CMS ───────────────────────────────────────────────────── */
.team-editor-shell { width: 100%; }

.team-header-grid {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(220px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.team-checkbox-row {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  font-size: 13px;
}

.team-workspace {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0;
  height: calc(100vh - 220px);
  align-items: stretch;
  overflow: hidden;
}

.team-left-col {
  overflow-y: auto;
  min-height: 0;
  min-width: 0;
  border-right: 1px solid rgba(255,255,255,0.1);
  padding-right: 16px;
}

.team-board-section { width: fit-content; }

.team-box-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.team-box-card,
.team-sacred-card {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 10px;
  background: rgba(255,255,255,0.04);
  width: fit-content;
}

.team-box-title {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.7;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.team-icon-tile {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 0 8px;
}

.team-icon-main {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 6px;
  background: rgba(0,0,0,0.22);
  color: var(--text-primary, #e8edf5);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
}

.team-icon-main img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.team-icon-main span {
  max-width: 100%;
  padding: 4px;
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}

.team-icon-tile--active .team-icon-main {
  border-color: var(--accent, #66d9ef);
  box-shadow: 0 0 0 2px rgba(102,217,239,0.18);
}

.team-alt-button {
  position: absolute;
  left: -5px;
  bottom: -5px;
  min-width: 24px;
  height: 24px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  background: rgba(30,36,48,0.96);
  color: var(--text-primary, #e8edf5);
  font-size: 12px;
  cursor: pointer;
}

.team-box-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.team-soulmate-cell {
  flex-shrink: 0;
}

.team-pw-cell {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.team-pw-cell .team-icon-tile,
.team-pw-cell .team-icon-main {
  width: 52px;
  height: 52px;
}

.team-pw-cell--disabled {
  opacity: 0.35;
  filter: grayscale(0.6);
}

.team-pw-label {
  font-size: 0.7rem;
  color: #8b949e;
  font-weight: 500;
  letter-spacing: 0.4px;
}

.team-pw-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  margin-bottom: 8px;
  background: rgba(88, 166, 255, 0.07);
  border: 1px solid rgba(88, 166, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  color: #8b949e;
  user-select: none;
}

.team-weapon-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

.team-weapon-cell .team-icon-tile,
.team-weapon-cell .team-icon-main {
  width: 72px;
  height: 72px;
}

.team-sacreds-section {
  margin-top: 16px;
}

.team-sacred-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.team-right-col {
  overflow-y: auto;
  min-height: 0;
  min-width: 280px;
  padding-left: 16px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.team-back-btn {
  display: none;
  width: 100%;
  border: 1px solid rgba(126, 151, 194, 0.28);
  border-radius: 6px;
  padding: 8px 14px;
  background: rgba(126, 151, 194, 0.06);
  color: #b7c0d3;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}

.team-back-btn:hover {
  background: rgba(126, 151, 194, 0.12);
  color: #e8edf5;
}

.team-panel { margin: 0; }

.team-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.team-alt-group {
  border: 1px solid rgba(126, 151, 194, 0.18);
  border-radius: 8px;
  padding: 10px 10px 8px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.team-alt-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.team-alt-group-name {
  flex: 1;
  font-size: 0.78rem !important;
  padding: 4px 8px !important;
  height: auto !important;
}

.team-alt-group-remove {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: transparent;
  color: #8b949e;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.team-alt-group-remove:hover {
  background: rgba(255, 80, 80, 0.18);
  color: #ff8c8c;
  border-color: rgba(255, 80, 80, 0.4);
}

.team-alternate-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 0;
  margin-bottom: 8px;
}

.team-alt-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 64px;
  gap: 4px;
}

.team-alt-tile .team-icon-tile,
.team-alt-tile .team-icon-main {
  width: 56px;
  height: 56px;
  margin: 0;
}

.team-alt-name {
  font-size: 10px;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  width: 100%;
  opacity: 0.8;
}

.team-alt-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(20, 22, 34, 0.95);
  color: #b7c0d3;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.team-alt-remove:hover {
  background: rgba(255, 80, 80, 0.18);
  color: #ff8c8c;
  border-color: rgba(255, 80, 80, 0.4);
}

.team-note-title {
  font-size: 13px;
  overflow-wrap: anywhere;
  margin-bottom: 8px;
}

.team-note-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  margin-bottom: 8px;
}

@media (max-width: 980px) {
  .team-header-grid,
  .team-workspace { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .team-left-col { border-right: none; padding-right: 0; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 16px; }
  .team-left-col, .team-right-col { overflow-y: visible; min-height: auto; padding-left: 0; }
  .team-board-section { width: auto; }
  .team-box-card, .team-sacred-card { width: auto; }
  .team-back-btn { display: block; }
}

