:root {
    /* MODO CLARO (Por defecto) */
    --primary: #4f46e5;
    --primary-light: #e0e7ff;
    --primary-dark: #3730a3;
    --secondary: #0ea5e9;
    --bg-page: #cbd5e1;
    --bg-app: #f8fafc;
    --bg-panel: #ffffff;
    --bg-hover: #f1f5f9;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --icon-btn-hover: #e0e7ff;
    
    --font: 'Nunito', sans-serif;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 12px;
}

/* MODO ESCURO */
[data-theme="dark"] {
    --primary: #818cf8;
    --primary-light: #3730a3;
    --primary-dark: #4f46e5;
    --secondary: #38bdf8;
    --bg-page: #0f172a;
    --bg-app: #1e293b;
    --bg-panel: #0f172a;
    --bg-hover: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #34d399;
    --success-light: #064e3b;
    --warning: #fbbf24;
    --warning-light: #78350f;
    --danger: #f87171;
    --danger-light: #7f1d1d;
    --icon-btn-hover: #334155;
}

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

body {
    font-family: var(--font);
    background-color: var(--bg-page);
    color: var(--text-main);
    display: block; /* Eliminate flex centering causing scroll clipping */
    min-height: 100vh;
    padding: 20px; /* Padding para pantallas pequenas */
    transition: background-color 0.3s;
}

/* Scrollbars Premium */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
    border: 2px solid var(--bg-app);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.app-container {
    display: flex;
    width: 100%;
    max-width: 1400px; /* Aumentado para acomodar 3 columnas */
    height: calc(100vh - 40px);
    min-height: 700px; 
    margin: 0 auto;
    background: var(--bg-app);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* SIDEBAR */
.sidebar {
    width: 280px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 15px; /* Reducir o gap lixeiramente */
    overflow-y: auto; /* Permitir scroll na barra lateral se hai moitas cousas */
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary);
}

.logo-icon {
    background: var(--primary-light);
    color: var(--primary);
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; justify-content: center; align-items: center;
}

.compose-btn {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: none;
    padding: 12px 24px;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
    transition: box-shadow 0.2s, background 0.2s;
    display: flex; justify-content: center; align-items: center; gap: 12px;
}
.compose-btn:hover { 
    background: #d3e3fd; 
    box-shadow: 0 1px 3px 0 rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15); 
}
[data-theme="dark"] .compose-btn { background: var(--primary); color: white; }
[data-theme="dark"] .compose-btn:hover { background: var(--primary-dark); }

.nav-menu { display: flex; flex-direction: column; gap: 5px; }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 15px;
    text-decoration: none;
    color: var(--text-main);
    border-radius: var(--radius);
    font-weight: 600;
    transition: background 0.2s;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active { background: var(--primary-light); color: var(--primary-dark); }
[data-theme="dark"] .nav-item.active { color: var(--text-main); }
.nav-item.active i { color: var(--primary); }
.nav-item i { font-size: 1.2rem; color: var(--text-muted); }

.badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 20px;
}

/* FOLDERS */
.folders-section { margin-top: 10px; margin-bottom: 5px;}
.folders-header { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 800; color: var(--text-muted); padding: 0 10px; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px;}
.icon-btn-sm { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1.1rem;}
.icon-btn-sm:hover { color: var(--primary); }

.folder-dropdown {
    position: absolute; top: 100%; left: 0; background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 180px; z-index: 60;
    padding: 8px; margin-top: 8px;
}
.folder-option {
    display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; cursor: pointer; color: var(--text-main); font-weight: 600;
}
.folder-option:hover { background: var(--bg-hover); }

/* SCORE PANEL */
.score-panel {
    background: var(--bg-hover);
    padding: 15px;
    border-radius: var(--radius);
    margin-top: 10px;
}
.score-header { display: flex; justify-content: space-between; font-weight: 700; font-size: 0.9rem; margin-bottom: 8px; color: var(--primary); }
.progress-bar { width: 100%; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress { height: 100%; background: var(--success); transition: width 0.4s ease; }

/* MISSIONS SIDEBAR (DEREITA) */
.missions-sidebar {
    width: 320px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
}

.missions-panel {
    background: var(--warning-light);
    border: 1px solid var(--warning);
    padding: 20px;
    border-radius: var(--radius);
    transition: box-shadow 0.3s;
    position: relative;
    cursor: default;
    height: auto; /* Deixamos que medre co contido */
    margin-bottom: 20px; /* Espazo ao final para que non pegue ao borde */
}

.missions-panel h3 { 
    font-size: 1.2rem; 
    color: var(--warning); 
    margin-bottom: 20px; 
    display: flex; 
    align-items: center; 
    gap: 10px;
    border-bottom: 2px solid var(--warning);
    padding-bottom: 10px;
}

.mission-list { list-style: none; display: flex; flex-direction: column; gap: 15px; }
.mission-item {
    font-size: 0.95rem;
    display: flex;
    gap: 12px;
    color: var(--text-muted);
    background: var(--bg-panel);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--border);
    line-height: 1.5;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    overflow-wrap: break-word;
    word-break: break-word;
}
.mission-item > div:last-child {
    flex: 1;
    min-width: 0;
}
.mission-item.active { 
    border-color: var(--warning); 
    background: var(--warning-light);
    color: var(--text-main);
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.2);
}
.mission-item.completed { opacity: 0.7; scale: 0.98; }
.mission-check { width: 22px; height: 22px; border: 2px solid var(--warning); border-radius: 6px; flex-shrink: 0; display:flex; justify-content:center; align-items:center; color: white; font-size: 14px;}
.mission-item.completed .mission-check { background: var(--success); border-color: var(--success); }
.mission-item.completed .mission-check::after { content: '\eb7b'; font-family: 'remixicon'; }
.mission-item.completed .mission-check::after { content: '✓'; }

