/* =============================================
   Story Planner — Global Styles
   Mobile-first approach
   ============================================= */

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #1877f2;
    --primary-dark: #1565c0;
    --success: #2e7d32;
    --danger: #c62828;
    --warning: #f57c00;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --transition: 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--gray-900);
    background: var(--gray-100);
    -webkit-font-smoothing: antialiased;
}

/* --- Sticky Header Container --- */
.app-header-sticky {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #fff;
    box-shadow: var(--shadow);
}

/* --- Global Update Banner --- */
.app-update-banner {
    background: var(--primary);
    color: #fff;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
    font-size: 14px;
}

.app-update-banner[hidden] {
    display: none;
}

.app-update-banner-text {
    font-weight: 600;
}

.app-update-banner .btn-primary {
    background: #fff;
    color: var(--primary);
    border-color: #fff;
}

.app-update-banner .btn-primary:hover {
    background: var(--gray-100);
    color: var(--primary-dark);
}

/* --- Navigation --- */
.nav {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: relative;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-mobile-switcher {
    flex: 1;
    min-width: 0;
    padding: 0 8px 0 12px;
}

.nav-logo {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.nav-title {
    font-weight: 600;
    font-size: 17px;
    color: var(--gray-900);
}

/* Hamburger */
.nav-toggle {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--gray-700);
    border-radius: 2px;
    transition: var(--transition);
}

.nav-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

/* Mobile menu */
.nav-menu {
    list-style: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    display: none;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.nav-menu.open {
    display: flex;
}

.nav-menu a {
    display: block;
    padding: 14px 7px;
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid var(--gray-100);
    transition: var(--transition);
}

.nav-menu a:hover,
.nav-menu a.active {
    color: var(--primary);
    background: var(--gray-50);
}

.nav-menu a.active {
    border-left: 3px solid var(--primary);
}

/* Desktop nav */
@media (min-width: 768px) {
    .nav {
        padding: 0 24px;
        justify-content: flex-start;
        gap: 12px;
    }

    .nav-toggle { display: none; }

    .nav-mobile-switcher {
        display: none;
    }

    .nav-menu {
        display: flex !important;
        position: static;
        flex-direction: row;
        border: none;
        box-shadow: none;
        gap: 4px;
        margin-left: auto;
    }

    .nav-menu a {
        padding: 16px 16px;
        border: none;
        border-radius: var(--radius);
        font-size: 14px;
    }

    .nav-menu a.active {
        border-left: none;
        background: rgba(24, 119, 242, 0.08);
    }

    .has-dropdown {
        position: relative;
    }

    .dropdown-menu {
        position: absolute;
        top: 100%;
        left: 0;
        background: #fff;
        min-width: 180px;
        box-shadow: var(--shadow-lg);
        border-radius: var(--radius);
        display: none;
        flex-direction: column;
        padding: 8px 0;
        z-index: 200;
    }

    .has-dropdown:hover .dropdown-menu,
    .has-dropdown:focus-within .dropdown-menu {
        display: flex;
    }

    .dropdown-menu li {
        list-style: none;
    }

    .dropdown-menu a {
        padding: 10px 20px;
        border-radius: 0;
        font-size: 14px;
    }

    .dropdown-menu a:hover {
        background: var(--gray-50);
    }
}

/* Mobile dropdown styles */
@media (max-width: 767px) {
    .has-dropdown .dropdown-menu {
        display: none;
        flex-direction: column;
        background: var(--gray-50);
        padding-left: 20px;
    }
    
    .has-dropdown:hover .dropdown-menu,
    .has-dropdown:focus-within .dropdown-menu {
        display: flex;
    }
    
    .has-dropdown .dropdown-menu a {
        border-left: 2px solid var(--gray-200);
        padding: 12px 20px;
    }
}

.has-dropdown .caret {
    font-size: 10px;
    margin-left: 4px;
    vertical-align: middle;
}


/* --- Main content --- */
.main {
    padding: 24px 24px 150px 24px;
    max-width: 1200px;
    margin: 0 auto;
}


/* --- Card --- */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.card-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--gray-900);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border: 1px solid var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { opacity: 0.9; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { opacity: 0.9; }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}
.btn-outline:hover {
    background: rgba(24, 119, 242, 0.05);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
#calendarNowButton {
    border-color: #fff;
}
#calendarNowButton:hover {
     border-color: var(--shadow);
 }
/* --- Forms --- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 2px 6px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--gray-900);
    background: #fff;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.15);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 25px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-details {
    margin-bottom: 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--gray-50);
    padding: 10px 12px 0;
}

.form-details summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 10px;
}

.form-hint {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

/* Switcher component */
.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    font-weight: 500;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.switch-slider {
    position: relative;
    width: 40px;
    height: 22px;
    background-color: var(--gray-300);
    transition: var(--transition);
    border-radius: 22px;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.switch input:checked + .switch-slider {
    background-color: var(--primary);
}

.switch input:focus + .switch-slider {
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.15);
}

.switch input:checked + .switch-slider:before {
    transform: translateX(18px);
}

.switch-label {
    color: var(--gray-800);
}

.wizard-shell {
    display: grid;
    gap: 16px;
}

.business-edit-grid {
    display: grid;
    gap: 16px;
}

.business-edit-card {
    display: grid;
    align-content: start;
    gap: 16px;
}

.business-edit-card .card-header {
    margin-bottom: 0;
}

.business-edit-subtitle {
    margin-top: 4px;
    font-size: 12px;
    color: var(--gray-600);
}

.business-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.business-edit-result {
    min-height: 1px;
}

.wizard-manager-list {
    display: grid;
    gap: 10px;
}

.wizard-manager-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: #fff;
    padding: 12px;
}

.wizard-step {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    background: var(--gray-50);
}

.wizard-step-folded .wizard-instructions,
.wizard-step-folded .wizard-grid,
.wizard-step-folded #wizardBusinessCheckResult,
.wizard-step-folded .wizard-import-row,
.wizard-step-folded #wizardImportResult,
.wizard-step-folded #wizardAssetCheckResult,
.wizard-step-folded #wizardAssetList {
    display: none !important;
}

.wizard-step-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.wizard-step-kicker {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--primary);
    margin-bottom: 4px;
}

.wizard-step-title {
    font-size: 18px;
    font-weight: 600;
}

.wizard-step-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.wizard-step-actions-end {
    margin-top: 16px;
    justify-content: flex-end;
}

.wizard-instructions {
    margin-bottom: 16px;
    font-size: 14px;
}

.wizard-instructions p {
    font-weight: 600;
    margin-bottom: 8px;
}

.wizard-instructions ol {
    padding-left: 18px;
}

.wizard-instructions li + li {
    margin-top: 4px;
}

.wizard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.wizard-grid-span-2 {
    grid-column: span 1;
}

.wizard-import-row {
    max-width: 320px;
}

.wizard-check-list {
    display: grid;
    gap: 12px;
}

.wizard-check-item {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: #fff;
    padding: 12px;
}

.wizard-asset-groups {
    display: grid;
    gap: 16px;
}

.wizard-asset-group {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 12px;
}

.wizard-asset-group h3 {
    font-size: 15px;
    margin-bottom: 10px;
}

.wizard-asset-list {
    display: grid;
    gap: 10px;
}

.wizard-asset-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.wizard-asset-item input {
    margin-top: 3px;
}

.wizard-asset-meta {
    display: grid;
    gap: 4px;
}

.wizard-asset-subline {
    font-size: 12px;
    color: var(--gray-600);
}

@media (min-width: 768px) {
    .business-edit-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: stretch;
    }

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

    .wizard-grid-span-2 {
        grid-column: span 2;
    }
}

