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

html {
overflow-y: scroll;
scrollbar-gutter: stable;
}

/* ============================================
   PREMIUM DARK LUXURY THEME - ROYAL GOLD
   ============================================ */

/* CSS Variables - Luxury Dark Palette */
:root {
    /* Core - Deep blacks and charcoals */
    --bg-primary: #050505;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #111111;
    --bg-card: #0d0d0d;
    --bg-elevated: #141414;
    --bg-surface: #080808;
    --bg-hover: #1a1a1a;
    
    /* Text - Warm off-white */
    --text-primary: #f5f0e8;
    --text-secondary: #b8aa8c;
    --text-tertiary: #7a6e55;
    --text-accent: #d4af37;
    --text-muted: #9ca3af;
    
    /* Borders - Refined metallic */
    --border-light: rgba(212, 175, 55, 0.12);
    --border-medium: rgba(212, 175, 55, 0.2);
    --border-accent: rgba(212, 175, 55, 0.4);
    --border-card: rgba(255, 255, 255, 0.06);
    
    /* Gradients - Warm gold / metallic */
    --gradient-primary: linear-gradient(135deg, #d4af37 0%, #8b7355 100%);
    --gradient-secondary: linear-gradient(135deg, #c5a059 0%, #6b5b3e 100%);
    --gradient-accent: linear-gradient(135deg, #e6c87a 0%, #b8942e 100%);
    --gradient-bg: radial-gradient(ellipse at 30% 40%, #1a1510 0%, #030303 100%);
    --gradient-card: linear-gradient(135deg, rgba(20, 18, 16, 0.8) 0%, rgba(10, 8, 6, 0.95) 100%);
    --gradient-success: linear-gradient(135deg, #d4af37 0%, #a17f2a 100%);
    --gradient-danger: linear-gradient(135deg, #9b2c2c 0%, #6b1a1a 100%);
    --gradient-warning: linear-gradient(135deg, #c5a059 0%, #8b5e23 100%);
    
    /* Shadows - Deep with gold undertone */
    --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.6);
    --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.8);
    --shadow-glow: 0 0 30px rgba(212, 175, 55, 0.25);
    --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(212, 175, 55, 0.1);
    
    /* Spacing & Transitions */
    --transition-fast: 0.2s ease-out;
    --transition-normal: 0.3s ease-out;
    --transition-slow: 0.5s ease-out;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gradient-bg);
    min-height: 100vh;
    color: var(--text-primary);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 20px 20px;
    padding-top: 0px;
}

/* Landing Page Styles */
.landing-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    position: relative;
    overflow: hidden;
}

.landing-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 40%, rgba(212, 175, 55, 0.08), transparent 60%);
    pointer-events: none;
}

.landing-content {
    max-width: 1200px;
    width: 100%;
    text-align: center;
    position: relative;
    z-index: 2;
}

.landing-title {
    font-size: 48px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 20px;
    text-shadow: var(--shadow-glow);
}

.landing-subtitle {
    font-size: 20px;
    color: var(--text-secondary);
    margin-bottom: 50px;
}

.pricing-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.pricing-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.pricing-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: var(--border-accent);
}

.pricing-card.featured {
    transform: scale(1.05);
    border: 1px solid var(--border-accent);
    box-shadow: var(--shadow-md), var(--shadow-glow);
    background: var(--bg-elevated);
}

.pricing-card.featured:hover {
    transform: scale(1.05) translateY(-5px);
}

.pricing-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.pricing-card h3 {
    font-size: 24px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 15px;
}

.price {
    font-size: 32px;
    font-weight: bold;
    color: var(--text-accent);
    margin-bottom: 20px;
}

.features {
    list-style: none;
    margin-bottom: 30px;
    text-align: left;
}

.features li {
    padding: 8px 0;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-medium);
    color: var(--text-accent);
}

.btn-outline:hover {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
}