/* EMAILS E ANEXOS */
.email-attachments-view {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px dashed var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.attachment-preview-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    max-width: 300px;
    box-shadow: var(--shadow-sm);
}

.attachment-filename {
    padding: 8px 12px;
    font-size: 0.85rem;
    background: var(--bg-app);
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

.image-preview {
    width: 100%;
    display: block;
    max-height: 200px;
    object-fit: contain;
    background: #000;
}

.email-attachment-view {
    padding: 10px 15px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 10px;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* MAIN CONTENT */
.main-content { flex: 1; display: flex; flex-direction: column; background: var(--bg-panel); position: relative; overflow: hidden; }
.active-view { display: flex !important; flex-direction: column; flex: 1; overflow: hidden;}
.hidden-view { display: none !important; }

.top-header { height: 65px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; padding: 0 25px; gap: 15px; }
.top-left-actions { flex: 1; display: flex; gap: 15px; align-items: center; max-width: 60%; }
.search-bar { flex: 1; display: flex; align-items: center; background: var(--bg-app); padding: 10px 15px; border-radius: var(--radius); color: var(--text-muted); }
.search-bar input { border: none; background: transparent; outline: none; margin-left: 10px; width: 100%; font-family: var(--font); color: var(--text-main); }

.top-actions { display: flex; align-items: center; gap: 15px; }

.refresh-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.refresh-btn i {
    font-size: 1.1rem;
    transition: transform 0.4s ease;
}

.refresh-btn:hover i {
    transform: rotate(180deg);
}
.user-profile { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text-main); position: relative; cursor: pointer; padding: 5px 10px; border-radius: 8px; transition: background 0.2s;}
.user-profile:hover { background: var(--bg-hover); }
.avatar-img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--secondary); border: 2px solid var(--border);}

/* AVATAR SELECTOR DROPDOWN */
.avatar-dropdown { position: absolute; top: 55px; right: 0; background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 15px; width: 220px; max-height: 400px; overflow-y: auto; z-index: 50;}
.avatar-dropdown h4 { margin-bottom: 10px; font-size: 0.95rem; color: var(--text-main); text-align: center; position: sticky; top: 0; background: var(--bg-panel); padding-bottom: 5px; z-index: 2;}
.avatar-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.avatar-option { width: 100%; aspect-ratio: 1; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: transform 0.2s, border-color 0.2s; }
.avatar-option:hover { transform: scale(1.1); }
.avatar-option.selected { border-color: var(--primary); }

/* INBOX / EMAILS */
.empty-state { flex: 1; display:flex; flex-direction: column; align-items:center; justify-content:center; color: var(--text-muted); font-size: 1.2rem; }
.empty-state i { font-size: 4rem; margin-bottom: 10px; opacity: 0.5;}
.list-header { padding: 20px 25px; border-bottom: 1px solid var(--border); }
.list-header h2 { font-size: 1.3rem; color: var(--text-main); }
.list-header p { color: var(--text-muted); font-size: 0.95rem; margin-top: 5px;}
.email-list { overflow-y: auto; flex: 1; }
.email-row { display: flex; align-items: center; padding: 15px 25px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.2s; }
.email-row:hover { background: var(--bg-hover); box-shadow: inset 3px 0 0 var(--secondary); }
.email-row.unread { background: var(--bg-panel); font-weight: 700; }
.email-row.read { background: var(--bg-app); color: var(--text-muted); }
.email-sender { width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-main); }
[data-theme="dark"] .email-row.read .email-sender { color: var(--text-muted); }
.email-subject { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-main);}
.email-date { width: 90px; text-align: right; font-size: 0.85rem; color: var(--text-muted);}

/* READ EMAIL */
.read-toolbar { 
    padding: 15px 25px; 
    border-bottom: 1px solid var(--border); 
    display: flex; 
    align-items: center;
    gap: 12px; 
    background: var(--bg-hover);
}
.read-toolbar .icon-btn {
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    font-size: 0.95rem;
    gap: 8px;
    color: var(--text-main);
    font-weight: 700;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}
