/* ==========================================
   1. CSS VARIABLES (DRIBBBLE DARK THEME)
   ========================================== */
:root {
    /* Deep Midnight Palette */
    --bg: #0b0f19;
    --s1: #151a28;
    --s2: #1e2436;
    --s3: #2a3249;
    /* Vibrant Neon Accents */
    --acc: #7c3aed;
    --acc2: #a78bfa;
    --acc3: #ddd6fe;
    /* Text Colors */
    --tx: #f8fafc;
    --tx2: #94a3b8;
    --tx3: #64748b;
    /* Borders & Status */
    --bd: rgba(255, 255, 255, 0.08);
    --bd2: rgba(255, 255, 255, 0.12);
    --bd3: rgba(255, 255, 255, 0.2);
    --ok: #10b981;
    --er: #ef4444;
    /* UI Metrics */
    --rad: 16px;
    --rad-sm: 8px;
    --shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
    --shadow-hover: 0 20px 40px -10px rgba(124, 58, 237, 0.15);
    /* ==========================================
   LIGHT MODE TYPOGRAPHY & BORDERS
   Garante contraste perfeito em fundos claros
   ========================================== */
[data-theme="light"] {
    --bg: #f8fafc;
    --s1: #ffffff;
    --h-bg: #ffffff;
    --tx: #0f172a;    /* Texto quase preto */
    --tx2: #475569;   /* Cinza escuro */
    --bd: rgba(0, 0, 0, 0.1);
    --acc: #6d28d9;   /* Roxo um pouco mais escuro para contraste */
}

/* Garante que o ícone do menu (hambúrguer) acompanha a cor do texto */
.hdr button, .hdr i {
    color: var(--tx);
}
}

/* ==========================================
   2. GLOBAL & TYPOGRAPHY
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body, header, nav, h1, h2, h3, input, button, select, textarea, div, span {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.notranslate, .ph, .ipa-chart, .gloss-orig, .gloss-morph {
    font-family: 'Doulos SIL', 'Charis SIL', 'Noto Sans', 'Arial Unicode MS', 'Segoe UI Historic', 'Times New Roman', sans-serif !important;
    font-feature-settings: "mark" 1, "mkmk" 1; 
    font-variant-ligatures: normal;
    letter-spacing: normal !important; 
}

body {
    background: var(--bg);
    color: var(--tx);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: radial-gradient(circle at 50% 0%, #1a1638 0%, transparent 50%);
    background-repeat: no-repeat;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--s3); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--acc); }

/* ==========================================
   3. NEW HEADER & SIDEBAR NAVIGATION
   ========================================== */
.hdr {
    background-color: var(--h-bg, var(--bg)) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--bd);
    padding: 15px 25px;
    position: sticky;
    top: 0;
    z-index: 100; /* Garante que o header fique na frente */
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.hdr-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    max-width: 1200px;
    margin: 0 auto;
}

.hdr-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hdr h1 {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(to right, var(--acc3), var(--acc2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
    margin: 0;
}

.pro-badge {
    font-size: 0.7rem;
    background: linear-gradient(135deg, var(--acc), var(--acc2));
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 900;
    letter-spacing: 1px;
}

.menu-toggle {
    background: transparent;
    border: none;
    color: var(--tx);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--rad-sm);
    transition: 0.2s;
}

.menu-toggle:hover { background: var(--s2); }

/* OVERLAY (O fundo embaçado que fecha o menu) */
.sidebar-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1; visibility: visible;
}

/* SIDEBAR (O menu travado na esquerda com 280px) */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 280px; /* Limite de largura restaurado */
    height: 100vh;
    background: var(--s1);
    border-right: 1px solid var(--bd);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column;
    box-shadow: 20px 0 50px rgba(0, 0, 0, 0.2);
}

.sidebar.active { transform: translateX(0); }

.sidebar-header {
    padding: 25px 20px 15px;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--bd);
}

.sidebar-scroll { overflow-y: auto; padding: 15px 0; flex: 1; }

/* BOTÕES DO MENU */
.sidebar .nb {
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    color: var(--tx2);
    border: none;
    border-radius: 0;
    text-align: left;
    padding: 14px 25px;
    width: 100%;
    border-left: 3px solid transparent;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar .nb:hover {
    background: var(--s2);
    color: var(--tx);
    border-left-color: var(--acc2);
}

.sidebar .nb.on {
    background: rgba(124, 58, 237, 0.1);
    border-left-color: var(--acc);
    color: var(--acc3);
}

/* ALINHAMENTO GERAL DE BOTÕES E ÍCONES */
.btn-hdr, .btn-auth, .btn, .btn-sm, .project-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Tamanho padrão pros ícones da Lucide */
.lucide {
    width: 18px;
    height: 18px;
    stroke-width: 2px;
}

.hdr-tools {
    display: flex; gap: 5px; align-items: center;
    background: var(--s1); padding: 4px; border-radius: 8px; border: 1px solid var(--bd);
    margin-left: auto;
}

.btn-hdr {
    background: transparent; color: var(--tx2); border: none;
    padding: 6px 12px; border-radius: 6px; font-size: 0.85rem; font-weight: 600;
    cursor: pointer; transition: all 0.3s;
}

.btn-hdr:hover {
    background: var(--s2); color: var(--tx); transform: translateY(-1px) scale(1.02);
}

.btn-auth {
    background: linear-gradient(135deg, var(--acc), var(--acc2));
    color: #ffffff; border: none; padding: 8px 18px; border-radius: 8px;
    font-size: 0.9rem; font-weight: bold; cursor: pointer; transition: 0.3s;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}

.btn-auth:hover { filter: brightness(1.1); transform: translateY(-2px) scale(1.05); box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4); }