/* Auth Container */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border-light);
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 30px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-medium);
    border-radius: 5px;
    font-size: 16px;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-group input:focus {
    outline: none;
    border-color: var(--border-accent);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

.btn {
    width: 100%;
    padding: 12px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: var(--gradient-primary);
}

.btn-secondary {
    background: var(--gradient-secondary);
}

.btn-secondary:hover {
    filter: brightness(1.05);
}

.btn-danger {
    background: var(--gradient-danger);
}

.btn-danger:hover {
    filter: brightness(1.05);
}

.btn-small {
    width: auto;
    padding: 6px 12px;
    font-size: 13px;
    min-width: unset;
    margin-right: 10px;
}

.link {
    text-align: center;
    margin-top: 20px;
}

.link a {
    color: var(--text-accent);
    text-decoration: none;
}

.link a:hover {
    text-decoration: underline;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    padding: 15px 0;
    margin-bottom: 30px;
    width: 100%;
}

.header .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/*
.user-info {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}*/

#userEmail {
    padding-right: 6px;
    /*max-width: 180px;*/
    max-width: 32ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}

/* Mobile: smaller email width */
@media (max-width: 768px) {
    #userEmail {
        max-width: 120px;
    }
}

.user-info {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    max-width: 100%;
    /*overflow: hidden;*/
    overflow: visible;
}

.user-type-badge {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    border: 1px solid var(--border-light);
}

.user-info .user-type-badge {
    margin-right: 10px;
}

.user-type-badge.guest {
    background: rgba(155, 44, 44, 0.2);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

.user-type-badge.free {
    background: rgba(197, 160, 89, 0.2);
    color: var(--text-accent);
    border-color: rgba(212, 175, 55, 0.3);
}

.user-type-badge.premium {
    background: var(--gradient-primary);
    color: white;
    border: none;
}

.premium-badge {
    background: var(--gradient-primary);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
}

/* Usage Card */
.usage-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 12px 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.usage-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.usage-right {
    display: flex;
    align-items: center;
}

.usage-card h3 {
    margin: 0;
    font-size: 16px;
    white-space: nowrap;
    color: var(--text-secondary);
}

.usage-stats {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

.usage-progress {
    width: 150px;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 4px;
}

.usage-progress-bar {
    height: 100%;
    background: var(--gradient-primary);
    transition: width 0.3s;
}

#usageText {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-accent);
    white-space: nowrap;
}

/* View Pills */
.view-pills {
    display: flex;
    gap: 8px;
    border: none;
    background: transparent;
}

.pill {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border-medium);
    background: var(--bg-card);
    color: var(--text-secondary);
}

.pill.active {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
    cursor: default;
}

.pill.active:hover {
    background: var(--gradient-primary);
    color: white;
    transform: none;
}

.pill:not(.active):not(:disabled):hover {
    background: var(--bg-hover);
    border-color: var(--border-accent);
}

.pill:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

:root {
    --selected-color: #d4af37;
    --selected-light: rgba(212, 175, 55, 0.15);
}

/* Selected tool card styling */
.tool-card.selected {
    background: var(--bg-elevated);
    border: 1px solid var(--border-accent);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.tool-card.selected .tool-icon {
    filter: brightness(0.9);
}

.tool-card.selected h3 {
    color: var(--text-accent);
}

/* View Containers */
.view-container {
    transition: opacity 0.2s ease;
}

.view-container.hidden {
    display: none;
}

/* Fix for splitUI height to match studioView */
#studioView {
    position: relative;
    min-height: 500px;
}

.split-ui-container {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 20px;
    margin-top: 0;
    box-shadow: var(--shadow-sm);
    width: 100%;
    position: relative;
    border: 1px solid var(--border-light);
}

/* Remove Pages Container - Card Background */
.remove-pages-container {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 20px;
    margin-top: 0;
    box-shadow: var(--shadow-sm);
    width: 100%;
    position: relative;
    border: 1px solid var(--border-light);
}

/* Split Top Section - Groups Card and Toolbar side by side */
.split-top-section {
    display: flex;
    gap: 20px;
    /*margin-bottom: 20px;*/
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 15px; /*20px*/
    flex-wrap: nowrap;
}

/* Groups Card - Terminal-like dark theme, 55% width, FIXED HEIGHT - NEVER GROWS */
.groups-card {
    width: 55%;
    background: var(--bg-tertiary);
    border-radius: 10px;
    border: 1px solid var(--border-medium);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 156px;
    /* FIXED height - NEVER changes */
}

