/* Editor Desktop Windowing */
#editor .xp-window {
    width: 1350px;
    height: 85vh;
    max-width: 98%;
    max-height: 95vh;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

/* Compact Header */
.editor-header {
    background: #ECE9D8;
    padding: 2px 5px;
    border-bottom: 1px solid #D4D0C8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 28px;
    flex-shrink: 0;
}

.editor-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.editor-header-right {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Main Layout Grid */
.editor-layout {
    display: flex;
    flex: 1;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* Sidebar - 1/3 width approx, but fixed width is often better for tools */
.editor-sidebar {
    width: 320px;
    min-width: 300px;
    background: #ECE9D8;
    border-right: 1px solid #808080;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    padding: 10px;
    gap: 10px;
    flex-shrink: 0;
}

/* Main Viewport - Takes remaining space (approx 2/3) */
.editor-viewport {
    flex: 1;
    position: relative;
    background: linear-gradient(135deg, #87CEEB 0%, #5DADE2 50%, #3a7bd5 100%);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Canvas Area */
#globe {
    width: 100%;
    height: 100%;
    cursor: crosshair;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Globe night mode (viewport sky darkens) */
.editor-viewport.globe-night {
    background: linear-gradient(135deg, #0a0a1a 0%, #1a1a2e 50%, #16213e 100%);
}

.editor-section {
    border: 1px solid #D4D0C8;
    background: white;
    padding: 2px;
    border-radius: 4px;
}

.editor-section-header {
    background: linear-gradient(180deg, #F0F0EA 0%, #D4D0C8 100%);
    padding: 5px;
    font-weight: bold;
    font-size: 12px;
    color: #333;
    border-bottom: 1px solid #D4D0C8;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    border-radius: 3px 3px 0 0;
    width: 100%;
    text-align: left;
    font-family: inherit;
    align-items: center;
}

/* When section header is a button, reset defaults */
button.editor-section-header {
    -webkit-appearance: none;
    appearance: none;
}

.editor-section-header:focus-visible {
    outline: 2px solid #0054E3;
    outline-offset: -2px;
}

.editor-section-content {
    padding: 5px;
}

/* Asset Grid - 3 items per row with equal sizing */
.asset-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 5px;
    max-height: 320px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    width: 100%;
    box-sizing: border-box;
}

/* Custom scrollbar for asset grid */
.asset-grid::-webkit-scrollbar {
    width: 8px;
}

.asset-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.asset-grid::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.asset-grid::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Editor menu buttons (File/View/Help) */
.editor-menu-btn {
  color: #2f3542;
}

/* ── Flat XP toolbar buttons (editor header) ── */
.editor-header .xp-btn,
.editor-header #coins-display {
  background: none !important;
  border: 1px solid transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 2px 6px !important;
  color: #2f3542 !important;
  cursor: default;
  text-shadow: none !important;
  font-weight: bold;
}

.editor-header .xp-btn:hover,
.editor-header #coins-display:hover {
  border: 1px solid #316AC5 !important;
  background-color: #C1D2EE !important;
  box-shadow: none !important;
  filter: none;
  transform: none;
}

.editor-header .xp-btn:active,
.editor-header #coins-display:active {
  border: 1px solid #316AC5 !important;
  background-color: #98B5E2 !important;
  box-shadow: none !important;
  transform: none;
}

/* Upgrade button keeps blue text for distinction */
.editor-header .xp-btn-primary {
  color: #245EDC !important;
}

/* ── Flat XP toolbar buttons (editor sidebar) ── */
.editor-sidebar .xp-btn {
  background: none !important;
  border: 1px solid transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  color: #2f3542 !important;
  text-shadow: none !important;
  cursor: default;
}

.editor-sidebar .xp-btn:hover {
  border: 1px solid #316AC5 !important;
  background-color: #C1D2EE !important;
  box-shadow: none !important;
  filter: none;
  transform: none;
}

.editor-sidebar .xp-btn:active {
  border: 1px solid #316AC5 !important;
  background-color: #98B5E2 !important;
  box-shadow: none !important;
  transform: none;
}

/* Active tool button (Place/Brush/Eraser/Move) */
.editor-sidebar .xp-btn.tool-active {
  border: 1px solid #316AC5 !important;
  background-color: #C1D2EE !important;
}

/* Night Mode Styles */
.night-mode {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --text-primary: #e0e0e0;
}

/* Night mode: menu buttons need light text */
.night-mode .editor-menu-btn {
  color: #e0e0e0;
}

/* Night mode: flat toolbar buttons (header) */
.night-mode .editor-header .xp-btn,
.night-mode .editor-header #coins-display {
  background: none !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
  color: #e0e0e0 !important;
  text-shadow: none !important;
}

.night-mode .editor-header .xp-btn:hover,
.night-mode .editor-header #coins-display:hover {
  border: 1px solid #4a8af4 !important;
  background-color: #1a3a6e !important;
  color: #fff !important;
}

