/* MyAwesomeNovelz AI — Responsive: Density, Enhancements, Media Queries (Dark-Zinc Pro Studio) */

/* Compact Pro Density Mode (13px fonts, tight padding/gap across all components) */
body.density-compact {
  font-size: 13px !important;
}

body.density-compact .view-panel {
  padding: 10px !important;
}

body.density-compact .ai-form-card {
  padding: 12px 14px !important;
  margin-bottom: 10px !important;
  border-radius: var(--radius-md) !important;
}

body.density-compact .view-header {
  margin-bottom: 10px !important;
  padding-bottom: 6px !important;
}

body.density-compact .view-header h2 {
  font-size: 1.15rem !important;
}

body.density-compact .view-header p {
  font-size: 0.78rem !important;
}

body.density-compact h3 {
  font-size: 0.9rem !important;
  margin-bottom: 8px !important;
}

body.density-compact .scene-item {
  padding: 5px 8px !important;
  font-size: 0.78rem !important;
}

body.density-compact .btn {
  padding: 4px 10px !important;
  font-size: 0.78rem !important;
}

body.density-compact .form-group {
  margin-bottom: 8px !important;
}

body.density-compact .form-label {
  font-size: 0.75rem !important;
  margin-bottom: 3px !important;
}

body.density-compact .form-input,
body.density-compact .form-select,
body.density-compact .form-textarea {
  padding: 5px 8px !important;
  font-size: 0.8rem !important;
}

body.density-compact .hub-subtabs-container {
  padding: 4px 10px !important;
}

body.density-compact .hub-pill-btn {
  padding: 3px 8px !important;
  font-size: 0.75rem !important;
}

body.density-compact .sidebar {
  padding: 8px 6px !important;
  gap: 8px !important;
}

body.density-compact .sidebar-item {
  padding: 5px 8px !important;
  font-size: 0.78rem !important;
}

/* Tactile Surface Refinements (Dark-Zinc Pro Studio) */
.ai-form-card {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 4px 20px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s var(--ease-spring), border-color 0.2s ease, box-shadow 0.2s ease;
}

.ai-form-card:hover {
  border-color: var(--border-hover, rgba(255, 255, 255, 0.18));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 6px 24px rgba(0, 0, 0, 0.45);
}

.scene-item {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.scene-item:hover {
  transform: translateX(2px);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--border-focus, #06B6D4) !important;
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
}

.btn {
  letter-spacing: -0.01em;
}

/* ==========================================================================
   Adaptive Responsive Design System — Simple Mode & Mobile Support
   ========================================================================== */

.simple-wizard-card {
  width: 100%;
  max-width: 1350px;
  margin: 0 auto;
  padding: 24px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.simple-wizard-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.simple-wizard-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.simple-wizard-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.simple-wizard-progress-track {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  gap: 8px;
}

.simple-wizard-progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  min-width: 56px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.simple-wizard-progress-step:active {
  transform: scale(0.92);
}

/* Wide Monitor Optimization (1440px and higher) */
@media (min-width: 1440px) {
  .simple-wizard-card {
    max-width: 1440px;
    padding: 32px;
  }
}

/* Screen Width < 1200px: Header Compactification */
@media (max-width: 1200px) {
  .master-hub-btn {
    padding: 6px 10px !important;
  }
  .master-hub-btn span {
    display: none !important;
  }
  .app-header .brand-title {
    font-size: 1.1rem;
  }
}

/* Tablet Screens (under 1024px) */
@media (max-width: 1024px) {
  .simple-wizard-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .simple-wizard-grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Mobile menu button visible on tablets & phones */
  .mobile-menu-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease, border-color 0.2s ease;
  }
  .mobile-menu-toggle:hover, .mobile-menu-toggle:active {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--primary-light);
  }

  .mobile-sidebar-close {
    display: inline-flex !important;
  }

  /* Off-canvas sidebar on tablets & small laptops */
  .sidebar#expert-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 300px !important;
    max-width: 86vw !important;
    z-index: 10001 !important;
    background: rgba(11, 14, 24, 0.98) !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.85) !important;
    transform: translateX(-100%) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
    padding-top: calc(14px + env(safe-area-inset-top, 0px)) !important;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 16px)) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar#expert-sidebar.mobile-open {
    transform: translateX(0) !important;
  }

  .sidebar-mobile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    transition: opacity 0.25s ease;
    opacity: 0;
  }

  .sidebar-mobile-backdrop.active {
    display: block !important;
    opacity: 1 !important;
  }

  .sidebar-item {
    padding: 10px 12px !important;
    min-height: 42px !important;
    font-size: 0.88rem !important;
  }
}

