/* ==============================================================================
   KANG HERMES STUDIO PRO SUITE - CORE STYLESHEET
   1. Cloud Asset Library (view-assets)
   2. Real-time VPS Storage Meter (Sidebar & Header)
   3. Floating Background Task Dock
   4. 60-Second Onboarding Tour Overlay
   5. BGM Royalty-Free Catalog & Audio Ducking
   ============================================================================== */

/* --- 1. ASSET LIBRARY LAYOUT & CARDS --- */
#view-assets {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  color: var(--text);
  overflow-y: auto;
}

.as-title-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.as-head-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.01em;
}

.as-head-icon {
  font-size: 1.25rem;
}

.as-head-sub {
  font-size: 0.76rem;
  color: var(--text-3);
  font-weight: 500;
}

.as-nav-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

/* Storage Badge in Header */
.as-storage-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: color-mix(in oklab, var(--surface) 80%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.as-st-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  transition: background 0.3s, box-shadow 0.3s;
}

.as-st-dot.warn {
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
}

.as-st-dot.danger {
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

.as-st-bar {
  width: 50px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.as-st-fill {
  height: 100%;
  background: #10b981;
  border-radius: 999px;
  transition: width 0.4s ease, background 0.3s;
}

.as-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 5rem 1.5rem;
  width: 100%;
  box-sizing: border-box;
}

/* Toolbar */
.as-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.as-filter-pills {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.as-pill {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.as-pill:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line-strong);
}

.as-pill.active {
  background: var(--primary, #2563eb);
  color: #fff;
  border-color: var(--primary, #2563eb);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.as-cnt {
  font-size: 0.72rem;
  padding: 1px 6px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 999px;
}

.as-search-box {
  position: relative;
  min-width: 280px;
  flex: 0 1 360px;
}

.as-search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-3);
  pointer-events: none;
}

.as-search-input {
  width: 100%;
  padding: 0.5rem 2.2rem 0.5rem 2.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.84rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.as-search-input:focus {
  border-color: var(--primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.as-search-clear {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 50%;
}

/* Media Grid */
.as-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.15rem;
}

/* Media Card */
.as-card {
  background: color-mix(in oklab, var(--surface) 90%, transparent);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
  position: relative;
}

.as-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 10px 24px -6px rgba(0, 0, 0, 0.45);
}

.as-thumb-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0a0c10;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.as-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.as-card:hover .as-thumb-img {
  transform: scale(1.04);
}

.as-thumb-audio-ph,
.as-thumb-video-ph {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  color: var(--text-3);
  width: 100%;
  height: 100%;
}

.as-thumb-audio-ph {
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.15), rgba(30, 27, 75, 0.6));
}

.as-thumb-video-ph {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.15), rgba(15, 23, 42, 0.6));
}

.as-type-badge {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  color: #fff;
  z-index: 2;
}

.as-type-badge.video {
  background: rgba(37, 99, 235, 0.85);
}

.as-type-badge.audio {
  background: rgba(147, 51, 234, 0.85);
}

.as-type-badge.image {
  background: rgba(16, 185, 129, 0.85);
}

.as-card-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.as-card:hover .as-card-play-overlay {
  opacity: 1;
}

.as-play-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  transform: scale(0.9);
  transition: transform 0.2s;
}

.as-card:hover .as-play-icon {
  transform: scale(1);
}

.as-card-info {
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.as-card-title {
  font-size: 0.84rem;
  font-weight: 600;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.as-card-meta {
  font-size: 0.72rem;
  color: var(--text-3);
  display: flex;
  justify-content: space-between;
}

.as-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
}

.as-btn-act {
  background: none;
  border: none;
  color: var(--text-2);
  padding: 4px 7px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.74rem;
  transition: all 0.15s;
}

.as-btn-act:hover {
  background: var(--surface-2);
  color: var(--text);
}

.as-btn-act.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* Empty State */
.as-empty {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--text-2);
}

.as-empty-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  opacity: 0.7;
}

/* --- LIGHTBOX MODAL --- */
.as-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  box-sizing: border-box;
}

.as-lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(14px);
}

.as-lb-content {
  position: relative;
  z-index: 2;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  animation: asPopIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes asPopIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.as-lb-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.as-lb-info h4 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
}

.as-lb-meta {
  font-size: 0.74rem;
  color: var(--text-3);
}

.as-lb-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.as-lb-body {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: auto;
  min-height: 320px;
}

.as-lb-body img {
  max-width: 100%;
  max-height: 65vh;
  object-fit: contain;
  border-radius: 8px;
}