.night-mode .editor-header .xp-btn:active,
.night-mode .editor-header #coins-display:active {
  border: 1px solid #4a8af4 !important;
  background-color: #0f2a50 !important;
}

.night-mode .editor-header .xp-btn-primary {
  color: #4a8af4 !important;
}

/* Night mode: flat toolbar buttons (sidebar) */
.night-mode .editor-sidebar .xp-btn {
  background: none !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
  color: #e0e0e0 !important;
  text-shadow: none !important;
}

.night-mode .editor-sidebar .xp-btn:hover {
  border: 1px solid #4a8af4 !important;
  background-color: #1a3a6e !important;
  color: #fff !important;
}

.night-mode .editor-sidebar .xp-btn:active {
  border: 1px solid #4a8af4 !important;
  background-color: #0f2a50 !important;
}

/* Night mode: active tool button */
.night-mode .editor-sidebar .xp-btn.tool-active {
  border: 1px solid #4a8af4 !important;
  background-color: #1a3a6e !important;
  color: #fff !important;
}

.night-mode .xp-window {
  background: #16213e;
  border-color: #0f3460;
}

.night-mode .xp-window-title {
  background: linear-gradient(180deg, #0f3460 0%, #1a1a2e 100%);
}

.night-mode .editor-sidebar {
  background: #16213e;
  color: #e0e0e0;
}

.night-mode .xp-taskbar {
  background: #0f3460;
}

.night-mode .editor-header {
  background: #0f3460;
  color: #e0e0e0;
}

.night-mode .editor-section {
  background: #1a1a2e;
  border-color: #0f3460;
}

.night-mode .editor-section-header {
  background: linear-gradient(180deg, #0f3460 0%, #1a1a2e 100%);
  color: #e0e0e0;
  border-color: #0f3460;
}

.night-mode .asset-item {
  background: #16213e;
  border-color: #0f3460;
  color: #e0e0e0;
}

.night-mode .asset-item:hover {
  background: #0f3460;
  color: #fff;
}

.night-mode .asset-item.selected {
  background: #1a3a6e;
  border-color: #4a8af4;
  color: #fff;
}

.night-mode .asset-name {
  color: #ccc;
}

.night-mode .asset-item.locked {
  opacity: 0.4;
}

.night-mode .asset-grid {
  scrollbar-color: #0f3460 #1a1a2e;
}

.night-mode .editor-section-content {
  background: #1a1a2e;
  color: #e0e0e0;
}

/* Preset row list */
.preset-list {
  display: flex;
  flex-direction: column;
  border: 1px solid #ced6e0;
  border-radius: 4px;
  overflow: hidden;
}

.preset-row {
  padding: 6px 10px;
  font-size: 11px;
  cursor: pointer;
  border-bottom: 1px solid #ced6e0;
  background: #fff;
  color: #2f3542;
  transition: background 0.1s;
  display: flex;
  align-items: center;
}

.preset-row:last-child {
  border-bottom: none;
}

.preset-row:hover {
  background: #e8f0fe;
}

.preset-row.active {
  background: #245EDC;
  color: #fff;
  font-weight: bold;
}

.preset-row.active::after {
  content: "●";
  margin-left: auto;
  font-size: 8px;
}

/* Night mode presets */
.night-mode .preset-list {
  border-color: #0f3460;
}

.night-mode .preset-row {
  background: #16213e;
  color: #e0e0e0;
  border-color: #0f3460;
}

.night-mode .preset-row:hover {
  background: #1a3a6e;
}

.night-mode .preset-row.active {
  background: #4a8af4;
  color: #fff;
}

.night-mode .preset-row.active::after {
  content: "●";
  margin-left: auto;
  font-size: 8px;
}

.night-mode .xp-input {
  background: #1a1a2e;
  color: #e0e0e0;
  border-color: #0f3460;
}

/* Character Creator Modal - Night Mode */
.night-mode #character-modal .xp-window {
  background: #16213e;
  border-color: #0f3460;
}

.night-mode #character-modal .xp-window-content {
  background: #1a1a2e;
}