/* Mobile Screens (Android & iPhone - under 768px) */
@media (max-width: 768px) {
  html, body {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
    min-height: 100dvh !important;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: rgba(139, 92, 246, 0.2);
  }

  /* Universal Workspace Padding to clear fixed Bottom Nav */
  body.mode-expert .view-panel {
    padding: 12px 10px calc(76px + env(safe-area-inset-bottom, 12px)) 10px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    min-height: 0;
  }

  body.mode-simple .view-panel {
    padding: 12px 10px 24px 10px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    min-height: 0;
  }

  /* ════════════════════════════════════════════════════════════════
     APP HEADER BAR: BULLETPROOF RESPONSIVE SYSTEM (< 768px)
     Guarantees ALL buttons are visible, accessible & fit without overflow
     ════════════════════════════════════════════════════════════════ */
  .app-header {
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    border-bottom: 1px solid var(--border-color) !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    padding: 0 8px !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px !important;
    overflow: visible !important;
    box-sizing: border-box !important;
    z-index: 1000 !important;
    background: rgba(11, 14, 24, 0.98) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5) !important;
  }

  /* Left Controls Group */
  .header-left {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    flex-shrink: 0 !important;
    min-width: 0 !important;
  }

  /* Mobile Hamburger Menu Toggle Button */
  .mobile-menu-toggle {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 34px !important;
    min-width: 34px !important;
    height: 34px !important;
    min-height: 34px !important;
    padding: 0 !important;
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--border-color) !important;
    background: rgba(255, 255, 255, 0.06) !important;
    color: #fff !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    touch-action: manipulation !important;
  }
  .mobile-menu-toggle:hover, .mobile-menu-toggle:active {
    background: rgba(139, 92, 246, 0.2) !important;
    border-color: var(--primary-light) !important;
  }

  /* Brand Icon Only (Title text hidden to maximize button space) */
  .brand {
    display: flex !important;
    align-items: center !important;
    gap: 0 !important;
    flex-shrink: 0 !important;
  }
  .brand-title {
    display: none !important;
  }
  .brand-icon {
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
  }
  .brand-logo-img {
    width: 20px !important;
    height: 20px !important;
    object-fit: contain !important;
  }

  /* Dual Mode Switcher (Simple vs Expert) */
  .mode-toggle-group {
    display: inline-flex !important;
    align-items: center !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--border-color) !important;
    padding: 2px !important;
    border-radius: 8px !important;
    gap: 2px !important;
    flex-shrink: 0 !important;
  }
  .mode-toggle-group .btn {
    height: 30px !important;
    min-height: 30px !important;
    line-height: 1 !important;
    padding: 0 7px !important;
    font-size: 0.74rem !important;
    font-weight: 700 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    white-space: nowrap !important;
    border-radius: 6px !important;
    touch-action: manipulation !important;
  }
  .mode-toggle-group .btn-subtext {
    display: none !important;
  }

  /* Right Controls Group */
  .header-right {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    flex-shrink: 0 !important;
    min-width: 0 !important;
    margin-left: auto !important;
    overflow: visible !important;
  }

  /* Dropdown Trigger Buttons (Settings & Services) -> Clean Icon Action Buttons */
  .nav-dropdown-group {
    position: relative !important;
    flex-shrink: 0 !important;
    overflow: visible !important;
  }
  .nav-dropdown-trigger {
    width: 34px !important;
    min-width: 34px !important;
    height: 34px !important;
    min-height: 34px !important;
    padding: 0 !important;
    border-radius: var(--radius-sm) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.8rem !important;
    flex-shrink: 0 !important;
    touch-action: manipulation !important;
  }
  .nav-dropdown-trigger .btn-text,
  .nav-dropdown-trigger .dropdown-caret {
    display: none !important;
  }
  .nav-dropdown-trigger svg {
    width: 16px !important;
    height: 16px !important;
    flex-shrink: 0 !important;
  }

  /* Dropdown Menu Popup - Floating Fixed Slide-Down Panel */
  .dropdown-menu {
    position: fixed !important;
    top: 52px !important;
    right: 8px !important;
    left: auto !important;
    width: calc(100vw - 16px) !important;
    max-width: 300px !important;
    max-height: calc(100dvh - 65px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.95), var(--shadow-glow) !important;
    z-index: 100000 !important;
    border-radius: var(--radius-md) !important;
    border: 1px solid var(--border-accent) !important;
    background: rgba(14, 17, 28, 0.98) !important;
  }

  .dropdown-item {
    padding: 10px 14px !important;
    min-height: 42px !important;
    font-size: 0.86rem !important;
    display: flex !important;
    align-items: center !important;
  }

  /* Tokens Credit Badge: Compact Number Display */
  .credit-badge {
    height: 34px !important;
    min-height: 34px !important;
    padding: 3px 8px !important;
    font-size: 0.76rem !important;
    font-weight: 800 !important;
    border-radius: var(--radius-sm) !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    touch-action: manipulation !important;
  }
  .credit-badge .btn-subtext {
    display: none !important;
  }
  .credit-badge svg {
    width: 14px !important;
    height: 14px !important;
    flex-shrink: 0 !important;
  }

  /* User Profile Button: Sleek Circular Avatar Button */
  .header-profile-btn,
  #btn-header-user-profile {
    width: 34px !important;
    min-width: 34px !important;
    height: 34px !important;
    min-height: 34px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    touch-action: manipulation !important;
  }
  .header-profile-btn .btn-text,
  .header-profile-btn .plan-badge,
  #btn-header-user-profile .btn-text,
  #btn-header-user-profile .plan-badge {
    display: none !important;
  }
  .header-profile-btn .profile-btn-content,
  #btn-header-user-profile span {
    gap: 0 !important;
    justify-content: center !important;
  }
  .header-profile-btn .profile-avatar-icon,
  #btn-header-user-profile .profile-avatar-circle {
    width: 26px !important;
    height: 26px !important;
    border: none !important;
  }

  /* Bottom Navigation Bar for Mobile Expert Hubs */
  body.mode-expert .header-center#expert-nav-center {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 9999 !important;
    background: rgba(11, 13, 22, 0.97) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-top: 1px solid var(--border-color) !important;
    border-radius: 0 !important;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 8px)) 4px !important;
    justify-content: space-around !important;
    gap: 2px !important;
    margin: 0 !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6) !important;
  }

  body.mode-simple .header-center#expert-nav-center,
  body.mode-simple #expert-nav-center {
    display: none !important;
  }

  .header-center#expert-nav-center .master-hub-btn {
    flex: 1 !important;
    min-width: 0 !important;
    min-height: 48px !important;
    padding: 5px 2px !important;
    flex-direction: column !important;
    gap: 3px !important;
    border: none !important;
    background: transparent !important;
    border-radius: var(--radius-sm) !important;
    touch-action: manipulation !important;
  }

  .header-center#expert-nav-center .master-hub-btn.active {
    background: rgba(139, 92, 246, 0.18) !important;
    color: var(--primary-light, #a78bfa) !important;
  }

  .header-center#expert-nav-center .master-hub-btn span {
    display: block !important;
    font-size: 0.65rem !important;
    line-height: 1 !important;
    font-weight: 700 !important;
  }

  .header-center#expert-nav-center .master-hub-btn svg {
    width: 18px !important;
    height: 18px !important;
  }

  /* Multi-Project Studio Selector Bar: Compact Mobile Scroll */
  #header-project-switcher-container {
    padding: 4px 10px !important;
    gap: 6px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  #header-project-switcher-container > div:first-child {
    display: none !important; /* Hide "Студии Новелл:" label on mobile */
  }

  .project-tab-item {
    padding: 4px 10px !important;
    font-size: 0.74rem !important;
    min-height: 32px !important;
    border-radius: 8px !important;
  }

  #btn-header-create-novel {
    padding: 4px 10px !important;
    font-size: 0.74rem !important;
    min-height: 32px !important;
    white-space: nowrap !important;
  }

  /* Mobile Segmented View Tabs for Multi-Column Workspaces */
  .mobile-segmented-control {
    display: flex !important;
    width: 100% !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    padding: 3px !important;
    gap: 3px !important;
    margin-bottom: 12px !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 30 !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4) !important;
  }

  .mobile-segmented-control .btn-seg {
    flex: 1 !important;
    padding: 8px 6px !important;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    border-radius: var(--radius-sm) !important;
    border: none !important;
    background: transparent !important;
    color: var(--text-muted) !important;
    text-align: center !important;
    cursor: pointer !important;
    min-height: 38px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px !important;
    touch-action: manipulation !important;
    transition: all 0.2s ease !important;
  }

  .mobile-segmented-control .btn-seg.active {
    background: var(--grad-primary) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4) !important;
  }

  /* Story Editor Mobile Tab Panels Switching */
  .story-panel-scenes,
  .story-panel-dialogues,
  .story-panel-settings {
    display: none !important;
    width: 100% !important;
  }

  .story-panel-scenes.mobile-active-section,
  .story-panel-dialogues.mobile-active-section,
  .story-panel-settings.mobile-active-section {
    display: block !important;
  }

  .dialogue-node-card {
    padding: 12px !important;
    margin-bottom: 10px !important;
  }

  .dlg-btn-up, .dlg-btn-down, .dlg-btn-delete, .btn-scene-action {
    min-width: 36px !important;
    min-height: 36px !important;
    padding: 6px !important;
    font-size: 0.84rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Node Graph Canvas Mobile Viewport */
  .node-canvas-viewport {
    height: calc(100dvh - 210px) !important;
    min-height: 360px !important;
  }

  .node-card {
    width: 270px !important;
  }

  /* Hide Desktop Floating Pill Bar on Mobile to keep bottom clear for Hub Nav */
  #quick-action-bar-container,
  div[style*="position:fixed; bottom:20px; left:50%"] {
    display: none !important;
  }

  /* Floating AI Companion Chat Window Mobile */
  div[style*="position:fixed; bottom:24px; right:24px"] {
    bottom: calc(56px + env(safe-area-inset-bottom, 8px)) !important;
    right: 8px !important;
    left: 8px !important;
  }

  div[style*="position:fixed; bottom:24px; right:24px"] > div[style*="width:380px"] {
    width: 100% !important;
    max-width: 100% !important;
    height: 70vh !important;
    max-height: 70vh !important;
  }

  /* Universal Responsive Grid & Flex Collapse for All Studios */
  .studio-adaptive-grid,
  .profile-tab-grid,
  .story-editor-container {
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
  }

  .adaptive-form-row,
  .profile-form-row {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .subtabs-container,
  .profile-subtabs-container,
  .nav-tabs-wrapper {
    gap: 6px !important;
    padding-bottom: 10px !important;
  }

  .subtabs-container .btn,
  .subtabs-container .btn-tab,
  .subtabs-container .filter-tab-btn,
  .subtabs-container .nav-category-btn,
  .profile-subtabs-container .btn-prof-tab,
  .nav-tabs-wrapper .btn {
    min-width: 90px !important;
    flex: 1 1 calc(50% - 6px) !important;
    padding: 8px 10px !important;
    font-size: 0.8rem !important;
    min-height: 38px !important;
  }

  div[style*="grid-template-columns:1fr 340px"],
  div[style*="grid-template-columns: 1fr 340px"],
  div[style*="grid-template-columns:340px 1fr"],
  div[style*="grid-template-columns: 340px 1fr"],
  div[style*="grid-template-columns:380px 1fr"],
  div[style*="grid-template-columns: 380px 1fr"],
  div[style*="grid-template-columns:360px 1fr"],
  div[style*="grid-template-columns: 360px 1fr"],
  div[style*="grid-template-columns:280px 1fr 320px"],
  div[style*="grid-template-columns: 280px 1fr 320px"],
  div[style*="grid-template-columns:1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns:repeat(3, 1fr)"],
  div[style*="grid-template-columns: repeat(3, 1fr)"],
  div[style*="grid-template-columns:repeat(4, 1fr)"],
  div[style*="grid-template-columns: repeat(4, 1fr)"],
  div[style*="grid-template-columns:repeat(2, 1fr)"],
  div[style*="grid-template-columns: repeat(2, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* View Header Title & Subtitle Mobile Scaling */
  .view-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
    padding: 6px 0 10px 0 !important;
    margin-bottom: 12px !important;
  }

  .view-header h2 {
    font-size: 1.25rem !important;
    line-height: 1.3 !important;
  }

  .view-header p {
    font-size: 0.82rem !important;
  }

  /* Form Cards & Inputs */
  .ai-form-card, .panel-card {
    padding: 14px !important;
    border-radius: var(--radius-md) !important;
    margin-bottom: 12px !important;
  }

  .form-row {
    flex-direction: column !important;
    gap: 10px !important;
  }

  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px !important; /* Prevents auto zoom on iOS Safari */
    min-height: 42px !important;
    padding: 8px 12px !important;
  }

  .code-preview-box, pre {
    max-height: 280px !important;
    font-size: 0.75rem !important;
  }

  /* Buttons & Touch Targets (44px Minimum) */
  .btn {
    min-height: 42px !important;
    font-size: 0.86rem !important;
    padding: 8px 14px !important;
    touch-action: manipulation !important;
  }

  /* Mobile Bottom-Sheet Modals */
  .modal-overlay,
  #modal-container .modal-overlay,
  #apikey-modal-container .modal-overlay,
  #hotkeys-modal-container .modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .modal-content,
  .sub-modal-content,
  .auth-modal-card {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 22px 22px 0 0 !important;
    border-bottom: none !important;
    max-height: 90dvh !important;
    padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 14px)) 16px !important;
    animation: modalSheetUp 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .modal-content::before,
  .sub-modal-content::before,
  .auth-modal-card::before {
    content: "";
    display: block;
    width: 38px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.25);
    margin: 0 auto 14px auto;
  }

  @keyframes modalSheetUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  /* Visual Novel Preview Frames */
  .vn-frame {
    aspect-ratio: 16/9 !important;
    width: 100% !important;
  }

  /* Simple Mode 10-Step Wizard on Mobile */
  .simple-wizard-card {
    padding: 14px !important;
    border-radius: var(--radius-md) !important;
  }

  .simple-wizard-grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  .simple-wizard-grid-3 {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .simple-wizard-grid-2 {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .simple-wizard-nav-bar {
    flex-direction: column-reverse !important;
    gap: 10px !important;
  }

  .simple-wizard-nav-bar .btn {
    width: 100% !important;
    padding: 12px !important;
    font-size: 0.92rem !important;
  }

  /* Data Tables Responsive Horizontal Scroll & Card Fallback */
  .figma-table-container,
  .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border-radius: 10px !important;
  }

  /* Games Portal Mobile Rules */
  .portal-container {
    padding: 16px 12px 60px 12px !important;
  }

  .portal-main-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  #novels-catalog-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
}