/* --- Planner --- */
#plannerPostsList {
    transition: max-height 0.8s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease;
    overflow: hidden;
    max-height: 5000px;
}

#plannerPostsList.slid-up {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    margin-bottom: 0;
}

.planner-status-card {
    text-align: center;
    padding: 40px 24px;
    animation: plannerCardFadeIn 0.5s ease forwards;
}

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

.planner-status-card__icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.planner-status-card__title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
}

.planner-status-card__text {
    color: var(--gray-600);
    max-width: 480px;
    margin: 0 auto 24px;
    font-size: 15px;
}

.planner-status-card .publish-progress-track {
    margin: 0 auto 12px;
    max-width: 400px;
    height: 10px;
    background: var(--gray-200);
    border-radius: 5px;
}

.planner-status-card .publish-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 5px;
    transition: width 0.3s ease;
}

.planner-status-card .publish-progress-meta {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
}

.planner-status-card__footer,
.planner-status-card__error-footer {
    margin-top: 32px;
    display: flex;
    justify-content: center;
    gap: 12px;
}

.planner-status-card.status-completed .publish-progress-bar {
    background: var(--success);
}

.planner-status-card.status-failed .publish-progress-bar {
    background: var(--danger);
}

/*   Planner — specific styles */
/* --- Table --- */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    font-size: 14px;
}

th {
    font-weight: 600;
    color: var(--gray-600);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:hover td { background: var(--gray-50); }

/* --- Badges / Status --- */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-pending   { background: #fff3e0; color: #e65100; }
.badge-retry     { background: #fff8e1; color: #ef6c00; }
.badge-published { background: #e8f5e9; color: #2e7d32; }
.badge-failed    { background: #ffebee; color: #c62828; }
.badge-error     { background: #ffebee; color: #c62828; }
.badge-cancelled { background: var(--gray-200); color: var(--gray-600); }

.badge-facebook  { background: #e3f2fd; color: #1565c0; text-transform: none; letter-spacing: normal; font-size: 13px; font-weight: 500; }
.badge-instagram { background: #fce4ec; color: #c2185b; text-transform: none; letter-spacing: normal; font-size: 13px; font-weight: 500; }

/* --- Alert / Toast --- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.alert-danger  { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }
.alert-warning { background: #fff3e0; color: #e65100; border: 1px solid #ffe0b2; }
.alert-info    { background: #e3f2fd; color: #1565c0; border: 1px solid #bbdefb; }

/* Toast notification */
.toast {
    position: fixed;
    top: 84px;
    right: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 280px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 14px 16px;
    border-radius: var(--radius);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transform: translateY(-16px);
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-message {
    flex: 1;
    line-height: 1.45;
}

.toast-close {
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
}

.toast-close:hover {
    color: #fff;
}

.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-warning { background: var(--warning); }

@media (max-width: 768px) {
    .toast {
        top: 72px;
        right: 12px;
        left: 12px;
        max-width: none;
        min-width: 0;
    }
}

/* --- Upload area --- */
.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--gray-500);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(24, 119, 242, 0.03);
    color: var(--primary);
}

.upload-area .upload-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.upload-area .upload-text {
    font-size: 14px;
}

.post-media-split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.post-media-slot {
    min-height: 190px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.post-media-preview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.post-media-preview-card {
    min-height: 180px;
}

#postVideoPreview,
#postCoverPreview {
    min-height: 100px;
}

@media (max-width: 768px) {
    .post-media-split,
    .post-media-preview-grid {
        grid-template-columns: 1fr;
    }
}

.upload-preview {
    margin-top: 16px;
}

.upload-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--radius);
    object-fit: cover;
}

/* --- Modal --- */
.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: 3000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: var(--transition);
}

.modal-overlay.open .modal {
    transform: translateY(0);
}

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

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-500);
    padding: 4px;
    line-height: 1;
}

.modal-footer {
    margin-top: 20px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* --- Stat cards (Dashboard) --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

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

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-label {
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* --- Empty state --- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-500);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

/* --- Loading spinner --- */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* --- Utilities --- */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--gray-500); }
.text-sm     { font-size: 13px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex  { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }

/* =============================================
   Planner — specific styles
   ============================================= */

/* --- Mode tabs --- */
.mode-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--gray-200);
    padding-bottom: 0;
}

.mode-tab {
    padding: 10px 16px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
}

.mode-tab:hover { color: var(--gray-700); }

.mode-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* --- Mode panels --- */
.mode-panel {
    display: none;
    padding-top: 4px;
}

.mode-panel.active {
    display: block;
}

.info-tabs {
    margin-bottom: 24px;
}

.info-panel {
    display: none;
}

.info-panel.active {
    display: block;
}

.info-phpinfo,
.info-server {
    overflow-x: auto;
}

.info-phpinfo-frame {
    display: block;
    width: 100%;
    min-height: 85vh;
    border: 0;
    background: #fff;
}

.info-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.info-subtitle {
    margin: 6px 0 0;
    color: var(--gray-500);
}

.info-version-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.1);
    color: #15803d;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.changelog-timeline {
    position: relative;
    padding-left: 28px;
}

.changelog-timeline::before {
    content: '';
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: 7px;
    width: 2px;
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.45), rgba(148, 163, 184, 0.18));
}

.info-server-wrap {
    overflow-x: auto;
}

.info-server-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.info-server-table th,
.info-server-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: top;
    text-align: left;
}

.info-server-table th {
    width: 260px;
    font-weight: 700;
    color: var(--gray-700);
    background: #f8fafc;
    white-space: nowrap;
}

.info-server-table td {
    word-break: break-word;
}

.info-server-list {
    margin: 0;
    padding-left: 18px;
}

.info-server-list li + li {
    margin-top: 4px;
}

.changelog-item {
    position: relative;
    padding-bottom: 24px;
}

.changelog-item:last-child {
    padding-bottom: 0;
}

.changelog-dot {
    position: absolute;
    top: 8px;
    left: -28px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #eff6ff;
    border: 4px solid #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.changelog-content {
    padding: 2px 0 0;
}

.changelog-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.changelog-head h3 {
    margin: 0;
    font-size: 28px;
    line-height: 1.1;
}

.changelog-head span {
    color: var(--gray-500);
    font-size: 14px;
    font-weight: 600;
}

.changelog-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.changelog-list li {
    position: relative;
    padding-left: 18px;
    margin-bottom: 10px;
    color: var(--gray-700);
    line-height: 1.55;
}

.changelog-list li:last-child {
    margin-bottom: 0;
}

.changelog-list li::before {
    content: '↗';
    position: absolute;
    left: 0;
    top: 0;
    color: #3b82f6;
    font-weight: 700;
}

.info-readme h1,
.info-readme h2,
.info-readme h3 {
    margin-top: 0;
    margin-bottom: 12px;
}

.info-readme h2,
.info-readme h3 {
    margin-top: 20px;
}

.info-readme p {
    margin: 0 0 12px;
    line-height: 1.6;
    color: var(--gray-700);
}

.info-readme ul {
    margin: 0 0 14px 18px;
    color: var(--gray-700);
}

.info-readme li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.info-readme code {
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--gray-100);
    font-size: 12px;
}

.media-source-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.media-source-tab {
    border: 1px solid var(--gray-300);
    background: #fff;
    color: var(--gray-700);
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 600;
    cursor: pointer;
}

.media-source-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.media-source-panel.hidden {
    display: none;
}