.night-mode #char-tab-bar {
  background: #16213e !important;
  border-color: #0f3460 !important;
}

.night-mode #char-tab-bar .xp-btn {
  color: #e0e0e0 !important;
  background: #1a1a2e !important;
}

.night-mode #char-tab-bar .xp-btn.active {
  background: #0f3460 !important;
  color: #fff !important;
}

.night-mode #char-preview-panel div {
  color: #ccc !important;
}

.night-mode #char-tab-content {
  background: #1a1a2e;
  color: #e0e0e0;
}

.night-mode #char-tab-content label,
.night-mode #char-tab-content span,
.night-mode #char-tab-content div {
  color: #e0e0e0 !important;
}

.night-mode #char-modal-body > div:last-child {
  background: #16213e !important;
  border-color: #0f3460 !important;
}

/* Character modal bottom action bar */
.night-mode #character-modal div[style*="background: #ECE9D8"] {
  background: #16213e !important;
  border-color: #0f3460 !important;
}

/* Character modal buttons - Night Mode contrast */
.night-mode #char-tab-content .xp-btn {
  background: #1a2d5a !important;
  color: #e0e0e0 !important;
  border-color: #0f3460 !important;
  box-shadow: none !important;
}

.night-mode #char-tab-content .xp-btn:hover {
  background: #1a3a6e !important;
  color: #fff !important;
  border-color: #4a8af4 !important;
}

.night-mode #char-tab-content .xp-btn[style*="background:#245EDC"],
.night-mode #char-tab-content .xp-btn[aria-checked="true"] {
  background: #245EDC !important;
  color: white !important;
  border-color: #1a4db8 !important;
}

.night-mode #char-tab-content h3 {
  color: #5ea4ff !important;
}

.night-mode #char-tab-content div[style*="background: #f5f5f5"] {
  background: #16213e !important;
  border-color: #0f3460 !important;
}

/* Closet items - Night Mode */
.night-mode #char-tab-content div[role="option"] {
  background: #16213e !important;
  border-color: #0f3460 !important;
  color: #e0e0e0 !important;
}

.night-mode #char-tab-content div[role="option"][aria-selected="true"] {
  background: #0f2a1a !important;
  border-color: #28a745 !important;
}

.night-mode #char-tab-content div[role="option"] div {
  color: #e0e0e0 !important;
}

.night-mode #char-tab-content div[role="option"] div:first-child {
  background: #1a2040 !important;
  border-color: #2a3a60 !important;
}

.night-mode #char-tab-content div[role="option"][aria-selected="true"] div:first-child {
  background: #1a3a2a !important;
  border-color: #28a745 !important;
}

/* Equipped section - Night Mode */
.night-mode #char-tab-content div[style*="background: #f0f0f0"] {
  background: #16213e !important;
  border-color: #0f3460 !important;
  color: #e0e0e0 !important;
}

/* Character preview panel - Night Mode */
.night-mode #char-preview-panel {
  background: linear-gradient(180deg, #0a0a2e 0%, #10102a 100%) !important;
}

.night-mode #char-preview-3d {
  background: linear-gradient(180deg, #0a0a2e, #10102a) !important;
}

/* Modal window buttons - Night Mode contrast */
.night-mode .xp-window-content .xp-btn {
  background: #1a2d5a;
  color: #e0e0e0;
  border-color: #0f3460;
  box-shadow: none;
}

