/* PlanEdu Pro - v9.0
   UI/UX Refactored: Clean, modern, teacher-friendly
   @version 9.0
*/

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* ========================================
   CSS VARIABLES
   ======================================== */
:root {
    /* Colors - Warm teal palette */
    --primary: #0F172A;
    --primary-light: #1E293B;
    --accent: #0D9488;
    --accent-hover: #0F766E;
    --accent-light: #F0FDFA;
    --accent-glow: rgba(13, 148, 136, 0.15);

    /* Backgrounds */
    --bg-page: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-subtle: #F1F5F9;
    --bg-elevated: #FFFFFF;

    /* Header */
    --header-height: 56px;

    /* Text */
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --text-inverse: #F8FAFC;

    /* Borders */
    --border-light: #E2E8F0;
    --border-medium: #CBD5E1;

    /* Status */
    --success: #10B981;
    --error: #EF4444;
    --warning: #F59E0B;

    /* Shadows - softer, more natural */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.06), 0 4px 8px rgba(0, 0, 0, 0.03);
    --shadow-xl: 0 16px 40px rgba(0, 0, 0, 0.08);

    /* Sizing */
    --sidebar-width: 300px;

    /* Radius - friendlier */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
}

/* ========================================
   RESET & BASE
   ======================================== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100dvh;
    background: linear-gradient(180deg, #1E293B 0%, #0F172A 100%);
    color: var(--text-inverse);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    z-index: 50;
    overflow-y: auto;
    transition: transform var(--transition-normal);
}

.btn-close-sidebar {
    display: none;
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 20px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.logo-icon svg {
    width: 20px;
    height: 20px;
}

.logo-img {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    flex-shrink: 0;
    object-fit: contain;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.logo-text span {
    color: var(--accent);
}

/* History */
.history-section {
    flex: 1;
    overflow-y: auto;
    margin-right: -8px;
    padding-right: 8px;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 4px;
    margin-bottom: 8px;
}

.history-title {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(148, 163, 184, 0.7);
    font-weight: 600;
    padding-left: 8px;
    margin-bottom: 0;
}

.btn-sort-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(148, 163, 184, 0.7);
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.625rem;
    font-weight: 500;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: all var(--transition-fast);
}

.btn-sort-toggle:hover {
    color: var(--primary-light, #5eead4);
    background: rgba(13, 148, 136, 0.15);
    border-color: rgba(13, 148, 136, 0.3);
}

.history-list {
    list-style: none;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-bottom: 1px;
    transition: background var(--transition-fast);
    font-size: 0.8125rem;
    color: rgba(248, 250, 252, 0.8);
    gap: 8px;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-inverse);
}

.history-item.active {
    background: rgba(13, 148, 136, 0.15);
    border: 1px solid rgba(13, 148, 136, 0.25);
    color: var(--text-inverse);
}

/* Delete button */
.history-item .btn-delete-history {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.history-item:hover .btn-delete-history {
    opacity: 1;
}

.history-item .btn-delete-history:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}

@media (pointer: coarse) {
    .history-item .btn-delete-history {
        opacity: 1;
    }

    .history-item .btn-rename-history {
        opacity: 1;
    }
}

/* Rename button */
.history-item .btn-rename-history {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.history-item:hover .btn-rename-history {
    opacity: 0.6;
}

.history-item .btn-rename-history:hover {
    opacity: 1;
    color: var(--primary);
}

/* Inline rename input */
.rename-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(13, 148, 136, 0.4);
    border-radius: 4px;
    color: var(--text-inverse);
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 2px 6px;
    outline: none;
    font-family: inherit;
}

.rename-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.2);
}

/* Sidebar Footer */
.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-footer:last-child {
    margin-top: 0;
    padding-top: 12px;
    border-top: none;
}

.sidebar-footer+.sidebar-footer {
    border-top: none;
    padding-top: 8px;
}

.btn-settings,
.btn-backup {
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: none;
    color: rgba(148, 163, 184, 0.8);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    margin-bottom: 2px;
}

.btn-settings:hover,
.btn-backup:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-inverse);
}

.btn-settings svg,
.btn-backup svg {
    opacity: 0.7;
    width: 18px;
    height: 18px;
}