.as-lb-body video {
  max-width: 100%;
  max-height: 65vh;
  border-radius: 8px;
  outline: none;
}

.as-lb-audio-wrap {
  width: 100%;
  max-width: 500px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

.as-lb-audio-wrap audio {
  width: 100%;
}

/* --- 2. SIDEBAR STORAGE METER --- */
.sb-storage-box {
  margin: 0.5rem 0.85rem;
  padding: 0.65rem 0.8rem;
  background: color-mix(in oklab, var(--surface) 60%, transparent);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sb-st-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.sb-st-label {
  color: var(--text-2);
}

.sb-st-val {
  font-weight: 700;
  color: #10b981;
}

.sb-st-val.warn {
  color: #f59e0b;
}

.sb-st-val.danger {
  color: #ef4444;
}

.sb-st-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.sb-st-bar {
  height: 100%;
  background: #10b981;
  border-radius: 999px;
  transition: width 0.4s ease, background 0.3s;
}

.sb-st-sub {
  font-size: 0.68rem;
  color: var(--text-3);
  text-align: right;
}

/* --- 3. FLOATING BACKGROUND TASK DOCK --- */
.ftd-dock {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  z-index: 85;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.05);
  width: 310px;
  max-width: calc(100vw - 2rem);
  color: #fff;
  overflow: hidden;
  animation: ftdSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.ftd-inner {
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.ftd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ftd-status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ftd-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #f8fafc;
}

.ftd-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: ftdSpin 0.8s linear infinite;
}

@keyframes ftdSpin {
  to { transform: rotate(360deg); }
}

.ftd-close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}

.ftd-close-btn:hover {
  color: #fff;
}

.ftd-desc {
  font-size: 0.74rem;
  color: #cbd5e1;
}

.ftd-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.2rem;
}

.ftd-bar {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.ftd-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: 2px;
}

/* Success flash */
.ftd-dock.success .ftd-bar {
  background: #10b981;
}

.ftd-dock.success .ftd-spinner {
  border-color: #10b981;
  animation: none;
}

/* --- 4. 60-SECOND ONBOARDING TOUR OVERLAY --- */
.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
}

.tour-cutout {
  position: absolute;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.78);
  border: 2px solid #38bdf8;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  animation: tourPulse 2s infinite;
}

@keyframes tourPulse {
  0%, 100% { box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.78), 0 0 15px rgba(56, 189, 248, 0.6); }
  50% { box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.78), 0 0 25px rgba(56, 189, 248, 0.9); }
}

.tour-card {
  position: absolute;
  pointer-events: auto;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  padding: 1.15rem 1.35rem;
  width: 340px;
  max-width: calc(100vw - 2.5rem);
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.7);
  transition: top 0.35s cubic-bezier(0.16, 1, 0.3, 1), left 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.tour-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.tour-step-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border-radius: 999px;
  text-transform: uppercase;
}

.tour-skip-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.75rem;
  cursor: pointer;
}

.tour-skip-btn:hover {
  color: #fff;
}

.tour-card-title {
  font-size: 1rem;
  font-weight: 800;
  margin: 0 0 0.35rem 0;
  letter-spacing: -0.01em;
}

.tour-card-body {
  font-size: 0.8rem;
  line-height: 1.5;
  color: #cbd5e1;
  margin: 0 0 1rem 0;
}

.tour-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 0.75rem;
}

.tour-dots {
  display: flex;
  gap: 5px;
}

.tour-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  transition: background 0.2s, transform 0.2s;
}

.tour-dot.active {
  background: #38bdf8;
  transform: scale(1.3);
}

.tour-btn-group {
  display: flex;
  gap: 0.4rem;
}

/* --- 5. BGM CATALOG & AUDIO DUCKING --- */
.as-bgm-modal-content {
  max-width: 680px;
}

.as-bgm-ducking-banner {
  margin: 0.85rem 1.25rem 0.5rem 1.25rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.15), rgba(147, 51, 234, 0.15));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.as-duck-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.as-duck-info b {
  font-size: 0.84rem;
  color: var(--text);
}

.as-duck-info span {
  font-size: 0.74rem;
  color: var(--text-2);
}

/* Toggle Switch */
.as-duck-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.as-duck-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.as-toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  transition: 0.3s;
}

.as-toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
}