/* ==========================================
   4. LAYOUT & CARDS
   ========================================== */
.content { padding: 40px 20px; max-width: 1100px; margin: 0 auto; }

.tab { display: none; animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
.tab.on { display: block; }

@keyframes slideUp { from { opacity: 0; transform: translateY(20px) } to { opacity: 1; transform: translateY(0) } }

.card {
    background: var(--s1); border: 1px solid var(--bd); border-radius: var(--rad);
    padding: 30px; margin-bottom: 25px; box-shadow: var(--shadow); transition: 0.3s;
}
.card:hover { border-color: var(--bd2); }

.card-title { font-size: 1.3rem; font-weight: 800; color: var(--tx); margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }

.info-box {
    background: rgba(124, 58, 237, 0.05); 
    border-left: 4px solid var(--acc);
    padding: 15px 20px; 
    border-radius: 0 var(--rad-sm) var(--rad-sm) 0;
    font-size: 0.9rem; 
    color: var(--tx2); 
    margin-bottom: 20px; 
    line-height: 1.6;
    
    /* A MÁGICA: Força a caixa a ocupar 100% da largura e pular linha, mesmo dentro de Grids ou Flexboxes */
    grid-column: 1 / -1;
    width: 100%;
    flex-basis: 100%;
}

/* ==========================================
   5. FORM ELEMENTS & BUTTONS
   ========================================== */
.form-label { font-size: 0.85rem; font-weight: 600; color: var(--tx2); display: block; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }

.fi {
    width: 100%; padding: 14px 16px; background: var(--bg); border: 1px solid var(--bd);
    border-radius: var(--rad-sm); color: var(--tx); outline: none; font-size: 1rem;
    transition: 0.3s ease; box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}
.fi:focus { border-color: var(--acc2); box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.15); }