.version-info {
    font-size: 0.6875rem;
    color: rgba(148, 163, 184, 0.4);
    text-align: center;
    margin-top: 8px;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.sidebar-version {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: auto;
    padding-top: 16px;
}

/* Home Buttons */
.btn-home-desktop {
    display: none;
    width: 100%;
    padding: 10px 14px;
    margin: 12px 0;
    background: var(--accent);
    border: none;
    color: white;
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
}

.btn-home-desktop:hover {
    background: var(--accent-hover);
}

.btn-home-desktop.visible {
    display: flex;
}

/* Logout */
.btn-logout {
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: none;
    color: rgba(239, 68, 68, 0.7);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    margin-top: 2px;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.btn-logout svg {
    opacity: 0.8;
}

/* ========================================
   MAIN CONTENT
   ======================================== */
.app-container {
    min-height: 100dvh;
}

.main-content {
    height: 100dvh;
    overflow-y: auto;
    margin-left: var(--sidebar-width);
    padding: 28px 32px;
    padding-bottom: 80px;
}

/* ========================================
   CONTENT LAYOUT
   ======================================== */
.content-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    align-items: flex-start;
    justify-content: center;
    transition: max-width var(--transition-medium);
}

/* Landscape Mode for full width editor */
body.landscape-editor .content-grid {
    max-width: 1600px;
    /* Expand to fill most modern wide screens */
    padding: 0 16px;
}

/* Form Panel */
.form-panel {
    flex: 999 1 560px;
    width: 100%;
    max-width: 780px;
    position: relative;
    z-index: 10;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    height: fit-content;
}

/* Onboarding Card */
.onboarding-card {
    flex: 1 1 320px;
    width: 100%;
    max-width: 420px;
    position: sticky;
    top: 28px;
    z-index: 10;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    height: fit-content;
}

.onboarding-card .panel-title {
    font-size: 1.125rem;
}

.onboarding-info {
    margin-top: 20px;
    padding: 16px;
    background: var(--accent-light);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent);
}

.onboarding-info p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.5;
}

.onboarding-info p:last-child {
    margin-bottom: 0;
}

.content-grid.result-mode .onboarding-card {
    display: none;
}

/* Result Panel */
.result-panel {
    display: none;
    flex: 1;
    min-width: 0;
    width: 100%;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    flex-direction: column;
    min-height: 600px;
    overflow: hidden;
}

/* View Modes */
.content-grid.result-mode .form-panel {
    display: none;
}

.content-grid.result-mode .result-panel {
    display: flex;
    flex: 1;
    width: 100%;
    min-height: calc(100dvh - 64px);
}

/* ========================================
   FORM ELEMENTS
   ======================================== */
.panel-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.panel-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.panel-description {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.required {
    color: var(--error);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    min-height: 80px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Checkbox styles */
.checkbox-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--accent-light);
    border: 1.5px solid rgba(13, 148, 136, 0.2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.checkbox-card:hover {
    border-color: var(--accent);
}

.checkbox-info h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
}

.checkbox-card input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.checkbox-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--accent-light);
    border: 1.5px solid rgba(13, 148, 136, 0.3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent-hover);
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.checkbox-compact:hover {
    border-color: var(--accent);
    background: rgba(13, 148, 136, 0.08);
}

.checkbox-compact input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

/* Noturno checkbox inline */
.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    width: fit-content;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.checkbox-inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

/* Wizard Mode Toggle */
.wizard-toggle {
    display: flex;
    justify-content: center;
    margin-top: 8px;
    margin-bottom: 4px;
}

.checkbox-wizard {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(168, 85, 247, 0.12));
    border: 1.5px solid rgba(139, 92, 246, 0.3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.checkbox-wizard:hover {
    border-color: rgba(139, 92, 246, 0.6);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(168, 85, 247, 0.18));
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.15);
}

.checkbox-wizard input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #8b5cf6;
    cursor: pointer;
}

.checkbox-wizard .wizard-badge {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #7c3aed;
    letter-spacing: 0.01em;
}

.checkbox-wizard:has(input:checked) {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(168, 85, 247, 0.22));
    border-color: #8b5cf6;
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.2);
}

.checkbox-wizard:has(input:checked) .wizard-badge {
    color: #6d28d9;
}

/* Wizard Timeline: textarea instead of input */
.lesson-focus-wizard {
    flex: 2;
    padding: 7px 10px;
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: inherit;
    min-height: 60px;
    resize: vertical;
    line-height: 1.4;
}

.lesson-focus-wizard::placeholder {
    color: var(--text-muted);
}

.lesson-focus-wizard:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15);
}

/* Wizard mode timeline row adjustment */
.timeline-row.wizard-row {
    align-items: flex-start;
    border-left-color: #8b5cf6;
}

.timeline-row.wizard-row:hover {
    border-left-color: #6d28d9;
}


/* Details/Summary */
details {
    margin-bottom: 20px;
}

