/* VH Posting System - Apple Liquid Glass Design */
/* Русский интерфейс | Light & Dark Theme */

/* ============ CSS Variables - Light Theme ============ */
:root {
    /* Core colors */
    --accent-color: #007AFF;
    --accent-hover: #0056CC;
    --accent-light: rgba(0, 122, 255, 0.15);
    --success-color: #34C759;
    --error-color: #FF3B30;
    --warning-color: #FF9500;

    /* Backgrounds */
    --bg-primary: #F2F2F7;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #E5E5EA;

    /* Glass effect */
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-bg-solid: rgba(255, 255, 255, 0.92);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    --glass-shadow-hover: 0 12px 48px rgba(0, 0, 0, 0.12);
    --glass-blur: blur(20px);

    /* Text */
    --text-primary: #1C1C1E;
    --text-secondary: #8E8E93;
    --text-tertiary: #AEAEB2;
    --text-inverse: #FFFFFF;

    /* Borders */
    --border-color: rgba(0, 0, 0, 0.08);
    --border-light: rgba(0, 0, 0, 0.04);
    --divider: rgba(60, 60, 67, 0.12);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-accent: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
    --gradient-bg: linear-gradient(180deg, #F2F2F7 0%, #E5E5EA 100%);

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ============ Dark Theme ============ */
[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #1C1C1E;
    --bg-tertiary: #2C2C2E;

    --glass-bg: rgba(44, 44, 46, 0.72);
    --glass-bg-solid: rgba(44, 44, 46, 0.92);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --glass-shadow-hover: 0 12px 48px rgba(0, 0, 0, 0.4);

    --text-primary: #FFFFFF;
    --text-secondary: #8E8E93;
    --text-tertiary: #636366;

    --border-color: rgba(255, 255, 255, 0.1);
    --border-light: rgba(255, 255, 255, 0.05);
    --divider: rgba(84, 84, 88, 0.65);

    --gradient-bg: linear-gradient(180deg, #1C1C1E 0%, #000000 100%);
}

/* ============ Base Styles ============ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
    background: var(--gradient-bg);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background var(--transition-normal), color var(--transition-normal);
}

/* ============ Glass Card Component ============ */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    transition: all var(--transition-normal);
}

.glass-card:hover {
    box-shadow: var(--glass-shadow-hover);
}

.glass-card-solid {
    background: var(--glass-bg-solid);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
}

/* ============ App Container ============ */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ============ Header ============ */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--glass-shadow);
    margin-bottom: 20px;
    transition: all var(--transition-normal);
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 16px;
}

.username {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Theme Toggle */
.theme-toggle {
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-normal);
}

.theme-toggle::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--bg-secondary);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all var(--transition-normal);
}

.theme-toggle.dark::before {
    transform: translateX(20px);
}

.theme-toggle.dark {
    background: var(--accent-color);
}

/* ============ Navigation ============ */
.main-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding: 8px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--glass-shadow);
    flex-wrap: wrap;
}

/* On narrow screens, switch to horizontal scrolling so 5+ tabs stay
   on one row instead of breaking into a tall stack. */
@media (max-width: 720px) {
    .main-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .main-nav::-webkit-scrollbar {
        display: none;
    }
    .nav-btn {
        flex: 0 0 auto;
        min-width: auto;
        white-space: nowrap;
        scroll-snap-align: start;
        padding: 10px 16px;
        font-size: 0.9rem;
    }
}

.nav-btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-btn:hover {
    background: var(--accent-light);
    color: var(--accent-color);
}

.nav-btn.active {
    background: var(--accent-color);
    color: var(--text-inverse);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

/* ============ Panels ============ */
.panel {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 28px;
    box-shadow: var(--glass-shadow);
    transition: all var(--transition-normal);
}

.panel h2 {
    margin: 0 0 8px 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.panel h3 {
    margin: 24px 0 16px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ============ Tabs ============ */
.tab-content {
    display: none;
    animation: fadeIn var(--transition-slow);
}

.tab-content.active {
    display: block;
}

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

/* ============ Forms ============ */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 200px;
}

input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px var(--accent-light);
}

textarea {
    resize: vertical;
    min-height: 120px;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238E8E93' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.hint {
    display: block;
    font-size: 0.85rem;
    color: var(--text-tertiary);
    margin-top: 6px;
}

.help-text {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-color);
    color: var(--text-inverse);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.25);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 16px rgba(0, 122, 255, 0.35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-accent {
    background: linear-gradient(135deg, #FF9500 0%, #FF3B30 100%);
    color: var(--text-inverse);
    box-shadow: 0 4px 12px rgba(255, 149, 0, 0.25);
}

.btn-accent:hover {
    box-shadow: 0 6px 16px rgba(255, 149, 0, 0.35);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success-color);
    color: var(--text-inverse);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.btn-large {
    padding: 16px 32px;
    font-size: 1.1rem;
    border-radius: var(--radius-lg);
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

/* ============ Alerts ============ */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 0.95rem;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

.alert-error {
    background: rgba(255, 59, 48, 0.15);
    color: var(--error-color);
    border: 1px solid rgba(255, 59, 48, 0.3);
}

.alert-success {
    background: rgba(52, 199, 89, 0.15);
    color: var(--success-color);
    border: 1px solid rgba(52, 199, 89, 0.3);
}

.alert-warning {
    background: rgba(255, 149, 0, 0.15);
    color: var(--warning-color);
    border: 1px solid rgba(255, 149, 0, 0.3);
}

/* ============ Status Badges ============ */
.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status.connected {
    background: rgba(52, 199, 89, 0.15);
    color: var(--success-color);
}

.status.connected::before {
    background: var(--success-color);
    box-shadow: 0 0 8px var(--success-color);
}

.status.disconnected {
    background: rgba(255, 59, 48, 0.15);
    color: var(--error-color);
}

.status.disconnected::before {
    background: var(--error-color);
}

/* ============ Login Page ============ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--gradient-primary);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-box {
    background: var(--glass-bg-solid);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    box-shadow: var(--glass-shadow-hover);
}

.login-logo {
    text-align: center;
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-logo-img {
    width: 100px !important;
    height: 100px !important;
    max-width: 100px !important;
    max-height: 100px !important;
    object-fit: contain;
    border-radius: var(--radius-lg);
    display: block;
}

.login-box h1 {
    font-size: 1.75rem;
    font-weight: 700;
    text-align: center;
    margin: 0 0 8px 0;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-box h2 {
    color: var(--text-secondary);
    text-align: center;
    font-weight: 400;
    font-size: 1.1rem;
    margin: 0 0 32px 0;
}

/* Login page mobile */
@media (max-width: 480px) {
    .login-page {
        padding: 16px;
    }

    .login-box {
        padding: 24px 20px;
    }

    .login-logo-img {
        width: 80px !important;
        height: 80px !important;
        max-width: 80px !important;
        max-height: 80px !important;
    }

    .login-box h1 {
        font-size: 1.4rem;
    }

    .login-box h2 {
        font-size: 1rem;
        margin-bottom: 24px;
    }
}

/* ============ Photo Gallery ============ */
.gallery-controls {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: flex-end;
}

.gallery-controls .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}

.selection-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--accent-light);
    border: 1px solid rgba(0, 122, 255, 0.2);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

#selected-count {
    font-weight: 600;
    color: var(--accent-color);
}