.read-toolbar .icon-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
    transform: translateY(-1px);
}
.read-toolbar .warning-btn:hover {
    background: var(--warning-light) !important;
    border-color: var(--warning) !important;
    color: #92400e !important;
}
.read-toolbar .icon-btn i { font-size: 1.1rem; }
.read-content { padding: 35px 40px; flex: 1; overflow-y: auto; }
.read-content h1 { font-size: 1.6rem; margin-bottom: 25px; color: var(--text-main);}
.read-meta { display: flex; align-items: center; gap: 15px; margin-bottom: 30px; }
.sender-info strong { display: block; color: var(--text-main);}
.sender-email { color: var(--text-muted); font-size: 0.9rem; }
.email-body { line-height: 1.7; font-size: 1.05rem; color: var(--text-main); }
.email-attachment-view { display: inline-flex; align-items: center; gap:8px; padding: 10px 15px; background: var(--bg-hover); border: 1px solid var(--border); border-radius: 8px; margin-top: 20px;}

/* EXAMPLES VIEW */
.examples-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 30px; overflow-y: auto;}
.example-card { padding: 25px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-panel); box-shadow: var(--shadow-sm); line-height: 1.6; color: var(--text-main);}
.example-card hr { border: 0; border-top: 1px solid var(--border); margin: 15px 0;}
.example-card.good { border-top: 4px solid var(--success); }
.example-card.bad { border-top: 4px solid var(--danger); background: var(--bg-app);}
.example-badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 20px; font-weight: 700; font-size: 0.85rem; margin-bottom: 15px; }
.good .example-badge { background: var(--success-light); color: var(--success); }
.bad .example-badge { background: var(--danger-light); color: var(--danger); }

/* COMPOSE MODAL (Dark mode adapt) */
.compose-modal {
    position: absolute; bottom: 0; right: 40px; width: 680px;
    background: var(--bg-panel); border-radius: 16px 16px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,0.3);
    display: flex; flex-direction: column; z-index: 100; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border);
}
.compose-modal.hidden { transform: translateY(110%); }
.compose-header { background: #334155; color: white; padding: 15px 20px; display: flex; justify-content: space-between; font-weight: 700; border-radius: 16px 16px 0 0; }
[data-theme="dark"] .compose-header { background: #1e293b; border-bottom: 1px solid var(--border);}
.compose-body { padding: 0 20px; display: flex; flex-direction: column; background: var(--bg-panel);}
.compose-field { display: flex; align-items: center; border-bottom: 1px solid var(--border); padding: 10px 0; }
.compose-field label { color: var(--text-muted); width: 85px; font-weight: 600; font-size: 0.95rem; }
.compose-field input { flex: 1; border: none; outline: none; background: transparent; color: var(--text-main); font-family: var(--font); font-size: 1rem; }
.toggle-cc-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-weight: 600;}

.editor-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.format-btn { padding: 6px; border-radius: 6px; font-size: 1.1rem; color: var(--text-main);}
.format-btn:hover { background: var(--bg-hover); color: var(--primary); }
.separator { width: 1px; height: 24px; background: var(--border); margin: 0 5px; }
.help-btn-sm { margin-left: auto; background: var(--warning-light); color: var(--warning); padding: 6px 12px; border-radius: 20px; font-weight: 700; font-size: 0.9rem;}

.editor-content { min-height: 250px; max-height: 400px; overflow-y: auto; padding: 15px 15px; font-size: 1.05rem; outline: none; line-height: 1.6; color: var(--text-main);}
.editor-content:empty:before { content: attr(placeholder); color: var(--text-muted); white-space: pre-wrap; font-style: italic;}
.editor-content blockquote { border-left: 3px solid var(--border); padding-left: 10px; margin-left: 0; color: var(--text-muted); font-style: italic; }
.editor-content ul, .editor-content ol { padding-left: 1.5em; margin: 4px 0; }
.editor-content ul li, .editor-content ol li { list-style-position: outside; margin-left: 0; padding-left: 0.3em; }
/* Fix: when text-align:center is applied, lists keep bullet/number next to text */
.editor-content [style*="text-align: center"] ul,
.editor-content [style*="text-align: center"] ol,
.editor-content ul[style*="text-align: center"],
.editor-content ol[style*="text-align: center"] { list-style-position: inside; padding-left: 0; }


.attachments-area:not(:empty) { 
    background: rgba(var(--primary-rgb, 26, 115, 232), 0.05);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 10px;
    margin-top: 5px;
}
.attachment-chip { background: white; border: 1px solid var(--border); padding: 6px 12px; border-radius: 20px; font-size: 0.9rem; display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-main); box-shadow: 0 1px 2px rgba(0,0,0,0.1);}
.remove-att { cursor: pointer; color: var(--danger); font-size: 1.1rem; transition: transform 0.2s;}
.remove-att:hover { transform: scale(1.2); }

.compose-footer { padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; background: var(--bg-app); border-top: 1px solid var(--border); }
.action-buttons { display: flex; align-items: center; gap: 15px; }
.send-btn { background: var(--primary); color: white; border: none; padding: 10px 24px; border-radius: 20px; font-weight: 600; font-size: 0.95rem; cursor: pointer; transition: background 0.2s, box-shadow 0.2s; box-shadow: 0 1px 2px rgba(60,64,67,0.3);}
.send-btn:hover { background: var(--primary-dark); box-shadow: 0 1px 3px rgba(60,64,67,0.5); }
.hidden-file-input { display: none; }
.icon-btn { background: none; border: none; font-size: 1.3rem; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; padding: 6px; border-radius: 50%;}
.icon-btn:hover { color: var(--primary); background: var(--icon-btn-hover); }