details summary {
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent);
    padding: 10px 0;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

details summary::-webkit-details-marker {
    display: none;
}

details summary::before {
    content: '';
    width: 6px;
    height: 6px;
    border-right: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent);
    transform: rotate(-45deg);
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

details[open] summary::before {
    transform: rotate(45deg);
}

details[open] summary {
    margin-bottom: 16px;
}

/* Continuidade Pedagógica */
.continuity-box {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
}

.continuity-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.continuity-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.45;
    flex: 1;
    margin: 0;
    padding-top: 2px;
}

.continuity-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.btn-continuity-load,
.btn-continuity-clear {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    line-height: 1;
}

.btn-continuity-load {
    color: var(--accent);
    background: var(--accent-glow);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.btn-continuity-load:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-continuity-load svg {
    flex-shrink: 0;
}

.btn-continuity-clear {
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border);
}

.btn-continuity-clear:hover {
    color: #ef4444;
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.06);
}

.btn-continuity-clear svg {
    flex-shrink: 0;
}

.prior-plan-info {
    padding: 8px 12px;
    margin-bottom: 10px;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-glow);
    border-radius: 6px;
    border-left: 3px solid var(--accent);
    line-height: 1.45;
}

.continuity-box #priorPlanText {
    font-size: 0.775rem;
    min-height: 50px;
    margin: 0;
}

.continuity-box .form-textarea {
    background: var(--bg-secondary);
}

/* Prior Plan Picker Modal */
.prior-plan-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.prior-plan-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.prior-plan-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.prior-plan-modal-header h3 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.prior-plan-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
}

.prior-plan-modal-body {
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}

.prior-plan-item {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.prior-plan-item:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.prior-plan-item-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.prior-plan-item-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Primary Button */
.btn-primary {
    width: 100%;
    padding: 14px 24px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: white;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25);
    margin-top: 8px;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: var(--border-medium);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary svg {
    width: 18px;
    height: 18px;
}

.btn-generate {
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 12px;
}

/* Shortcut Buttons */
.shortcut-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.btn-shortcut {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1.5px solid var(--border-medium);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 1.125rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.btn-shortcut:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: var(--shadow-md);
}

.btn-shortcut.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-shortcut-full {
    padding: 8px 10px;
    background: var(--bg-subtle);
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: normal;
    line-height: 1.3;
    text-align: center;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-shortcut-full:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent-hover);
}

.btn-shortcut-full.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 2px 8px var(--accent-glow);
}

/* ========================================
   GRADE BUTTONS (Radio Pills)
   ======================================== */
.grade-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

#gradeButtons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

#numClassesButtons {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
}

#numClassesButtons .grade-btn {
    padding: 8px 10px;
    min-width: 40px;
}

.grade-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 16px;
    background: var(--bg-subtle);
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.grade-btn input[type="radio"] {
    display: none;
}

.grade-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent-hover);
}

.grade-btn.active,
.grade-btn:has(input:checked) {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.grade-btn-text {
    pointer-events: none;
}

/* ========================================
   TIMELINE / SEQUENCE BUILDER
   ======================================== */
.timeline-container {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timeline-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-subtle);
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: all var(--transition-fast);
}

