.settings {
  position: fixed; inset: 0; z-index: 40; display: flex; background: var(--bg); color: var(--text);
}
.settings-nav-region { flex: 1 0 280px; display: flex; justify-content: flex-end; background: var(--panel); overflow-y: auto; padding: 60px 8px 60px 20px; }
.settings-nav { width: 218px; flex: none; }
.settings-nav-title { font-size: 12px; font-weight: 700; color: var(--muted); padding: 6px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-nav-label { font-size: 12px; font-weight: 700; color: var(--muted); padding: 6px 10px 2px; }
.settings-nav-sep { height: 1px; background: var(--divider); margin: 8px 10px; }
.settings-nav-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; margin-bottom: 2px;
  background: none; border: 0; border-radius: 4px; color: #c4c9ce; font-weight: 500; text-align: left; cursor: pointer;
}
.settings-nav-item:hover { background: var(--hover); color: var(--head); }
.settings-nav-item.active { background: var(--active); color: var(--head); }
.settings-nav-item.danger { color: #f87c7f; }
.settings-nav-item .icon { font-size: 16px; }
.settings-nav-item .grow { flex: 1; }

.settings-content-region { flex: 1 1 800px; position: relative; overflow-y: auto; padding: 60px 120px 120px 40px; }
.settings-page-host { max-width: 1000px; }
.settings-close { position: fixed; top: 60px; right: 32px; display: grid; gap: 6px; justify-items: center; background: none; border: 0; color: var(--muted); cursor: pointer; }
.settings-close-circle { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 2px solid currentColor; font-size: 18px; }
.settings-close:hover { color: var(--head); }
.settings-close-key { font-size: 13px; font-weight: 700; }

.sp-layout { display: flex; gap: 40px; align-items: flex-start; }
.sp-form { flex: 1 1 620px; min-width: 0; max-width: 620px; }
.sp-single { max-width: 620px; }
.sp-preview { flex: 0 0 330px; position: sticky; top: 0; }
.sp-heading h1 { margin: 0 0 6px; font-size: 20px; color: var(--head); }
.sp-sub { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.sp-section { padding: 20px 0; border-top: 1px solid var(--divider); }
.sp-heading + .sp-section { border-top: 0; padding-top: 0; }
.sp-label { font-size: 16px; font-weight: 700; color: var(--head); margin-bottom: 6px; }
.sp-hint { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.sp-input, .sp-textarea {
  width: 100%; background: var(--rail); color: var(--text); border: 0; border-radius: 4px; padding: 10px 12px; font: inherit;
}
.sp-textarea { resize: vertical; min-height: 96px; }
.sp-input:focus, .sp-textarea:focus, .game-search:focus, .trait-text:focus { outline: 2px solid var(--accent); }
.sp-counter { display: flex; justify-content: flex-end; margin-top: 4px; }
.btn.sp-accent { background: #a000e0; }
.btn.sp-accent:hover:not(:disabled) { background: #8a00c2; }

.banner-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.banner-swatch { height: 70px; border: 2px solid transparent; border-radius: 6px; cursor: pointer; padding: 0; }
.banner-swatch:hover { transform: scale(1.03); }
.banner-swatch.active { outline: 2px solid #fff; outline-offset: 2px; }

.trait-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.trait-slot { min-width: 0; position: relative; display: flex; align-items: center; gap: 6px; background: var(--rail); border-radius: 6px; padding: 4px 8px; }
.trait-emoji { background: none; border: 0; color: #8a3fc4; font-size: 18px; cursor: pointer; width: 28px; height: 28px; display: grid; place-items: center; padding: 0; }
.trait-text { flex: 1; width: 100%; min-width: 0; background: none; border: 0; color: var(--text); font: inherit; font-size: 14px; padding: 6px 2px; }
.emoji-picker { position: absolute; z-index: 5; top: 100%; left: 0; margin-top: 4px; width: 264px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; background: var(--bg); border: 1px solid var(--divider); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); }
.emoji-option { background: none; border: 0; border-radius: 4px; font-size: 20px; padding: 4px; cursor: pointer; }
.emoji-option:hover { background: var(--hover); }
.emoji-option.clear { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }

.game-combo { position: relative; }
.game-search { width: 100%; background: var(--rail); color: var(--text); border: 0; border-radius: 4px; padding: 11px 36px 11px 12px; font: inherit; }
.game-caret { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted); }
.game-options { position: absolute; z-index: 5; left: 0; right: 0; top: 100%; margin-top: 4px; background: var(--bg); border: 1px solid var(--divider); border-radius: 8px; padding: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); }
.game-option { display: block; width: 100%; background: none; border: 0; color: var(--text); text-align: left; padding: 8px 10px; border-radius: 4px; cursor: pointer; font: inherit; }
.game-option:hover { background: var(--accent); color: #fff; }
.game-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.game-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--rail); border-radius: 14px; padding: 4px 6px 4px 12px; font-size: 14px; }
.chip-remove { display: grid; place-items: center; width: 18px; height: 18px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; padding: 0; font-size: 12px; }
.chip-remove:hover { background: var(--hover); color: var(--head); }

.sp-private { display: flex; gap: 24px; align-items: flex-start; }
.sp-private-text { flex: 0 0 240px; }
.sp-private-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sp-private-preview { flex: 1; min-width: 0; }
.switch { position: relative; width: 40px; height: 24px; flex: none; border: 0; border-radius: 12px; background: #4e5058; cursor: pointer; padding: 0; transition: background .15s; }
.switch.on { background: #7b2cf5; }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on .switch-knob { left: 19px; }

.scard { background: var(--panel); border: 1px solid var(--divider); border-radius: 12px; overflow: hidden; position: relative; }
.scard-banner { height: 133px; background-size: cover; background-position: center; }
.scard-icon {
  position: absolute; left: 18px; top: 96px; width: 78px; height: 78px; border-radius: 22px; display: grid; place-items: center;
  background-color: var(--panel); background-size: cover; background-position: center; box-shadow: 0 0 0 6px var(--panel); overflow: hidden;
}
.scard-icon.has-img .scard-initials { display: none; }
.scard-initials { color: #fff; font-weight: 700; font-size: 15px; letter-spacing: -.02em; }
.scard-body { padding: 48px 18px 18px; }
.scard-name { font-size: 16px; font-weight: 700; color: var(--head); overflow-wrap: anywhere; }
.scard-name.large { font-size: 20px; }
.scard-stats { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 4px; font-size: 13px; color: #c4c9ce; }
.scard-stat { display: inline-flex; align-items: center; gap: 5px; }
.stat-dot { width: 8px; height: 8px; border-radius: 50%; background: #80848e; }
.stat-dot.online { background: var(--ok); }
.scard-est { font-size: 13px; color: #c4c9ce; margin-top: 2px; }
.scard-note { margin: 6px 0 0; font-size: 13px; color: #c4c9ce; }
.scard-desc { margin: 12px 0 0; font-size: 14px; color: var(--head); white-space: pre-wrap; overflow-wrap: anywhere; }
.scard-traits { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.scard-trait { display: inline-flex; gap: 5px; align-items: center; background: var(--rail); border-radius: 12px; padding: 3px 10px; font-size: 13px; }
.scard-games { margin-top: 12px; font-size: 13px; color: #c4c9ce; }
.scard-games-label { font-weight: 700; margin-right: 6px; color: var(--muted); text-transform: uppercase; font-size: 11px; }
.scard.private .scard-banner { height: 133px; }
.join-preview { margin: 12px 0 16px; }

.settings-savebar {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 140%); z-index: 45;
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; background: #111214; border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .6); transition: transform .2s; max-width: calc(100vw - 24px);
}
.settings-savebar.visible { transform: translate(-50%, 0); }
.settings-savebar.shake { animation: savebar-shake .4s; background: #4a1c1d; }
.savebar-text { font-weight: 500; color: var(--head); }
.savebar-error { color: var(--bad); font-size: 13px; }
.savebar-error:empty { display: none; }
@keyframes savebar-shake { 0%, 100% { margin-left: 0; } 20% { margin-left: -8px; } 40% { margin-left: 8px; } 60% { margin-left: -6px; } 80% { margin-left: 4px; } }

.sp-rows { display: flex; flex-direction: column; margin-top: 8px; }
.sp-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--divider); }
.sp-row-text { flex: 1; min-width: 0; }
.sp-row-name { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--head); }
.sp-row-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-row-actions { display: flex; gap: 8px; }
.sp-count { margin: 12px 0 0; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.sp-empty { padding: 32px 8px; text-align: center; color: var(--muted); }
.sp-soon-card { display: grid; justify-items: center; gap: 8px; padding: 56px 16px; border: 1px dashed var(--divider); border-radius: 12px; color: var(--muted); text-align: center; }
.sp-soon-card .icon { font-size: 40px; opacity: .6; }
.sp-soon-card strong { color: var(--head); }
.admin-actions { margin-top: 12px; }

@media (max-width: 1100px) {
  .sp-layout { flex-direction: column-reverse; }
  .sp-preview { position: static; flex-basis: auto; width: 100%; max-width: 620px; }
}
@media (max-width: 760px) {
  .settings { flex-direction: column; overflow-y: auto; }
  .settings-nav-region { flex: none; justify-content: flex-start; padding: 56px 12px 8px; max-height: 40vh; }
  .settings-nav { width: 100%; }
  .settings-content-region { flex: none; padding: 20px 16px 120px; overflow: visible; }
  .settings-close { top: 8px; right: 12px; }
  .sp-private { flex-direction: column; }
  .trait-grid { grid-template-columns: 1fr 1fr; }
  .banner-grid { grid-template-columns: repeat(5, 1fr); }
}