.gallery-selection-summary {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    color: var(--gray-700);
    font-size: 14px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.gallery-grid.dragover {
    outline: 2px dashed var(--primary);
    outline-offset: 6px;
    border-radius: 14px;
    background: rgba(24, 119, 242, 0.04);
}

.gallery-view-switch {
    display: flex;
    align-items: center;
    gap: 0;
}

.gallery-zoom-switch {
    display: flex;
    align-items: center;
    gap: 0;
}

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

.gallery-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.gallery-folder-shell {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gallery-folder-bar {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.gallery-folder-bar-side {
    display: flex;
    align-items: center;
    gap: 8px;
}


.gallery-folder-bar-side-right {
    justify-content: flex-end;
}

.gallery-folder-select,
.gallery-bulk-action-select {
    min-width: 190px;
}

#galleryBulkApplyBtn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.gallery-folder-meta {
    line-height: 1.3;
}

.gallery-folder-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 999px;
    background: #fff;
    color: var(--gray-800);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}

.gallery-folder-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.gallery-folder-pill.is-active {
    background: rgba(24, 119, 242, 0.08);
    border-color: rgba(24, 119, 242, 0.35);
    color: var(--primary);
    box-shadow: 0 0 0 1px rgba(24, 119, 242, 0.08);
}

.gallery-folder-pill-icon {
    width: 16px;
    height: 16px;
    display: block;
}

.gallery-folder-pill-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--gray-100);
    color: var(--gray-700);
    font-size: 11px;
    font-weight: 700;
}

.gallery-sort-select {
    width: auto;
    min-width: 170px;
}

.gallery-view-switch .btn {
    border-radius: 0;
}

.gallery-zoom-switch .btn {
    border-radius: 0;
}

.gallery-zoom-switch .btn + .btn {
    margin-left: -1px;
}

.gallery-view-switch .btn:first-child {
    border-top-left-radius: var(--radius);
    border-bottom-left-radius: var(--radius);
}

.gallery-view-switch .btn:last-child {
    border-top-right-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.gallery-zoom-switch .btn:first-child {
    border-top-left-radius: var(--radius);
    border-bottom-left-radius: var(--radius);
}

.gallery-zoom-switch .btn:last-child {
    border-top-right-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

#galleryGrid {
    --gallery-card-min-width: 180px;
    --gallery-preview-size: 84px;
    --gallery-card-padding: 10px;
}

#galleryGrid {
    grid-template-columns: repeat(auto-fill, minmax(var(--gallery-card-min-width, 180px), 1fr));
    min-height: 180px;
}

#postMediaPickerModal .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.gallery-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
    padding: 10px;
    border: 1px solid transparent;
    border-radius: 16px;
    background: #fff;
    cursor: pointer;
    box-shadow: var(--shadow);
}

#postMediaPickerModal .gallery-card {
    padding: 8px;
    gap: 8px;
    border-radius: 12px;
}

#galleryGrid .gallery-card {
    padding: 0;
    gap: 0;
    overflow: hidden;
}

.gallery-card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.18);
}

.gallery-card-check {
    position: absolute;
    bottom: 4px;
    left: 5px;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
}

.gallery-card-checkbox {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.gallery-card-manage {
    cursor: pointer;
}

.gallery-card-preview {
    --gallery-kind-icon-size: 28px;
    --gallery-kind-icon-offset: 6px;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 0 10px 10px 10px;
    background: var(--gray-100);
    position: relative;
    overflow: hidden;
}

#galleryGrid .gallery-card-preview {
    aspect-ratio: 4 / 5;
    height: auto;
    border-radius: 0;
}

#postMediaPickerModal .gallery-card-preview {
    --gallery-kind-icon-size: 24px;
    --gallery-kind-icon-offset: 6px;
    aspect-ratio: 1 / 1;
    max-height: 84px;
    border-radius: 0 8px 8px 8px;
}

.gallery-card-preview-video {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    color: var(--gray-700);
    background: linear-gradient(135deg, var(--gray-100), #fff);
    /*border: 1px dashed var(--gray-300);*/
    font-weight: 700;
    position: relative;
}

.gallery-card-preview-video-cover {
    position: relative;
    overflow: hidden;
    /*background: #000;*/
    /*border: 1px solid rgba(255, 255, 255, 0.08);*/
}

.gallery-card-preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-card-kind-icon {
    position: absolute;
    top: var(--gallery-kind-icon-offset);
    left: calc(var(--gallery-kind-icon-offset) + 2px);
    z-index: 2;
    width: var(--gallery-kind-icon-size);
    height: var(--gallery-kind-icon-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.46);
    backdrop-filter: blur(6px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    padding: 0;
    border: 0;
    cursor: pointer;
}

.gallery-card-kind-icon-video {
    border-radius: 999px;
}

.gallery-card-kind-icon-image {
    border-radius: 8px;
}

.gallery-card-kind-icon-svg {
    width: calc(var(--gallery-kind-icon-size) - 10px);
    height: calc(var(--gallery-kind-icon-size) - 10px);
    object-fit: contain;
    display: block;
    filter: brightness(0) invert(1);
    pointer-events: none;
}

#galleryGrid .gallery-card-preview-video {
    min-height: calc(var(--gallery-preview-size, 84px) * 1.25);
}

#postMediaPickerModal .gallery-card-preview-video {
    gap: 4px;
    min-height: 84px;
    font-size: 12px;
}

.gallery-video-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(24, 119, 242, 0.12);
    color: var(--primary);
    font-size: 18px;
}

.gallery-video-label {
    font-size: 12px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.gallery-card-preview-take-cover-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    left: auto;
    z-index: 3;
    width: 26px;
    height: 26px;
    min-width: 26px;
    padding: 0;
    border-radius: 999px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 12px;
}

.gallery-card-preview-take-cover-btn.is-loading {
    background: rgba(24, 119, 242, 0.95);
    color: #fff;
}

.gallery-take-cover-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 12px;
}

.gallery-take-cover-spinner {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    animation: gallery-spin 0.8s linear infinite;
}

@keyframes gallery-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.gallery-card-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

#postMediaPickerModal .gallery-card-meta {
    gap: 4px;
}

#galleryGrid .gallery-card-meta {
    flex: 1 1 auto;
    padding: 5px 9px;
    line-height: 1;
}

#galleryGrid .gallery-card-name {
    align-items: flex-start;
}

.gallery-card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
    display: flex;
    flex-direction: column; /* Змінюємо на колонку для надійності */
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
}

#postMediaPickerModal .gallery-card-name {
    font-size: 12px;
    gap: 4px;
}

.gallery-card-last-used {
    display: block;
    font-size: 10px;
    font-weight: 500;
    color: white;
    margin-top: 1px;
    background: var(--gray-400);
    white-space: nowrap;
    padding: 1px 3px 3px 3px;
    border-radius: 2px;
}

.gallery-last-used-icon {
    width: 10px;
    height: 10px;
    display: inline-block;
    vertical-align: -1px;
    filter: brightness(0) invert(1);
}

.gallery-card-last-used-old {
    background: #a00 !important; /* Dark Red */
}

.gallery-card-last-used-future {
    background: #bbdbbb !important; /* Pale Green */
    color: #060 !important; /* Dark Green text */
}

.gallery-card-last-used-future .gallery-last-used-icon {
    filter: brightness(0) saturate(100%) invert(20%) sepia(90%) hue-rotate(100deg) brightness(90%) contrast(100%);
}

.gallery-card-name span,
.gallery-card-name-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

.gallery-card-resolution {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-500);
    line-height: 1.2;
}

.gallery-card-size {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-500);
    line-height: 1.2;
    margin-top: auto;
    align-self: stretch;
    text-align: right;
}

.gallery-card-action {
    display: inline-flex;
    align-self: flex-start;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--gray-100);
    color: var(--gray-700);
    font-size: 11px;
    font-weight: 600;
}

#postMediaPickerModal .gallery-card-action {
    padding: 3px 6px;
    font-size: 10px;
}

.gallery-modal-body {
    padding: 18px 24px;
}