.timeline-row:hover {
    border-left-color: var(--accent-hover);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.lesson-badge {
    background: var(--primary);
    color: var(--text-inverse);
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    min-width: 52px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.lesson-select {
    padding: 7px 10px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: inherit;
    cursor: pointer;
    flex: 1;
    max-width: 160px;
}

.lesson-focus {
    flex: 2;
    padding: 7px 10px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: inherit;
}

.lesson-focus::placeholder {
    color: var(--text-muted);
}

.lesson-select:focus,
.lesson-focus:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

/* NotebookLM Slides Checkbox */
.lesson-notebook-label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.lesson-notebook-label:hover {
    background: var(--accent-light);
}

.lesson-notebook {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.lesson-notebook-icon {
    font-size: 1rem;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
}

.lesson-notebook-label:hover .lesson-notebook-icon,
.lesson-notebook:checked+.lesson-notebook-icon {
    opacity: 1;
}

.lesson-notebook:checked+.lesson-notebook-icon {
    filter: drop-shadow(0 0 4px var(--accent));
}

/* ========================================
   RESULT PANEL & GENERATED CONTENT
   ======================================== */
.result-header {
    padding: 16px 20px;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    gap: 12px;
}

.result-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.result-title svg {
    width: 18px;
    height: 18px;
    color: var(--accent);
}

.result-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.btn-icon {
    padding: 7px 10px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
}

.btn-icon:hover {
    color: var(--text-primary);
    border-color: var(--border-medium);
    background: var(--bg-subtle);
}

.btn-icon svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

/* Action button specific colors */
.btn-action-home {
    background-color: var(--bg-subtle);
    color: var(--text-secondary);
    border-color: var(--border-light);
    text-decoration: none;
}

.btn-action-new {
    background-color: var(--bg-subtle);
    color: var(--text-secondary);
    border-color: var(--border-light);
}

.btn-action-edit {
    background-color: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.btn-action-edit:hover {
    background-color: #dcfce7;
    border-color: #86efac;
}

.result-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 48px 24px;
}

.empty-illustration {
    width: 88px;
    height: 88px;
    background: linear-gradient(135deg, var(--accent-light) 0%, rgba(13, 148, 136, 0.08) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.empty-illustration svg {
    width: 40px;
    height: 40px;
    color: var(--accent);
}

.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 0.875rem;
    color: var(--text-muted);
    max-width: 320px;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 48px 24px;
    gap: 12px;
}

.loading-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.loading-state p {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.loading-tip {
    font-size: 0.75rem !important;
    color: var(--text-muted) !important;
    opacity: 0.7;
}

.btn-cancel-generation {
    margin-top: 12px;
    background: transparent;
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.btn-cancel-generation:hover {
    border-color: var(--error);
    color: var(--error);
    background: rgba(239, 68, 68, 0.04);
}

/* Error State */
.error-state {
    text-align: center;
    padding: 2rem;
}

.error-state h3 {
    font-size: 1.125rem;
    margin-bottom: 8px;
}

/* Spinner */
.spinner-large {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Batch Progress */
.batch-progress-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.batch-progress-percent {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.batch-progress-bar-track {
    width: 100%;
    background-color: var(--border-light);
    border-radius: 9999px;
    height: 8px;
    overflow: hidden;
}

.batch-progress-bar-fill {
    height: 100%;
    background-color: var(--accent);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.batch-warning {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* Generated Content Typography */
.generated-content {
    line-height: 1.7;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 100%;
}

.generated-content h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--accent);
}

.generated-content h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary-light);
    margin-top: 28px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.generated-content h2::before {
    content: '';
    width: 3px;
    height: 18px;
    background: var(--accent);
    border-radius: 2px;
    flex-shrink: 0;
}

.generated-content p {
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.generated-content ul,
.generated-content ol {
    margin-bottom: 12px;
    padding-left: 20px;
}

.generated-content li {
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.generated-content .info-card {
    background: var(--bg-subtle);
    border-left: 3px solid var(--accent);
    padding: 16px;
    margin: 16px 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Tables */
.generated-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.8125rem;
    display: block;
    overflow-x: auto;
}

.generated-content th,
.generated-content td {
    padding: 10px 14px;
    text-align: left;
    border: 1px solid var(--border-light);
}

.generated-content th {
    background: var(--bg-subtle);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
}

/* ========================================
   GOOGLE AUTH BUTTON
   ======================================== */
.btn-google-custom {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: white;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    padding: 0;
}

.btn-google-custom:hover {
    background: #f8f9fa;
    box-shadow: var(--shadow-md);
}

.google-icon-img {
    width: 18px;
    height: 18px;
}

.google-btn-wrapper {
    position: relative;
    width: 40px;
    height: 40px;
    margin-top: 12px;
    margin-left: 2px;
}

#googleBtnContainer {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    opacity: 0.01;
    z-index: 10;
    overflow: hidden;
    border-radius: 50%;
}

#googleBtnContainer iframe {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
}

/* Responsive Text Helpers */
.school-short {
    display: none;
}

.school-full {
    display: inline;
}

/* ========================================
   MODAL (DIALOG)
   ======================================== */
.modal {
    border: none;
    border-radius: var(--radius-lg);
    padding: 0;
    background: transparent;
    width: 90%;
    max-width: 520px;
    box-shadow: var(--shadow-xl);
    color: var(--text-primary);
}

.modal::backdrop {
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(6px);
}

.modal[open] {
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.modal-header h3 {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text-primary);
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    transition: all var(--transition-fast);
}

.btn-close:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-subtle);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Settings modal grade checkboxes */
.checkbox-grade {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8125rem;
    transition: background var(--transition-fast);
}

.checkbox-grade:hover {
    background: var(--accent-light);
}

.checkbox-grade input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

/* Settings modal section divider */
.settings-section-divider {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.settings-section-label {
    margin-bottom: 4px;
}

.settings-section-hint {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.settings-grades-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

/* Logo Upload Area */
.logo-upload-area {
    border: 2px dashed var(--border-medium);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--bg-subtle);
    position: relative;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-upload-area:hover,
.logo-upload-area.drag-over {
    border-color: var(--accent);
    background: rgba(13, 148, 136, 0.04);
}

/* Compact variant for inline school rows */
.logo-upload-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    margin-top: -4px;
}

.logo-upload-label {
    font-size: 0.6875rem !important;
    white-space: nowrap;
    color: var(--text-muted) !important;
    min-width: fit-content;
}

.logo-upload-compact {
    min-height: 48px;
    padding: 8px 12px;
    flex: 1;
}

.logo-upload-compact .logo-preview-img {
    max-height: 40px;
}

.logo-upload-compact .logo-upload-placeholder {
    flex-direction: row;
    gap: 6px;
}

.logo-upload-compact .logo-upload-placeholder span {
    font-size: 0.6875rem;
}

.logo-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.logo-upload-placeholder span {
    font-size: 0.75rem;
}

.logo-preview-container {
    position: relative;
    display: inline-block;
}

.logo-preview-img {
    max-width: 100%;
    max-height: 80px;
    height: auto;
    border-radius: 4px;
}

.btn-remove-logo {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--error);
    color: white;
    border: 2px solid white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform var(--transition-fast);
}

.btn-remove-logo:hover {
    transform: scale(1.1);
}

/* Plan Header - Two Column Layout */
.plan-header-logos {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e2e8f0;
}

.plan-header-logo-left,
.plan-header-logo-right {
    display: flex;
    align-items: center;
    gap: 0;
}

.plan-header-logo-left img,
.plan-header-logo-right img {
    max-height: 80px;
    width: auto;
}

.plan-header-school-info {
    text-align: right;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

.plan-header-school-info strong {
    display: block;
    font-size: 0.85rem;
    color: var(--text-primary);
}

@media print {
    .plan-header-logos {
        display: flex !important;
    }

    .plan-header-logos img {
        max-height: 70px !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}

@media (max-width: 640px) {
    .plan-header-logos {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }

    .plan-header-school-info {
        text-align: center;
    }
}

/* Dialog - Centered positioning */
dialog.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
}

dialog.modal::backdrop {
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(6px);
}

dialog.modal .modal-content {
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

dialog.modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-light);
    gap: 16px;
}

dialog.modal .modal-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

dialog.modal .modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-light);
}

/* Diary Summary Items */
.summary-item {
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 12px;
}

.summary-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.summary-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent);
    letter-spacing: 0.05em;
}

.btn-copy-summary {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all var(--transition-fast);
}

.btn-copy-summary:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.summary-text {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text-primary);
    margin: 0;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */
.toast {
    position: fixed;
    bottom: 88px;
    right: 24px;
    background: var(--primary);
    color: var(--text-inverse);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 9999999;
    transform: translateY(120%);
    opacity: 0;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 360px;
}

.toast.visible {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

.toast.warning {
    background: var(--warning);
    color: var(--primary);
}

/* ========================================
   MOBILE HEADER
   ======================================== */
.mobile-toggle {
    display: none;
}

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    background: var(--primary);
    z-index: 1000;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.12);
}

.mobile-header .logo-mobile {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    font-weight: 700;
    font-size: 1.125rem;
}

.mobile-header .logo-mobile span {
    color: var(--accent);
}

.mobile-header .btn-mobile-menu {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.mobile-header .btn-mobile-menu:hover {
    background: rgba(255, 255, 255, 0.08);
}

.btn-home-mobile {
    display: none;
    background: var(--accent);
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    margin-left: auto;
    margin-right: 8px;
    transition: background var(--transition-fast);
}

.btn-home-mobile:hover {
    background: var(--accent-hover);
}

.btn-home-mobile.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

/* ========================================
   RESPONSIVE - Tablet & Mobile
   ======================================== */
@media (max-width: 1024px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        z-index: 1200;
        top: 0;
        width: 80%;
        max-width: 300px;
        height: 100dvh;
        max-height: 100dvh;
        padding: 20px 16px;
        padding-bottom: 80px;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1100;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.visible {
        opacity: 1;
        visibility: visible;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .btn-close-sidebar {
        position: absolute;
        top: 16px;
        right: 12px;
        background: transparent;
        border: none;
        color: var(--text-muted);
        cursor: pointer;
        padding: 8px;
        display: block;
    }

    .btn-close-sidebar:hover {
        color: var(--text-inverse);
    }

    .main-content {
        margin-left: 0;
        margin-top: var(--header-height);
        height: calc(100dvh - var(--header-height)) !important;
        overflow-y: auto !important;
        padding: 20px;
        padding-top: 12px;
        padding-bottom: max(120px, calc(120px + env(safe-area-inset-bottom)));
        -webkit-overflow-scrolling: touch;
    }

    .content-grid {
        flex-direction: column;
        gap: 20px;
    }

    .form-panel {
        width: 100%;
        max-width: 100%;
        flex: 1 1 100%;
        position: static;
        max-height: none;
        overflow-y: visible;
        padding: 20px;
        padding-bottom: max(80px, calc(80px + env(safe-area-inset-bottom))) !important;
    }

    .onboarding-card {
        position: static;
        max-width: 100%;
    }

    .mobile-toggle {
        display: flex;
    }
}

@media (max-width: 1280px) {
    .form-panel {
        max-height: none !important;
        overflow-y: visible !important;
    }

    .shortcut-buttons {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    #gradeButtons {
        grid-template-columns: repeat(4, 1fr) !important;
    }

    .school-full,
    .grade-suffix {
        display: none !important;
    }

    .school-short {
        display: inline !important;
    }
}

@media (max-width: 768px) {
    .timeline-row {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .lesson-select,
    .lesson-focus {
        max-width: none;
        width: 100%;
    }

    .lesson-badge {
        align-self: flex-start;
    }
}

@media (max-width: 640px) {
    .main-content {
        padding: 12px;
        padding-top: 8px;
    }

    .form-panel,
    .result-panel {
        padding: 16px;
        width: 100%;
        max-width: 100%;
        border-radius: var(--radius-md);
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .panel-header {
        padding-bottom: 12px;
    }

    .panel-title {
        font-size: 1.125rem;
    }

    .btn-primary {
        padding: 12px 20px;
    }

    /* Mobile Result Optimization */
    .result-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 12px 16px;
    }

    .result-title {
        margin-bottom: 10px;
        width: 100%;
        border-bottom: 1px solid var(--border-light);
        padding-bottom: 10px;
        font-size: 0.875rem;
    }

    .result-actions {
        width: 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 4px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .result-actions::-webkit-scrollbar {
        display: none;
    }

    .result-actions .btn-icon {
        flex: 0 0 auto;
        justify-content: center;
        padding: 8px;
    }

    .result-actions .btn-icon span {
        display: none;
    }

    .result-actions .btn-icon svg {
        width: 18px;
        height: 18px;
    }

    #btnActionNew {
        display: none !important;
    }

    .result-content {
        padding: 16px;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {

    .sidebar,
    .mobile-toggle,
    .mobile-header,
    .result-header,
    .toast,
    .form-panel,
    .planedu-float-container {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
        padding: 0;
        height: auto !important;
        overflow: visible !important;
    }

    body {
        height: auto !important;
        overflow: visible !important;
        position: static !important;
    }

    .result-panel {
        box-shadow: none;
        border: none;
        min-height: 0;
    }

    .result-content {
        overflow: visible;
        padding: 0;
    }
}

/* ========================================
   CONTEÚDO PARA CADERNO
   ======================================== */
.conteudo-caderno {
    background-color: #fffbeb;
    border-left: 4px solid #f59e0b;
    padding: 20px 24px;
    border-radius: 8px;
    margin: 24px 0;
    page-break-inside: avoid;
}

.conteudo-caderno h2 {
    color: #92400e;
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.conteudo-caderno p {
    line-height: 1.8;
    margin-bottom: 10px;
}

.conteudo-caderno strong {
    color: #78350f;
}

.conteudo-caderno ul,
.conteudo-caderno ol {
    padding-left: 24px;
    margin-bottom: 10px;
    line-height: 1.8;
}

.conteudo-caderno table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}

.conteudo-caderno table th,
.conteudo-caderno table td {
    border: 1px solid #d97706;
    padding: 6px 10px;
    text-align: left;
}

.conteudo-caderno table th {
    background-color: #fef3c7;
    font-weight: 600;
}

@media print {
    .conteudo-caderno {
        border-left: 3px solid #000;
        background-color: #f9f9f9 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ========================================
   SCROLLBARS
   ======================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08) !important;
    border: none;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.12) !important;
}

/* ========================================
   SHARE MODE (Clean View / A4 Paper)
   ======================================== */
html.share-mode,
body.share-mode {
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100dvh !important;
    position: static !important;
    background-color: #e9ecef !important;
}

body.share-mode .sidebar,
body.share-mode .sidebar-wrapper,
body.share-mode #sidebar-wrapper,
body.share-mode .mobile-header,
body.share-mode .form-panel,
body.share-mode .onboarding-card,
body.share-mode #onboardingCard,
body.share-mode #btnToggleEdit,
body.share-mode #btnActionNew,
body.share-mode #editorContainer,
body.share-mode #emptyState {
    display: none !important;
}

body.share-mode .app-container,
body.share-mode .main-content,
body.share-mode .content-grid,
body.share-mode #wrapper,
body.share-mode #page-content-wrapper {
    margin-left: 0 !important;
    padding-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: flex-start !important;
    background-color: #e9ecef !important;
    box-shadow: none !important;
    border: none !important;
}

body.share-mode .main-content {
    margin: 0 !important;
    padding: 20px !important;
    height: auto !important;
    overflow: visible !important;
}

body.share-mode .content-grid {
    width: 100% !important;
}

body.share-mode .result-panel,
body.share-mode .container-fluid {
    flex: 0 0 auto !important;
    display: block !important;
    margin: 40px auto !important;
    width: 210mm !important;
    max-width: 90% !important;
    min-height: 297mm !important;
    height: auto !important;
    background-color: #ffffff !important;
    padding: 25mm 20mm !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12) !important;
    border-radius: 2px !important;
    border: none !important;
    overflow: visible !important;
}

body.share-mode .result-header {
    background: transparent !important;
    border-bottom: 1px solid var(--border-light) !important;
    padding: 0 0 16px 0 !important;
    margin-bottom: 20px !important;
    border-radius: 0 !important;
}

body.share-mode #staticView {
    display: block !important;
    padding: 0 !important;
}

body.share-mode #btnActionHome {
    display: inline-flex !important;
}