.warning-btn { color: var(--warning); }
.warning-btn:hover { background: var(--warning-light) !important; color: #b45309 !important; }

/* FEEDBACK PANEL */
.feedback-panel { 
    position: absolute; 
    top: 60px; /* Baixalo para que non tape o header do modal */
    left: 10px; 
    right: 10px;
    background: var(--bg-panel); 
    border: 2px solid var(--danger);
    border-radius: 12px;
    padding: 20px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.3); 
    z-index: 150; 
    color: var(--text-main); 
    animation: fadeInScale 0.3s ease-out; 
}
.feedback-panel.success { border-color: var(--success); }
.feedback-header { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 1.1rem; color: var(--danger); margin-bottom: 12px; }
@keyframes fadeInScale { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.feedback-panel.success .feedback-header { color: var(--success); }
.feedback-body { font-size: 1rem; color: var(--text-main); line-height: 1.5; }
.feedback-body ul { margin-left: 25px; margin-top: 10px; }

/* HINTS PANEL */
.hints-panel { position: absolute; bottom: 90px; right: 620px; background: var(--bg-panel); border: 2px solid var(--primary); border-radius: var(--radius); padding: 20px; width: 300px; box-shadow: var(--shadow-lg); z-index: 99; color: var(--text-main);}
.hint-section { margin-bottom: 15px; font-size: 0.9rem; }
.hint-section strong { display: block; margin-bottom: 6px; color: var(--text-main);}
.hint-chip { display: inline-block; background: var(--bg-app); border: 1px solid var(--border); padding: 6px 10px; border-radius: 6px; margin: 3px 3px 3px 0; cursor: pointer; transition: all 0.2s; font-weight: 600;}
.hint-chip:hover { background: var(--primary-light); border-color: var(--primary); color: var(--text-main); }
.hint-info { background: var(--primary-light); padding: 10px; border-radius: 8px; border-left: 3px solid var(--secondary); margin-top: 10px; color: var(--text-main);}
[data-theme="dark"] .hint-info { background: var(--bg-app); }
.close-hints { width: 100%; background: var(--primary); color: white; border: none; padding: 8px; border-radius: 8px; cursor: pointer; font-weight: 700; margin-top: 5px;}
.close-hints:hover { background: var(--primary-dark); }

.hidden { display: none !important; }

/* SELECTOR DE IDIOMA DESPLEGABLE */
.lang-dropdown-container {
    position: relative;
    z-index: 1000;
}
.lang-dropdown {
    position: relative;
    background: var(--bg-panel);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    min-width: 80px;
    user-select: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}
.lang-dropdown:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}
.lang-current {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-weight: 800;
}
.lang-current i:last-child {
    color: var(--primary);
    font-size: 1rem;
}

.welcome-lang .lang-dropdown {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}
.welcome-lang .lang-current i {
    color: white !important;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.lang-options {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    width: 160px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    overflow: hidden;
    animation: slideDown 0.2s ease-out;
    z-index: 3001;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-main) !important;
    font-size: 0.9rem;
}

.lang-option:hover { 
    background: var(--bg-hover); 
    color: var(--primary) !important;
}

.lang-option img { width: 24px; border-radius: 3px; }

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

/* ==========================================
   PANTALLA DE BENVIDA (ONBOARDING)
   ========================================== */

.welcome-screen {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    z-index: 1000;
    overflow-y: auto; /* Clave para poder facer scroll se a pantalla de inicio é moi grande */
    color: white;
}

[data-theme="dark"] .welcome-screen {
    background: linear-gradient(135deg, var(--bg-page) 0%, var(--primary-light) 100%);
}

.welcome-step {
    background: var(--bg-panel);
    color: var(--text-main);
    padding: 40px 50px;
    border-radius: var(--radius);
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    max-width: 800px;
    width: 90%;
    margin: 60px auto; /* Centrar horizontalmente e deixar espazo por arriba */
    text-align: center;
    animation: fadeInSlideUp 0.6s ease-out;
    position: relative;
    z-index: 1010;
}

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

.hidden-step { display: none !important; }

.welcome-title { font-size: 2.5rem; margin-bottom: 15px; color: var(--primary); font-weight: 800;}
.welcome-subtitle { font-size: 1.2rem; margin-bottom: 35px; line-height: 1.5; color: var(--text-muted); }

/* Teoría Box */
.theory-box {
    background: var(--bg-app);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 30px;
    margin-bottom: 35px;
}