.groups-card-header {
    background: var(--bg-surface);
    padding: 6px 16px;
    border-bottom: 1px solid var(--border-medium);
    flex-shrink: 0;
}

.groups-card-header h3 {
    color: var(--text-accent);
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.5px;
    font-family: 'Courier New', monospace;
}

/* Segments Container inside Groups Card - scrollable with auto-scroll */
.groups-card .segments-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: var(--bg-tertiary);
    min-height: 0;
    /* Important for flex scrolling */
}

/* Custom scrollbar for Groups card */
.groups-card .segments-container::-webkit-scrollbar {
    width: 8px;
}

.groups-card .segments-container::-webkit-scrollbar-track {
    background: var(--bg-surface);
    border-radius: 4px;
}

.groups-card .segments-container::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
}

.groups-card .segments-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-accent);
}

/* Toolbar Wrapper - Takes remaining space */
.split-toolbar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Split PDF Toolbar - RIGHT ALIGNED like before */
.split-toolbar {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    /* Right align all content */
    gap: 15px;
    width: 100%;
}

.split-mode-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    /* Radio buttons left-aligned within right-aligned container */
    width: auto;
    margin-right: 40px;
    /* Keep original right margin */
}

.split-mode-selector .mode-option {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.mode-option {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Split Actions - Right aligned */
.split-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    width: 100%;
    padding-right: 18px;
    /* Keep original padding */
}

.split-actions-row-1,
.split-actions-row-2 {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
    width: 100%;
}

/* All buttons same size */
.split-actions .btn-small,
.split-actions .btn-primary,
.split-actions .btn-danger {
    width: 120px;
    padding: 6px 12px;
    font-size: 13px;
    min-width: 125px;
    text-align: center;
    white-space: nowrap;
}

/* For Add Segment button */
.split-actions .btn-secondary {
    width: 120px;
    padding: 6px 12px;
    font-size: 13px;
    min-width: 125px;
    text-align: center;
    white-space: nowrap;
}

/* Split Bottom Section - Pages Grid */
.split-bottom-section {
    margin-top: 0;
}

.pages-grid-wrapper {
    width: 100%;
}

.pages-grid-container h4 {
    margin-top: 10px;
    margin-bottom: 5px;
    color: var(--text-secondary);
}

/* Remove Pages Toolbar */
.remove-toolbar {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 15px;
    /*margin-bottom: 20px;*/
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-light);
}

.remove-mode-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    width: auto;
    margin-right: 20px;
}

.remove-mode-selector .mode-option {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Remove Pages Actions */
.remove-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    width: 100%;
    padding-right: 18px;
}

.remove-actions-row-1,
.remove-actions-row-2 {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
    width: 100%;
}

/* All buttons same size */
.remove-actions .btn-small,
.remove-actions .btn-primary,
.remove-actions .btn-danger {
    width: 120px;
    padding: 6px 12px;
    font-size: 13px;
    min-width: 125px;
    text-align: center;
    white-space: nowrap;
}

/* Segments */
.segments-container {
    margin-bottom: 0;
    padding: 0;
    background: transparent;
    border-radius: 0;
    overflow-x: visible;
}

.segment-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.segment-card:last-child {
    margin-bottom: 0;
}

.segment-card:hover {
    transform: translateX(4px);
    border-color: var(--border-accent);
}

.segment-card.selected {
    border: 1px solid var(--border-accent);
    box-shadow: var(--shadow-glow);
    background: var(--bg-elevated);
}

.segment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.segment-title {
    font-weight: bold;
    color: var(--text-accent);
    font-size: 13px;
}