.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.photo-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 1;
    background: var(--bg-tertiary);
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.photo-item:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-item .checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 26px;
    height: 26px;
    background: var(--glass-bg-solid);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 2px solid var(--glass-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.photo-item.selected .checkbox {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--text-inverse);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.4);
}

.photo-item.selected .checkbox::after {
    content: '✓';
    font-size: 14px;
    font-weight: bold;
}

.photo-item .title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 12px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.photo-preview-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: var(--glass-bg-solid);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 2px solid var(--glass-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    opacity: 0;
    transition: all var(--transition-fast);
    z-index: 5;
}

.photo-item:hover .photo-preview-btn {
    opacity: 1;
}

.photo-preview-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    transform: scale(1.1);
}

/* Video Badge */
.photo-item.is-video {
    position: relative;
}

.video-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    pointer-events: none;
    transition: all 0.2s ease;
}

.photo-item:hover .video-badge {
    background: rgba(234, 67, 53, 0.9);
    transform: translate(-50%, -50%) scale(1.1);
}

.video-icon {
    color: white;
    font-size: 20px;
    margin-left: 4px;
}

.photo-item.is-video .photo-preview-btn {
    background: rgba(234, 67, 53, 0.9);
    border-color: rgba(234, 67, 53, 0.9);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

#page-info {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Photos Preview */
.photos-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    min-height: 100px;
}

.photos-preview .placeholder {
    color: var(--text-tertiary);
    width: 100%;
    text-align: center;
    padding: 24px;
}

.preview-thumb {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-thumb .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.preview-thumb:hover .remove-btn {
    opacity: 1;
}

/* Result Message */
.result-message {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-top: 20px;
    display: none;
    animation: fadeIn var(--transition-normal);
}

.result-message.success {
    display: block;
    background: rgba(52, 199, 89, 0.15);
    color: var(--success-color);
    border: 1px solid rgba(52, 199, 89, 0.3);
}

.result-message.error {
    display: block;
    background: rgba(255, 59, 48, 0.15);
    color: var(--error-color);
    border: 1px solid rgba(255, 59, 48, 0.3);
}

/* ============ Settings ============ */
.settings-section {
    border-bottom: 1px solid var(--divider);
    padding-bottom: 28px;
    margin-bottom: 28px;
}

.settings-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* ============ Loading State ============ */
.loading {
    text-align: center;
    padding: 48px;
    color: var(--text-secondary);
}

.loading::after {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 12px;
    vertical-align: middle;
}

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

/* Placeholder */
.placeholder {
    color: var(--text-tertiary);
    text-align: center;
    padding: 24px;
}

/* ============ Platform Cards ============ */
.platforms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.platform-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: all var(--transition-fast);
}

.platform-card:hover {
    border-color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.1);
}

.platform-card.platform-disabled {
    opacity: 0.6;
}

.platform-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.platform-checkbox {
    position: relative;
    display: flex;
    cursor: pointer;
}

.platform-checkbox input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.platform-checkbox .checkmark {
    width: 24px;
    height: 24px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.platform-checkbox input:checked + .checkmark {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.platform-checkbox input:checked + .checkmark::after {
    content: '✓';
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.platform-info {
    flex: 1;
}

.platform-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.status-mini {
    display: block;
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.status-mini.connected {
    color: var(--success-color);
}

.platform-target {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-primary);
}

.platform-note {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin: 0;
    padding: 8px 0 0 0;
}

/* ============ Gallery Header & Toolbar ============ */
.gallery-header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.gallery-header h2 {
    margin: 0;
}

.gallery-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.album-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 200px;
}

.toolbar-select {
    flex: 1;
    min-width: 150px;
    max-width: 280px;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--accent-light);
    color: var(--accent-color);
    transform: scale(1.05);
}

.btn-icon:active {
    transform: scale(0.95);
}

.btn-icon.active {
    background: var(--accent-color);
    color: white;
}

.toolbar-search {
    flex: 1;
    min-width: 150px;
    max-width: 250px;
}

.toolbar-search input {
    width: 100%;
    margin: 0;
}

/* ============ Gallery Views ============ */
.gallery-view {
    animation: fadeIn 0.3s ease;
}

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

/* ============ Albums Grid ============ */
.albums-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    padding: 8px 0;
}