/* TUTORIAL HIGHLIGHT E OVERLAY */
#tutorialOverlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(15,23,42,0.6); z-index: 9000; transition: all 0.3s ease;}
.tutorial-box { position: absolute; background: var(--bg-panel); border: 2px solid var(--primary); border-radius: 12px; padding: 20px; width: 350px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); z-index: 9001; transition: all 0.3s ease; }
.tutorial-box h3 { color: var(--primary); margin-bottom: 15px; font-size: 1.3rem; display:flex; align-items:center; gap:8px;}
.tutorial-box p { color: var(--text-main); font-size: 1.05rem; margin-bottom: 25px; line-height: 1.5; }
.tutorial-footer { display: flex; justify-content: space-between; align-items: center; }
#tutorialStepIndicator { font-size: 0.9rem; color: var(--text-muted); font-weight: 700; background: var(--bg-hover); padding: 4px 10px; border-radius:12px;}
.tutorial-btn { background: var(--primary); color: white; border: none; padding: 10px 18px; border-radius: 20px; cursor: pointer; font-weight: 700; transition: all 0.2s;}
.tutorial-btn-alt { background: transparent; color: var(--text-muted); border: none; padding: 10px 15px; cursor: pointer; font-weight:600;  transition: all 0.2s;}
.tutorial-btn:hover { background: var(--primary-dark); transform:translateY(-2px);}
.tutorial-btn-alt:hover { color: var(--text-main); }

.tutorial-highlight {
    position: relative;
    z-index: 9002 !important;
    box-shadow: 0 0 0 6px rgba(56, 189, 248, 0.4), 0 0 25px rgba(56, 189, 248, 0.6) !important;
    background: var(--bg-panel) !important;
    border-radius: 8px;
    pointer-events: none; /* Evitar clics mentres se fai o titorial */
}

/* COMIC FLOATING TOOLTIPS (Substitutos de alert) */
.comic-floating-tooltip {
    position: absolute;
    background: var(--bg-app);
    color: var(--text-main);
    border: 2px solid var(--primary);
    padding: 10px 15px;
    border-radius: 12px;
    font-size: 0.9rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: 9999;
    width: max-content;
    max-width: 250px;
    text-align: center;
    line-height: 1.4;
    animation: popIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards, fadeOut 0.3s ease-in 3.5s forwards;
    pointer-events: none;
}
.comic-floating-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: var(--primary);
}
@keyframes popIn {
    0% { opacity: 0; transform: translate(-50%, 10px) scale(0.9); }
    100% { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes fadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* RESET BUTTON (Comezar de novo) */
#resetBtn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-panel);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 700;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: var(--shadow-sm);
}
#resetBtn:hover {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
#resetBtn i {
    font-size: 1.1rem;
}
#resetBtn:hover::before {
    content: attr(data-tooltip);
    position: absolute;
    top: 130%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-panel);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    white-space: normal;
    text-align: center;
    width: max-content;
    max-width: 200px;
    z-index: 9999;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    animation: fadeIn 0.15s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}
.theory-box h3 { margin-bottom: 25px; color: var(--text-main); font-size: 1.4rem;}

.email-anatomy {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.anatomy-part {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.part-text { font-size: 1.8rem; font-weight: 800; font-family: monospace; letter-spacing: 1px; margin-bottom: 8px;}
.part-label { font-size: 0.9rem; font-weight: 600; opacity: 0.9;}

.part-user { background: var(--secondary); color: white; }
.part-at { background: var(--text-muted); color: white; border-radius: 50%; padding: 10px; width: 90px; height: 90px; justify-content: center; text-align: center;}
.part-at .part-text { font-size: 1.4rem; margin-bottom: 2px; }
.part-at .part-label { font-size: 0.8rem; line-height: 1.1; }
.part-domain { background: var(--success); color: white; }

/* Creation Box */
.creation-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    background: var(--bg-app);
    padding: 30px;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    margin-bottom: 30px;
    text-align: left;
}

.creation-box h3 { font-size: 1.2rem; margin-bottom: 15px; color: var(--text-main); }

.welcome-avatar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    background: var(--bg-panel);
    padding: 15px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    max-height: 250px;
    overflow-y: auto;
}
.welcome-avatar-grid img { width: 100%; aspect-ratio: 1; border-radius: 50%; border: 4px solid transparent; cursor: pointer; transition: transform 0.2s;}
.welcome-avatar-grid img:hover { transform: scale(1.1); }
.welcome-avatar-grid img.selected { border-color: var(--primary); background: var(--primary-light); }

.address-input-group {
    display: flex;
    align-items: center;
    background: var(--bg-panel);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 10px;
}
.address-input-group:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }

.address-input-group input {
    flex: 1;
    padding: 15px;
    border: none;
    outline: none;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    background: transparent;
    width: 100%;
    user-select: text !important;
    -webkit-user-select: text !important;
    appearance: none;
    -webkit-appearance: none;
}
.at-symbol {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-muted);
    padding: 0 10px;
    background: var(--bg-app);
    height: 100%;
    display: flex;
    align-items: center;
}
.address-input-group select {
    padding: 15px 15px 15px 5px;
    border: none;
    outline: none;
    font-size: 1.1rem;
    background: var(--bg-app);
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
}

.error-msg { display: block; color: var(--danger); font-size: 0.9rem; font-weight: 700; margin-top: 10px; }