.gallery-preview-modal {
    width: min(96vw, 980px);
    max-width: min(96vw, 980px);
    height: 96vh;
    max-height: 96vh;
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.gallery-preview-modal .modal-header {
    flex: 0 0 auto;
    margin-bottom: 12px;
}

.gallery-bulk-modal {
    width: min(92vw, 420px);
    max-width: min(92vw, 420px);
}

.gallery-bulk-modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px 24px 24px;
}

.gallery-bulk-modal-summary {
    line-height: 1.4;
}

.gallery-bulk-modal-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--gray-700);
}

.gallery-bulk-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.gallery-preview-header-copy {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.gallery-preview-toolbar.hidden {
    display: none;
}

.gallery-preview-folder-control {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--gray-700);
}

.gallery-preview-folder-select {
    min-width: 170px;
    height: 36px;
    padding-top: 6px;
    padding-bottom: 6px;
}

.gallery-preview-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.gallery-preview-frame {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.gallery-preview-stage {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-preview-image,
.gallery-preview-video {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 12px;
    background: #000;
    object-fit: contain;
}

.gallery-preview-video {
    width: 100%;
    height: 100%;
}

.gallery-preview-take-cover-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.gallery-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

#galleryGrid .gallery-card-actions {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    padding: 0;
}

#galleryGrid .gallery-card:hover .gallery-card-actions,
#galleryGrid .gallery-card:focus-within .gallery-card-actions {
    opacity: 1;
    pointer-events: auto;
}

#galleryGrid .gallery-card-delete-btn {
    background: #fff;
    color: var(--danger);
    border: 1px solid var(--danger);
    box-shadow: none;
}

#galleryGrid .gallery-card-delete-btn .btn-icon-image {
    filter: brightness(0) saturate(100%) invert(19%) sepia(82%) saturate(2047%) hue-rotate(340deg) brightness(88%) contrast(97%);
}

#galleryGrid .gallery-card-delete-btn:hover {
    background: var(--danger);
    color: #fff;
}

#galleryGrid .gallery-card-delete-btn:hover .btn-icon-image {
    filter: brightness(0) invert(1);
}

.upload-progress {
    margin-top: 12px;
}

.upload-debug {
    margin-top: 10px;
}

.upload-debug-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.upload-debug-details {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.upload-debug-details summary {
    cursor: pointer;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-muted);
    user-select: none;
}

.upload-debug-log {
    margin: 0;
    padding: 0 12px 12px;
    max-height: 220px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text);
    background: transparent;
}

@media (max-width: 640px) {
    .gallery-folder-bar-side-left,
    .gallery-folder-bar-side-right {
        flex: 1 1 100%;
        justify-content: stretch;
    }

    .gallery-folder-select,
    .gallery-bulk-action-select {
        min-width: 0;
        width: 100%;
    }

    .gallery-folder-bar-side-right .btn {
        width: 100%;
    }

    .gallery-preview-folder-control {
        flex-direction: column;
        align-items: stretch;
    }

    .gallery-preview-folder-select {
        min-width: 0;
        width: 100%;
    }
}

.planner-media-preview {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 120px;
}

.planner-preview-media {
    display: block;
    width: 100%;
    min-width: 100px;
    max-width: 180px;
    height: auto;
    border-radius: 10px;
    object-fit: cover;
    background: var(--gray-100);
}

.planner-video-preview-wrap {
    position: relative;
    display: inline-block;
}

.preview-remove-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.preview-remove-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* --- Image grid (multi-upload) --- */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.image-grid-item {
    position: relative;
    aspect-ratio: 9 / 16;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--gray-200);
    background: var(--gray-100);
    cursor: grab;
}

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

#postImageGrid .image-grid-item {
    aspect-ratio: auto;
}

#postImageGrid .image-grid-item img {
    display: block;
    height: auto;
    object-fit: contain;
}

.image-grid-item.is-dragging {
    opacity: 0;
    cursor: grabbing;
}

.image-grid-item.is-drop-target {
    outline: 2px dashed var(--primary);
    outline-offset: -4px;
}

.image-grid-num {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 4px;
}

.image-grid-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(198, 40, 40, 0.85);
    color: #fff;
    border: none;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-grid-remove:hover {
    background: var(--danger);
}

.image-grid-toggle {
    position: absolute;
    left: 4px;
    right: 4px;
    bottom: 24px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.2;
}

.image-grid-toggle input {
    margin: 0;
    flex: 0 0 auto;
}

.image-grid-toggle span {
    min-width: 0;
}

.planner-crop-modal {
    max-width: 520px;
}

.planner-crop-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.planner-crop-toolbar-side {
    display: flex;
    align-items: center;
    gap: 8px;
}

.planner-crop-toolbar-side-right {
    margin-left: auto;
}

.planner-crop-stage {
    position: relative;
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #101828;
}

.planner-crop-stage canvas {
    display: block;
    max-width: 100%;
    height: auto;
    touch-action: none;
}

.planner-crop-notice {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(17, 24, 39, 0.88);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 2;
}

.planner-crop-notice.show {
    opacity: 1;
    transform: translateY(0);
}

/* --- Calendar Picker (Mode B) --- */
.picker-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.picker-header {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    padding: 6px 0;
    text-transform: uppercase;
}

.picker-empty {
    padding: 8px;
}

.picker-day {
    text-align: center;
    padding: 8px 4px;
    font-size: 14px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.picker-day:hover {
    background: var(--gray-100);
}

.picker-past {
    color: var(--gray-400);
    cursor: default;
}

.picker-past:hover {
    background: transparent;
}

.picker-selected {
    background: var(--primary) !important;
    color: #fff !important;
    font-weight: 600;
}

/* --- Account checkbox list --- */
.account-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.account-check {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.account-check:hover {
    border-color: var(--primary);
    background: var(--gray-50);
}

.account-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.account-check input:checked ~ .account-check-info {
    color: var(--gray-900);
}

.account-check:has(input:checked) {
    border-color: var(--primary);
    background: #e3f2fd;
}

.account-check-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 14px;
    color: var(--gray-600);
}

.account-check-info strong {
    color: var(--gray-900);
}

/* --- Weekday selector (Mode C) --- */
.weekday-selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.weekday-btn {
    cursor: pointer;
    user-select: none;
}

.weekday-btn input {
    display: none;
}

.weekday-btn span {
    display: inline-block;
    padding: 8px 14px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    transition: var(--transition);
}

.weekday-btn input:checked + span {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.weekday-btn:hover span {
    border-color: var(--primary);
}

/* --- Mobile planner adjustments --- */
@media (max-width: 767px) {
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }

    .mode-tab {
        padding: 8px 10px;
        font-size: 13px;
    }

    .weekday-btn span {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* =============================================
   Shared extracted styles
   ============================================= */
.nav-brand {
    text-decoration: none;
}

.brand-stack {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.nav-brand-image {
    height: 32px;
    width: auto;
}

.app-version-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 14px;
    padding: 0 6px;
    border: 1px solid var(--gray-300);
    border-radius: 999px;
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.02em;
}

.form-hint-danger {
    color: var(--danger);
}

.btn-verify {
    background: #e3f2fd;
    color: #1565c0;
}

.btn-refresh {
    background: #e8f5e9;
    color: #2e7d32;
}

.btn-icon {
    width: 27px;
    height: 27px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-image {
    width: 18px;
    height: 18px;
    display: block;
}

.btn-danger .btn-icon-image {
    filter: brightness(0) invert(1);
}

.status-icon {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.status-icon-active {
    background: #e8f5e9;
}

.status-icon-inactive {
    background: var(--gray-200);
}

.status-icon-image {
    width: 16px;
    height: 16px;
    display: block;
}

.status-toggle-btn {
    border: 0;
    cursor: pointer;
    padding: 0;
}

.accounts-status-col {
    width: 1%;
    white-space: nowrap;
}

.accounts-actions-col {
    width: 1%;
    white-space: nowrap;
}

.text-success { color: var(--success); }
.font-semibold { font-weight: 600; }
.mb-20 { margin-bottom: 20px; }
.flex-1 { flex: 1; }
.w-80 { width: 80px; }
.w-150 { width: 150px; }
.w-200 { width: 200px; }
.max-w-320 { max-width: 320px; }
.modal-wide { max-width: 560px; }
.modal-wider { max-width: 600px; }

#postMediaPickerModal .modal {
    width: min(96vw, 1400px);
    max-width: none;
}

.table-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.post-preview-media-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 240px;
}

.post-preview-media-item {
    position: relative;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
}

.post-preview-media-item .table-thumb {
    width: 100%;
    height: 100%;
    display: block;
}

.post-preview-media-order {
    position: absolute;
    right: 2px;
    bottom: 2px;
    min-width: 14px;
    height: 14px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.76);
    color: #fff;
    font-size: 9px;
    line-height: 14px;
    text-align: center;
    font-weight: 700;
    padding: 0 3px;
    box-sizing: border-box;
}

.post-preview-media-kind {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.76);
    color: #fff;
    font-size: 8px;
    line-height: 14px;
    text-align: center;
    font-weight: 700;
}

.post-preview-media-video-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--gray-100), #fff);
    border: 1px dashed var(--gray-300);
    color: var(--gray-700);
    font-size: 12px;
    font-weight: 700;
}