@media (max-width: 768px) {
    body.share-mode .result-panel {
        width: 95% !important;
        padding: 20px !important;
        margin-top: 16px !important;
        margin-bottom: 16px !important;
    }
}

/* ========================================
   FLOATING WHATSAPP + BACK TO TOP
   ======================================== */
.planedu-float-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    pointer-events: none;
}

.planedu-float-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: transparent;
    border-radius: 32px;
    overflow: visible;
    border: none;
    pointer-events: auto;
    transition: background var(--transition-fast), border-radius var(--transition-fast), box-shadow var(--transition-fast);
}

/* When back-to-top is visible, pill becomes a solid elongated container */
.planedu-float-pill:has(.planedu-btn-top.visible) {
    background: #1a2e3d;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.planedu-float-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    background: transparent;
    border: none;
    outline: none;
    text-decoration: none !important;
    padding: 0;
    margin: 0;
}

.planedu-float-btn svg {
    width: 22px;
    height: 22px;
    transition: all var(--transition-fast);
}

/* Back to Top */
.planedu-btn-top {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    height: 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
    min-height: 0;
}

.planedu-btn-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
    height: 48px;
}

.planedu-btn-top svg {
    color: rgba(245, 240, 232, 0.8);
}

.planedu-btn-top:hover {
    background: rgba(255, 255, 255, 0.08);
}