@media (min-width: 768px) {
    .albums-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (min-width: 1024px) {
    .albums-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (min-width: 1400px) {
    .albums-grid {
        grid-template-columns: repeat(7, 1fr);
    }
}

.album-card {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-tertiary);
    box-shadow: var(--glass-shadow);
    transition: all var(--transition-normal);
    user-select: none;
}

.album-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--glass-shadow-hover);
}

.album-card.dragging {
    opacity: 0.6;
    transform: scale(1.05) rotate(2deg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.album-card.drag-over {
    transform: scale(0.95);
    border: 3px solid var(--accent-color);
}

.album-card-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-normal);
}

.album-card:hover .album-card-cover {
    transform: scale(1.1);
}

.album-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
    color: white;
}

.album-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.album-card-count {
    font-size: 0.7rem;
    opacity: 0.8;
}

.album-card-drag-handle {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    opacity: 0;
    transition: opacity var(--transition-fast);
    cursor: grab;
}

.album-card:hover .album-card-drag-handle {
    opacity: 1;
}

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

/* Placeholder for empty cover */
.album-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    font-size: 2rem;
}

/* Drag hint */
.drag-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    margin: 8px 0 16px;
    opacity: 0.7;
}

.drag-hint.hidden {
    display: none;
}

/* ============ Breadcrumb Navigation ============ */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.breadcrumb-separator {
    color: var(--text-tertiary);
}

.breadcrumb-current {
    font-weight: 600;
    color: var(--text-primary);
}