.cal-list-media {
    display: block;
    flex: 0 0 auto;
    border-radius: 4px;
    background: var(--gray-100);
}

.cal-list-media-story {
    width: 40px;
    height: 72px;
    object-fit: cover;
}

.cal-list-media-post,
.cal-list-media-carousel {
    width: 40px;
    height: 40px;
    object-fit: cover;
}

.cal-list-media-video {
    width: 40px;
    height: 72px;
    align-items: center;
    justify-content: center;
}

.cal-list-media-video.cal-list-media-post,
.cal-list-media-video.cal-list-media-carousel {
    width: 40px;
    height: 40px;
}

.cal-activity-video-thumb {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    border: 1px dashed var(--gray-300);
    background: linear-gradient(135deg, var(--gray-100), #fff);
    color: var(--gray-700);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    padding: 3px;
    text-align: center;
}

.cal-activity-video-thumb.cal-list-media-story {
    width: 40px;
    height: 72px;
}

.cal-activity-video-thumb.cal-list-media-post,
.cal-activity-video-thumb.cal-list-media-carousel {
    width: 40px;
    height: 40px;
}

.cal-activity-video-thumb .gallery-video-icon {
    font-size: 10px;
    line-height: 1;
}

.cal-activity-video-thumb .gallery-video-label {
    font-size: 8px;
    line-height: 1;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.planner-media-preview {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 120px;
}

.platform-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: 8px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1;
    font-weight: 700;
    background: var(--gray-200);
    color: var(--gray-700);
    flex: 0 0 auto;
}

.platform-icon-instagram {
    background: rgba(225, 48, 108, 0.14);
    color: #c13584;
}

.platform-icon-facebook {
    background: rgba(24, 119, 242, 0.14);
    color: #1877f2;
}

.planner-media-video,
.planner-media-cover {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 6px;
    background: var(--gray-100);
    display: block;
}

.planner-media-video-placeholder,
.planner-preview-video-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 6px;
    background: linear-gradient(135deg, var(--gray-100), #fff);
    border: 1px dashed var(--gray-300);
    color: var(--gray-700);
    font-weight: 600;
}

.planner-preview-cover-note {
    font-size: 12px;
    color: var(--gray-600);
    text-align: center;
}

.publish-progress-stage {
    font-weight: 700;
    margin-bottom: 8px;
}

.publish-progress-track {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: var(--gray-200);
    overflow: hidden;
}

.publish-progress-bar {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), #7cc4ff);
    transition: width 0.2s ease;
}

.publish-progress-meta {
    margin-top: 8px;
    color: var(--gray-600);
    font-size: 13px;
}

.publish-progress-log {
    margin-top: 16px;
    display: grid;
    gap: 8px;
    max-height: 220px;
    overflow: auto;
}

.publish-progress-step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gray-700);
}

.publish-progress-step.done {
    color: var(--success);
}

.publish-progress-step.active {
    color: var(--primary-dark);
    font-weight: 600;
}

.publish-progress-launcher {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 180;
    border: 0;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    padding: 12px 18px;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    font-weight: 700;
}

.publish-progress-launcher:hover {
    background: var(--primary-dark);
}

.publish-job-banner {
    position: fixed;
    right: 20px;
    bottom: 76px;
    z-index: 179;
    width: min(420px, calc(100vw - 40px));
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(24, 119, 242, 0.18);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(8px);
}

.publish-job-banner-main {
    flex: 1;
    min-width: 0;
}

.publish-job-banner-title {
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 2px;
}

.publish-job-banner-meta {
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.publish-job-banner-track {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: var(--gray-200);
    overflow: hidden;
}

.publish-job-banner-bar {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), #7cc4ff);
    transition: width 0.2s ease;
}

.publish-job-banner-actions {
    flex: 0 0 auto;
}

.publish-job-items {
    margin-top: 16px;
    display: grid;
    gap: 10px;
    max-height: 280px;
    overflow: auto;
}

.publish-job-item {
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 12px 14px;
    background: var(--gray-50);
}

.publish-job-item.status-running {
    border-color: rgba(24, 119, 242, 0.35);
    background: rgba(24, 119, 242, 0.05);
}

.publish-job-item.status-done {
    border-color: rgba(46, 125, 50, 0.25);
    background: rgba(46, 125, 50, 0.05);
}

.publish-job-item.status-failed {
    border-color: rgba(198, 40, 40, 0.25);
    background: rgba(198, 40, 40, 0.05);
}

.publish-job-item-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--gray-900);
}

.publish-job-item-meta {
    margin-top: 4px;
    font-size: 13px;
    color: var(--gray-600);
}

@media (max-width: 767px) {
    .publish-job-banner {
        right: 12px;
        left: 12px;
        width: auto;
        bottom: 76px;
        flex-direction: column;
        align-items: stretch;
    }

    .publish-job-banner-actions {
        align-self: stretch;
    }

    .publish-job-banner-actions .btn {
        width: 100%;
    }
}

.planner-preview-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.planner-preview-switch {
    display: inline-flex;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 2px;
    background: var(--gray-50);
}

.planner-preview-switch .btn {
    border: 0;
    background: transparent;
}