.remove-segment-btn {
    background: var(--gradient-danger);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.remove-segment-btn:hover {
    transform: scale(1.1);
}

.segment-pages {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12px;
    color: var(--text-tertiary);
    min-height: 30px;
}

.segment-page-badge {
    background: var(--bg-hover);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

.segment-page-badge .remove-page {
    cursor: pointer;
    color: #f56565;
    font-weight: bold;
    margin-left: 4px;
}

.segment-page-badge .remove-page:hover {
    color: #e53e3e;
}

/* Pages Grid - Horizontal scroll for desktop */
.pages-grid-container {
    margin-top: 0;
}

.pages-grid {
    display: flex;
    flex-direction: row;
    gap: 15px;
    overflow-x: auto;
    overflow-y: hidden;
    /*padding: 10px;*/
    padding-top:5px;
    padding-bottom:10px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

/* Fix for page cards in horizontal layout */
.pages-grid .page-card {
    position: relative;
    flex: 0 0 auto;
    width: 140px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
}

.pages-grid.selectable-grid .page-card {
    cursor: pointer;
}

.page-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    border-color: var(--border-accent);
}

.page-card.selected {
    border-color: var(--border-accent);
    background: var(--bg-elevated);
}

/* Remove Pages - Color Coding */
.page-card.selected-for-remove {
    border-color: #f56565 !important;
    background: rgba(245, 101, 101, 0.15) !important;
}

.page-card.selected-for-keep {
    border-color: var(--text-accent) !important;
    background: rgba(212, 175, 55, 0.1) !important;
}

.page-card .checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    z-index: 2;
    accent-color: var(--text-accent);
}

.page-card .page-thumbnail {
    width: 100%;
    height: 180px;
    object-fit: contain;
    background: var(--bg-surface);
    border-radius: 4px;
    margin-bottom: 8px;
}

.page-card .page-number {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 5px;
    padding: 0;
}

/* Scrollbar styling for horizontal pages grid */
.pages-grid::-webkit-scrollbar {
    height: 8px;
}

.pages-grid::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.pages-grid::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
}

.pages-grid::-webkit-scrollbar-thumb:hover {
    background: var(--border-accent);
}

/* Preview Containers */
.page-preview-container {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 20px;
    margin-top: 0px;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    border: 1px solid var(--border-light);
}

.page-preview-title {
    margin-top:10px;
    margin-bottom: 5px;
    color: var(--text-accent);
    font-weight: bold;
}

.page-preview-list {
    display: flex;
    flex-direction: row;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 10px;
    min-height: 200px;
    /*margin-bottom: 10px;*/
}

.page-preview-card {
    flex: 0 0 auto;
    width: 150px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 10px;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border-medium);
    user-select: none;
}

.page-preview-card:active {
    cursor: grabbing;
}

.page-preview-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.page-preview-card.drag-over {
    border-color: var(--border-accent);
    background: var(--bg-elevated);
}

.page-preview-card canvas,
.page-preview-card img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    margin-bottom: 8px;
    background: var(--bg-surface);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.drag-handle {
    text-align: center;
    font-size: 20px;
    cursor: grab;
    color: var(--text-tertiary);
    margin-top: 5px;
}

.drag-handle:active {
    cursor: grabbing;
}

.finish-reorder-btn {
    /*margin-top: 15px;*/
    width: auto;
    padding: 6px 12px;
    background: var(--gradient-success);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.finish-reorder-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.reorder-actions {
    display: flex;
    gap: 10px;
    padding-top:5px;
    /*margin-top: 10px;*/
    justify-content: flex-end;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    color: var(--text-accent);
    margin-bottom: 15px;
}

.modal-content p {
    color: var(--text-secondary);
}

.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-accent);
}

.alert {
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.alert-error {
    background: rgba(155, 44, 44, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.alert-success {
    background: rgba(212, 175, 55, 0.15);
    color: var(--text-accent);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid var(--border-light);
}

.guest-warning {
    background: rgba(212, 175, 55, 0.15);
    border-left: 4px solid var(--text-accent);
    padding: 4.5px;
    border-radius: 5px;
    width: auto;
}

.guest-warning a {
    color: var(--text-accent);
    text-decoration: underline;
    cursor: pointer;
}

#upgradePrompt {
    width: 100%;
}

/* Tools Grid - Right aligned rows */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

/* Row 1: Merge, Split, Remove (columns 2, 3, 4) */
.tool-card:nth-child(1) { grid-column: 2 / 3; }
.tool-card:nth-child(2) { grid-column: 3 / 4; }
.tool-card:nth-child(3) { grid-column: 4 / 5; }

/* Row 2: Reorder, Image (columns 3, 4) */
.tool-card:nth-child(4) { grid-row: 2; grid-column: 3 / 4; }
.tool-card:nth-child(5) { grid-row: 2; grid-column: 4 / 5; }

.tool-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md), var(--shadow-glow);
    border-color: var(--border-accent);
}