.as-duck-toggle input:checked + .as-toggle-slider {
  background-color: var(--primary, #2563eb);
}

.as-duck-toggle input:checked + .as-toggle-slider:before {
  transform: translateX(20px);
}

.as-bgm-list {
  padding: 0.75rem 1.25rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 55vh;
  overflow-y: auto;
}

.as-bgm-track {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  gap: 0.75rem;
  transition: all 0.2s;
}

.as-bgm-track:hover {
  background: color-mix(in oklab, var(--surface-2) 80%, #fff 2%);
  border-color: var(--line-strong);
}

.as-bgm-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.as-bgm-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}

.as-bgm-play-btn:hover {
  background: var(--primary, #2563eb);
  color: #fff;
  border-color: var(--primary, #2563eb);
}

.as-bgm-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.as-bgm-title {
  font-size: 0.84rem;
  font-weight: 700;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.as-bgm-sub {
  font-size: 0.72rem;
  color: var(--text-3);
  display: flex;
  gap: 0.5rem;
}

.as-bgm-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 768px) {
  .as-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
  }
  .as-search-box {
    min-width: 100%;
    flex: 1 1 100%;
  }
  .ftd-dock {
    bottom: 4.8rem;
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
  }
}

/* ==============================================================================
   ULTRA-NEAT STUDIO POLISH SUITE (DESKTOP & MOBILE HARMONIZATION)
   Strict Visual Alignment, 56px Header Lock, Bento Card System & Zero Overflow
   ============================================================================== */

/* --- 1. GLOBAL OVERFLOW & SCROLLBAR POLISH --- */
html, body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
}

#app {
  max-width: 100vw !important;
  overflow-x: hidden !important;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* Hide Builder Topbar when inactive so it never leaks on mobile */
body:not(.sb-active) #sbTopBar {
  display: none !important;
}

/* --- 2. SIDEBAR RAIL MODE STORAGE METER POLISH --- */
#app[data-rail="1"] .sb-storage-box {
  margin: 6px auto !important;
  padding: 6px 2px !important;
  width: 44px !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: 44px !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  background: rgba(255, 255, 255, 0.03) !important;
  border-radius: 8px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  box-sizing: border-box !important;
}

#app[data-rail="1"] .sb-storage-box:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.22) !important;
  transform: scale(1.04);
}

#app[data-rail="1"] .sb-st-head {
  width: 100% !important;
  justify-content: center !important;
  margin: 0 !important;
  padding: 0 !important;
}

#app[data-rail="1"] .sb-st-head .sb-st-label,
#app[data-rail="1"] .sb-st-sub {
  display: none !important;
}

#app[data-rail="1"] .sb-st-val {
  font-size: 0.65rem !important;
  font-weight: 800 !important;
  line-height: 1 !important;
  text-align: center !important;
  margin: 0 !important;
}

#app[data-rail="1"] .sb-st-track {
  width: 28px !important;
  height: 3px !important;
  margin: 3px auto 0 auto !important;
  background: rgba(255, 255, 255, 0.1) !important;
}

/* --- 3. UNIFIED GLOBAL 56px HEADER STANDARD --- */
.page-head,
.uupm-navbar,
.ve-topbar {
  min-height: 56px !important;
  max-height: 56px !important;
  height: 56px !important;
  padding: 0 1.25rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  box-sizing: border-box !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  background: rgba(8, 11, 20, 0.88) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 40 !important;
}