/* Botóns Benvida */
.welcome-actions { display: flex; justify-content: center; gap: 20px;}
.welcome-btn {
    background: var(--primary);
    color: white;
    font-size: 1.2rem;
    font-weight: 800;
    padding: 15px 35px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1020;
}
.welcome-btn:hover { background: var(--primary-dark); transform: translateY(-3px); }
.welcome-btn i { font-size: 1.5rem; }

.welcome-btn-secondary {
    background: var(--bg-app);
    color: var(--text-main);
    font-size: 1.1rem;
    font-weight: 700;
    padding: 15px 25px;
    border: 2px solid var(--border);
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    z-index: 1020;
}
.welcome-btn-secondary:hover { background: var(--border); }

/* ==========================================
   DIPLOMA E MODAL DE VICTORIA
   ========================================== */

.diploma-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.98); backdrop-filter: blur(10px);
    z-index: 2000; display: block; /* Cambiamos a block para un mellor control do scroll interno */
    padding: 60px 0; overflow-y: auto;
}

.victory-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(8px);
    z-index: 2000; display: flex; flex-direction: column;
    justify-content: center; align-items: center;
}

.victory-content {
    background: var(--bg-panel); padding: 50px; border-radius: 20px;
    text-align: center; max-width: 500px;
    animation: bounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.victory-content h1 { font-size: 2.5rem; color: var(--warning); margin-bottom: 20px; }
.victory-content p { font-size: 1.2rem; color: var(--text-main); margin-bottom: 30px; line-height: 1.5; }
.victory-actions { display: flex; justify-content: center; gap: 15px; }

@keyframes bounceIn {
    0% { transform: scale(0.5); opacity: 0; }
    80% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.diploma-container {
    background: #0f172a; 
    width: 1000px;
    max-width: 95vw;
    margin: 0 auto; /* Centrar no modo block */
    padding: 25px; 
    box-shadow: 0 0 60px rgba(56, 189, 248, 0.3);
    color: #e2e8f0;
    font-family: 'Rajdhani', 'Nunito', sans-serif;
    animation: slideUpFade 0.4s ease-out;
    border-radius: 4px; /* Bordes máis técnicos, menos redondeados */
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(56, 189, 248, 0.2);
}

/* Background grid e radial glow */
.diploma-container::before {
    content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: 
        radial-gradient(circle at center, rgba(56, 189, 248, 0.15) 0%, transparent 70%),
        linear-gradient(rgba(56, 189, 248, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(56, 189, 248, 0.05) 1px, transparent 1px);
    background-size: 100% 100%, 25px 25px, 25px 25px; 
    z-index: 1; pointer-events: none;
}

/* Liña de escaneo animada */
.diploma-container::after {
    content: ''; position: absolute; top: -100%; left: 0; width: 100%; height: 100px;
    background: linear-gradient(to bottom, transparent, rgba(56, 189, 248, 0.1), transparent);
    z-index: 3; pointer-events: none;
    animation: scanline 6s linear infinite;
}

@keyframes scanline {
    0% { top: -10%; }
    100% { top: 110%; }
}

.diploma-border {
    border: 1px solid rgba(56, 189, 248, 0.4); 
    padding: 40px; 
    text-align: center; 
    background: rgba(15, 23, 42, 0.6);
    position: relative; 
    z-index: 2; 
    height: 100%; 
    box-shadow: inset 0 0 30px rgba(56, 189, 248, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Tech Corners con Glow */
.tech-corner { position: absolute; width: 40px; height: 40px; border: 2px solid #38bdf8; box-shadow: 0 0 10px #38bdf8; }
.tech-corner.tl { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.tech-corner.tr { top: -1px; right: -1px; border-left: none; border-bottom: none; }
.tech-corner.bl { bottom: -1px; left: -1px; border-right: none; border-top: none; }
.tech-corner.br { bottom: -1px; right: -1px; border-left: none; border-top: none; }

.diploma-header { margin-bottom: 20px; display: flex; flex-direction: column; align-items: center; }
.cyber-badge { 
    width: 90px; height: 90px; 
    background: rgba(15, 23, 42, 0.8); 
    border: 2px solid #38bdf8;
    border-radius: 50%; 
    display: flex; justify-content: center; align-items: center;
    font-size: 3.5rem; color: #38bdf8; 
    margin-bottom: 20px; 
    box-shadow: 0 0 30px rgba(56, 189, 248, 0.6);
    position: relative;
}
.cyber-badge::after {
    content: ''; position: absolute; width: 120%; height: 120%;
    border-radius: 50%; border: 1px dashed rgba(56, 189, 248, 0.3);
    animation: rotate 10s linear infinite;
}

@keyframes rotate { 100% { transform: rotate(360deg); } }

.diploma-header h2 { 
    font-size: 2.5rem; 
    color: #38bdf8; 
    text-transform: uppercase; 
    letter-spacing: 5px; 
    text-shadow: 0 0 15px rgba(56, 189, 248, 0.8); 
    font-weight: 800;
    margin-bottom: 5px;
}
.tech-divider { 
    width: 250px; height: 4px; background: #38bdf8; margin: 10px auto; 
    box-shadow: 0 0 15px #38bdf8; 
    border-radius: 2px;
}

.mono-text { 
    font-family: 'Rajdhani', monospace; 
    font-size: 1.2rem; 
    color: #94a3b8; 
    letter-spacing: 2px; 
    font-weight: 500;
}

.diploma-body h3 { 
    font-size: 4rem; 
    color: #ffffff; 
    margin: 20px 0; 
    text-transform: uppercase; 
    letter-spacing: 4px;
    text-shadow: 0 0 20px rgba(56, 189, 248, 0.5), 0 0 40px rgba(56, 189, 248, 0.2);
    font-weight: 900;
    position: relative;
}

.tech-skills-grid { 
    display: grid; grid-template-columns: 1fr 1fr; gap: 20px; 
    max-width: 800px; margin: 25px auto; 
}
.tech-skill { 
    background: rgba(30, 41, 59, 0.4); 
    border: 1px solid rgba(56, 189, 248, 0.2); 
    padding: 18px; 
    border-radius: 6px; 
    display: flex; align-items: center; gap: 15px; 
    font-size: 1.1rem; color: #cbd5e1;
    text-align: left; 
    transition: all 0.3s;
}
.tech-skill:hover {
    background: rgba(56, 189, 248, 0.1);
    border-color: rgba(56, 189, 248, 0.5);
    transform: translateY(-2px);
}
.tech-skill i { color: #38bdf8; font-size: 1.8rem; filter: drop-shadow(0 0 5px #38bdf8); }

.diploma-footer { 
    margin-top: 30px; 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 0 20px;
}
.barcode-container { display: flex; flex-direction: column; align-items: flex-start; }
.barcode { 
    width: 150px; height: 50px; 
    background: repeating-linear-gradient(90deg, #94a3b8, #94a3b8 2px, transparent 2px, transparent 6px, #94a3b8 6px, #94a3b8 7px, transparent 7px, transparent 12px);
    margin-bottom: 5px; opacity: 0.8;
}

.diploma-signatures { display: flex; gap: 40px; }
.tech-signature { 
    text-align: center; 
    border-top: 1px dashed rgba(56, 189, 248, 0.5); 
    padding-top: 15px; 
    width: 200px; 
    position: relative; 
}
.verified-badge { 
    position: absolute; top: -28px; left: 50%; transform: translateX(-50%);
    background: #0f172a; 
    color: #10b981; 
    border: 1px solid #10b981;
    padding: 4px 12px; 
    border-radius: 20px; 
    font-size: 0.8rem; font-weight: 800; 
    display: flex; align-items: center; gap: 5px;
    white-space: nowrap;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}
.verified-badge.admin { color: #38bdf8; border-color: #38bdf8; box-shadow: 0 0 10px rgba(56, 189, 248, 0.3); }

.tech-signature p { 
    font-family: 'Rajdhani', sans-serif; 
    font-size: 1rem; 
    color: #f8fafc; 
    letter-spacing: 2px;
    font-weight: 700;
    text-transform: uppercase;
}

.diploma-actions { 
    margin: 40px auto 60px auto; /* Máis marxe abaixo para o scroll */
    display: flex; gap: 20px; 
    justify-content: center;
    position: relative; z-index: 2010;
}

/* REGRAS DE IMPRESIÓN (Adapting tech theme to print) */
@media print {
    body * { visibility: hidden !important; }
    .diploma-overlay { position: absolute; left: 0; top: 0; margin: 0; padding: 0; background: none; }
    #diplomaPrintArea, #diplomaPrintArea * { visibility: visible !important; }
    #diplomaPrintArea { position: absolute; left: 0; top: 0; width: 100%; padding:0; box-shadow: none; background: white !important; color: black !important; }
    .diploma-container::before { display: none; }
    .diploma-border { background: white !important; border-color: #333 !important; box-shadow: none !important;}
    .tech-corner { border-color: #333 !important; }
    .cyber-badge, .tech-skill { border-color: #333 !important; background: transparent !important; color: black !important;}
    .cyber-badge i, .tech-skill i, .diploma-header h2 { color: black !important; text-shadow: none !important; }
    .diploma-body h3 { -webkit-text-fill-color: black !important; border-bottom-color: black !important; }
    .tech-divider { background: black !important; box-shadow: none !important; }
    .mono-text, .tech-signature p { color: black !important; }
    .verified-badge { border-color: black !important; color: black !important; }
    .no-print { display: none !important; }
    
    @page { size: landscape; margin: 1cm; }
}

/* COMPOSE MODAL */
.compose-modal {
    position: absolute;
    bottom: 0;
    right: 30px;
    width: 680px;
    height: 600px;
    background: var(--bg-panel);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -5px 25px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    z-index: 80;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.3s;
}

.compose-header {
    background: var(--bg-hover);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
}

.compose-header span { color: var(--text-main); }
.compose-actions button { background: none; border: none; font-size: 1.2rem; margin-left: 10px; cursor: pointer; color: var(--text-muted); }
.compose-actions button:hover { color: var(--primary); }

.compose-body { flex: 1; display: flex; flex-direction: column; overflow-y: auto; padding: 0 20px; }

.compose-field {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
    position: relative;
}
.compose-field label { width: 85px; color: var(--text-muted); font-size: 0.9rem; cursor: help;}
.compose-field input { flex: 1; border: none; outline: none; background: transparent; font-family: var(--font); color: var(--text-main); font-size: 1rem;}

.compose-editor-toolbar {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-panel);
}
.compose-editor-toolbar button { background: none; border: none; padding: 5px; cursor: pointer; color: var(--text-muted); font-size: 1.1rem; border-radius: 4px;}
.compose-editor-toolbar button:hover { background: var(--bg-hover); color: var(--text-main); }

.compose-textarea {
    flex: 1; min-height: 150px; padding: 20px 0; border: none; outline: none; resize: none; font-family: var(--font); font-size: 1.05rem; line-height: 1.6; color: var(--text-main);
}
.compose-textarea[contenteditable]:empty::before { content: attr(placeholder); color: var(--text-muted); opacity: 0.6;}

.compose-attachments { padding: 10px 0; display: flex; flex-wrap: wrap; gap: 8px; }
.attachment-chip { background: var(--bg-app); border: 1px solid var(--border); padding: 5px 12px; border-radius: 15px; font-size: 0.85rem; display: flex; align-items: center; gap: 5px;}

.compose-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-hover);
}

.compose-left-actions { display: flex; align-items: center; gap: 10px; }
.send-btn { background: var(--primary); color: white; border: none; padding: 8px 24px; border-radius: 20px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; box-shadow: 0 1px 2px rgba(60,64,67,0.3); transition: background 0.2s, box-shadow 0.2s;}
.send-btn:hover { background: var(--primary-dark); box-shadow: 0 1px 3px rgba(60,64,67,0.5); }
.compose-left-actions .icon-btn { background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; padding: 5px; border-radius: 4px;}
.compose-left-actions .icon-btn:hover { background: var(--border); color: var(--text-main); }

.compose-right-actions button { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer;}
.compose-right-actions button:hover { color: var(--danger); }
/* ==========================================
   RESPONSIVIDADE (MEDIA QUERIES)
   ========================================== */

@media (max-width: 1024px) {
    .app-container { max-width: 100%; border-radius: 0; }
    .sidebar { width: 240px; }
    .missions-sidebar { width: 260px; padding: 15px; }
}

@media (max-width: 900px) {
    body { padding: 0; }
    .app-container { height: 100vh; flex-direction: column; border-radius: 0; box-shadow: none; }
    
    /* Sidebar horizontal */
    .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 10px; }
    .sidebar-header { margin-bottom: 10px; }
    .nav-menu { flex-direction: row; overflow-x: auto; padding-bottom: 5px; gap: 5px; }
    .nav-item { padding: 8px 12px; font-size: 0.85rem; flex-shrink: 0; border-radius: 20px; }
    
    /* Ocultamos o que non cabe pero deixamos o esencial */
    .data-management, .sidebar-footer, .folders-section { display: none; }
    .score-panel { margin-top: 0; padding: 10px; }
    
    /* Main Content */
    .main-content { height: 60vh; }
    
    /* Misións pasan a ser unha sección debaixo do contido */
    .missions-sidebar { 
        width: 100%; 
        height: auto; 
        border-left: none; 
        border-top: 1px solid var(--border); 
        background: var(--bg-app);
        padding: 20px;
        flex: none;
    }
    .missions-panel { margin-bottom: 0; }
    
    .top-header { height: 55px; padding: 0 10px; }
    .search-bar { display: none; }
    
    .email-row { padding: 15px 10px; }
    .email-sender { width: 100px; font-size: 0.85rem; }
    .email-subject { font-size: 0.85rem; }
    .email-date { width: 50px; font-size: 0.7rem; }
    
    .compose-modal { width: 100%; right: 0; border-radius: 0; height: 100%; top: 0; }
    .read-content { padding: 15px; }
    .read-toolbar { overflow-x: auto; white-space: nowrap; padding-bottom: 5px; }
    
    /* Diploma adaptativo */
    .diploma-container { width: 98vw; padding: 10px; aspect-ratio: auto; height: auto; }
    .diploma-border { padding: 25px; }
    .diploma-header h2 { font-size: 1.5rem; letter-spacing: 2px; }
    .diploma-body h3 { font-size: 1.8rem; margin: 15px 0; }
    .tech-skills-grid { grid-template-columns: 1fr; gap: 10px; }
    .tech-skill { padding: 12px; font-size: 0.9rem; }
    .diploma-signatures { flex-direction: column; gap: 30px; align-items: center; margin-top: 20px;}
    .tech-signature { width: 100%; border-top-width: 1px; }
}

@media (max-width: 600px) {
    .welcome-step { padding: 20px; margin: 20px auto; }
    .welcome-title { font-size: 1.8rem; }
    .creation-box { grid-template-columns: 1fr; gap: 20px; }
    .email-anatomy { transform: scale(0.8); }
    .theory-box grid { grid-template-columns: 1fr; }
}