.tool-card.premium-tool {
    position: relative;
}

/*
.premium-label {
    display: inline-block;
    background: var(--gradient-warning);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 5px;
    vertical-align: middle;
}
*/

.premium-label {
    display: inline-block;
    background: var(--gradient-warning);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 5px;
    vertical-align: middle;
}

.tool-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.tool-card h3 {
    margin-bottom: 10px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

#studioView {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Upload Area */
/*
Grows/Animates
.upload-area {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    border: 2px dashed var(--border-medium);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-height: 320px;
}
*/

.upload-area {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    border: 2px dashed var(--border-medium);
    cursor: pointer;
    transition: border-color 0.3s, background 0.3s;  /* ← ONLY border and background */
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-height: 317px;  /* ← fixed min-height */  /*was 320*/
    /*height: 320px;       ← add fixed height to prevent any growth */
}

.upload-area p {
    margin: 0;
    font-size: 16px;
    color: var(--text-tertiary);
}

.upload-area:hover {
    border-color: var(--border-accent);
    background: var(--bg-hover);
}

/* Responsive */
@media (max-width: 1024px) {
    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .tool-card:nth-child(1),
    .tool-card:nth-child(2),
    .tool-card:nth-child(3),
    .tool-card:nth-child(4),
    .tool-card:nth-child(5) {
        grid-row: auto;
        grid-column: auto;
    }
    
    .split-top-section {
        flex-wrap: wrap;
    }
    
    .groups-card {
        width: 100%;
    }
}

/* Mobile styles - vertical scrolling for pages grid */
@media (max-width: 768px) {
    .pricing-cards {
        grid-template-columns: 1fr;
    }
    
    .pricing-card.featured {
        transform: scale(1);
    }
    
    .pricing-card.featured:hover {
        transform: translateY(-5px);
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .user-info {
        justify-content: center;
    }
    
    .usage-card {
        flex-direction: column;
        align-items: stretch;
    }
    
    .usage-left {
        justify-content: space-between;
    }
    
    .usage-right {
        justify-content: center;
    }
    
    .tools-grid {
        grid-template-columns: 1fr;
    }
    
    .tool-card:nth-child(1),
    .tool-card:nth-child(2),
    .tool-card:nth-child(3),
    .tool-card:nth-child(4),
    .tool-card:nth-child(5) {
        grid-row: auto;
        grid-column: auto;
    }
    
    .remove-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .remove-mode-selector {
        align-items: flex-start;
        margin-right: 0;
    }
    
    .remove-actions {
        justify-content: flex-start;
    }
    
    .remove-actions-row-1,
    .remove-actions-row-2 {
        justify-content: flex-start;
    }
    
    /* Fix for Split buttons - keep first row on one line */
    .split-actions {
        padding-right: 0;
    }
    
    .split-actions-row-1 {
        flex-wrap: nowrap;
        gap: 6px;
        justify-content: flex-end;
    }
    
    .split-actions-row-2 {
        flex-wrap: wrap;
        gap: 6px;
        justify-content: flex-end;
    }
    
    .split-actions .btn-small,
    .split-actions .btn-primary,
    .split-actions .btn-danger,
    .split-actions .btn-secondary,
    .remove-actions .btn-small,
    .remove-actions .btn-primary,
    .remove-actions .btn-danger {
        width: auto;
        min-width: 80px;
        white-space: nowrap;
        padding: 10px 14px;
        font-size: 14px;
        margin-right: 0;
        border-radius: 8px;
    }
    
    /* Add Segment button same size */
    .split-actions .btn-secondary {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    /* Process Split and Cancel buttons */
    .split-actions .btn-primary,
    .split-actions .btn-danger {
        padding: 10px 16px;
        font-size: 14px;
        font-weight: 500;
    }
    
    /* Very small screens - allow wrap as last resort */
    @media (max-width: 420px) {
        .split-actions-row-1 {
            flex-wrap: wrap;
            justify-content: flex-end;
        }
        .split-actions .btn-small,
        .split-actions .btn-secondary {
            font-size: 10px;
            padding: 5px 6px;
        }
    }
    
    /* Mobile: Switch back to vertical grid scrolling */
    .pages-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        flex-direction: row;
        flex-wrap: wrap;
        overflow-x: visible;
        overflow-y: auto;
        max-height: 450px;
    }
    
    .pages-grid .page-card {
        flex: 1 1 auto;
        width: auto;
    }
    
    .page-card .page-thumbnail {
        height: 120px;
    }
    
    .segment-card {
        font-size: 12px;
    }
    
    .split-top-section {
        flex-wrap: wrap;
    }
    
    .groups-card {
        width: 100%;
    }
    
    /* ===== ADD THIS NEW SECTION FOR IMAGE SCALING OPTIONS ON MOBILE ===== */
    .image-scaling-options {
        align-items: flex-start;
        width: 100%;
        padding: 12px;
    }
    
    .image-scaling-options > div {
        flex-direction: column;
        gap: 12px;
        width: 100%;
    }
    
    .image-scaling-options label {
        justify-content: flex-start;
        width: 100%;
        white-space: normal;
        padding: 8px 0;
    }
    
    .image-scaling-options > div:last-child label:first-child,
    .image-scaling-options > div:last-child label:last-child {
        min-width: auto;
    }
    
    .upload-area {
        min-height: auto !important;
        flex: 1;
        height: auto;
    }
    
    #studioView {
        display: flex;
        flex-direction: column;
        flex: 1;
    }
    
    /* Make the container use flex but DON'T touch body/html to preserve gradient */
    .container {
        display: flex;
        flex-direction: column;
        flex: 1;
    }
    
    /* Ensure the main content area takes remaining space */
    body > .container:first-of-type {
        min-height: calc(100vh - 80px);
        display: flex;
        flex-direction: column;
    }
    
    /* Override any previous body/html flex that broke the gradient */
    body {
        display: block;
        min-height: 100vh;
    }
    
    html {
        height: auto;
    }
}

/* GIANT RADIO BUTTONS */
input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--text-accent);
}

