:root {
    /* DEFAULT: FLUFFY (Vải Nỉ 3D Mềm) */
    --bg-app: #e2e8f0;
    --bg-panel: #f1f5f9;
    --bg-input: #e2e8f0;
    
    --text-main: #334155;
    --text-muted: #64748b;
    
    --primary: #4f46e5;
    --success: #10b981;
    --danger: #ef4444;
    
    --radius-lg: 32px;
    --radius-md: 20px;
    --radius-sm: 12px;
    
    /* Neumorphism / Fluffy Shadows */
    --shadow-out: 8px 8px 16px #cbd5e1, -8px -8px 16px #ffffff;
    --shadow-in: inset 6px 6px 12px #cbd5e1, inset -6px -6px 12px #ffffff;
    --shadow-btn: 5px 5px 10px #cbd5e1, -5px -5px 10px #ffffff;
    --shadow-btn-active: inset 4px 4px 8px #cbd5e1, inset -4px -4px 8px #ffffff;
    
    --border-glass: none;
    --blur-glass: blur(0px);
}

[data-theme="liquid"] {
    /* LIQUID GLASS (Kính Trong Suốt Apple) */
    --bg-app: transparent;
    --bg-panel: rgba(255, 255, 255, 0.4);
    --bg-input: rgba(255, 255, 255, 0.5);
    
    --text-main: #0f172a;
    
    --radius-lg: 24px;
    --radius-md: 16px;
    
    --shadow-out: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --shadow-in: inset 2px 2px 5px rgba(255,255,255,0.8);
    --shadow-btn: 0 4px 15px rgba(31, 38, 135, 0.1);
    --shadow-btn-active: inset 2px 2px 5px rgba(0,0,0,0.1);
    
    --border-glass: 1px solid rgba(255, 255, 255, 0.6);
    --blur-glass: blur(20px);
}

/* RESET */
* { box-sizing: border-box; margin: 0; padding: 0; outline: none; font-family: 'Montserrat', sans-serif; }
body { background: var(--bg-app); color: var(--text-main); height: 100vh; overflow: hidden; transition: 0.4s; }
body.loading .tab-pane { display: none !important; }