.night-mode .xp-window-content .xp-btn:hover {
  background: #1a3a6e;
  color: #fff;
  border-color: #4a8af4;
}

.night-mode .xp-window-content .xp-btn-primary {
  background: #245EDC;
  color: white;
  border-color: #0c2e75;
}

/* Missions modal - Night Mode */
.night-mode #missions-modal .xp-window-content {
  background: #1a1a2e;
  color: #e0e0e0;
}

.night-mode #missions-modal .xp-window-content div {
  color: #e0e0e0;
}

.night-mode #missions-modal .xp-window-content span {
  color: #e0e0e0;
}

/* Solar System modal - Night Mode */
.night-mode #system-modal .xp-window-content {
  background: #1a1a2e;
  color: #e0e0e0;
}

.night-mode #system-modal .xp-window-content div {
  color: #e0e0e0 !important;
}

.night-mode #system-modal .xp-window-content span {
  color: #e0e0e0 !important;
}

.night-mode #system-modal #system-connections-list {
  background: #16213e !important;
  border-color: #0f3460 !important;
}

.night-mode #system-modal #system-connections-list div[style*="border-bottom"] {
  border-color: #0f3460 !important;
}

.night-mode #system-modal .xp-window-content div[style*="background: #ECE9D8"] {
  background: #16213e !important;
  border-color: #0f3460 !important;
}

.night-mode #system-modal .xp-input {
  background: #1a1a2e !important;
  color: #e0e0e0 !important;
  border-color: #0f3460 !important;
}

/* Stats modal - Night Mode */
.night-mode #stats-modal .xp-window-content {
  background: #1a1a2e;
  color: #e0e0e0;
}

.night-mode #stats-modal .xp-window-content div {
  color: #e0e0e0 !important;
}

.night-mode #stats-modal .xp-window-content span {
  color: #e0e0e0 !important;
}

/* Upload sections - Night Mode */
.night-mode .editor-sidebar div[style*="background: #f5f5f5"],
.night-mode .editor-sidebar div[style*="background: #f0f8ff"] {
  background: #1a1a2e !important;
  border-color: #0f3460 !important;
  color: #e0e0e0 !important;
}

.night-mode .editor-sidebar div[style*="background: #f5f5f5"] div,
.night-mode .editor-sidebar div[style*="background: #f0f8ff"] div,
.night-mode .editor-sidebar div[style*="background: #f5f5f5"] span,
.night-mode .editor-sidebar div[style*="background: #f0f8ff"] span {
  color: #e0e0e0 !important;
}

.night-mode .editor-sidebar .tool-row span {
  color: #e0e0e0 !important;
}

/* Logo style toggle - Night Mode */
.night-mode #logo-style-toggle {
  background: #16213e !important;
  color: #e0e0e0 !important;
}
.night-mode #logo-style-toggle span,
.night-mode #logo-style-toggle label {
  color: #e0e0e0 !important;
}

.night-mode #tool-instruction {
  background: #16213e !important;
  color: #e0e0e0 !important;
}

/* Preset/upload labels with inline color:#333 - Night Mode override */
.night-mode .editor-sidebar div[style*="color: #333"] {
  color: #e0e0e0 !important;
}

/* Coins display - Night Mode (flat, inherits from header rules) */
.night-mode #coins-display span {
  color: inherit !important;
}

/* Link items - Night Mode */
.night-mode .link-item {
  background: #16213e !important;
  border-color: #0f3460 !important;
}

.night-mode .link-item div {
  color: #e0e0e0 !important;
}

.night-mode #connections-content select {
  background: #1a1a2e !important;
  color: #e0e0e0 !important;
  border-color: #0f3460 !important;
}

.asset-item {
    border: 1px solid transparent;
    padding: 6px 4px;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: #F9F9F9;
    border-radius: 4px;
    transition: all 0.1s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

.asset-item.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.asset-item:hover {
    border: 1px solid #316AC5;
    background: #E0E8F9; /* Highlight color */
    transform: scale(1.05);
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
    z-index: 1;
}

.asset-item.selected {
    border: 2px solid #316AC5;
    background: #C1D2EE;
    font-weight: bold;
}

.asset-item img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.1));
    flex-shrink: 0;
}