input[type="radio"]:checked {
    accent-color: var(--text-accent);
}

@media (min-width: 768px) {
    input[type="radio"] {
        width: 20px;
        height: 20px;
    }
}

/* Give padding-right specifically to radio button containers */
.remove-mode-selector .mode-option {
    padding-right: 85px;
}

#loginBtn {
    margin-right: 28px;
}

#registerBtn {
    margin-right: 3px;
}

/* Style image scaling options - column layout, right aligned */
.image-scaling-options {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    margin: 10px 0 15px 0;
    padding: 0 18px 12px 18px;
    background: var(--bg-card);
    border-radius: 8px;
}

.image-scaling-options > div {
    display: flex;
    gap: 40px;
}

.image-scaling-options label {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.image-scaling-options {
    margin: 0 !important;
}

/* Dark theme horizontal rule */
hr {
    border: none;
    border-top: 1px solid var(--border-medium);
    margin: 10px 0 15px 0;
}

/* Processing Overlay - Dimmed background like modal */
.processing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.processing-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 30px 40px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    border: 1px solid var(--border-light);
}

.processing-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-medium);
    border-top-color: var(--text-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 15px auto;
}

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

.processing-card p {
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 500;
    margin: 0;
}

.image-scaling-options > div:last-child label:first-child {
    min-width: 266px;
}

.image-scaling-options > div:last-child label:last-child {
    min-width: 261px;
}

/* =========================================
   DIAGONAL SNAP REVEAL (REVERSED)
   ORDER:
   1 → 4
   [micro pause]
   3
   [micro pause]
   2 → 5
========================================= */