/* NỀN LIQUID SHAPES */
.bg-shapes { position: fixed; inset: 0; z-index: -1; background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%); overflow: hidden; }
[data-theme="fluffy"] .hidden-fluffy { display: none; }
.shape { position: absolute; filter: blur(70px); opacity: 0.7; border-radius: 50%; animation: float 12s infinite alternate; }
.shape-1 { width: 400px; height: 400px; background: #ff9a9e; top: -10%; left: -10%; }
.shape-2 { width: 500px; height: 500px; background: #a1c4fd; bottom: -20%; right: -10%; animation-delay: -3s; }
.shape-3 { width: 350px; height: 350px; background: #fecfef; top: 40%; left: 30%; animation-delay: -6s; }
@keyframes float { 0% { transform: translate(0,0); } 100% { transform: translate(40px, -40px); } }

/* THEME CORE CLASSES */
.theme-panel {
    background: var(--bg-panel); border-radius: var(--radius-md); box-shadow: var(--shadow-out);
    backdrop-filter: var(--blur-glass); border: var(--border-glass); padding: 20px; transition: 0.3s;
}
.theme-element {
    background: var(--bg-panel); border-radius: var(--radius-sm); box-shadow: var(--shadow-btn);
    backdrop-filter: var(--blur-glass); border: var(--border-glass); transition: 0.3s;
}
.input-theme {
    background: var(--bg-input); border-radius: var(--radius-sm); box-shadow: var(--shadow-in);
    border: var(--border-glass); padding: 10px 15px; color: var(--text-main); font-weight: 500; transition: 0.3s;
}
[data-theme="liquid"] .input-theme:focus { background: rgba(255,255,255,0.8); border-color: var(--primary); }

.theme-btn {
    border-radius: var(--radius-sm); box-shadow: var(--shadow-btn); border: var(--border-glass);
    transition: 0.3s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700;
}
.theme-btn:active { box-shadow: var(--shadow-btn-active); transform: scale(0.98); }
[data-theme="fluffy"] .btn-primary { background: var(--primary); color: white; box-shadow: 5px 5px 10px rgba(79,70,229,0.3), -5px -5px 10px #ffffff; }
[data-theme="fluffy"] .btn-primary:active { box-shadow: inset 3px 3px 6px rgba(0,0,0,0.2); }

/* APP LAYOUT */
.app-container { display: flex; flex-direction: column; height: 100%; position: relative; z-index: 1; }

.top-navbar {
    display: flex; justify-content: space-between; align-items: center;
    height: 70px; padding: 0 30px; margin: 15px; border-radius: var(--radius-lg); flex-shrink: 0;
}
.logo-area { font-weight: 800; font-size: 18px; color: var(--primary); display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 36px; height: 36px; background: var(--bg-input); border-radius: 50%; display: flex; justify-content: center; align-items: center; box-shadow: var(--shadow-in); }
[data-theme="liquid"] .logo-icon { background: rgba(255,255,255,0.5); box-shadow: var(--shadow-out); border: var(--border-glass); }

.nav-center { display: flex; gap: 15px; height: 100%; align-items: center; }
.nav-tab {
    background: transparent; border: none; padding: 10px 20px; border-radius: var(--radius-md);
    cursor: pointer; font-weight: 700; color: var(--text-muted); transition: 0.3s;
}
.nav-tab:hover { color: var(--primary); }
.nav-tab.active { background: var(--bg-input); box-shadow: var(--shadow-in); color: var(--primary); }
[data-theme="liquid"] .nav-tab.active { background: rgba(255,255,255,0.6); box-shadow: var(--shadow-out); border: var(--border-glass); }

.btn-theme { padding: 10px 20px; font-weight: 700; cursor: pointer; color: var(--text-main); }

/* MAIN TABS */
.main-content { flex: 1; overflow: hidden; padding: 0 15px 15px 15px; }
.tab-pane { display: none; height: 100%; flex-direction: column; }
.tab-pane.active { display: flex; animation: fadeIn 0.3s; }
.full-height { overflow: hidden; }
@keyframes fadeIn { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform:0; } }

/* UTILS */
.hidden { display: none !important; }
.flex-1 { flex: 1; min-height: 0; min-width: 0; } .flex-2 { flex: 2; }
.w-100 { width: 100%; } .w-150 { width: 150px; }
.flex-col { display: flex; flex-direction: column; }
.flex-gap { display: flex; gap: 15px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-end { display: flex; justify-content: flex-end; }
.mb-5 { margin-bottom: 5px; } .mb-10 { margin-bottom: 10px; } .mb-15 { margin-bottom: 15px; } .mb-20 { margin-bottom: 20px; }
.p-15 { padding: 15px; }
.bold { font-weight: 700; } .text-sm { font-size: 12px; } .text-muted { color: var(--text-muted); } .text-danger { color: var(--danger); }
.grid-4-cols { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.grid-2-cols { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; }
.gap-5 { gap: 5px; }

/* BADGES */
.badge-theme { padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--bg-input); box-shadow: var(--shadow-in); border: var(--border-glass); }
[data-theme="liquid"] .badge-theme { box-shadow: var(--shadow-out); background: rgba(255,255,255,0.6); }
.badge-theme.gray { color: #475569; } .badge-theme.yellow { color: #d97706; } .badge-theme.blue { color: #2563eb; } .badge-theme.purple { color: #9333ea; } .badge-theme.green { color: #059669; }

/* SCROLLBAR */
.custom-scrollbar::-webkit-scrollbar { width: 8px; height: 8px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 10px; }

/* BUTTONS BASIC */
.btn { padding: 10px 20px; font-size: 13px; border: none; cursor: pointer; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-outline { background: transparent; color: var(--text-main); }
.btn-success { background: var(--success); color: white; }
.btn-glow { animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(79,70,229, 0.4); } 70% { box-shadow: 0 0 0 10px rgba(79,70,229, 0); } 100% { box-shadow: 0 0 0 0 rgba(79,70,229, 0); } }

/* TAB 3: EDITOR (Ngang 100%) */
.editor-workspace { display: flex; gap: 20px; height: 100%; }
.editor-box { flex: 1; padding: 0; overflow: hidden; }
.box-title { padding: 15px 20px; border-bottom: 1px solid rgba(0,0,0,0.05); }
.badge-group { display: flex; gap: 8px; }
#raw-text, #processed-output { border: none; background: transparent; padding: 20px; font-size: 15px; line-height: 1.6; resize: none; color: var(--text-main); }
#processed-output { white-space: pre-wrap; }
.box-footer { border-top: 1px solid rgba(0,0,0,0.05); }

/* HIGHLIGHTS EDITOR */
mark.hl-replaced { background: #bbf7d0; color: #14532d; font-weight: 700; border-radius: 6px; padding: 2px 6px; box-shadow: var(--shadow-out); }
mark.hl-new-entity { background: #e9d5ff; color: #581c87; font-weight: 700; border-radius: 6px; padding: 2px 6px; box-shadow: var(--shadow-out); }
[data-theme="fluffy"] mark { border: none; }

/* TAB 4: SPLIT CHIA CHƯƠNG (Ngang 1/4 và 3/4) */
.split-layout-horizontal { display: grid; grid-template-columns: 1fr 3fr; gap: 20px; height: 100%; }
.split-input-area { padding: 20px; }
.split-cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 15px; align-content: start; }
.split-card { padding: 0; height: 350px; }
.split-card-header { padding: 15px; font-weight: 700; border-bottom: 1px solid rgba(0,0,0,0.05); }
.split-card textarea { background: transparent; border: none; padding: 15px; resize: none; font-size: 14px; line-height: 1.6; }

/* LAYOUT CÓ SIDEBAR TRONG (Lore, Settings) */
.layout-with-sidebar { display: flex; gap: 20px; height: 100%; }
.inner-sidebar { width: 250px; padding: 15px; display: flex; flex-direction: column; gap: 10px; }
.inner-tab-btn { text-align: left; padding: 12px 15px; border: none; background: transparent; border-radius: var(--radius-sm); font-weight: 700; color: var(--text-muted); cursor: pointer; transition: 0.3s; }
.inner-tab-btn.active { background: var(--bg-input); box-shadow: var(--shadow-in); color: var(--primary); }
[data-theme="liquid"] .inner-tab-btn.active { background: rgba(255,255,255,0.6); box-shadow: var(--shadow-out); }
.inner-content { flex: 1; overflow-y: auto; padding-right: 10px; }
.inner-pane { display: none; flex-direction: column; height: 100%; }
.inner-pane.active { display: flex; animation: fadeIn 0.3s; }

/* CARDS & TOGGLES CÀI ĐẶT */
.option-card { padding: 15px; border-radius: var(--radius-md); background: var(--bg-input); box-shadow: var(--shadow-in); cursor: pointer; transition: 0.3s; }
[data-theme="liquid"] .option-card { box-shadow: var(--shadow-out); border: var(--border-glass); background: rgba(255,255,255,0.4); }
.option-card.active { box-shadow: inset 0 0 0 2px var(--primary), var(--shadow-in); }
[data-theme="liquid"] .option-card.active { box-shadow: 0 0 0 2px var(--primary), var(--shadow-out); background: rgba(255,255,255,0.8); }

.btn-toggle { padding: 10px 15px; border-radius: var(--radius-sm); font-weight: 700; border: none; background: var(--bg-input); box-shadow: var(--shadow-out); color: var(--text-muted); cursor: pointer; }
.btn-toggle.active { background: var(--primary); color: white; box-shadow: var(--shadow-in); }

/* RADIO CSS */
.radio-btn { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; cursor: pointer; }
.split-mode-btn { padding: 10px 0; border: none; background: var(--bg-input); border-radius: var(--radius-sm); font-weight: 700; cursor: pointer; box-shadow: var(--shadow-out); color: var(--text-muted); }
.split-mode-btn.active { background: var(--primary); color: white; box-shadow: var(--shadow-in); }

/* LORE TABLE */
.toolbar { display: flex; justify-content: space-between; padding: 15px; margin-bottom: 20px; }
.theme-table { width: 100%; border-collapse: collapse; text-align: left; }
.theme-table th { padding: 15px; font-size: 13px; color: var(--text-muted); border-bottom: 1px solid rgba(0,0,0,0.05); }
.theme-table td { padding: 15px; font-size: 14px; border-bottom: 1px solid rgba(0,0,0,0.03); }

/* MODALS */
.theme-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(5px); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.modal-content { width: 500px; max-width: 90%; animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popIn { 0% { opacity:0; transform: scale(0.9); } 100% { opacity:1; transform: scale(1); } }
.modal-header { border-bottom: 1px solid rgba(0,0,0,0.05); padding-bottom: 15px; }
.close { cursor: pointer; font-size: 24px; color: var(--text-muted); font-weight: bold; }

/* NOTIFICATIONS */
#notification-container { position: fixed; top: 90px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.notify-toast { padding: 15px 20px; font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 10px; animation: slideIn 0.3s; }
@keyframes slideIn { from { transform: translateX(100%); opacity:0; } to { transform: translateX(0); opacity:1; } }
