/* ═══════════════════════════════════════════════════════════
   Design tokens — kept for JS-generated HTML that can't use Tailwind
═══════════════════════════════════════════════════════════ */
:root {
  --void:                #0a0a0f;
  --deep:                #0e0e18;
  --glass-bg:            rgba(255,255,255,0.04);
  --glass-bg-hover:      rgba(255,255,255,0.07);
  --glass-bg-active:     rgba(255,255,255,0.10);
  --glass-border:        rgba(255,255,255,0.08);
  --glass-border-strong: rgba(255,255,255,0.14);
  --accent:              #38bdf8;
  --accent-glow:         rgba(56,189,248,0.18);
  --accent-subtle:       rgba(56,189,248,0.08);
  --text-primary:        rgba(255,255,255,0.92);
  --text-secondary:      rgba(255,255,255,0.50);
  --text-muted:          rgba(255,255,255,0.28);
  --danger:              #f87171;
  --radius-sm:           8px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  background: var(--void);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ── Visibility utility (needs !important — toggled 14× across JS files) ── */
.hidden { display: none !important; }

/* ── View-screen system ── */
.view-screen { width: 100%; height: 100%; }
#galleryView { display: flex; flex-direction: column; }
#editorView  { height: 100%; }


/* ════════════════════════════════════════════════════════
   GALLERY — Locale sections (gallery.js)
════════════════════════════════════════════════════════ */
.locale-section           { padding: 28px 0 32px; border-bottom: 1px solid var(--glass-border); }
.locale-section:last-child { border-bottom: none; }
.locale-section-header    { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.locale-section-title     { display: flex; align-items: center; gap: 10px; }
.locale-flag              { font-size: 20px; line-height: 1; }
.locale-name              { font-size: 16px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.01em; }
.locale-primary-badge     { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); background: var(--accent-subtle); border: 1px solid rgba(56,189,248,0.22); border-radius: 20px; padding: 2px 8px; line-height: 1.6; }
.locale-shot-badge        { font-size: 11px; font-weight: 500; color: var(--text-muted); background: var(--glass-bg-hover); border: 1px solid var(--glass-border); border-radius: 20px; padding: 2px 9px; line-height: 1.6; }
.locale-section-actions   { display: flex; align-items: center; }
.btn-locale-delete        { padding: 4px 12px; background: none; border: 1px solid var(--glass-border); border-radius: var(--radius-sm); color: var(--text-muted); font-size: 12px; cursor: pointer; font-family: inherit; transition: all .15s; }
.btn-locale-delete:hover  { background: rgba(248,113,113,0.08); border-color: rgba(248,113,113,0.3); color: var(--danger); }


/* ════════════════════════════════════════════════════════
   GALLERY — Screenshot cards (gallery.js)
════════════════════════════════════════════════════════ */
.screenshot-gallery-grid  { display: flex; flex-wrap: wrap; gap: 16px; }
.screenshot-gallery-card  { display: flex; flex-direction: column; gap: 10px; width: 200px; cursor: pointer; }

/* Portrait thumbnail — height driven by --ar CSS variable */
.gallery-card-thumb {
  width: 200px;
  height: calc(200px / var(--ar, 0.461));
  border-radius: 12px; overflow: hidden; position: relative;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  transition: transform .2s cubic-bezier(.22,1,.36,1), box-shadow .2s, border-color .2s;
}
.screenshot-gallery-card:not(.screenshot-gallery-card-add):hover .gallery-card-thumb { transform: scale(1.025) translateY(-2px); box-shadow: 0 12px 36px rgba(0,0,0,.55); border-color: rgba(255,255,255,.12); }
.screenshot-gallery-card.drag-over .gallery-card-thumb  { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 8px 32px var(--accent-glow); transform: scale(1.03) translateY(-3px); }
.screenshot-gallery-card.drag-over .gallery-card-empty  { color: var(--accent); }
.gallery-card-img   { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-card-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: rgba(255,255,255,.18); font-size: 11px; }
.gallery-card-empty svg { display: block; }
.gallery-card-meta  { display: flex; flex-direction: column; gap: 2px; padding: 0 2px; }
.gallery-card-title { font-size: 12px; font-weight: 500; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gallery-card-dims  { font-size: 11px; color: var(--text-muted); font-family: 'SF Mono', ui-monospace, monospace; }

.screenshot-gallery-card-add .gallery-card-thumb        { background: transparent !important; border: 1px dashed rgba(255,255,255,.1); display: flex; align-items: center; justify-content: center; box-shadow: none; }
.screenshot-gallery-card-add:hover .gallery-card-thumb  { border-color: rgba(255,255,255,.2); background: var(--glass-bg) !important; transform: none; box-shadow: none; }
.screenshot-gallery-card-add .gallery-card-empty        { color: rgba(255,255,255,.2); }
.screenshot-gallery-card-add:hover .gallery-card-empty  { color: rgba(255,255,255,.4); }
.screenshot-gallery-card-add.drag-over .gallery-card-empty { color: var(--accent); }
.screenshot-gallery-card-add .gallery-card-title        { color: var(--text-muted); }


/* ════════════════════════════════════════════════════════
   EDITOR — Locale tabs + screenshot slots (editor.js)
════════════════════════════════════════════════════════ */
.locale-tab               { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; color: var(--text-secondary); transition: all .12s; }
.locale-tab:hover         { background: var(--glass-bg-hover); color: var(--text-primary); }
.locale-tab.active        { background: var(--accent-subtle); border: 1px solid rgba(56,189,248,.2); color: var(--accent); }
.locale-tab .delete-locale       { opacity: 0; font-size: 11px; cursor: pointer; padding: 0 2px; color: var(--text-muted); }
.locale-tab:hover .delete-locale { opacity: .55; }
.locale-tab.active .delete-locale { opacity: .7; color: var(--accent); }

.screenshot-slot               { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text-secondary); transition: all .12s; }
.screenshot-slot:hover         { background: var(--glass-bg-hover); color: var(--text-primary); }
.screenshot-slot.active        { background: var(--accent-subtle); border: 1px solid rgba(56,189,248,.2); color: var(--accent); }
.screenshot-slot .slot-thumb      { width: 26px; height: 26px; border-radius: 4px; background: var(--glass-bg-hover); border: 1px solid var(--glass-border); overflow: hidden; flex-shrink: 0; }
.screenshot-slot .slot-thumb img  { width: 100%; height: 100%; object-fit: cover; }
.screenshot-slot .slot-label      { font-size: 12px; }
.screenshot-slot .slot-label .slot-num { font-weight: 600; }
.screenshot-slot .delete-slot     { margin-left: auto; opacity: 0; font-size: 11px; cursor: pointer; color: var(--text-muted); }
.screenshot-slot:hover .delete-slot  { opacity: .5; }
.screenshot-slot.active .delete-slot { opacity: .7; color: var(--accent); }


/* ════════════════════════════════════════════════════════
   INSPECTOR — Text layer items (inspector.js)
════════════════════════════════════════════════════════ */
.text-layer-item               { padding: 8px 10px; background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-sm); margin-bottom: 6px; cursor: pointer; transition: border-color .15s; }
.text-layer-item:hover,
.text-layer-item.active        { border-color: rgba(56,189,248,.3); }
.text-layer-header             { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.text-layer-preview            { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.text-layer-delete             { font-size: 11px; cursor: pointer; color: var(--text-muted); }
.text-layer-delete:hover       { color: var(--danger); }
.text-props                    { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.text-prop label               { font-size: 11px; color: var(--text-secondary); display: block; margin-bottom: 2px; }
.text-prop-full                { grid-column: span 2; }


/* ════════════════════════════════════════════════════════
   LOCALE PICKER — List items (locale-picker.js)
════════════════════════════════════════════════════════ */
.locale-list-item              { display: flex; align-items: center; gap: 13px; padding: 13px 22px; cursor: pointer; border-bottom: 1px solid var(--glass-border); transition: background .1s; user-select: none; }
.locale-list-item:last-child   { border-bottom: none; }
.locale-list-item:hover        { background: var(--glass-bg-hover); }
.locale-list-item.selected     { background: var(--accent-subtle); }
.locale-list-item-added        { opacity: .4; cursor: default; }
.locale-list-flag              { font-size: 20px; line-height: 1; flex-shrink: 0; width: 24px; text-align: center; }
.locale-list-name              { flex: 1; font-size: 14px; font-weight: 500; color: var(--text-primary); }
.locale-list-code              { font-size: 11px; color: var(--text-muted); font-family: 'SF Mono', ui-monospace, monospace; letter-spacing: .02em; }
.locale-list-check             { width: 18px; display: flex; align-items: center; justify-content: center; color: var(--accent); flex-shrink: 0; }
.locale-list-item:not(.selected) .locale-list-check svg { display: none; }
.locale-list-item.selected .locale-list-check svg       { display: block; }
.locale-list-item-added .locale-list-check svg          { display: block; }


/* ════════════════════════════════════════════════════════
   CANVAS — Absolute positioning (can't be expressed in Tailwind)
════════════════════════════════════════════════════════ */
.canvas-wrapper          { position: relative; transform-origin: top center; display: inline-block; box-shadow: 0 12px 60px rgba(0,0,0,.7); border-radius: 3px; cursor: grab; overflow: hidden; }
.canvas-wrapper.dragging { cursor: grabbing; }
#mainCanvas              { display: block; }
#bezelLayer              { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; pointer-events: none; will-change: transform; }
#bezelLayer > canvas,
#bezelLayer > img        { position: absolute; }
#frameImg                { pointer-events: none; display: block; }
.text-layer-overlay      { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.align-guide             { position: absolute; z-index: 30; pointer-events: none; background: #22d3ee; opacity: 0; transition: opacity .08s; }
.align-guide.visible     { opacity: .75; }
.align-guide-h           { left: 0; right: 0; height: 1px; top: 50%; }
.align-guide-v           { top: 0; bottom: 0; width: 1px; left: 50%; }
.text-overlay-item       { position: absolute; cursor: move; pointer-events: all; user-select: none; transform: translate(-50%,-50%); white-space: pre; line-height: 1.2; }
.text-overlay-item.selected { outline: 1px dashed rgba(56,189,248,.7); outline-offset: 4px; }

/* Canvas drag-over uses color-mix() — not available in Tailwind */
.canvas-viewport.drag-over { background: color-mix(in srgb, var(--accent) 8%, transparent); outline: 2px dashed var(--accent); outline-offset: -8px; border-radius: 12px; }


/* ════════════════════════════════════════════════════════
   MODAL — Entrance animation
════════════════════════════════════════════════════════ */
@keyframes sheetIn {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}


/* ════════════════════════════════════════════════════════
   INSPECTOR — JS-toggled states
════════════════════════════════════════════════════════ */
/* bg-panel visibility toggled by inspector.js */
.bg-panel.hidden { display: none; }
/* bg-tab.active toggled by inspector.js — needs !important to override Tailwind base */
.bg-tab.active   { background: var(--accent-subtle) !important; border-color: rgba(56,189,248,.3) !important; color: var(--accent) !important; }


/* ════════════════════════════════════════════════════════
   NATIVE FORM CONTROL OVERRIDES
════════════════════════════════════════════════════════ */
/* Applies to both static HTML and inspector.js-generated inputs/selects */
select, input[type=text], input[type=number] {
  width: 100%; padding: 6px 8px;
  background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 12px; font-family: inherit;
  outline: none; transition: border-color .15s;
}
select:focus, input:focus { border-color: rgba(56,189,248,.5); }
input[type=range] { accent-color: var(--accent); }
input[type=color] { width: 32px; height: 32px; padding: 2px; border: 1px solid var(--glass-border); border-radius: 6px; background: var(--glass-bg); cursor: pointer; }
input[type=file]  { display: none; }


/* ════════════════════════════════════════════════════════
   CUSTOM SCROLLBARS
════════════════════════════════════════════════════════ */
::-webkit-scrollbar       { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--glass-border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }


/* ════════════════════════════════════════════════════════
   MOBILE — Panel switching for bottom tab bar
════════════════════════════════════════════════════════ */
.mobile-tab        { color: rgba(255,255,255,.28); background: none; border: none; cursor: pointer; font-family: inherit; }
.mobile-tab.active { color: #38bdf8; }

@media (max-width: 767px) {
  /* Shrink app-shell height to leave room for the fixed 60px tab bar */
  .app-shell { height: calc(100% - 60px) !important; }
  /* Hide all panels by default; JS adds .mobile-active to the selected one */
  .editor-panel               { display: none !important; }
  .editor-panel.mobile-active { display: flex !important; }
}