/* Smartphone Screens (under 580px) - Header Compact Mode Toggle */
@media (max-width: 580px) {
  .mode-toggle-group .btn {
    width: 30px !important;
    min-width: 30px !important;
    padding: 0 !important;
  }
  .mode-toggle-group .btn .btn-text {
    display: none !important;
  }
}

/* Small Smartphone Screens (under 480px) */
@media (max-width: 480px) {
  .app-header {
    padding: 0 6px !important;
    gap: 4px !important;
  }
  .header-left, .header-right {
    gap: 4px !important;
  }

  .subtabs-container .btn,
  .subtabs-container .btn-tab,
  .subtabs-container .filter-tab-btn,
  .subtabs-container .nav-category-btn,
  .profile-subtabs-container .btn-prof-tab,
  .nav-tabs-wrapper .btn {
    flex: 1 1 100% !important;
    min-width: 100% !important;
  }

  .simple-wizard-grid-4 {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .asset-card .asset-preview {
    height: 130px !important;
  }

  .desktop-text {
    display: none !important;
  }
}

/* Ultra-Small Smartphone Screens (under 380px, down to 320px) */
@media (max-width: 380px) {
  .app-header {
    padding: 0 4px !important;
    gap: 3px !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
  }
  .header-left, .header-right {
    gap: 3px !important;
  }
  .mobile-menu-toggle {
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
  }
  .brand-icon {
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
  }
  .brand-logo-img {
    width: 17px !important;
    height: 17px !important;
  }
  .mode-toggle-group .btn {
    width: 26px !important;
    min-width: 26px !important;
    height: 26px !important;
    min-height: 26px !important;
  }
  .nav-dropdown-trigger {
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
  }
  .credit-badge {
    height: 30px !important;
    min-height: 30px !important;
    padding: 2px 5px !important;
    font-size: 0.7rem !important;
    gap: 2px !important;
  }
  .header-profile-btn,
  #btn-header-user-profile {
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
  }
  .header-profile-btn .profile-avatar-icon,
  #btn-header-user-profile .profile-avatar-circle {
    width: 22px !important;
    height: 22px !important;
  }
  .dropdown-menu {
    top: 48px !important;
    right: 4px !important;
    width: calc(100vw - 8px) !important;
  }
}