.btn { border: none; padding: 12px 24px; border-radius: var(--rad-sm); cursor: pointer; font-weight: 600; font-size: 1rem; transition: 0.3s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-save { background: linear-gradient(135deg, var(--ok), #059669); color: #fff; box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3); }
.btn-save:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4); }
.btn-cancel { background: var(--s2); color: var(--tx); border: 1px solid var(--bd); }
.btn-cancel:hover { background: var(--er); border-color: var(--er); color: #fff; }
.btn-edit { background: var(--acc); color: #fff; box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3); }
.btn-edit:hover { filter: brightness(1.1); transform: translateY(-2px); }
.btn-sm { font-size: 0.8rem; padding: 6px 12px; border-radius: 6px; cursor: pointer; border: none; font-weight: 600; transition: 0.2s; }
.btn-sm:hover { filter: brightness(1.2); }

.cb-wrap { display: flex; align-items: center; gap: 12px; background: var(--bg); padding: 12px 16px; border-radius: var(--rad-sm); border: 1px solid var(--bd); cursor: pointer; transition: 0.2s; }
.cb-wrap:hover { border-color: var(--acc2); background: rgba(124, 58, 237, 0.05); }
.cb-wrap input { accent-color: var(--acc); width: 20px; height: 20px; cursor: pointer; }
.cb-wrap span { font-size: 0.95rem; color: var(--tx); }
.cb-hl { color: var(--acc2); font-weight: 700; }

/* ==========================================
   6. IPA MAP
   ========================================== */
.ipa-wrapper { overflow-x: auto; margin: 15px 0; background: var(--bg); border: 1px solid var(--bd); border-radius: var(--rad-sm); padding: 15px; }
.ipa-chart { width: 100%; border-collapse: separate; border-spacing: 2px; font-size: 0.85rem; text-align: center; }
.ipa-chart th, .ipa-chart td { background: var(--s1); padding: 8px; border-radius: 4px; }
.ipa-chart th { color: var(--tx2); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; background: transparent; }
.ipa-chart td.imp { background: rgba(0,0,0,0.4); }
.ipa-cell { display: flex; justify-content: space-evenly; align-items: center; min-height: 28px; }
.ph { cursor: pointer; padding: 4px 8px; border-radius: 6px; font-size: 1.2rem; transition: 0.2s; color: var(--tx); border: 1px solid transparent; }
.ph:hover { background: rgba(124, 58, 237, 0.15); border-color: var(--acc); }
.ph.selected { background: var(--acc); color: #fff; border-color: var(--acc2); box-shadow: 0 0 10px rgba(124, 58, 237, 0.5); }
.vowel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(45px, 1fr)); gap: 8px; margin-top: 10px; }
.vowel-grid .ph { background: var(--s1); border: 1px solid var(--bd); text-align: center; padding: 10px 0; }

/* ==========================================
   7. DICTIONARY & GLOSSARY CARDS
   ========================================== */
.et { display: inline-block; font-size: 0.7rem; padding: 4px 10px; border-radius: 99px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; }
.et-v { background: rgba(59, 130, 246, 0.2); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.et-s { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.et-a { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.et-o { background: rgba(139, 92, 246, 0.2); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.3); }

.dict-card { background: var(--s1); border: 1px solid var(--bd); border-left: 4px solid var(--acc); padding: 20px; border-radius: var(--rad); cursor: pointer; transition: 0.3s; animation: popIn 0.5s both; position: relative; overflow: hidden; }
.dict-card:hover { border-color: var(--bd2); background: var(--s2); transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.dict-actions { display: flex; gap: 10px; margin-top: 15px; border-top: 1px solid var(--bd); padding-top: 15px; }
.paradigm-panel { margin-top: 20px; background: var(--bg); padding: 20px; border-radius: var(--rad-sm); border: 1px solid var(--bd); font-size: 0.9rem; display: none; cursor: default; animation: slideDown 0.3s both; }

/* ==========================================
   8. SYNTAX ANALYZER COMPONENTS
   ========================================== */
.gloss-grid { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 20px; align-items: flex-start; }
.gloss-word { background: var(--s1); border: 1px solid var(--bd); border-radius: var(--rad-sm); padding: 15px; min-width: 160px; display: flex; flex-direction: column; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.gloss-orig { font-size: 1.2rem; font-weight: 800; color: var(--tx); margin-bottom: 6px; }
.gloss-morph { font-size: 0.8rem; color: var(--acc2); border-bottom: 1px dashed var(--bd3); padding-bottom: 6px; margin-bottom: 8px; }
.gloss-trans { font-size: 0.95rem; color: var(--tx); font-weight: 600; margin-bottom: 8px; }
.gloss-tag { display: inline-block; font-size: 0.65rem; padding: 3px 6px; border-radius: 4px; background: var(--s2); color: var(--tx2); margin-right: 4px; margin-top: 4px; border: 1px solid var(--bd); font-weight: 600; letter-spacing: 0.5px; }

.role-select {
    font-size: 0.75rem; font-weight: 700; background: var(--acc); color: white; padding: 6px 24px 6px 10px;
    border-radius: 6px; display: inline-block; margin-bottom: 10px; border: none; outline: none; cursor: pointer;
    appearance: none; background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="white" viewBox="0 0 24 24"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat; background-position: right 8px center; transition: 0.2s;
}
.role-select:hover { background: var(--acc2); }
.role-select option { background: var(--s1); color: var(--tx); }

/* ==========================================
   9. MODALS & NEW SAAS AUTH
   ========================================== */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); display: none; justify-content: center; align-items: center; z-index: 100000; }
.modal-content { background: var(--s1); padding: 35px; border-radius: var(--rad); border: 1px solid var(--bd2); width: 90%; max-width: 550px; max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.8); animation: slideUp 0.3s ease-out; }

/* Modal Auth SaaS */
.auth-box { max-width: 420px; padding: 40px; }
.auth-header { text-align: center; margin-bottom: 25px; }
.auth-header h3 { font-size: 1.8rem; color: var(--acc3); margin-bottom: 8px; letter-spacing: -0.5px; }
.auth-header p { font-size: 0.9rem; color: var(--tx2); }
.auth-social { display: flex; gap: 10px; margin-bottom: 20px; }
.btn-social { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; border-radius: var(--rad-sm); background: var(--bg); border: 1px solid var(--bd); color: var(--tx); font-weight: 600; font-size: 0.9rem; cursor: pointer; transition: 0.2s; }
.btn-social:hover { background: var(--s2); border-color: var(--acc2); }
.auth-divider { display: flex; align-items: center; text-align: center; color: var(--tx3); font-size: 0.8rem; margin: 20px 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; border-bottom: 1px solid var(--bd); }
.auth-divider span { padding: 0 10px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-info-box { background: rgba(16, 185, 129, 0.05); border-left: 3px solid var(--ok); padding: 12px 15px; border-radius: 0 var(--rad-sm) var(--rad-sm) 0; font-size: 0.8rem; color: var(--tx2); line-height: 1.5; margin-top: 5px; margin-bottom: 10px; }

.rule-row { display: flex; gap: 12px; align-items: center; background: var(--bg); padding: 12px; border-radius: var(--rad-sm); border: 1px solid var(--bd); margin-bottom: 10px; flex-wrap: wrap; }
.rule-row input, .rule-row select { margin: 0; }

#toast { position: fixed; bottom: 30px; right: 30px; background: var(--s1); color: var(--tx); padding: 16px 24px; border-radius: var(--rad-sm); font-weight: 600; border-left: 4px solid var(--acc); box-shadow: 0 10px 25px rgba(0,0,0,0.5); opacity: 0; pointer-events: none; transition: 0.4s cubic-bezier(0.16, 1, 0.3, 1); z-index: 9999; transform: translateY(20px) scale(0.95); }
#toast.show { opacity: 1; transform: translateY(0) scale(1); }

/* ==========================================
   10. MEDIA QUERIES (MOBILE)
   ========================================== */
@media (max-width: 768px) {
    .hdr { padding: 15px; }
    .hdr-flex { flex-wrap: wrap; }
    .hdr-tools { display: flex; 
        width: 100%; 
        justify-content: center; 
        margin-top: 10px; } 
    .app-titulo-dinamico { font-size: 1.4rem !important; }
    .rule-row { flex-direction: column; align-items: stretch; }
    .content { padding: 20px 10px; }
    .card { padding: 20px; }
/* NOVO: Ajustes da Tela Inicial (Hub) para mobile */
    #dynamic-greeting-title { font-size: 2.2rem !important; }
    #tab-inicio .card { padding: 40px 20px !important; }
}

/* ==========================================
   11. THEMING (LIGHT MODE)
   ========================================== */
[data-theme="light"] {
    --bg: #f8fafc; --s1: #ffffff; --s2: #f1f5f9; --s3: #e2e8f0;
    --acc: #6d28d9; --acc2: #8b5cf6; --acc3: #4c1d95;
    --tx: #0f172a; --tx2: #334155; --tx3: #64748b;
    --bd: rgba(0, 0, 0, 0.1); --bd2: rgba(0, 0, 0, 0.2); --bd3: rgba(0, 0, 0, 0.3);
    background-image: radial-gradient(circle at 50% 0%, #e2e8f0 0%, transparent 50%);
}

[data-theme="light"] .hdr { background: rgba(255, 255, 255, 0.9); }
[data-theme="light"] .sidebar { background: #ffffff; }
[data-theme="light"] .info-box { background: rgba(109, 40, 217, 0.08); color: var(--tx2); border-left-color: var(--acc); }
[data-theme="light"] .et-v { background: rgba(59, 130, 246, 0.15); color: #1d4ed8; border-color: rgba(59, 130, 246, 0.3); }
[data-theme="light"] .et-s { background: rgba(16, 185, 129, 0.15); color: #047857; border-color: rgba(16, 185, 129, 0.3); }
[data-theme="light"] .et-a { background: rgba(245, 158, 11, 0.15); color: #b45309; border-color: rgba(245, 158, 11, 0.3); }
[data-theme="light"] .et-o { background: rgba(139, 92, 246, 0.15); color: #6d28d9; border-color: rgba(139, 92, 246, 0.3); }
[data-theme="light"] .gloss-word { background: var(--s1); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
[data-theme="light"] .fi { background: var(--s1); border: 1px solid var(--bd2); box-shadow: inset 0 1px 2px rgba(0,0,0,0.05); }
[data-theme="light"] .fi:focus { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.1), inset 0 1px 2px rgba(0,0,0,0.05); }
[data-theme="light"] .card { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

.btn-theme { background: transparent; border: 1px solid var(--bd); color: var(--tx); padding: 8px 16px; border-radius: 99px; cursor: pointer; font-size: 1.1rem; transition: 0.3s; display: flex; align-items: center; justify-content: center; }
.btn-theme:hover { background: var(--s2); transform: scale(1.05); }

/* ==========================================
   12. ANIMATIONS & MICRO-INTERACTIONS
   ========================================== */
@keyframes popIn { 0% { opacity: 0; transform: scale(0.95) translateY(15px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes slideDown { 0% { opacity: 0; transform: translateY(-10px); } 100% { opacity: 1; transform: translateY(0); } }

/* ==========================================
   13. DANGER ZONE MODS
   ========================================== */
.card-danger { border-color: var(--er); background: rgba(239, 68, 68, 0.05); }
.card-danger .card-title { color: var(--er); }
.btn-danger { background: var(--er); color: #fff; box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3); }
.btn-danger:hover { filter: brightness(1.1); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4); }
[data-theme="light"] .card-danger { background: rgba(239, 68, 68, 0.08); }

/* ==========================================
   14. INTERACTIVE READER & TOOLTIPS
   ========================================== */
#reader-output {
    margin-top: 20px;
    padding: 25px;
    background: var(--s2);
    border: 1px solid var(--bd);
    border-radius: var(--rad);
    font-size: 1.2rem;
    line-height: 2.5; /* More space so tooltips don't overlap text */
    color: var(--tx);
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.1);
    min-height: 150px;
}

.reader-word { position: relative; cursor: pointer; color: var(--acc2); font-weight: 700; border-bottom: 2px solid transparent; transition: 0.2s; }
.reader-word:hover { border-bottom-color: var(--acc); color: var(--acc3); }

.reader-tooltip { position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%) translateY(10px); background: rgba(15, 23, 42, 0.95); backdrop-filter: blur(12px); border: 1px solid var(--bd2); padding: 15px; border-radius: 12px; width: max-content; min-width: 180px; max-width: 250px; box-shadow: 0 15px 35px rgba(0,0,0,0.6); opacity: 0; pointer-events: none; transition: 0.2s; z-index: 100; text-align: left; line-height: 1.4; }
.reader-word:hover .reader-tooltip { opacity: 1; transform: translateX(-50%) translateY(0); }
.reader-tooltip::after { content: ''; position: absolute; top: 100%; left: 50%; margin-left: -6px; border-width: 6px; border-style: solid; border-color: rgba(15, 23, 42, 0.95) transparent transparent transparent; }

[data-theme="light"] .reader-tooltip { background: rgba(255, 255, 255, 0.98); border-color: var(--bd2); color: var(--tx); box-shadow: 0 15px 35px rgba(0,0,0,0.15); }
[data-theme="light"] .reader-tooltip::after { border-color: rgba(255, 255, 255, 0.98) transparent transparent transparent; }

.tt-title { font-weight: 900; color: var(--acc3); font-size: 1.2rem; border-bottom: 1px solid var(--bd); padding-bottom: 6px; margin-bottom: 6px; }
[data-theme="light"] .tt-title { color: var(--acc); }
.tt-ipa { font-family: monospace; font-size: 0.85rem; color: var(--tx2); font-weight: normal; margin-left: 5px; }
.tt-type { font-size: 0.75rem; text-transform: uppercase; color: var(--acc); font-weight: bold; margin-bottom: 4px; letter-spacing: 0.5px; }
.tt-trans { font-size: 1rem; color: var(--tx); margin-bottom: 6px; }
.tt-morph { font-size: 0.8rem; color: var(--tx3); font-style: italic; background: var(--s1); padding: 4px 8px; border-radius: 4px; display: inline-block; }


/* ==========================================
   16. GRAMMAR WIKI EDITOR
   ========================================== */
.wiki-container { 
    display: flex; flex-direction: row; align-items: stretch; 
    min-height: 500px; height: 60vh; 
    
    /* NEW: Forces limits on width and centers the container */
    max-width: 900px; 
    margin: 0 auto; 
    
    gap: 1rem; margin-top: 1rem; 
}

.wiki-sidebar-inner { width: 250px; background-color: var(--s2); border: 1px solid var(--bd); border-radius: var(--rad-sm); padding: 1.5rem; display: flex; flex-direction: column; color: var(--tx); }
.wiki-sidebar-inner ul { list-style: none; padding: 0; margin: 0 0 1rem 0; flex-grow: 1; }
.wiki-sidebar-inner li { display: flex; align-items: center; margin-bottom: 0.3rem; border-radius: 6px; transition: 0.2s; }
.wiki-sidebar-inner li:hover { background-color: rgba(124, 58, 237, 0.1); }

.menu-btn { background: transparent; border: none; color: var(--tx); flex-grow: 1; text-align: left; cursor: pointer; font-size: 0.95rem; font-weight: 600; padding: 0.8rem; border-radius: 6px; font-family: inherit; }
.menu-btn:hover { color: var(--acc2); }

.delete-btn { background: transparent; border: none; color: var(--er); cursor: pointer; padding: 0.8rem; font-size: 1rem; opacity: 0; transition: 0.2s; }
.wiki-sidebar-inner li:hover .delete-btn { opacity: 1; }

.add-page-btn { background-color: transparent; color: var(--tx); border: 1px dashed var(--bd); padding: 0.8rem; border-radius: 6px; cursor: pointer; transition: 0.2s; font-weight: bold; }
.add-page-btn:hover { background-color: rgba(124, 58, 237, 0.1); color: var(--acc2); border-color: var(--acc); }

.wiki-editor-area { 
    flex-grow: 1; display: flex; flex-direction: column; 
    background-color: var(--s1); 
    color: var(--tx); 
    border: 1px solid var(--bd); 
    border-radius: var(--rad-sm); overflow: hidden; 
}

.editor-toolbar { padding: 0.5rem 1rem; background-color: var(--s2); border-bottom: 1px solid var(--bd); display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.editor-toolbar button { padding: 0.4rem 0.6rem; cursor: pointer; background: var(--bg); color: var(--tx); border: 1px solid var(--bd); border-radius: 6px; font-size: 1rem; min-width: 36px; height: 36px; transition: 0.2s; font-weight: bold; }
.editor-toolbar button:hover { background-color: var(--acc); color: #fff; border-color: var(--acc2); }

.toolbar-select { padding: 0.4rem 0.8rem; border: 1px solid var(--bd); border-radius: 6px; background-color: var(--bg); color: var(--tx); cursor: pointer; height: 36px; font-weight: bold; outline: none; }
.toolbar-select:focus { border-color: var(--acc); }

.editor-content { flex-grow: 1; padding: 2rem; outline: none; overflow-y: auto; line-height: 1.6; font-size: 1.05rem; }
.editor-content h1, .editor-content h2, .editor-content h3 { color: var(--acc3); margin-top: 1.2em; margin-bottom: 0.5em; font-weight: 800; }
[data-theme="light"] .editor-content h1, [data-theme="light"] .editor-content h2, [data-theme="light"] .editor-content h3 { color: var(--acc); }
/* ==========================================
   15. NEW INSTITUTIONAL FOOTER
   ========================================== */
.footer-hub { background: var(--bg); border-top: 1px solid var(--bd); padding: 60px 20px 30px; margin-top: 60px; text-align: center; }
.footer-content { max-width: 800px; margin: 0 auto; }
.footer-brand p { color: var(--tx2); margin-top: 10px; font-size: 1rem; max-width: 500px; margin-left: auto; margin-right: auto; }
.social-links { display: flex; justify-content: center; gap: 15px; margin-top: 20px; flex-wrap: wrap; }
.social-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: 99px; background: var(--s1); border: 1px solid var(--bd); color: var(--tx); text-decoration: none; font-weight: 700; transition: 0.3s; box-shadow: var(--shadow); }
.social-btn:hover { background: var(--s2); transform: translateY(-3px); border-color: var(--acc2); box-shadow: var(--shadow-hover); }
.discord-btn { background: #5865F2; border-color: #5865F2; color: white; }
.discord-btn:hover { background: #4752C4; border-color: #4752C4; color: white; }
.footer-bottom { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--bd); color: var(--tx3); font-size: 0.85rem; }


/* ==========================================
   17. TAG PILLS & FILTERS
   ========================================== */
.tag-pill { background: rgba(124, 58, 237, 0.15); color: var(--acc2); border: 1px solid rgba(124, 58, 237, 0.3); padding: 2px 8px; border-radius: 12px; font-size: 0.7rem; font-weight: 600; text-transform: lowercase; transition: 0.2s; }
.tag-pill:hover { background: rgba(124, 58, 237, 0.25); border-color: var(--acc); }
[data-theme="light"] .tag-pill { background: rgba(109, 40, 217, 0.08); color: var(--acc); border-color: rgba(109, 40, 217, 0.2); }

.filter-btn { background: var(--s2); color: var(--tx2); border: 1px solid var(--bd); padding: 8px 18px; border-radius: 99px; cursor: pointer; font-size: 0.85rem; font-weight: 600; transition: 0.2s; }
.filter-btn:hover { background: var(--s3); color: var(--tx); }
.filter-btn.active { background: rgba(124, 58, 237, 0.15); color: var(--acc2); border-color: var(--acc); }
.alpha-bar { background: var(--s1); border: 1px solid var(--bd); padding: 12px 20px; border-radius: 12px; display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 25px; }
.alpha-btn { background: transparent; color: var(--acc2); border: 1px solid transparent; cursor: pointer; padding: 4px 10px; border-radius: 6px; font-weight: 700; font-size: 0.95rem; transition: 0.2s; }
.alpha-btn:hover { background: rgba(124, 58, 237, 0.1); }
.alpha-btn.active { background: var(--acc); color: #fff; box-shadow: 0 4px 10px rgba(124, 58, 237, 0.3); }

/* ==========================================
   18. FLASHCARDS (3D FLIP)
   ========================================== */
.fc-container { perspective: 1000px; width: 100%; height: 320px; cursor: pointer; }
.fc-inner { position: relative; width: 100%; height: 100%; transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1); transform-style: preserve-3d; }
.fc-inner.is-flipped { transform: rotateY(180deg); }
.fc-front, .fc-back { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; justify-content: center; align-items: center; border-radius: var(--rad); padding: 30px; box-shadow: var(--shadow); border: 2px solid var(--bd); }
.fc-front { background: linear-gradient(145deg, var(--s1), var(--s2)); }
.fc-back { background: linear-gradient(145deg, var(--s2), var(--s3)); transform: rotateY(180deg); }
.fc-word { font-size: 3.5rem; font-weight: 900; color: var(--acc3); margin-bottom: 10px; letter-spacing: 1px; }
.fc-ipa { font-size: 1.2rem; color: var(--tx2); font-family: monospace; }
.fc-trans { font-size: 2rem; font-weight: 700; color: var(--tx); margin-bottom: 15px; }

/* ==========================================
   19. PDF GENERATOR
   ========================================== */
#print-view { display: none; }
@media print {
    .hdr, .sidebar, .sidebar-overlay, .content, .footer-hub, #toast, .modal-overlay { display: none !important; }
    #print-view { display: block !important; width: 100%; color: #000; background: #fff; }
    body, html { background: #ffffff !important; background-image: none !important; color: #000000 !important; }
    @page { margin: 2cm; size: A4 portrait; }
}

/* ==========================================
   20. ANALYTICS & READ-ONLY
   ========================================== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 25px; }
.stat-card { background: var(--s2); border: 1px solid var(--bd); border-radius: var(--rad); padding: 20px; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.1); transition: 0.2s; }
.stat-card:hover { transform: translateY(-5px); border-color: var(--bd3); }
.stat-title { font-size: 0.85rem; color: var(--tx2); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; margin-bottom: 10px; }
.stat-value { font-size: 2.5rem; font-weight: 900; color: var(--acc2); margin-bottom: 5px; }
.stat-desc { font-size: 0.75rem; color: var(--tx3); }
[data-theme="light"] .stat-card { background: #fff; border-color: #e2e8f0; }

.read-only-mode #nb-criar, .read-only-mode #nb-config, .read-only-mode .dict-actions, .read-only-mode .editor-toolbar, .read-only-mode #btn-auth { display: none !important; }
.read-only-mode .wiki-editor-area { pointer-events: none; border: none; }

/* ==========================================
   DASHBOARD & PROJECT CARDS
   ========================================== */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.project-card {
    background: var(--s1);
    border: 1px solid var(--bd);
    border-radius: var(--rad);
    padding: 25px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 160px;
    text-align: left;
}

.project-card:hover {
    border-color: var(--acc2);
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    background: var(--s2);
}

/* Detalhe visual (faixa lateral de cor) */
.project-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: linear-gradient(to bottom, var(--acc), var(--acc2));
}

.project-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--tx);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-meta {
    font-size: 0.85rem;
    color: var(--tx2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px dashed var(--bd);
}

.project-card-new {
    background: rgba(124, 58, 237, 0.05);
    border: 2px dashed var(--acc);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: var(--acc2);
    font-weight: bold;
    text-align: center;
}

.project-card-new::before { display: none; }

.project-card-new:hover {
    background: rgba(124, 58, 237, 0.1);
    color: var(--acc3);
    border-style: solid;
}

[data-theme="light"] .project-card-new {
    background: rgba(109, 40, 217, 0.03);
    border-color: rgba(109, 40, 217, 0.3);
}

/* Unicode support for Conlang, IPA and combining diacritics */
.notranslate, .ph, .ipa-chart, .gloss-orig, .gloss-morph {
    font-family: 'Noto Sans', 'Arial Unicode MS', 'Segoe UI Historic', 'Times New Roman', sans-serif !important;

    text-rendering: optimizeLegibility !important;
    font-feature-settings: "mark" 1, "mkmk" 1, "ccmp" 1 !important; 
    font-variant-ligatures: contextual !important;
    
    letter-spacing: normal !important; 
}

/* Unicode support for Conlang and IPA */
.notranslate, .ph, .ipa-chart, .gloss-orig, .gloss-morph {
    font-family: 'Segoe UI', 'Segoe UI Historic', 'Arial Unicode MS', 'Times New Roman', sans-serif !important;
    
    text-rendering: optimizeLegibility !important;
    font-feature-settings: "mark" 1, "mkmk" 1, "ccmp" 1 !important; 
    font-variant-ligatures: contextual !important;
    letter-spacing: normal !important; 
}

/* ==========================================
   21. LEIPZIG IGT (GLOSSING) OVERRIDES
   ========================================== */
.leipzig-container {
    overflow-x: auto; /* Adds horizontal scroll on mobile to prevent stretching */
    padding-bottom: 5px;
}

/* Forces the Leipzig injected classes to inherit your custom fonts */
.leipzig-container .gloss, 
.leipzig-container .gloss__word, 
.leipzig-container .gloss__line {
    font-family: 'Doulos SIL', 'Charis SIL', 'Noto Sans', 'Arial Unicode MS', sans-serif !important;
}

/* Fixes the spacing between glossed words */
.leipzig-container .gloss {
    display: flex;
    flex-wrap: wrap; /* Allows lines to wrap naturally if they hit the edge */
    gap: 15px 25px; /* Vertical gap: 15px, Horizontal gap: 25px */
}

/* Overrides Leipzig's default margins */
.leipzig-container .gloss__word {
    margin: 0 !important;
}

/* Container principal dos controles abaixo do canvas */
.font-studio-controls {
  display: flex;
  justify-content: space-between; /* Empurra o pincel pra esquerda e botões pra direita */
  align-items: center; /* Centraliza verticalmente o slider e os botões */
  margin-top: 20px;
  width: 100%;
  gap: 15px;
}

/* Grupo do Pincel */
.brush-group {
  display: flex;
  flex-direction: column; /* Coloca o texto em cima do slider */
  align-items: center;
  gap: 5px;
  color: #fff;
}

/* Grupo de Botões */
.action-buttons {
  display: flex;
  gap: 10px; /* Espaço entre os botões */
  align-items: center;
  flex-wrap: wrap; /* Se a tela for pequena, eles quebram a linha sem amassar */
}

/* Prevenindo o bug do esticamento (Stretch) nos botões */
.action-buttons button {
  height: max-content; /* Garante que a altura seja apenas o tamanho do texto/ícone */
  padding: 10px 15px;
  flex: 0 0 auto; /* Impede que o botão tente crescer e ocupar espaço extra */
  border-radius: 8px; /* Mantendo o estilo do seu modal */
  cursor: pointer;
  /* Adicione aqui suas cores específicas, ex: border: none; font-weight: bold; */
}

/* Exemplo de cor para o botão de salvar que aparece na sua imagem */
.btn-primary {
  background-color: #10b981; /* Verde esmeralda */
  color: white;
}

#tab-inicio {
    position: relative; /* O pai dita as regras do espaço */
    min-height: 100vh;
    width: 100%;
}

#bg-greetings {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 999 !important; /* CRÍTICO: Força o container a ficar na frente de TUDO */
}

.bg-word {
    position: absolute;
    top: 0;
    left: 0;
    white-space: nowrap;
    will-change: transform;
    user-select: none;
    /* A Mágica do Visual Clean: */
    color: rgba(255, 255, 255, 0.58) !important; 
    font-family: 'Inter', 'Noto Sans', sans-serif;
    font-weight: 300; /* Deixa a letra fininha e elegante */
    letter-spacing: 1px; /* Dá um leve respiro entre as letras */
}

/* ==========================================
   22. PROFILE ACTIVITY & BADGES
   ========================================== */

/* Grid Responsivo Inteligente: Lado a lado no PC, Empilhado no Mobile */
.profile-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 25px;
}

/* --- Timeline de Atividades --- */
.activity-timeline {
    position: relative;
    padding-left: 20px;
    border-left: 2px solid var(--bd);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.activity-item {
    position: relative;
}

/* O pontinho (dot) na linha do tempo */
.activity-dot {
    position: absolute;
    left: -26px; /* Ajuste fino para centralizar na borda */
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--acc2);
    border: 2px solid var(--s1);
    box-shadow: 0 0 0 2px var(--bd);
}

.activity-content p {
    font-size: 0.9rem;
    color: var(--tx);
    margin-bottom: 3px;
    line-height: 1.4;
}

.activity-content b {
    color: var(--acc3);
}

.activity-time {
    font-size: 0.75rem;
    color: var(--tx3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* --- Badges & Achievements --- */
.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 15px;
}

.badge-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--rad-sm);
    background: var(--s2);
    border: 1px solid var(--bd);
    transition: all 0.3s ease;
    cursor: help; /* Cursor de ajuda para a tooltip do title */
}

.badge-item i {
    width: 28px;
    height: 28px;
    transition: all 0.3s ease;
}

/* Quando desbloqueado (Dourado/Roxo brilhante) */
.badge-item.unlocked {
    background: rgba(124, 58, 237, 0.15);
    border-color: var(--acc);
    box-shadow: inset 0 0 15px rgba(124, 58, 237, 0.1);
}

.badge-item.unlocked i {
    color: var(--acc2);
    filter: drop-shadow(0 2px 5px rgba(124, 58, 237, 0.5));
}

.badge-item.unlocked:hover {
    transform: translateY(-3px) scale(1.05);
    background: rgba(124, 58, 237, 0.25);
}

/* Quando trancado (Cinza opaco) */
.badge-item.locked {
    opacity: 0.4;
    background: var(--bg);
}

.badge-item.locked i {
    color: var(--tx3);
}

/* ==========================================
   23. CONFIGURATION SUB-TABS
   ========================================== */
.config-subnav {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.cfg-section {
    display: none;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.cfg-section.active {
    display: block;
}

/* ==========================================
   UX/UI SUITE: KINETIC FEEDBACK
   Purpose: Makes buttons feel tactile, responsive, and physically "pressed".
   ========================================== */

/* Applies a subtle shrink effect when the user holds down the mouse click */
.btn:active,
.btn-sm:active,
.filter-btn:active,
.btn-hdr:active,
.btn-auth:active,
.btn-social:active,
.nb:active,
.alpha-btn:active,
.add-page-btn:active,
.social-btn:active,
.menu-toggle:active,
.btn-theme:active {
    transform: scale(0.95);
    transition: transform 0.05s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ensures the return animation is smooth when the mouse is released */
.btn, .btn-sm, .filter-btn, .btn-hdr, .btn-auth, .btn-social, 
.nb, .alpha-btn, .add-page-btn, .social-btn, .menu-toggle, .btn-theme {
    transition: all 0.2s ease, transform 0.1s ease;
}

/* Specific fix for the project cards on the dashboard to feel clickable */
.project-card:active {
    transform: scale(0.98);
    transition: transform 0.05s ease;
}

/* ==========================================
   UX/UI SUITE: SIDEBAR GROUPS & THEME PRESETS
   ========================================== */

/* Etiquetas de categoria na barra lateral */
.nav-group-label {
    font-size: 0.65rem;
    color: var(--tx3);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 800;
    margin: 20px 0 8px 15px;
    opacity: 0.7;
}

.sidebar-scroll .nav-group-label:first-child {
    margin-top: 5px;
}

/* Botões redondos de templates de cores */
.theme-preset-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid var(--bd2);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.theme-preset-btn:hover {
    transform: scale(1.15);
    border-color: var(--acc);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* ==========================================
   UX/UI SUITE: SIDEBAR GROUPS, THEME PRESETS & COLOR PICKER FIX
   ========================================== */

/* Etiquetas de categoria na barra lateral */
.nav-group-label {
    font-size: 0.65rem;
    color: var(--tx3);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 800;
    margin: 20px 0 8px 15px;
    opacity: 0.7;
}

.sidebar-scroll .nav-group-label:first-child {
    margin-top: 5px;
}

/* Botões redondos de templates de cores */
.theme-preset-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid var(--bd2);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.theme-preset-btn:hover {
    transform: scale(1.15);
    border-color: var(--acc);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* FIX: Garante que os seletores de cor nativos (Color Pickers) fiquem lindos e visíveis */
.fi-color {
    padding: 0 !important;
    cursor: pointer !important;
    border-radius: 6px !important;
    border: 1px solid var(--bd) !important;
    outline: none !important;
    background: transparent !important; /* Deixa a cor nativa brilhar */
    height: 35px;
}

/* No Chrome/Safari/Edge, isto controla a "caixinha" de cor interna */
.fi-color::-webkit-color-swatch-wrapper {
    padding: 3px !important;
}

.fi-color::-webkit-color-swatch {
    border-radius: 4px !important;
    border: none !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Suporte para o Firefox */
.fi-color::-moz-color-swatch {
    border-radius: 4px !important;
    border: none !important;
}

.header{background: var(--h-bg) !important;}