.asset-name {
    font-size: 11px;
    margin-top: 3px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    width: 100%;
    line-height: 1.3;
    word-break: break-word;
    text-align: center;
}

.asset-item.locked {
    opacity: 0.5;
    filter: grayscale(100%);
}

/* Link Editor (Subdomain) - XP Address Bar Style */
#subdomain-edit {
    display: none;
    padding: 8px;
    background: linear-gradient(180deg, #F0F0EA 0%, #ECE9D8 100%);
    border: 1px solid #D4D0C8;
    border-radius: 4px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#subdomain-input {
    font-family: 'Tahoma', sans-serif;
    border: 1px solid #7F9DB9;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

/* Premium/Locked features */
.premium-feature.locked {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

/* Tool rows */
.tool-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-size: 12px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 60px;
    right: 20px;
    background: #FFFFE1;
    border: 1px solid #000;
    padding: 5px 10px;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
    font-size: 12px;
    display: none;
    z-index: 2000;
    color: black;
}
.toast.show { display: block; }

/* Loader */
.loader {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ECE9D8;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.xp-progress-bar {
    width: 200px;
    height: 15px;
    border: 1px solid #808080;
    background: white;
    padding: 2px;
    margin-top: 10px;
}

.xp-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #378B1D, #5CB85C);
    width: 0%;
    animation: load 2s infinite;
}

@keyframes load {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* Site-wide dark mode: taskbar */
.night-mode .xp-taskbar {
  background: linear-gradient(180deg, #0f1a3a 0%, #162044 10%, #0f1a3a 100%);
  border-top-color: #1e3a6e;
}

.night-mode .xp-task-item {
  background: linear-gradient(180deg, #1a2d5a 0%, #0f1a3a 100%);
}

.night-mode .xp-task-item.active {
  background: #091230;
}

.night-mode .xp-tray {
  background: #0a1535;
  border-left-color: #0f1a3a;
}

.night-mode .xp-btn-start {
  background: linear-gradient(180deg, #1a5a1a 0%, #0f3a0f 100%);
}

/* Site-wide dark mode: window frame */
.night-mode .xp-window {
  border-color: #0f3460;
}

/* Account page dark mode */
.night-mode .account-window {
  background: #16213e;
}

.night-mode .account-window .xp-window-content {
  background: #1a1a2e;
  color: #e0e0e0;
}

.night-mode .account-window h4 {
  color: #5ea4ff !important;
}

.night-mode .account-window .xp-label {
  color: #c0c0c0;
}

.night-mode .account-window .xp-input {
  background: #16213e;
  color: #e0e0e0;
  border-color: #0f3460;
}

.night-mode .account-window div[style*="background: #ECE9D8"],
.night-mode .account-window div[style*="background: #f5f5f5"] {
  background: #16213e !important;
  color: #e0e0e0 !important;
  border-color: #0f3460 !important;
}

.night-mode .account-window div[style*="background: #f5f5f5"] span,
.night-mode .account-window div[style*="background: #f5f5f5"] div {
  color: #e0e0e0 !important;
}

.night-mode .account-window .tab-btn {
  background: #16213e;
  color: #e0e0e0;
  border-color: #0f3460;
}

.night-mode .account-window .tab-btn.active {
  background: #1a1a2e;
  border-bottom-color: #1a1a2e;
}

.night-mode .account-window div[style*="border-top: 1px solid"] {
  border-color: #0f3460 !important;
}

.night-mode .account-window div[style*="border-bottom: 1px solid"] {
  border-color: #0f3460 !important;
}

.night-mode .account-window #status-message {
  color: #ccc;
}

.night-mode .account-window div[style*="background: #E3F2FD"] {
  background: #0f2a4a !important;
  border-left-color: #2a6dd4 !important;
  color: #e0e0e0 !important;
}

.night-mode .account-window div[style*="background: #E3F2FD"] div,
.night-mode .account-window div[style*="background: #E3F2FD"] li {
  color: #c0c0c0 !important;
}

/* Night mode: share modal instruction text */
.night-mode .share-instruction-text {
  color: #e0e0e0 !important;
  background: rgba(255,255,255,0.1) !important;
}