/* Default state - completely hidden, no visibility */
.tools-grid .tool-card {
    position: relative;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(0,0,0,.14);
    clip-path: inset(0 100% 100% 0 round 10px);
    opacity: 0;
}

.tools-grid .tool-card .tool-icon,
.tools-grid .tool-card h3,
.tools-grid .tool-card p {
    opacity: 0;
    transform: translate(-24px,-24px);
}

/* Card 3 uses different transform */
.tools-grid .tool-card:nth-child(3) .tool-icon,
.tools-grid .tool-card:nth-child(3) h3,
.tools-grid .tool-card:nth-child(3) p {
    transform: translate(-24px,24px);
}

/* When animate-tools class is added, trigger animations */
.tools-grid.animate-tools .tool-card {
    animation: cardReveal .55s cubic-bezier(.22,1,.36,1) forwards;
    animation-delay: var(--card-delay, 0s);
}

.tools-grid.animate-tools .tool-card .tool-icon,
.tools-grid.animate-tools .tool-card h3,
.tools-grid.animate-tools .tool-card p {
    animation: contentReveal .22s cubic-bezier(.2,.9,.2,1) forwards;
    animation-delay: var(--content-delay, 0s);
}

/* Card 3 needs different animation for the card itself */
.tools-grid.animate-tools .tool-card:nth-child(3) {
    animation-name: cardRevealBL;
}

/* Card 3 content animation */
.tools-grid.animate-tools .tool-card:nth-child(3) .tool-icon,
.tools-grid.animate-tools .tool-card:nth-child(3) h3,
.tools-grid.animate-tools .tool-card:nth-child(3) p {
    animation-name: contentRevealBL;
}

/* Card delays */
.tools-grid .tool-card:nth-child(1) { --card-delay: 0.00s; --content-delay: 0.08s; }
.tools-grid .tool-card:nth-child(4) { --card-delay: 0.10s; --content-delay: 0.18s; }
.tools-grid .tool-card:nth-child(3) { --card-delay: 0.22s; --content-delay: 0.30s; }
.tools-grid .tool-card:nth-child(2) { --card-delay: 0.42s; --content-delay: 0.50s; }
.tools-grid .tool-card:nth-child(5) { --card-delay: 0.54s; --content-delay: 0.62s; }

/* Keyframes - these control visibility entirely */
@keyframes cardReveal {
    0% {
        clip-path: inset(0 100% 100% 0 round 10px);
        opacity: 0;
    }
    100% {
        clip-path: inset(0 0 0 0 round 10px);
        opacity: 1;
    }
}

@keyframes cardRevealBL {
    0% {
        clip-path: inset(100% 100% 0 0 round 10px);
        opacity: 0;
    }
    100% {
        clip-path: inset(0 0 0 0 round 10px);
        opacity: 1;
    }
}

@keyframes contentReveal {
    0% {
        opacity: 0;
        transform: translate(-24px,-24px);
    }
    100% {
        opacity: 1;
        transform: translate(0,0);
    }
}

@keyframes contentRevealBL {
    0% {
        opacity: 0;
        transform: translate(-24px,24px);
    }
    100% {
        opacity: 1;
        transform: translate(0,0);
    }
}

#usageTitle {
    transition: opacity 0.2s ease;
}

/* ==========================================================================
   FLIP CLOCK STYLES (ISOLATED - NO CONFLICT)
   ========================================================================== */

.flip-clock-wrapper {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-left: 8px;
}