.planner-preview-switch .btn.active {
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.planner-preview-calendar {
    display: grid;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.planner-calendar-month {
    border: 1px solid var(--gray-200);
    border-radius: 14px;
    padding: 12px;
    background: #fff;
    min-width: 900px;
}

.planner-calendar-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 10px;
}

.planner-calendar-weekdays,
.planner-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.planner-calendar-weekday {
    padding: 0 4px 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-align: center;
}

.planner-calendar-day {
    min-height: 140px;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 2px;
    background: var(--gray-50);
}

.planner-calendar-day-drop-target {
    border-color: var(--primary);
    box-shadow: inset 0 0 0 1px var(--primary);
    background: #eef6ff;
}

.planner-calendar-day-empty {
    background: transparent;
    border-style: dashed;
    opacity: 0.45;
}

.planner-calendar-day-num {
    font-size: 12px;
    font-weight: 700;
    color: var(--gray-700);
    margin: 0px 4px 0 4px;
}

.planner-calendar-items {
    display: grid;
    gap: 6px;
}

.planner-calendar-item {
    position: relative;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 4px;
    align-items: center;
    padding: 0;
    border-radius: 5px;
    background: #fff;
    border: 1px solid var(--gray-200);
    cursor: grab;
}

.planner-calendar-item-dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.planner-calendar-thumb {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    background: var(--gray-100);
}

.planner-calendar-item-meta {
    min-width: 0;
}

.planner-calendar-item-time {
    font-size: 12px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}

.planner-calendar-item-account {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    margin-top: 2px;
    font-size: 11px;
    color: var(--gray-600);
    max-width: 100%;
}

.planner-calendar-item-account-text {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.planner-calendar-item-account-icons-only {
    gap: 0;
}

.planner-readonly {
    opacity: 0.88;
}

.planner-time-group {
    display: grid;
    gap: 8px;
}

.planner-time-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.planner-time-header .form-label {
    margin-bottom: 0;
}

.planner-time-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.planner-time-remove {
    color: var(--danger);
    border-color: #f3b4b4;
}

.planner-calendar-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border: 0;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
}

.post-caption-cell {
    max-width: 320px;
    white-space: pre-wrap;
    word-break: break-word;
}

.location-search {
    position: relative;
}

.location-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 20;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    max-height: 260px;
    overflow-y: auto;
}

.location-search-item {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid var(--border-color);
    background: #fff;
    text-align: left;
    cursor: pointer;
}

.location-search-item:last-child {
    border-bottom: 0;
}

.location-search-item:hover {
    background: #f8fafc;
}

.location-search-empty {
    color: var(--text-muted);
    cursor: default;
}

.location-search-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.account-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    margin-right: 4px;
    text-transform: none;
    letter-spacing: normal;
}

.settings-subnav {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.card-flat {
    border: 1px solid var(--gray-200);
    box-shadow: none;
}

.page-title {
    margin-bottom: 20px;
}

.auth-card .page-title {
    color: white;
}

.section-title {
    font-size: 18px;
}

.body-modal-open {
    overflow: hidden;
}

.upload-input-hidden {
    display: none;
}

/* =============================================
   Calendar extracted from page
   ============================================= */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    width: 100%;
    /*min-width: 700px;*/
    gap: 1px;
    background: var(--gray-200);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: auto;
}

.calendar-grid-scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

.calendar-grid-week {
    gap: 12px;
    background: transparent;
    border: none;
    overflow: visible;
}