.btn-text {
    background: none;
    border: none;
    color: var(--accent-color);
    font-size: 0.95rem;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.btn-text:hover {
    background: var(--accent-light);
}

.btn-icon-text {
    margin-right: 6px;
}

.photos-count {
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ============ Loading Spinner ============ */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============ Floating Action Bar ============ */
.floating-action-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: var(--glass-bg-solid);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

.floating-action-bar.hidden {
    display: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.action-bar-left {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding-right: 16px;
    border-right: 1px solid var(--divider);
}

.selection-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

.selection-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.action-bar-center,
.action-bar-right {
    display: flex;
    gap: 8px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-primary);
}

.action-btn:hover {
    background: var(--accent-light);
}

.action-btn:active {
    transform: scale(0.95);
}

.action-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.action-text {
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
}

.action-btn.action-primary {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.action-btn.action-primary:hover {
    background: var(--accent-hover);
}

.action-btn.action-secondary {
    background: var(--bg-tertiary);
}

.action-btn.action-secondary:hover {
    background: var(--border-color);
}

/* Mobile floating bar */
@media (max-width: 768px) {
    .floating-action-bar {
        left: 12px;
        right: 12px;
        transform: none;
        bottom: 12px;
        padding: 10px 16px;
        gap: 8px;
    }

    .action-bar-left {
        padding-right: 12px;
    }

    .selection-count {
        font-size: 1.2rem;
    }

    .action-btn {
        padding: 6px 10px;
    }

    .action-text {
        display: none;
    }

    .action-icon {
        font-size: 1.4rem;
    }
}

/* ============ Scrollbar Styling ============ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ============ Selection ============ */
::selection {
    background: var(--accent-light);
    color: var(--accent-color);
}

/* ============ Responsive ============ */
@media (max-width: 768px) {
    .app-container {
        padding: 12px;
    }

    .app-header {
        flex-direction: column;
        text-align: center;
        gap: 16px;
        padding: 20px;
    }

    .main-nav {
        padding: 6px;
    }

    .nav-btn {
        min-width: auto;
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .panel {
        padding: 20px;
    }

    .form-row {
        flex-direction: column;
    }

    .form-row .form-group {
        min-width: 100%;
    }

    .photo-gallery {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }

    .selection-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .login-box {
        padding: 32px 24px;
    }
}

/* ============ Print Styles ============ */
@media print {
    .app-header,
    .main-nav,
    .btn,
    .selection-bar,
    .pagination {
        display: none !important;
    }

    .panel {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ============ Photo Lightbox ============ */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox.hidden {
    display: none;
}

.lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1;
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: -40px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 10;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.lightbox-image-container {
    position: relative;
    max-width: 85vw;
    max-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.5);
}

.lightbox-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    transition: opacity 0.3s ease;
}

.lightbox-video-container {
    width: 100%;
    max-width: 85vw;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.lightbox-video {
    width: 100%;
    height: 100%;
    border: none;
}

/* Video Play Overlay in Lightbox */
.video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: background 0.2s ease;
    z-index: 10;
}

.video-play-overlay:hover {
    background: rgba(0, 0, 0, 0.3);
}

.video-play-overlay:hover .video-play-button {
    transform: scale(1.1);
    background: rgba(234, 67, 53, 1);
}

.video-play-button {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(234, 67, 53, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: white;
    padding-left: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.video-play-text {
    margin-top: 16px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.lightbox-loading.hidden {
    display: none;
}

.lightbox-info {
    margin-top: 16px;
    text-align: center;
}

.lightbox-title {
    color: white;
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
    max-width: 60vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lightbox-actions {
    margin-top: 20px;
    display: flex;
    gap: 12px;
}

.lightbox-actions .btn {
    min-width: 130px;
}

.lightbox-actions .btn-success {
    background: var(--success-color);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: -80px;
}

.lightbox-next {
    right: -80px;
}

/* Mobile lightbox adjustments */
@media (max-width: 768px) {
    .lightbox-close {
        top: 10px;
        right: 10px;
    }

    .lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 22px;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-actions {
        flex-direction: column;
        width: 100%;
        padding: 0 20px;
    }

    .lightbox-actions .btn {
        width: 100%;
    }

    .lightbox-title {
        max-width: 90vw;
        font-size: 0.9rem;
    }
}

/* ============ Download Choice Dialog ============ */
.download-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.download-dialog {
    background: var(--glass-bg-solid);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: var(--radius-xl);
    padding: 32px;
    min-width: 320px;
    max-width: 90vw;
    box-shadow: var(--glass-shadow-hover);
    border: 1px solid var(--glass-border);
    position: relative;
    text-align: center;
    animation: slideUp 0.3s ease;
}

.download-dialog h3 {
    margin: 0 0 8px 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.download-dialog p {
    margin: 0 0 24px 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.download-dialog-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.download-dialog-buttons .btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    min-width: 130px;
}

.download-dialog-buttons .btn-icon {
    font-size: 1.5rem;
}

.download-dialog-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 50%;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.download-dialog-close:hover {
    background: var(--error-color);
    color: white;
}

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

/* ============ OAuth Banner ============ */
.oauth-banner {
    background: linear-gradient(135deg, #FF9500 0%, #FF6B00 100%);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 16px;
    animation: slideDown 0.3s ease;
}

.oauth-banner.hidden {
    display: none;
}

.oauth-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.oauth-banner-icon {
    font-size: 1.25rem;
}

.oauth-banner-text {
    flex: 1;
    color: white;
    font-size: 0.9rem;
}

.oauth-banner-text strong {
    display: block;
    font-size: 1rem;
}

.oauth-banner .btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    white-space: nowrap;
}

.oauth-banner .btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============ Text Editor Toolbar ============ */
.text-editor {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-secondary);
}

.editor-toolbar {
    display: flex;
    gap: 4px;
    padding: 8px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.toolbar-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-btn:hover {
    background: var(--accent-light);
    color: var(--accent-color);
}

.toolbar-btn.active {
    background: var(--accent-color);
    color: white;
}

.toolbar-separator {
    width: 1px;
    background: var(--border-color);
    margin: 0 4px;
}

.text-editor textarea {
    border: none;
    border-radius: 0;
    resize: vertical;
}

.text-editor textarea:focus {
    box-shadow: none;
}

/* ============ Tags System ============ */
.tags-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px;
    min-height: 44px;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.tags-list:empty {
    display: none;
}

.tags-list + .tags-input-wrapper {
    margin-top: 0;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--accent-light);
    color: var(--accent-color);
    border-radius: 20px;
    font-size: 0.85rem;
    animation: tagAppear 0.2s ease;
}

@keyframes tagAppear {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

.tag-chip .tag-remove {
    width: 16px;
    height: 16px;
    border: none;
    background: transparent;
    color: var(--accent-color);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    opacity: 0.6;
    transition: var(--transition-fast);
    border-radius: 50%;
}

.tag-chip .tag-remove:hover {
    opacity: 1;
    background: var(--accent-color);
    color: white;
}

.tags-input-wrapper {
    position: relative;
}

.tags-input {
    border: none !important;
    background: transparent !important;
    padding: 4px 8px !important;
    font-size: 0.9rem;
    width: 100%;
    min-width: 120px;
}

.tags-input:focus {
    box-shadow: none !important;
    outline: none;
}

.tags-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--glass-shadow);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.tags-suggestions.visible {
    display: block;
}

.tag-suggestion {
    padding: 8px 12px;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tag-suggestion:hover,
.tag-suggestion.selected {
    background: var(--accent-light);
}

.tag-suggestion .tag-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.tags-presets {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.tags-presets-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.tag-preset {
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition-fast);
    color: var(--text-primary);
}

.tag-preset:hover {
    background: var(--accent-light);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.presets-list {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}

.preset-add-btn,
.preset-manage-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px dashed var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.preset-add-btn:hover,
.preset-manage-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: var(--accent-light);
}

/* ============ Modal Styles ============ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* Preset Modal */
.preset-modal {
    max-width: 500px;
    width: 90%;
}

.preset-manager-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.preset-manager-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 8px;
    background: var(--bg-secondary);
}

.preset-manager-item:hover {
    border-color: var(--accent-color);
}

.preset-info {
    flex: 1;
    min-width: 0;
}

.preset-info .preset-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.preset-info .preset-tags-preview {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preset-actions {
    display: flex;
    gap: 8px;
    margin-left: 12px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.2s ease;
}

.btn-icon:hover {
    background: var(--bg-hover);
}

.btn-icon.preset-delete:hover {
    background: rgba(239, 68, 68, 0.1);
}

.preset-form-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.btn-block {
    width: 100%;
}

/* ============ Infinite Scroll Loading ============ */
.albums-loading-more,
.photos-loading-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    grid-column: 1 / -1;
    width: 100%;
}

.albums-loading-more .loading-spinner,
.photos-loading-more .loading-spinner {
    width: 24px;
    height: 24px;
}

#albums-scroll-sentinel,
#photos-scroll-sentinel {
    visibility: hidden;
}

/* ============ Converter Grid Layout ============ */
.converter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.converter-input-section,
.converter-text-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.converter-output-section {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.output-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

.copy-status {
    font-size: 0.85rem;
    color: var(--success-color);
    opacity: 0;
    transition: opacity 0.3s;
}

.copy-status.visible {
    opacity: 1;
}

@media (max-width: 768px) {
    .converter-grid {
        grid-template-columns: 1fr;
    }

    .tags-presets {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ============ Widget Settings ============ */
.widget-albums-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
}

.widget-album-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    background: var(--glass-bg);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.widget-album-item:hover {
    background: var(--bg-hover);
}

.widget-album-item.selected {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
}

.widget-album-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.widget-album-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.widget-album-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.widget-album-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.code-block {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
}

.code-block p {
    margin: 0 0 8px 0;
    color: var(--text-secondary);
}

.code-block code {
    display: block;
    background: var(--bg-tertiary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', monospace;
    font-size: 0.85rem;
    word-break: break-all;
    color: var(--text-primary);
}

.save-status {
    margin-left: 12px;
    font-size: 0.9rem;
}

.save-status.success {
    color: var(--success);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

/* ============ Photo Source Buttons ============ */
.photo-source-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.photo-source-buttons .btn {
    flex: 1;
    min-width: 140px;
}

/* Combined preview for all photos */
.combined-preview {
    min-height: 80px;
    border: 2px dashed transparent;
    transition: all 0.2s ease;
}

.combined-preview.drag-over {
    border-color: var(--accent-color);
    background: var(--bg-tertiary);
}

.combined-preview .preview-thumb .source-badge {
    position: absolute;
    bottom: 2px;
    left: 2px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 8px;
    padding: 1px 4px;
    border-radius: 3px;
    text-transform: uppercase;
}

.combined-preview .preview-thumb.uploading {
    opacity: 0.6;
}

.combined-preview .preview-thumb .upload-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid var(--bg-primary);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ============ File Upload Area ============ */
.upload-area {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border: 2px dashed var(--divider);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    transition: all 0.2s ease;
}

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

.uploaded-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.uploaded-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-tertiary);
}

.uploaded-item .preview-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.uploaded-item .remove-uploaded {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.uploaded-item .video-badge {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
}

.uploaded-item .file-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 9px;
    padding: 2px 4px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uploaded-item.uploading {
    opacity: 0.7;
}

.uploaded-item .upload-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ============ Post Options Grid ============ */
.post-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.checkbox-label.compact {
    font-size: 0.9rem;
}

.schedule-options {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    border: 2px solid var(--accent-color);
}

.schedule-options.hidden {
    display: none;
}

.schedule-label {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.schedule-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.schedule-presets .preset-btn {
    padding: 8px 14px;
    border: 1px solid var(--divider);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.schedule-presets .preset-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent-color);
}

.schedule-presets .preset-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.schedule-custom {
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: var(--radius-sm);
}

.schedule-date-row {
    display: flex;
    gap: 12px;
}

.schedule-field {
    flex: 1;
}

.schedule-field label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.schedule-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    border: 1px solid var(--divider);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.schedule-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.datetime-input {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border: 1px solid var(--divider);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.post-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.post-actions .btn {
    flex: 1;
}

/* ============ Scheduled Posts Section ============ */
.scheduled-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--divider);
}

.scheduled-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.scheduled-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.badge {
    background: var(--accent-color);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.scheduled-posts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.scheduled-post-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid var(--divider);
}

.scheduled-post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 8px;
}

.scheduled-time {
    font-weight: 600;
    color: var(--accent-color);
    font-size: 0.9rem;
}

.scheduled-platforms {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    background: var(--bg-tertiary);
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
}

/* Photo previews in scheduled posts */
.scheduled-photos-preview {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.scheduled-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--divider);
}

.more-photos {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.scheduled-post-content {
    margin-bottom: 10px;
}

.scheduled-text {
    margin: 0 0 8px 0;
    color: var(--text-primary);
}

.scheduled-photos,
.scheduled-tags {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-right: 12px;
}

.scheduled-post-actions {
    display: flex;
    gap: 8px;
}

.scheduled-platforms label {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Inline editor for scheduled posts */
.scheduled-post-card.editing {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(var(--accent-color-rgb, 0,122,255), 0.15);
}

.inline-editor {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.inline-editor-photos {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex-direction: row;
}

.inline-editor-photos .preview-thumb {
    width: 80px;
    height: 80px;
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
}

.inline-editor-photos .preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.inline-editor-photos .remove-btn {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(220,40,40,0.85);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inline-editor-text {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--divider);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    box-sizing: border-box;
}

.inline-editor-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.inline-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.inline-tags-input {
    flex: 1;
    min-width: 100px;
    padding: 4px 8px;
    border: 1px solid var(--divider);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.inline-editor-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.inline-editor-field {
    display: flex;
    align-items: center;
    gap: 6px;
}

.inline-editor-field label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.inline-editor-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-accent {
    background: var(--success, #34c759);
    color: white;
}

.btn-accent:hover {
    opacity: 0.9;
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

/* Photo counter on posting page */
.photo-counter {
    font-weight: 600;
    font-size: 0.9em;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.photo-counter.at-limit {
    background: var(--error);
    color: white;
}

/* ============ Published Posts Archive ============ */
.archive-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--divider);
}

.archive-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.archive-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-secondary);
}

.published-posts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.archive-post-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    border: 1px solid var(--divider);
    opacity: 0.85;
}

.archive-post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    flex-wrap: wrap;
    gap: 6px;
}

.archive-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.archive-results {
    font-size: 0.75rem;
    display: flex;
    gap: 8px;
}

.archive-results .result-success {
    color: var(--success-color);
}

.archive-results .result-error {
    color: var(--error-color);
}

.archive-photos-preview {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
    align-items: center;
}

.archive-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--divider);
}

.archive-text {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.3;
}

/* ============ Reduced Motion ============ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============ Mobile Responsive Styles ============ */

/* Tablet and smaller */
@media (max-width: 1024px) {
    .converter-grid {
        grid-template-columns: 1fr;
    }

    .platforms-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile devices */
@media (max-width: 768px) {
    .app-container {
        padding: 8px;
    }

    /* Header - compact horizontal layout */
    .app-header {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 12px;
        justify-content: space-between;
        align-items: center;
    }

    .app-header h1 {
        font-size: 1.1rem;
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .user-menu {
        gap: 6px;
        flex-shrink: 0;
    }

    .user-menu .username {
        display: none;
    }

    .user-menu .btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .theme-toggle {
        width: 36px;
        height: 20px;
    }

    .theme-toggle::before {
        width: 16px;
        height: 16px;
    }

    .theme-toggle.dark::before {
        transform: translateX(16px);
    }

    /* Navigation - grid layout for mobile */
    .main-nav {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
        padding: 6px;
        margin-bottom: 12px;
    }

    .nav-btn {
        padding: 10px 6px;
        font-size: 0.75rem;
        text-align: center;
        min-width: 0;
        flex: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Make settings button span 2 columns for 5 items grid */
    .nav-btn:nth-child(4) {
        grid-column: 1 / 2;
    }
    .nav-btn:nth-child(5) {
        grid-column: 2 / 4;
    }

    .panel {
        padding: 12px;
        border-radius: var(--radius-md);
    }

    .panel h2 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }

    .panel h3 {
        font-size: 1rem;
        margin: 16px 0 10px;
    }

    .help-text {
        font-size: 0.85rem;
        margin-bottom: 12px;
    }

    /* Post options grid - horizontal on mobile */
    .post-options-grid {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .post-options-grid .form-group {
        margin-bottom: 0;
        flex: 1 1 auto;
        min-width: 0;
    }

    .post-options-grid .form-group:first-child {
        flex: 1 1 100%;
    }

    .checkbox-label.compact {
        padding: 10px 12px;
        background: var(--bg-tertiary);
        border-radius: var(--radius-sm);
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    /* Platforms grid - single column on mobile */
    .platforms-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .platform-card {
        padding: 10px;
    }

    .platform-header {
        margin-bottom: 8px;
    }

    .platform-name {
        font-size: 0.9rem;
    }

    .platform-target {
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    /* Schedule options */
    .schedule-options {
        padding: 10px;
        margin-bottom: 12px;
    }

    .schedule-label {
        font-size: 0.9rem;
        margin-bottom: 8px;
    }

    .schedule-presets {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        margin-bottom: 12px;
    }

    .schedule-presets .preset-btn {
        padding: 10px 8px;
        font-size: 0.75rem;
        text-align: center;
    }

    .schedule-date-row {
        flex-direction: row;
        gap: 8px;
    }

    .schedule-field {
        flex: 1;
    }

    .schedule-field label {
        font-size: 0.75rem;
    }

    .schedule-input {
        font-size: 16px;
        padding: 8px 10px;
    }

    .schedule-custom {
        padding: 10px;
    }

    /* Scheduled posts */
    .scheduled-section {
        margin-top: 20px;
        padding-top: 16px;
    }

    .scheduled-header {
        margin-bottom: 10px;
    }

    .scheduled-header h3 {
        font-size: 0.95rem;
        margin: 0;
    }

    .badge {
        font-size: 0.75rem;
        padding: 2px 8px;
    }

    .scheduled-post-card {
        padding: 10px;
    }

    .scheduled-post-header {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        margin-bottom: 8px;
    }

    .scheduled-time {
        font-size: 0.8rem;
    }

    .scheduled-platforms {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    .scheduled-photos-preview {
        gap: 4px;
        margin-bottom: 8px;
    }

    .scheduled-thumb,
    .more-photos {
        width: 44px;
        height: 44px;
    }

    .more-photos {
        font-size: 0.75rem;
    }

    .scheduled-text {
        font-size: 0.85rem;
        margin-bottom: 6px;
    }

    .scheduled-photos,
    .scheduled-tags {
        font-size: 0.75rem;
    }

    .scheduled-post-actions {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .scheduled-post-actions .btn {
        padding: 8px 4px;
        font-size: 0.75rem;
        justify-content: center;
    }

    /* Archive section */
    .archive-section {
        margin-top: 16px;
        padding-top: 14px;
    }

    .archive-header h3 {
        font-size: 0.9rem;
    }

    .archive-post-card {
        padding: 8px 10px;
    }

    .archive-thumb {
        width: 32px;
        height: 32px;
    }

    .archive-text {
        font-size: 0.8rem;
    }

    /* Photos preview */
    .photos-preview {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        padding: 12px;
        min-height: 80px;
    }

    .preview-thumb {
        width: 56px;
        height: 56px;
    }

    /* Upload area */
    .upload-area {
        flex-direction: column;
        padding: 12px;
        gap: 8px;
        text-align: center;
    }

    .upload-area .hint {
        font-size: 0.75rem;
    }

    .uploaded-preview {
        margin-top: 6px;
    }

    .uploaded-item {
        width: 60px;
        height: 60px;
    }

    /* Text editor */
    .text-editor textarea {
        min-height: 80px;
        padding: 10px;
        font-size: 16px;
    }

    .editor-toolbar {
        padding: 6px;
        gap: 2px;
    }

    .toolbar-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .toolbar-separator {
        margin: 0 2px;
    }

    /* Tags */
    .tags-container {
        padding: 6px;
    }

    .tag-chip {
        font-size: 0.75rem;
        padding: 3px 6px;
    }

    .tags-input {
        font-size: 16px !important;
        padding: 6px !important;
    }

    .tags-presets {
        flex-wrap: wrap;
        gap: 4px;
        margin-top: 6px;
    }

    .tags-presets-label {
        font-size: 0.7rem;
        width: 100%;
    }

    .tag-preset {
        padding: 4px 8px;
        font-size: 0.7rem;
    }

    .preset-add-btn,
    .preset-manage-btn {
        width: 24px;
        height: 24px;
        font-size: 14px;
    }

    /* Form elements */
    .form-group {
        margin-bottom: 12px;
    }

    .form-group label {
        font-size: 0.85rem;
        margin-bottom: 4px;
    }

    input[type="text"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px;
        padding: 10px 12px;
    }

    .hint {
        font-size: 0.75rem;
        margin-top: 4px;
    }

    /* Buttons */
    .btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .btn-small {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .btn-large {
        padding: 14px 20px;
        font-size: 0.95rem;
    }

    .post-actions {
        gap: 8px;
        margin-bottom: 16px;
    }

    .post-actions .btn {
        flex: 1;
    }

    /* Gallery */
    .gallery-header {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 12px;
    }

    .gallery-header h2 {
        font-size: 1.1rem;
        margin: 0;
    }

    .gallery-toolbar {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }

    .toolbar-search {
        flex: 1;
        min-width: 120px;
    }

    .toolbar-search input {
        padding: 8px 10px;
    }

    #btn-load-albums {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .albums-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .album-card-overlay {
        padding: 8px;
    }

    .album-card-title {
        font-size: 0.75rem;
    }

    .album-card-count {
        font-size: 0.6rem;
    }

    .photo-gallery {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }

    .photo-item .checkbox {
        width: 22px;
        height: 22px;
        top: 4px;
        left: 4px;
    }

    .photo-item .title {
        padding: 6px 8px;
        font-size: 0.65rem;
    }

    /* Breadcrumb */
    .breadcrumb {
        flex-wrap: wrap;
        gap: 4px;
    }

    #btn-back-to-albums {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    .breadcrumb-current {
        font-size: 0.85rem;
    }

    .photos-count {
        font-size: 0.75rem;
    }

    #btn-download-album {
        font-size: 0.75rem;
        padding: 6px 10px;
    }

    /* Pagination */
    .pagination {
        gap: 8px;
        margin-top: 12px;
    }

    #page-info {
        font-size: 0.85rem;
    }

    /* Floating action bar - compact horizontal */
    .floating-action-bar {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 12px;
        bottom: 8px;
        left: 8px;
        right: 8px;
        border-radius: 16px;
    }

    .action-bar-left {
        padding-right: 10px;
        border-right: 1px solid var(--divider);
        flex-shrink: 0;
    }

    .selection-count {
        font-size: 1.1rem;
    }

    .selection-label {
        font-size: 0.7rem;
    }

    .action-bar-center,
    .action-bar-right {
        display: flex;
        gap: 4px;
    }

    .action-btn {
        padding: 8px;
        flex-direction: row;
        gap: 0;
    }

    .action-icon {
        font-size: 1.2rem;
    }

    .action-text {
        display: none;
    }

    /* Settings sections */
    .settings-section {
        padding-bottom: 16px;
        margin-bottom: 16px;
    }

    .settings-section h3 {
        font-size: 0.95rem;
    }

    /* Status badges */
    .status {
        padding: 4px 10px;
        font-size: 0.75rem;
    }

    /* Modal */
    .modal-content {
        margin: 8px;
        max-height: calc(100vh - 16px);
        width: calc(100% - 16px);
    }

    .modal-header {
        padding: 12px 16px;
    }

    .modal-header h3 {
        font-size: 1rem;
    }

    .modal-body {
        padding: 16px;
    }

    /* Drag hint */
    .drag-hint {
        font-size: 0.75rem;
        margin: 6px 0 12px;
    }

    /* Lightbox mobile */
    .lightbox-image-container {
        max-width: 95vw;
        max-height: 60vh;
    }

    .lightbox-image {
        max-height: 60vh;
    }

    /* Converter */
    .converter-input-section,
    .converter-text-section {
        gap: 10px;
    }

    .output-actions {
        flex-wrap: wrap;
        gap: 6px;
    }

    .output-actions .btn {
        flex: 1 1 auto;
        min-width: 100px;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .app-container {
        padding: 6px;
    }

    .app-header {
        padding: 8px 10px;
    }

    .app-header h1 {
        font-size: 1rem;
    }

    .main-nav {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
    }

    /* Adjust nav buttons for 2-column grid */
    .nav-btn:nth-child(5) {
        grid-column: 1 / 3;
    }

    .nav-btn {
        padding: 10px 4px;
        font-size: 0.7rem;
    }

    .panel {
        padding: 10px;
    }

    .panel h2 {
        font-size: 1rem;
    }

    .albums-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .photo-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
    }

    .scheduled-thumb,
    .more-photos {
        width: 40px;
        height: 40px;
    }

    .scheduled-post-actions {
        grid-template-columns: repeat(2, 1fr);
    }

    .scheduled-post-actions .btn:last-child {
        grid-column: 1 / 3;
    }

    .floating-action-bar {
        padding: 8px 10px;
    }

    .action-bar-left {
        padding-right: 8px;
    }

    .selection-count {
        font-size: 1rem;
    }

    .action-icon {
        font-size: 1.1rem;
    }

    .action-btn {
        padding: 6px;
    }
}

/* Extra small phones */
@media (max-width: 360px) {
    .app-header h1 {
        font-size: 0.9rem;
    }

    .nav-btn {
        font-size: 0.65rem;
        padding: 8px 2px;
    }

    .panel {
        padding: 8px;
    }

    .btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .photo-gallery {
        gap: 3px;
    }
}

/* Touch devices optimization */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .nav-btn,
    .action-btn,
    .toolbar-btn {
        min-height: 44px;
    }

    .album-card:hover,
    .photo-item:hover {
        transform: none;
    }

    /* Remove hover shadows on touch */
    .album-card:hover,
    .platform-card:hover {
        box-shadow: var(--glass-shadow);
    }

    /* Better touch targets */
    .photo-item .checkbox {
        width: 28px;
        height: 28px;
    }

    .platform-checkbox .checkmark {
        width: 28px;
        height: 28px;
    }

    /* Visible preview button on touch */
    .photo-preview-btn {
        opacity: 0.8;
    }
}

/* Landscape phones */
@media (max-width: 768px) and (orientation: landscape) {
    .main-nav {
        grid-template-columns: repeat(5, 1fr);
    }

    .nav-btn:nth-child(4),
    .nav-btn:nth-child(5) {
        grid-column: auto;
    }

    .floating-action-bar {
        bottom: 6px;
        padding: 8px 16px;
    }

    .photo-gallery {
        grid-template-columns: repeat(4, 1fr);
    }

    .albums-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .lightbox-image-container {
        max-height: 80vh;
    }

    .lightbox-image {
        max-height: 75vh;
    }
}

/* ============ Digital Badge Tab ============ */
.badge-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 8px;
}

.badge-item {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.badge-item:hover {
    transform: translateY(-2px);
}

.badge-item.active {
    border-color: #007AFF;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.18);
}

.badge-item .badge-item-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.badge-item .badge-item-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.badge-item:hover .badge-item-remove {
    opacity: 1;
}

/* Touch devices: always-visible controls (no hover state). */
@media (hover: none) {
    .badge-item .badge-item-remove,
    .badge-history-item .badge-history-actions {
        opacity: 1;
    }
    .badge-actions .btn,
    .badge-items-grid,
    .badge-history-grid {
        -webkit-tap-highlight-color: transparent;
    }
    .badge-items-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    /* Larger touch targets for action buttons. */
    .badge-history-item .badge-history-actions button {
        font-size: 13px;
        padding: 6px 10px;
    }
}

.badge-item .badge-item-badge-dot {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #34C759;
    box-shadow: 0 0 0 2px #fff;
    display: none;
}

.badge-item.has-extras .badge-item-badge-dot {
    display: block;
}

.badge-editor {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
}

.badge-editor.hidden,
#badge-batch-actions.hidden,
.badge-sub-options.hidden {
    display: none;
}

.badge-editor-layout {
    display: grid;
    grid-template-columns: minmax(280px, 480px) 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 800px) {
    .badge-editor-layout {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    /* Keep the canvas visible while the user scrolls down through the
       controls — sticky to the top of the viewport. The thumbnail shrinks
       to ~62vw so the controls below have room to breathe. */
    .badge-canvas-wrapper {
        position: sticky;
        top: 0;
        z-index: 20;
        background: var(--bg-secondary);
        padding: 8px 0 6px;
        margin: 0 -8px;
        border-bottom: 1px solid var(--border-color);
    }
    #badge-canvas {
        max-width: min(62vw, 320px);
    }
    .badge-canvas-hint {
        font-size: 0.78em;
    }
    .badge-controls {
        padding-top: 4px;
    }
    /* Stack form rows tightly on phones. */
    .badge-color-row {
        gap: 6px;
    }
    .badge-color-swatch {
        width: 32px;
        height: 32px;
    }
}

.badge-canvas-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

#badge-canvas {
    width: 100%;
    max-width: 480px;
    height: auto;
    aspect-ratio: 1 / 1;
    background:
        linear-gradient(45deg, #d8d8de 25%, transparent 25%) 0 0/16px 16px,
        linear-gradient(-45deg, #d8d8de 25%, transparent 25%) 0 8px/16px 16px,
        linear-gradient(45deg, transparent 75%, #d8d8de 75%) 8px -8px/16px 16px,
        linear-gradient(-45deg, transparent 75%, #d8d8de 75%) -8px 0/16px 16px,
        #f0f0f3;
    border-radius: 12px;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

[data-theme="dark"] #badge-canvas {
    background:
        linear-gradient(45deg, #2a2a2e 25%, transparent 25%) 0 0/16px 16px,
        linear-gradient(-45deg, #2a2a2e 25%, transparent 25%) 0 8px/16px 16px,
        linear-gradient(45deg, transparent 75%, #2a2a2e 75%) 8px -8px/16px 16px,
        linear-gradient(-45deg, transparent 75%, #2a2a2e 75%) -8px 0/16px 16px,
        #1c1c1e;
}

#badge-canvas:active {
    cursor: grabbing;
}

.badge-canvas-hint {
    font-size: 0.85em;
    color: var(--text-secondary);
    text-align: center;
}

.badge-controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.badge-controls .form-group {
    margin-bottom: 8px;
}

.badge-controls input[type="range"] {
    width: 100%;
    accent-color: #007AFF;
}

.badge-radio-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 4px;
}

.radio-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.92em;
    color: var(--text-primary);
}

.radio-label input[type="radio"] {
    accent-color: #007AFF;
    cursor: pointer;
}

.badge-sub-options {
    padding-left: 22px;
    margin-top: 6px;
}

.badge-color-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
}

.badge-color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    padding: 0;
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1) inset;
    transition: transform 0.12s ease, border-color 0.12s ease;
}

.badge-color-swatch:hover {
    transform: scale(1.08);
}

.badge-color-swatch.active {
    border-color: #007AFF;
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.25);
}

.badge-color-row input[type="color"] {
    width: 36px;
    height: 30px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    padding: 2px;
}

.badge-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 8px;
}

.badge-history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 8px;
}

.badge-history-item {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.badge-history-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.badge-history-item .badge-history-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 6px 8px;
    background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,0.55));
    opacity: 0;
    transition: opacity 0.15s ease;
}

.badge-history-item:hover .badge-history-actions {
    opacity: 1;
}

.badge-history-item .badge-history-actions button {
    border: none;
    background: rgba(255,255,255,0.92);
    color: #1c1c1e;
    border-radius: 8px;
    font-size: 12px;
    padding: 4px 8px;
    cursor: pointer;
}

.badge-history-item .badge-history-actions button.danger {
    background: rgba(255, 59, 48, 0.92);
    color: #fff;
}

.badge-history-item .badge-history-date {
    position: absolute;
    top: 6px;
    left: 6px;
    font-size: 10px;
    color: #fff;
    background: rgba(0,0,0,0.5);
    padding: 2px 6px;
    border-radius: 6px;
}