.flip-clock-wrapper .flip-clock {
    text-align: center;
    perspective: 400px;
    font-size: 0.9rem;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.flip-clock-wrapper .flip-clock__piece {
    display: inline-block;
}

.flip-clock-wrapper .flip-clock__slot {
    font-size: 0.55em;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-top: 4px;
    display: block;
    color: var(--text-secondary);
}

.flip-clock-wrapper .card {
    display: block;
    position: relative;
    padding-bottom: 0.72em;
    font-size: 0.85em;
    line-height: 0.95;
}

.flip-clock-wrapper .card__top,
.flip-clock-wrapper .card__bottom,
.flip-clock-wrapper .card__back::before,
.flip-clock-wrapper .card__back::after {
    display: block;
    height: 0.72em;
    color: #ccc;
    background: #222;
    padding: 0.2em 0.25em;
    border-radius: 0.28em 0.28em 0 0;
    backface-visibility: hidden;
    transform-style: preserve-3d;
    width: calc(1.5em + 2px);
    transform: translateZ(0);
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
    text-align: center;
    box-sizing: border-box;
}

.flip-clock-wrapper .card__bottom {
    color: #fff;
    position: absolute;
    top: 50%;
    left: 0;
    border-top: 1px solid #000;
    background: #393939;
    border-radius: 0 0 0.28em 0.28em;
    pointer-events: none;
    overflow: hidden;
}

.flip-clock-wrapper .card__bottom::after {
    display: block;
    margin-top: -0.72em;
}

.flip-clock-wrapper .card__back::before,
.flip-clock-wrapper .card__bottom::after {
    content: attr(data-value);
}

.flip-clock-wrapper .card__back {
    position: absolute;
    top: 0;
    height: 100%;
    left: 0;
    pointer-events: none;
}

.flip-clock-wrapper .card__back::before {
    position: relative;
    z-index: -1;
    overflow: hidden;
    background: #222;
    width: 1.5em;
    padding: 0.2em 0.25em;
    border-radius: 0.28em 0.28em 0 0;
    text-align: center;
    color: #ccc;
    font-weight: 700;
    box-sizing: border-box;
    display: block;
    height: 0.72em;
}

.flip-clock-wrapper .flip .card__back::before {
    animation: flipTop 0.3s cubic-bezier(.37,.01,.94,.35);
    animation-fill-mode: both;
    transform-origin: center bottom;
}

.flip-clock-wrapper .flip .card__back .card__bottom {
    animation: flipBottom 0.6s cubic-bezier(.15,.45,.28,1);
    animation-fill-mode: both;
    transform-origin: center top;
}

@keyframes flipTop {
    0% { transform: rotateX(0deg); z-index: 2; }
    99% { opacity: 0.99; }
    100% { transform: rotateX(-90deg); opacity: 0; }
}

@keyframes flipBottom {
    0%, 50% { z-index: -1; transform: rotateX(90deg); opacity: 0; }
    51% { opacity: 0.99; }
    100% { opacity: 0.99; transform: rotateX(0deg); z-index: 5; }
}

.offer-ends-inline {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.offer-ends-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ==========================================================================
   REMOVE PAGES - KEEP/DELETE PILL STYLES
   ========================================================================== */

/* Keep/Delete pill - positioned at top, aligned with checkbox */
.keep-delete-pill {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 20px;
    text-align: center;
    white-space: nowrap;
    z-index: 2;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.pill-delete {
    background: var(--gradient-danger);
    color: white;
}

.pill-keep {
    background: var(--gradient-success);
    color: white;
}

/* Simple checkbox styles - default color only */
.page-checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    z-index: 3;
    accent-color: var(--text-accent);
}

/* ==========================================================================
   INSTAGRAM POPUP STYLES
   ========================================================================== */

#instagramPopupOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: instagramFadeIn 0.3s ease;
}

.instagram-popup-modal {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 30px 25px;
    max-width: 320px;
    width: 85%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    animation: instagramSlideUp 0.3s ease;
}

.instagram-popup-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.instagram-popup-title {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 15px;
    font-size: 24px;
    font-weight: bold;
}

.instagram-popup-message {
    color: var(--text-secondary);
    margin-bottom: 25px;
    line-height: 1.5;
    font-size: 16px;
}

.instagram-unlock-btn {
    background: var(--gradient-success);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 50px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.instagram-unlock-btn:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

@keyframes instagramFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Mobile adjustments */
@media (max-width: 768px) {
    .instagram-popup-modal {
        max-width: 280px;
        padding: 25px 20px;
    }
    
    .instagram-popup-icon {
        font-size: 52px;
    }
    
    .instagram-popup-title {
        font-size: 20px;
    }
    
    .instagram-popup-message {
        font-size: 14px;
    }
    
    .instagram-unlock-btn {
        padding: 12px 24px;
        font-size: 16px;
    }
}