.cal-toolbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.cal-toolbar-left,
.cal-toolbar-right,
.cal-toolbar-center,
.cal-view-switch,
.cal-date-switch,
.cal-period-picker {
    display: flex;
    align-items: center;
    gap: 8px;
}
.cal-date-switch {
    gap: 0;
}
.cal-view-switch {
    gap: 0;
}
.cal-view-switch .btn {
    border-radius: 0;
}
.cal-view-switch a:nth-child(2) {
    border-left: 0;
    border-right: 0;
}
.cal-view-switch a:first-child {
    border-top-left-radius: var(--radius);
    border-bottom-left-radius: var(--radius);
}
.cal-view-switch a:last-child {
    border-top-right-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.cal-toolbar-center {
    justify-content: center;
    text-align: center;
}

@media (max-width: 768px) {
    .info-heading {
        flex-direction: column;
    }

    .changelog-head h3 {
        font-size: 24px;
    }
}

.cal-toolbar-right {
    justify-content: flex-end;
}

.cal-period-picker .form-control {
    min-width: 160px;
    padding: 4px 12px;
}

.cal-filter {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.cal-filter-search {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.cal-filter-search .form-control {
    min-width: 0;
    flex: 1 1 auto;
}

.cal-filter-actions {
    display: flex;
    justify-content: flex-end;
    align-items: end;
    gap: 8px;
    margin-top: 8px;
}
.cal-filter-actions .btn {
    padding: 4px 18px;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.cal-header {
    background: var(--gray-100);
    padding: 8px 4px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
}

.cal-day {
    background: #fff;
    min-height: 80px;
    padding: 4px;
    position: relative;
}

.cal-empty {
    background: var(--gray-50);
}

.cal-week-board {
    overflow-x: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: #fff;
}

.cal-week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.cal-week-head-cell {
    border-right: 1px solid var(--gray-200);
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
    text-align: center;
}

.cal-week-head-cell:last-child {
    border-right: none;
}

.cal-week-head-cell-today {
    background: rgba(24, 119, 242, 0.08);
}

.cal-week-col {
    min-height: 400px;
    padding: 3px;
    border-right: 1px solid var(--gray-200);
    background: #fff;
    min-width: 50px;
}

.cal-week-col:last-child {
    border-right: none;
}

.cal-week-col-today {
    background: rgba(24, 119, 242, 0.04);
}


.cal-week-event {
    display: flex;
    gap: 6px;
    align-items: flex-start;
    padding: 4px;
    margin-bottom: 4px;
    white-space: normal;
}

.cal-week-event-image {
    max-width: 34px;
    max-height: 52px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    background: var(--gray-100);
    flex: 0 0 auto;
}

.cal-event-image {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 4px;
    background: var(--gray-100);
    flex: 0 0 auto;
}

.cal-event-type-story .cal-event-image {
    width: 20px;
    height: 36px;
}

.cal-event-type-post .cal-event-image,
.cal-event-type-carousel .cal-event-image {
    width: 20px;
    height: 20px;
}

.cal-week-event-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cal-week-event .cal-event-account {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
    overflow: hidden;
}

.cal-week-event .cal-event-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.calendar-list-wrap {
    display: grid;
    gap: 12px;
}

.calendar-list-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.calendar-list-wrap .table-wrap {
    overflow-x: hidden;
}

.cal-list-row {
    cursor: pointer;
}

.cal-list-row td {
    vertical-align: top;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.cal-list-row.cal-event-pending td   { background: #fff3e0; color: #e65100; }
.cal-list-row.cal-event-published td { background: #e8f5e9; color: #2e7d32; }
.cal-list-row.cal-event-failed td    { background: #ffebee; color: #c62828; }
.cal-list-row.cal-event-error td     { background: #ffebee; color: #c62828; border-top: 1px solid #ef9a9a; border-bottom: 1px solid #ef9a9a; }
.cal-list-row.cal-event-cancelled td { background: var(--gray-200); color: var(--gray-600); }

.cal-list-row.cal-event-pending:hover td   { background: #ffe0b2; }
.cal-list-row.cal-event-published:hover td { background: #c8e6c9; }
.cal-list-row.cal-event-failed:hover td    { background: #ffcdd2; }
.cal-list-row.cal-event-error:hover td     { background: #ffcdd2; }
.cal-list-row.cal-event-cancelled:hover td { background: var(--gray-300); }

.cal-list-row td:first-child {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.cal-list-row td:last-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.cal-list-select-cell {
    width: 34px;
    white-space: nowrap;
}

.calendar-list-table th:nth-child(1),
.calendar-list-table td:nth-child(1) {
    width: 34px;
}

.calendar-list-table th:nth-child(2),
.calendar-list-table td:nth-child(2) {
    width: 96px;
}

.calendar-list-table th:nth-child(3),
.calendar-list-table td:nth-child(3) {
    width: 50px;
}

.calendar-list-table th:nth-child(4),
.calendar-list-table td:nth-child(4) {
    width: 140px;
}

.calendar-list-table th:nth-child(5),
.calendar-list-table td:nth-child(5) {
    width: auto;
}

.cal-list-content-col {
    white-space: nowrap;
}

.cal-list-content-text {
    font-size: 12px;
    line-height: 1.35;
    white-space: normal;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cal-list-row .text-sm.text-muted {
    color: currentColor;
    opacity: 0.7;
}

.cal-list-scheduled-time {
    font-weight: 600;
    font-size: 12px;
}

.cal-list-select-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cal-today {
    background: rgba(24, 119, 242, 0.04);
}

.cal-today .cal-day-num {
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cal-day-num {
    font-size: 1rem;
    font-weight: 800;
    color: var(--gray-700);
    display: inline-block;
    margin-bottom: 2px;
}

.cal-event {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 3px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cal-event-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.btn-cal-retry {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 4px;
    padding: 3px 6px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
    color: #fff;
    background-color: #c62828;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    width: 100%;
    z-index: 2;
}

.cal-event-failed .btn-cal-retry,
.cal-event-error .btn-cal-retry,
.cal-event-retry .btn-cal-retry {
    display: flex;
}

.btn-cal-retry:hover {
    background-color: #b71c1c;
}

.btn-cal-retry:active {
    transform: translateY(1px);
}

.btn-cal-retry.is-loading {
    pointer-events: none;
    opacity: 0.7;
    color: transparent;
    position: relative;
}

.btn-cal-retry.is-loading::after {
    content: "";
    position: absolute;
    width: 10px;
    height: 10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: cal-spin 0.6s linear infinite;
    left: calc(50% - 6px);
    top: calc(50% - 6px);
}

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


.cal-event[data-selectable="1"] {
    position: relative;
    padding-left: 22px;
}

.cal-select-toggle {
    position: absolute;
    left: 4px;
    top: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.cal-week-event .cal-select-toggle {
    top: 6px;
}

.cal-event-pending   { background: #fff3e0; color: #e65100; }
.cal-event-published { background: #e8f5e9; color: #2e7d32; }
.cal-event-failed    { background: #ffebee; color: #c62828; }
.cal-event-error     { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.cal-event-cancelled { background: var(--gray-200); color: var(--gray-600); }

.cal-event-pending:hover   { background: #ffe0b2; }
.cal-event-published:hover { background: #c8e6c9; }
.cal-event-failed:hover    { background: #ffcdd2; }
.cal-event-error:hover     { background: #ffcdd2; }
.cal-event-cancelled:hover { background: var(--gray-300); }

.cal-event[hidden],
.cal-week-event[hidden],
.cal-post-row[hidden] {
    display: none;
}

.cal-activity-filters {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
    align-items: end;
}

.cal-activity-actions {
    display: flex;
    gap: 8px;
    align-items: end;
}

.cal-activity-details {
    max-width: 360px;
    white-space: pre-wrap;
    word-break: break-word;
}

.cal-activity-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
}

.cal-bulk-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

#calendarSelectedCount,
.cal-bulk-select-all {
    white-space: nowrap;
}

#calendarBulkAction {
    flex: 0 0 200px;
    width: 200px;
    min-width: 200px;
    max-width: 200px;
}

#calendarBulkApplyBtn {
    flex: 0 0 auto;
}

.cal-bulk-select-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.btn.disabled {
    pointer-events: none;
    opacity: 0.5;
}

.cal-event-time {
    font-weight: 600;
}

.cal-event-account {
    display: inline-flex;
    align-items: center;
    gap: 0;
    min-width: 0;
}

.cal-platform-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding-right: 3px;
}

.cal-platform-icon-facebook {
    color: #1877f2;
}

.cal-platform-icon-instagram {
    color: #e1306c;
}

.cal-account-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    text-transform: none;
    letter-spacing: normal;
}

.cal-event-name {
    margin-left: 2px;
}

.cal-post-row {
    cursor: pointer;
}

.cal-preview-tooltip {
    position: fixed;
    z-index: 1000;
    width: 220px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    pointer-events: none;
}

.cal-preview-image {
    display: block;
    width: 100%;
    max-height: 360px;
    height: auto;
    object-fit: contain;
    background: var(--gray-100);
}

.cal-preview-meta {
    padding: 10px 12px;
}

.cal-preview-account {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.cal-preview-time,
.cal-preview-status {
    font-size: 12px;
    color: var(--gray-600);
}

.cal-preview-status {
    margin-top: 2px;
}

.cal-edit-preview {
    display: flex;
    gap: 12px;
    align-items: center;
}

.cal-edit-preview-media {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 0 0 auto;
    max-width: 232px;
}

.cal-edit-preview-media img,
.cal-edit-preview-placeholder {
    max-width: 96px;
    max-height: 128px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    background: var(--gray-100);
    display: block;
    flex: 0 0 auto;
}

.cal-edit-preview-placeholder {
    width: 96px;
    height: 128px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 6px;
    background: linear-gradient(135deg, var(--gray-100), #fff);
    border: 1px dashed var(--gray-300);
    color: var(--gray-700);
    font-weight: 600;
}

.cal-edit-preview-media.is-carousel img,
.cal-edit-preview-media.is-carousel .cal-edit-preview-placeholder {
    width: 72px;
    height: 72px;
    max-width: none;
    max-height: none;
    object-fit: cover;
    border-radius: 8px;
}

.cal-edit-preview-media .gallery-video-icon {
    font-size: 18px;
    line-height: 1;
}

.cal-edit-preview-media .gallery-video-label {
    font-size: 11px;
    line-height: 1;
}

.cal-edit-preview-media .is-zoomable {
    cursor: zoom-in;
}

.cal-image-viewer-overlay {
    background: rgba(15, 23, 42, 0.94);
}

.cal-image-viewer {
    position: relative;
    width: min(100vw, 1440px);
    height: min(100vh, 980px);
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 72px;
}

.cal-image-viewer-stage {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cal-image-viewer-stage img {
    max-width: 100%;
    max-height: calc(100vh - 140px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
    background: rgba(255, 255, 255, 0.06);
}

.cal-image-viewer-close,
.cal-image-viewer-nav {
    position: absolute;
    border: 0;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.16s ease, transform 0.16s ease;
}

.cal-image-viewer-close:hover,
.cal-image-viewer-nav:hover {
    background: rgba(255, 255, 255, 0.22);
}

.cal-image-viewer-close:hover {
    transform: translateY(-1px);
}

.cal-image-viewer-close {
    top: 18px;
    right: 22px;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    font-size: 28px;
    line-height: 1;
}

.cal-image-viewer-nav {
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    border-radius: 999px;
    font-size: 34px;
    line-height: 1;
}

.cal-image-viewer-prev {
    left: 14px;
}

.cal-image-viewer-next {
    right: 14px;
}

.cal-image-viewer-nav:disabled {
    opacity: 0.35;
    cursor: default;
    transform: translateY(-50%);
}

.cal-image-viewer-nav:hover {
    transform: translateY(calc(-50% - 1px));
}

.cal-image-viewer-nav:disabled:hover {
    background: rgba(255, 255, 255, 0.14);
    transform: translateY(-50%);
}

.cal-image-viewer-counter {
    position: absolute;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.cal-edit-preview-meta {
    min-width: 0;
}

.cal-edit-preview-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.cal-edit-logs {
    margin-top: 12px;
    border-top: 1px solid var(--gray-200);
    padding-top: 12px;
}

.cal-edit-logs summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
}

.cal-edit-logs-list {
    margin-top: 10px;
    display: grid;
    gap: 10px;
}

.cal-edit-log-item {
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 10px;
    background: var(--gray-50);
}

.cal-edit-log-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.cal-edit-log-response {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12px;
    color: var(--gray-700);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

#editPostDeleteBtn {
    margin-right: auto;
}

@media (max-width: 767px) {
    .main {
        padding: 10px 8px 150px;
    }
    .card {
        padding: 12px 7px;
    }
    .planner-preview-header {
        width: 100%;
        margin-left: 0;
        justify-content: flex-start;
    }

    .planner-preview-switch {
        width: 100%;
    }

    .planner-preview-switch .btn {
        flex: 1 1 50%;
    }

    .cal-toolbar,
    .cal-toolbar-left,
    .cal-toolbar-right,
    .cal-toolbar-center,
    .cal-view-switch,
    .cal-period-picker {
        width: 100%;
    }

    .cal-toolbar {
        grid-template-columns: 1fr;
    }

    .cal-filter {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .form-label {
        margin-bottom: 0;
    }
    .form-group {
        margin-bottom: 0;
    }
    .cal-filter-actions {
        margin-top: 18px;
        justify-content: space-evenly;
    }
    .cal-filter-actions .btn {
        padding: 4px 8px;
    }

    .cal-toolbar-left,
    .cal-toolbar-right {
        justify-content: space-between;
        /*flex-wrap: wrap;*/
    }

    .cal-period-picker .form-control {
        min-width: 0;
        flex: 1 1 auto;
    }

    .cal-week-board-inner {
        min-width: 920px;
    }

    .calendar-list-table {
        min-width: 920px;
    }

    .cal-activity-filters {
        grid-template-columns: 1fr;
    }

    .cal-activity-actions {
        flex-wrap: wrap;
    }

    .cal-activity-details {
        max-width: 220px;
    }

    .cal-day {
        min-height: 50px;
        padding: 2px;
    }

    .cal-event-name {
        display: none;
    }

    .cal-event {
        font-size: 9px;
        padding: 1px 2px;
    }

    .cal-header {
        font-size: 10px;
        padding: 6px 2px;
    }

    .cal-day-num {
        font-size: 11px;
    }

    .cal-preview-tooltip {
        display: none;
    }

    .cal-edit-preview {
        align-items: flex-start;
    }

    .cal-edit-preview-media img,
    .cal-edit-preview-placeholder {
        max-width: 72px;
        max-height: 106px;
    }

    .cal-edit-preview-media.is-carousel img,
    .cal-edit-preview-media.is-carousel .cal-edit-preview-placeholder {
        width: 56px;
        height: 56px;
        max-width: none;
        max-height: none;
    }

    .cal-image-viewer {
        padding: 56px 16px 76px;
    }

    .cal-image-viewer-close {
        top: 10px;
        right: 12px;
        width: 40px;
        height: 40px;
        font-size: 24px;
    }

    .cal-image-viewer-nav {
        width: 44px;
        height: 44px;
        font-size: 28px;
    }

    .cal-image-viewer-prev {
        left: 8px;
    }

    .cal-image-viewer-next {
        right: 8px;
    }

    .cal-image-viewer-stage img {
        max-height: calc(100vh - 132px);
    }

    .cal-image-viewer-counter {
        bottom: 14px;
        font-size: 12px;
    }
}

.nav-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    list-style: none;
}

.nav-switcher {
    min-width: 180px;
}

.nav-business-clock {
    min-width: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-700);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.nav-business-clock-separator {
    display: inline-block;
    width: 0.5em;
    text-align: center;
    animation: nav-business-clock-blink 1s steps(1, end) infinite;
}

@keyframes nav-business-clock-blink {
    0%, 49% {
        opacity: 1;
    }

    50%, 100% {
        opacity: 0.2;
    }
}

.nav-business-clock-mobile {
    display: none;
}

.nav-user {
    font-size: 13px;
    color: var(--gray-800);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu {
    position: relative;
}

.nav-update-button {
    border: 1px solid var(--primary);
    background: rgba(24, 119, 242, 0.08);
    color: var(--primary);
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.nav-update-button:hover {
    background: rgba(24, 119, 242, 0.14);
}

.nav-update-button[hidden] {
    display: none;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--gray-200);
    background: #fff;
    border-radius: 999px;
    padding: 6px 10px 6px 6px;
    cursor: pointer;
}

.user-avatar-image,
.user-avatar-fallback,
.profile-avatar-image,
.profile-avatar-fallback {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    object-fit: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
}

.user-dropdown-menu {
    right: 0;
    left: auto;
    min-width: 220px;
}

.profile-avatar-row {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
}

.profile-avatar-preview {
    flex: 0 0 auto;
}

.profile-avatar-image,
.profile-avatar-fallback {
    width: 72px;
    height: 72px;
}

.avatar-crop-modal {
    max-width: 560px;
}

.avatar-crop-stage {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.post-cover-preview-box {
    position: relative;
    min-height: 160px;
    border: 1px dashed #d1d5db;
    border-radius: 12px;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    overflow: hidden;
    padding: 12px;
}

.post-cover-preview-box.is-clickable {
    cursor: pointer;
}

.post-cover-preview-box img {
    display: block;
    width: 100%;
    aspect-ratio: 9 / 16;
    object-fit: cover;
    border-radius: 10px;
}

.post-cover-preview-box .post-cover-preview-empty {
    min-height: 136px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

.post-cover-ratio-status {
    font-size: 12px;
    line-height: 1.4;
}

.post-cover-crop-modal {
    max-width: 640px;
    width: min(640px, calc(100vw - 24px));
}

.post-cover-crop-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.post-cover-crop-toolbar-side {
    display: flex;
    align-items: center;
    gap: 8px;
}

.post-cover-crop-stage {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

#postCoverCropCanvas {
    width: min(100%, 360px);
    height: auto;
    border-radius: 12px;
    background: #101828;
    touch-action: none;
    cursor: grab;
}

#postCoverCropCanvas.is-dragging {
    cursor: grabbing;
}

.post-cover-crop-zoom {
    width: 100%;
}

#avatarCropCanvas {
    width: min(100%, 420px);
    height: auto;
    border-radius: 12px;
    background: #101828;
    touch-action: none;
    cursor: crosshair;
}

.auth-shell {
    min-height: calc(100vh - 48px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}

.auth-card {
    width: min(100%, 420px);
    background: #111827;
    border: 1px solid #1f2937;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

.auth-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.invite-auth-switch {
    margin-top: 12px;
}

.invite-auth-panel {
    padding: 0;
    background: transparent;
    border: 0;
}

.invite-auth-title {
    margin: 0 0 16px;
    font-size: 18px;
    font-weight: 700;
    color: #f9fafb;
}

.invite-auth-panel .form-label {
    color: #e5e7eb;
}

.invite-auth-footer {
    margin-top: 4px;
}

.invite-auth-panel .btn-outline.btn-block {
    margin-top: 10px;
}

@media (max-width: 767px) {
    .nav {
        gap: 8px;
    }

    .nav-brand {
        flex: 0 0 auto;
    }

    .nav-mobile-switcher {
        display: block;
    }

    .nav-meta .nav-switcher {
        display: none;
    }

    .nav-meta {
        width: 100%;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .nav-switcher {
        min-width: 0;
        width: 100%;
    }

    .nav-business-clock-mobile {
        display: block;
        min-width: 48px;
        font-size: 12px;
        justify-content: flex-end;
    }

    .nav-business-clock-desktop {
        display: none;
    }

    .nav-meta .nav-business-clock {
        width: 100%;
        justify-content: flex-start;
        padding: 0 20px;
    }

    .user-menu {
        width: 100%;
    }

    .nav-update-button {
        width: 100%;
    }

    .user-menu-trigger {
        width: 100%;
        justify-content: flex-start;
        border: none;
        border-radius: 0;
        padding: 12px 20px;
        background: transparent;
    }

    .user-menu .user-dropdown-menu {
        display: flex;
        position: static;
        box-shadow: none;
        border-radius: 0;
        min-width: 0;
    }

    .user-dropdown-menu {
        left: 0;
        right: auto;
        width: 100%;
    }

    .profile-avatar-row {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 400px) {
    .nav-mobile-switcher {
        padding-right: 4px;
    }

    .nav-business-clock-mobile {
        min-width: 44px;
        font-size: 11px;
    }
}