.planedu-btn-top:hover svg {
    color: #FFFFFF;
}

/* Divider */
.planedu-float-divider {
    width: 24px;
    height: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast), height var(--transition-fast);
    overflow: hidden;
}

.planedu-float-divider.visible {
    opacity: 1;
    height: 1px;
}

/* WhatsApp */
.planedu-btn-whatsapp {
    background: linear-gradient(135deg, #00C896 0%, #009688 100%);
    border-radius: 50%;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
    transition: border-radius var(--transition-fast), box-shadow var(--transition-fast);
}

/* When back-to-top is visible, WhatsApp is bottom half of pill */
.planedu-btn-whatsapp:not(.solo) {
    border-radius: 0 0 32px 32px;
    box-shadow: none;
}

.planedu-btn-whatsapp svg {
    color: #FFFFFF;
    width: 24px;
    height: 24px;
}

.planedu-btn-whatsapp:hover {
    background: linear-gradient(135deg, #26A69A 0%, #00897B 100%);
}

/* Tooltips */
.planedu-tooltip {
    position: absolute;
    right: 60px;
    background: #FFFFFF;
    color: #1a2e3d;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(6px);
    transition: all var(--transition-fast);
    pointer-events: none;
    box-shadow: var(--shadow-md);
}

.planedu-tooltip::after {
    content: '';
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-left-color: #FFFFFF;
    border-right: none;
}

.planedu-float-btn:hover .planedu-tooltip {
    opacity: 1;
    transform: translateX(0);
}

/* Wave animation */
.planedu-wave-indicator {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #00C896;
    opacity: 0;
    animation: planedu-wave-pulse 2.5s infinite;
    pointer-events: none;
    top: 0;
    left: 0;
}

.planedu-wave-indicator:nth-child(2) {
    animation-delay: 0.6s;
}

@keyframes planedu-wave-pulse {
    0% {
        transform: scale(1);
        opacity: 0.4;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

@media (max-width: 768px) {
    .planedu-float-container {
        bottom: 16px;
        right: 16px;
    }

    .planedu-tooltip {
        display: none;
    }

    .planedu-float-btn {
        width: 44px;
        height: 44px;
    }

    .planedu-btn-top.visible {
        height: 44px;
    }
}

/* ========================================
   DESKTOP LAYOUT LOCK (end-of-file override)
   ======================================== */
html,
body {
    height: 100dvh !important;
    width: 100% !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

.main-content {
    height: 100dvh;
    overflow-y: auto !important;
}

@media (max-width: 1024px) {
    .main-content {
        height: calc(100dvh - var(--header-height)) !important;
        overflow-y: auto !important;
    }
}

/* ========================================
   SSS INLINE EDITOR
   ======================================== */

/* Floating edit bar shown above the SSS plan when in edit mode */
.sss-edit-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
    color: #e2e8f0;
    padding: 10px 16px;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 4px;
}

@media print {
    .sss-edit-bar {
        display: none !important;
    }
}

.sss-edit-bar-label {
    flex: 1;
    opacity: 0.9;
}

.sss-edit-bar-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.sss-edit-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sss-btn-save {
    background: #16a34a;
    color: white;
}

.sss-btn-save:hover {
    background: #15803d;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.4);
}

.sss-btn-cancel {
    background: rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.sss-btn-cancel:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.3);
}

/* Editable content cells — dashed blue outline */
.sss-cell-editing {
    outline: 2px dashed #3b82f6 !important;
    outline-offset: -1px;
    cursor: text;
    min-height: 32px;
    transition: outline-color 0.15s;
}

.sss-cell-editing:focus {
    outline: 2px solid #2563eb !important;
    background-color: #eff6ff !important;
}

/* Info row editable cells — lighter indicator */
.sss-info-editing {
    outline: 1px dashed #94a3b8 !important;
}

.sss-info-editing:focus {
    outline: 1px solid #0ea5e9 !important;
    background-color: #f0f9ff !important;
}

/* ========================================
   FREE PLAN MODE — Button & Output Styles
   ======================================== */

/* FREE selector button — violet identity */
.grade-btn-free.active,
.grade-btn-free input:checked~.grade-btn-text {
    background: linear-gradient(135deg, #7c3aed, #6d28d9) !important;
    color: #fff !important;
    border-color: #7c3aed !important;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.grade-btn-free:hover {
    border-color: #7c3aed;
    color: #7c3aed;
}

/* Generate button in FREE mode */
.btn-generate-free {
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%) !important;
    border-color: #7c3aed !important;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35) !important;
}

.btn-generate-free:hover {
    background: linear-gradient(135deg, #6d28d9 0%, #7e22ce 100%) !important;
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45) !important;
    transform: translateY(-1px);
}

/* FREE plan output — idea cards */
.free-idea-card {
    background: var(--bg-card);
    border: 1px solid #e9d5ff;
    border-left: 4px solid #7c3aed;
    border-radius: var(--radius-md, 8px);
    padding: 18px 20px;
    margin: 16px 0;
    transition: box-shadow 0.2s;
}

.free-idea-card:hover {
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.1);
}

.free-idea-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #5b21b6;
    margin-bottom: 8px;
}

.free-idea-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
    background: #f5f3ff;
    border-radius: 6px;
    padding: 6px 10px;
    margin-bottom: 12px;
    display: inline-block;
}

.free-idea-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.free-idea-card ol,
.free-idea-card ul {
    padding-left: 18px;
    margin-bottom: 8px;
}

.free-idea-card li {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* FREE plan — closing tip box */
.free-plan-tip {
    background: linear-gradient(135deg, #faf5ff 0%, #f5f3ff 100%);
    border: 1px solid #d8b4fe;
    border-radius: var(--radius-md, 8px);
    padding: 16px 20px;
    margin-top: 24px;
}

.free-plan-tip h3 {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #5b21b6;
    margin-bottom: 8px;
}

.free-plan-tip p {
    font-size: 0.875rem;
    color: #4c1d95;
    line-height: 1.6;
    margin: 0;
}