/* AI Director Header Alignment */
.b-header {
  padding: 0 !important;
  gap: 0 !important;
  background: rgba(8, 11, 20, 0.88) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.b-header .b-header-top-row {
  min-height: 56px !important;
  max-height: 56px !important;
  height: 56px !important;
  padding: 0 1.25rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  box-sizing: border-box !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.b-header .b-stepper {
  min-height: 40px !important;
  height: 40px !important;
  padding: 0 1.25rem !important;
  background: rgba(0, 0, 0, 0.25) !important;
  display: flex !important;
  align-items: center !important;
  box-sizing: border-box !important;
}

.b-step-btn {
  padding: 4px 12px !important;
  font-size: 0.78rem !important;
  border-radius: 6px !important;
}

/* Header Text & Title Normalization */
.page-head h1,
.page-head .as-head-title,
.b-header .b-brand-title,
.uupm-logo {
  font-size: 0.96rem !important;
  font-weight: 700 !important;
  letter-spacing: -0.01em !important;
  margin: 0 !important;
  color: #f8fafc !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.45rem !important;
  line-height: 1 !important;
}

.menu-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 34px !important;
  height: 34px !important;
  border-radius: 8px !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  background: rgba(255, 255, 255, 0.04) !important;
  color: var(--text-2, #94a3b8) !important;
  cursor: pointer !important;
  transition: all 0.18s ease !important;
}

.menu-btn:hover {
  background: rgba(255, 255, 255, 0.09) !important;
  color: #fff !important;
}

/* --- 4. HARMONIZED BENTO CARD & CONTROL GEOMETRY --- */
.as-card,
.uupm-card,
.dash-card,
.pst-card,
.b-card,
.b-synopsis-card,
.b-scene-card,
.clp-card {
  border-radius: 12px !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  background: rgba(15, 23, 42, 0.65) !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.22s, box-shadow 0.22s !important;
}

.as-card:hover,
.uupm-card:hover,
.dash-card:hover,
.pst-card:hover,
.b-card:hover,
.b-scene-card:hover,
.clp-card:hover {
  border-color: rgba(255, 255, 255, 0.22) !important;
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.6) !important;
}

/* Harmonized Buttons & Inputs */
input[type="text"],
input[type="search"],
input[type="password"],
textarea,
select {
  border-radius: 8px !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  background: rgba(10, 14, 23, 0.75) !important;
  color: #f8fafc !important;
  font-family: inherit !important;
  transition: border-color 0.18s, box-shadow 0.18s !important;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary, #2563eb) !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25) !important;
}

.btn {
  border-radius: 8px !important;
  font-weight: 600 !important;
  letter-spacing: -0.01em !important;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Explicit removal of top-right Tanya Antigravity button */
#dashBtnAi,
.uupm-btn-copilot {
  display: none !important;
}

/* --- 5. MOBILE-FIRST RESPONSIVE PERFECTION --- */
@media (max-width: 768px) {
  /* Prevent horizontal blowout & ghost overflow */
  html, body, #app, #main, .view.page {
    max-width: 100vw !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  /* Inactive panels must not exist in layout tree */
  body:not(.drawer-open) #drawer,
  #drawer:not(.open) {
    display: none !important;
  }
  body:not(.copilot-open) #view-chat.copilot-dock {
    display: none !important;
  }
  body:not(.sb-active) #sbTopBar,
  body:not(.sb-drawer-open) #sbStyleDrawer {
    display: none !important;
  }

  /* Hide desktop-only floating FAB on mobile screens (Copilot lives in mobileBottomNav) */
  #aiCopilotFab {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  /* Bottom clearance so bottom nav never covers cards/buttons */
  .page-in,
  .view.page .page-in,
  .view.page .page-in.wide,
  .as-container,
  .b-pane-container,
  .ve-main,
  .clp-main,
  #main {
    padding-left: 12px !important;
    padding-right: 12px !important;
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 16px)) !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  /* Clean floating task dock above bottom nav */
  #floatingTaskDock {
    bottom: calc(70px + env(safe-area-inset-bottom, 12px)) !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-width: calc(100vw - 24px) !important;
    box-sizing: border-box !important;
    z-index: 85 !important;
  }

  /* Universal 56px Header Alignment on Mobile */
  .page-head,
  .uupm-navbar,
  .b-header,
  .b-header .b-header-top-row,
  .ve-topbar {
    height: 56px !important;
    min-height: 56px !important;
    max-height: 56px !important;
    margin: 8px 12px 12px !important;
    padding: 0 12px !important;
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    box-sizing: border-box !important;
    border-radius: 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
  }

  .uupm-nav-left {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }

  .uupm-logo {
    font-size: 0.92rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .uupm-nav-links,
  .as-storage-badge,
  .as-head-sub {
    display: none !important;
  }

  .uupm-nav-right,
  .as-nav-right {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex-shrink: 0 !important;
  }

  #btnOpenBgmCatalog {
    padding: 0.35rem 0.6rem !important;
    font-size: 0.74rem !important;
    border-radius: 8px !important;
  }

  /* Hero Banner */
  .uupm-hero {
    padding: 1.5rem 1rem !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    position: relative !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .uupm-glow-left,
  .uupm-glow-right {
    width: 160px !important;
    height: 160px !important;
    opacity: 0.15 !important;
    pointer-events: none !important;
  }

  /* Swipeable badges on mobile */
  .uupm-badges {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scrollbar-width: none !important;
    -webkit-overflow-scrolling: touch !important;
    gap: 6px !important;
    margin-bottom: 12px !important;
    padding-bottom: 2px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .uupm-badges::-webkit-scrollbar { display: none !important; }

  .uupm-badge-pill {
    flex-shrink: 0 !important;
    font-size: 0.65rem !important;
    padding: 0.3rem 0.6rem !important;
    white-space: nowrap !important;
  }

  .uupm-hero-title {
    font-size: 1.5rem !important;
    line-height: 1.25 !important;
    letter-spacing: -0.02em !important;
    margin-bottom: 0.65rem !important;
  }

  .uupm-hero-sub {
    font-size: 0.8rem !important;
    line-height: 1.5 !important;
    margin-bottom: 1rem !important;
    color: var(--text-2) !important;
  }

  .uupm-terminal-pill {
    padding: 0.4rem 0.75rem !important;
    font-size: 0.72rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    scrollbar-width: none !important;
  }

  /* CTA Buttons: Thumb-Friendly Vertical Stack */
  .uupm-cta-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 1rem 0 !important;
  }

  .uupm-cta-row a,
  .uupm-cta-row button {
    width: 100% !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 0.72rem 1rem !important;
    min-height: 44px !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    border-radius: 12px !important;
    box-sizing: border-box !important;
  }

  /* 2-Column Responsive Stats Grid */
  .uupm-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .uupm-stat-card {
    padding: 0.85rem 0.65rem !important;
    border-radius: 12px !important;
  }

  .uupm-stat-num {
    font-size: 1.25rem !important;
  }

  .uupm-stat-label {
    font-size: 0.68rem !important;
  }

  /* 2-Column Server Status Bar */
  .server-status-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    padding: 10px !important;
    border-radius: 14px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .srv-card {
    padding: 8px !important;
  }

  .srv-label { font-size: 0.68rem !important; }
  .srv-val { font-size: 0.95rem !important; }
  .srv-sub { font-size: 0.62rem !important; }

  /* Single-Column Pipeline Steps */
  .dash-pipeline {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .pipe-step {
    padding: 1rem !important;
    border-radius: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Single-Column Bento Grid */
  .dash-bento-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .dash-card {
    border-radius: 14px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Post Konten Mobile */
  #view-postkonten .pk-grid,
  .pk-grid {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    gap: 1rem !important;
  }

  .pk-col-left,
  .pk-col-right {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .pk-card,
  .sect.pk-card {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 1rem !important;
    border-radius: 14px !important;
  }

  .pst-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scrollbar-width: none !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    box-sizing: border-box !important;
    gap: 6px !important;
  }
  .pst-tabs::-webkit-scrollbar { display: none !important; }
  .pst-tab {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    padding: 0.5rem 0.85rem !important;
    font-size: 0.78rem !important;
  }

  /* Flow Studio Mobile */
  #view-flow .flow-grid,
  #view-flow .flow-grid.flow-grid-q,
  #view-flow .flow-grid.flow-grid-s {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    gap: 1rem !important;
  }

  #view-flow .int-hero {
    padding: 1.25rem 1rem !important;
    border-radius: 14px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  #flowSubTabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scrollbar-width: none !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    box-sizing: border-box !important;
    gap: 6px !important;
  }
  #flowSubTabs::-webkit-scrollbar { display: none !important; }
  #flowSubTabs a {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    padding: 0.5rem 0.85rem !important;
    font-size: 0.78rem !important;
  }

  /* AI Director Mobile */
  .b-header {
    margin: 8px 12px 12px !important;
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    box-sizing: border-box !important;
    border-radius: 16px !important;
  }

  .b-stepper {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scrollbar-width: none !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    box-sizing: border-box !important;
    gap: 6px !important;
  }
  .b-stepper::-webkit-scrollbar { display: none !important; }
  .b-step-btn {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    font-size: 0.76rem !important;
    padding: 0.4rem 0.75rem !important;
  }

  .b-inspiration-pills {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scrollbar-width: none !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    box-sizing: border-box !important;
    gap: 6px !important;
  }
  .b-inspiration-pills::-webkit-scrollbar { display: none !important; }
  .b-insp-btn {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    font-size: 0.76rem !important;
    padding: 0.4rem 0.75rem !important;
  }

  /* Video Editor Mobile */
  .ve-topbar {
    margin: 8px 12px 12px !important;
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    box-sizing: border-box !important;
    overflow-x: auto !important;
    scrollbar-width: none !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
  }
  .ve-tb-grp {
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
  }

  /* Cloud Assets Mobile */
  .as-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .as-filter-pills {
    display: flex !important;
    gap: 0.45rem !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    padding-bottom: 2px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .as-filter-pills::-webkit-scrollbar { display: none !important; }

  .as-pill {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    font-size: 0.76rem !important;
    padding: 0.4rem 0.75rem !important;
  }

  .as-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .as-card {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    border-radius: 14px !important;
  }

  .as-actions .as-btn {
    min-height: 38px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.45rem 0.85rem !important;
    font-size: 0.78rem !important;
  }
}
