:root {
    /* Color Palette */
    --bg-main: #000000;
    --bg-soft: #0a0a0a;
    --bg-panel: rgba(18, 18, 18, 0.6);
    --bg-input: rgba(17, 24, 39, 0.5);
    
    /* Brand Colors */
    --primary: #f97316;       /* Orange 500 */
    --primary-dark: #c2410c;  /* Orange 700 */
    --secondary: #eab308;     /* Yellow 500 */
    --accent: #fde047;        /* Yellow 300 */
    
    /* Text Colors */
    --text-main: #e5e7eb;     /* Gray 200 */
    --text-muted: #9ca3af;    /* Gray 400 */
    --text-dark: #000000;
    --text-white: #ffffff;

    /* Borders & Glows */
    --border-soft: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --glow: rgba(249, 115, 22, 0.25);
    
    /* Semantic Colors */
    --success: #22c55e;
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.1);
    --indigo: #6366f1;
}

/* --- Resets & Base --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

button {
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all 0.2s ease;
    user-select: none;
    touch-action: manipulation;
}

button:active {
    transform: scale(0.97);
}

button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

a {
    text-decoration: none;
    color: inherit;
}

/* --- Utilities --- */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.grid { display: grid; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.mr-1 { margin-right: 0.25rem; }
.mr-2 { margin-right: 0.5rem; }
.w-full { width: 100%; }
.items-center { align-items: center; }

/* --- Layout --- */
.container {
    width: 100%;
    max-width: 1024px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    flex-grow: 1;
}

/* --- Navbar --- */
.navbar {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-soft);
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 0.75rem 1rem;
}

.nav-content {
    max-width: 1024px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--text-dark);
    box-shadow: 0 0 20px var(--glow);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    white-space: nowrap;
}

.text-orange { color: var(--primary); }
.text-lg { font-size: 1.125rem; }

/* --- Auth Buttons --- */
.btn-login {
    background: var(--text-white);
    color: var(--text-dark);
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 0.875rem;
}
.btn-login:hover { background: #e5e7eb; }

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-badge {
    display: none;
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--text-muted);
    background: #111827;
    padding: 0.5rem 0.75rem;
    border-radius: 9999px;
    border: 1px solid #1f2937;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.6rem;
    background: #111827;
    color: var(--text-muted);
    border: 1px solid #1f2937;
}
.btn-logout:hover { color: var(--danger); border-color: rgba(239,68,68,0.3); }

/* --- Hero / Login View --- */
.hero-view {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 1.5rem;
    padding: 2rem 1rem;
}

.hero-icon-wrapper { position: relative; }
.hero-glow {
    position: absolute;
    inset: -1rem;
    background: rgba(249, 115, 22, 0.2);
    filter: blur(24px);
    border-radius: 50%;
}
.hero-icon {
    font-size: 3.5rem;
    color: var(--text-white);
    position: relative;
    z-index: 10;
}

.hero-title {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
    background: linear-gradient(to bottom, #ffffff, #6b7280);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero-sub {
    color: var(--text-muted);
    font-size: 1rem;
    max-width: 20rem;
    line-height: 1.5;
}

/* --- Dashboard Actions --- */
.action-bar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    width: 100%;
}

.search-wrapper {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #4b5563;
    pointer-events: none;
}

.search-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid #1f2937;
    color: var(--text-white);
    font-size: 0.875rem;
    border-radius: 0.75rem;
    padding: 0.875rem 1rem 0.875rem 2.75rem;
    outline: none;
    transition: all 0.2s;
}
.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.25);
    background: rgba(17, 24, 39, 0.8);
}

.btn-group {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    justify-content: center;
}
.btn-group::-webkit-scrollbar { display: none; }

/* Base Button Styles */
.btn-gradient, .btn-secondary, .btn-danger-ghost {
    border-radius: 0.75rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-gradient {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--text-dark);
    font-weight: 700;
    box-shadow: 0 10px 15px -3px rgba(124, 45, 18, 0.2);
}

.btn-secondary {
    background: #1f2937;
    border: 1px solid #374151;
    color: var(--text-white);
    font-weight: 600;
}
.btn-secondary:hover { background: #374151; }

.btn-danger-ghost {
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    font-weight: 600;
}
.btn-danger-ghost:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #f87171;
}

/* --- RESPONSIVE BUTTONS (ICON ONLY ON MOBILE) --- */
#btn-import, #btn-add-subject, #btn-clear-all {
    font-size: 0;           
    width: 3rem;            
    height: 3rem;           
    padding: 0;             
    flex: none;             
}

#btn-import i, #btn-add-subject i, #btn-clear-all i {
    font-size: 1.25rem;     
    margin: 0 !important;   
}

.btn-icon-only {
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    font-size: 1.3rem;
    border-radius: 0.75rem;
}

/* --- Share Mode Bar --- */
.share-bar {
    background: rgba(124, 45, 18, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.3);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.share-text {
    color: #fdba74;
    font-weight: 600;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
}
.btn-sm-text {
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.5rem;
    background: transparent;
}
.btn-sm-primary {
    background: var(--primary);
    color: var(--text-dark);
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
}

/* --- Cards Grid --- */
.cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding-bottom: 6rem;
}

/* --- Subject Card Component --- */
.glass-card {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-soft);
    padding: 1.25rem;
    border-radius: 1rem;
    position: relative;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s, transform 0.2s;
}
.glass-card:hover { 
    border-color: var(--border-hover); 
    transform: translateY(-2px);
}

.animate-fade-up {
    animation: fadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(10px);
}
@keyframes fadeUp { to { opacity: 1; transform: none; } }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    min-height: 2rem;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    border: 1px solid transparent;
    letter-spacing: 0.025em;
    max-width: 70%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.badge-blue    { background: rgba(59, 130, 246, 0.1); color: #60a5fa; border-color: rgba(59, 130, 246, 0.2); }
.badge-purple  { background: rgba(168, 85, 247, 0.1); color: #c084fc; border-color: rgba(168, 85, 247, 0.2); }
.badge-emerald { background: rgba(16, 185, 129, 0.1); color: #34d399; border-color: rgba(16, 185, 129, 0.2); }
.badge-rose    { background: rgba(244, 63, 94, 0.1);  color: #fb7185; border-color: rgba(244, 63, 94, 0.2); }
.badge-amber   { background: rgba(245, 158, 11, 0.1);  color: #fbbf24; border-color: rgba(245, 158, 11, 0.2); }
.badge-cyan    { background: rgba(6, 182, 212, 0.1);   color: #22d3ee; border-color: rgba(6, 182, 212, 0.2); }

.card-actions { display: flex; gap: 0.25rem; }
.btn-card-action {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-muted);
}
.btn-card-action:hover { background: rgba(255,255,255,0.1); color: var(--text-white); }
.btn-card-action.delete:hover { background: rgba(239, 68, 68, 0.2); color: #f87171; }

.links-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.link-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgb(13 18 32 / 58%);
    padding: 0.25rem 0.5rem 0.25rem 0.75rem;
    border-radius: 0.6rem;
    border: 1px solid transparent;
    transition: background 0.2s, transform 0.1s;
    min-height: 2.75rem;
    position: relative;
    user-select: none;
}
.link-item:hover {
    background: rgba(31, 41, 55, 0.8);
    border-color: #374151;
}
.link-item:active {
    transform: scale(0.99); 
}

.link-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #d1d5db;
    font-size: 0.875rem;
    font-weight: 500;
    overflow: hidden;
    flex: 1;
    padding-right: 0.5rem;
}
.link-content:hover { color: var(--text-white); }
.link-icon {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.35rem;
    background: #1f2937;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.link-actions {
    display: flex;
    gap: 0.1rem;
    opacity: 0.8;
}
@media (min-width: 1024px) {
    .link-actions { opacity: 0; transition: opacity 0.2s; }
    .link-item:hover .link-actions { opacity: 1; }
}

.btn-link-action {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: transparent;
    border-radius: 0.35rem;
}
.btn-link-action:hover { color: #818cf8; background: rgba(255,255,255,0.05); }
.btn-link-action.delete:hover { color: #f87171; }

.btn-add-link {
    margin-top: 1rem;
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.75rem;
    border: 1px dashed #374151;
    background: rgba(17, 24, 39, 0.3);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}
.btn-add-link:hover {
    border-color: var(--indigo);
    color: #818cf8;
    background: rgba(31, 41, 55, 0.5);
}

.share-select {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    z-index: 20;
}
.share-checkbox {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: 2px solid white;
    background: var(--indigo);
    cursor: pointer;
    appearance: none;
    display: grid;
    place-content: center;
}
.share-checkbox:checked { background: var(--success); }
.share-checkbox:checked::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    background: white;
    border-radius: 50%;
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: #0A0A0A;
    border: 1px solid var(--border-soft);
    padding: 1.5rem;
    border-radius: 1rem;
    width: 100%;
    max-width: 24rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-white);
    margin-bottom: 1.5rem;
}

.input-field {
    width: 100%;
    background: #111827;
    border: 1px solid #1f2937;
    color: var(--text-white);
    border-radius: 0.75rem;
    padding: 0.875rem 1rem;
    outline: none;
    margin-bottom: 0.75rem;
    font-family: inherit;
    font-size: 0.9rem;
}
.input-field:focus {
    box-shadow: 0 0 0 2px var(--primary);
    border-color: transparent;
}

.btn-primary-block {
    width: 100%;
    background: var(--text-white);
    color: var(--text-dark);
    font-weight: 700;
    padding: 0.875rem;
    border-radius: 0.75rem;
    font-size: 1rem;
}
.btn-primary-block:hover { background: #e5e7eb; }

.btn-cancel-block {
    width: 100%;
    margin-top: 0.75rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 0.75rem;
    background: transparent;
}
.btn-cancel-block:hover { color: var(--text-white); }

/* --- MODERN EDITOR LIST (Minimalist & Smooth) --- */

#subject-links-editor {
    display: flex;
    flex-direction: column;
    gap: 0.75rem; /* More breathing room */
    padding: 0.5rem;
}

.editor-item {
    display: grid;
    grid-template-columns: 2rem 1fr auto; /* Handle | Content | Actions */
    align-items: center;
    gap: 0.75rem;
    
    background: rgba(31, 41, 55, 0.4); /* Darker, subtle base */
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 0.75rem;
    padding: 0.75rem 0.75rem 0.75rem 0.25rem;
    
    transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1), 
                box-shadow 0.2s, 
                background-color 0.2s;
    cursor: default;
    position: relative;
    overflow: hidden;
}

/* Hover Effect: Slight lift and glow */
.editor-item:hover {
    background: rgba(31, 41, 55, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Dragging State: Visual feedback */
.editor-item.dragging {
    opacity: 0.5;
    background: var(--bg-soft);
    border: 1px dashed var(--primary);
    transform: scale(0.98);
}

/* --- 1. Drag Handle (Left) --- */
.drag-handle {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4b5563;
    cursor: grab;
    transition: color 0.2s;
}
.editor-item:hover .drag-handle { color: #9ca3af; }
.drag-handle:active { cursor: grabbing; color: var(--primary); }

/* --- 2. Content Area (Middle) --- */
.editor-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow: hidden; /* Prevents text spill */
}

/* Seamless Title Input */
.modern-input {
    background: transparent;
    border: none;
    color: var(--text-white);
    font-weight: 600;
    font-size: 0.95rem;
    width: 100%;
    padding: 0;
    outline: none;
    font-family: inherit;
    transition: color 0.2s;
}
.modern-input::placeholder { color: #4b5563; font-weight: 400; }
.modern-input:focus { color: var(--primary); }

/* URL Badge */
.url-badge {
    font-size: 0.7rem;
    color: #6b7280;
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.8;
}

/* --- 3. Actions (Right) --- */
.editor-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: #4b5563;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-white);
    border-color: rgba(255, 255, 255, 0.1);
}

/* Specific button colors on hover */
.icon-btn.fetch:hover { 
    color: #ef4444; /* YouTube Red */
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}
.icon-btn.delete:hover { 
    color: #f87171; 
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

/* --- Import Modal --- */
.modal-lg { 
    max-width: 42rem; 
    height: 85vh; 
    display: flex; 
    flex-direction: column; 
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.btn-close-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: #1f2937;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}
.import-area { 
    flex-grow: 1; 
    width: 100%; 
    background: #111827; 
    border: 1px solid #1f2937; 
    color: #d1d5db; 
    border-radius: 0.75rem; 
    padding: 1rem; 
    font-family: 'JetBrains Mono', monospace; 
    font-size: 0.875rem; 
    resize: none; 
    margin-bottom: 1rem; 
    outline: none; 
}
.import-area:focus { box-shadow: 0 0 0 2px var(--primary); }

.preview-list { flex-grow: 1; overflow-y: auto; padding-right: 0.5rem; margin-bottom: 1rem; }

/* Import Actions (New) */
.import-actions {
    display: flex;
    gap: 0.75rem;
    padding-top: 1.25rem;
    margin-top: 1rem;
    border-top: 1px solid var(--border-soft);
    width: 100%;
}

#btn-detect-smart {
    width: 100%;
    margin-top: 1rem;
    padding: 1rem;
    font-size: 1rem;
    box-shadow: 0 4px 20px rgba(249, 115, 22, 0.3); 
    transition: transform 0.2s, box-shadow 0.2s;
}
#btn-detect-smart:active { transform: scale(0.98); }

#btn-reset-import {
    background: transparent;
    border: 1px solid #374151;
    color: var(--text-muted);
    flex: 1; 
    border-radius: 0.75rem;
    font-weight: 600;
}
#btn-reset-import:hover {
    border-color: var(--text-white);
    color: var(--text-white);
    background: rgba(255,255,255,0.05);
}

#btn-save-import {
    flex: 2; 
}

/* --- Drag & Drop Styles (Global) --- */
.preview-item {
    background: rgba(31, 41, 55, 0.5);
    padding: 0.75rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(55, 65, 81, 0.5);
    margin-bottom: 0.75rem;
    transition: transform 0.2s, border-color 0.2s;
    cursor: grab;
}
.preview-item:active {
    cursor: grabbing;
}
.preview-item.drag-over {
    border: 2px dashed var(--primary);
    background: rgba(249, 115, 22, 0.1);
    transform: scale(1.02);
}

.preview-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; gap: 0.5rem; }
.preview-select {
    background: #111827;
    border: 1px solid #374151;
    color: white;
    border-radius: 0.5rem;
    padding: 0.375rem;
    font-size: 0.75rem;
    outline: none;
    flex: 1;
    max-width: 200px;
}

/* --- LONG PRESS DETAILS MODAL --- */
.details-hero {
    width: 100%;
    height: 12rem;
    background: #1f2937;
    border-radius: 0.75rem;
    margin-bottom: 1.25rem;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: flex-end;
    padding: 1rem;
    position: relative;
    overflow: hidden;
}
.details-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
}
.details-meta {
    position: relative;
    z-index: 10;
    display: flex;
    gap: 0.75rem;
}
.details-badge {
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    color: var(--text-white);
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 0.25rem;
    border: 1px solid rgba(255,255,255,0.1);
}
.details-desc {
    font-size: 0.9rem;
    color: #d1d5db;
    line-height: 1.6;
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 1.5rem;
    padding-right: 0.5rem;
    white-space: pre-wrap;
}
.details-desc::-webkit-scrollbar { width: 4px; }
.details-desc::-webkit-scrollbar-thumb { background: #374151; border-radius: 4px; }

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(5rem);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #111827;
    border: 1px solid #1f2937;
    color: var(--text-white);
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 300;
    white-space: nowrap;
    max-width: 90vw;
}
.toast.active { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast-success i { color: var(--success); }
.toast-error i { color: var(--danger); }

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 1rem;
    text-align: center;
    border: 1px dashed #1f2937;
    border-radius: 1.5rem;
    background: rgba(17, 24, 39, 0.2);
    margin-top: 2rem;
}
.empty-icon-box {
    width: 4rem;
    height: 4rem;
    background: #1f2937;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}
.empty-title { color: var(--text-white); font-weight: 700; font-size: 1.125rem; }
.empty-desc { color: var(--text-muted); font-size: 0.875rem; margin-top: 0.25rem; }

/* --- Loader --- */
.loader-container { display: flex; justify-content: center; padding: 5rem 0; }
.loader-icon { font-size: 1.875rem; color: #374151; }

/* --- Shared View --- */
.shared-banner {
    background: rgba(124, 45, 18, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.2);
    padding: 1.5rem;
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}
.shared-banner h2 { font-size: 1.5rem; font-weight: 700; color: #fb923c; }
.btn-save-shared {
    background: #ea580c;
    color: black;
    padding: 0.75rem 2rem;
    border-radius: 0.75rem;
    font-weight: 700;
    width: 100%;
    display: flex; 
    align-items: center; 
    justify-content: center;
}
.btn-save-shared:hover { background: #f97316; }

/* --- Media Queries (Desktop) --- */
@media (min-width: 768px) {
    .container { padding: 2rem 1rem; }
    
    .hero-title { font-size: 3.75rem; }
    .user-badge { display: block; }
    
    .action-bar { flex-direction: row; }
    .search-wrapper { width: 24rem; }
    
    .btn-group { width: auto; padding-bottom: 0; }

    /* RESTORE TEXT ON BUTTONS FOR DESKTOP */
    #btn-import, #btn-add-subject, #btn-clear-all {
        font-size: 0.875rem;        
        width: auto;                
        height: auto;               
        padding: 0.75rem 1.25rem;   
        flex: 1;                    
    }
    
    #btn-import i, #btn-add-subject i, #btn-clear-all i {
        font-size: inherit;         
        margin-right: 0.5rem !important; 
    }
    
    .btn-gradient, .btn-secondary, .btn-danger-ghost {
        flex: none;
        width: auto;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 0.75rem;
    }
    
    /* FIX: Force icon-only button to stay square and fixed-size on desktop */
    .btn-icon-only {
        width: 3rem !important;
        flex: 0 0 3rem !important; /* Prevent Flex Grow/Shrink */
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .cards-grid { grid-template-columns: repeat(2, 1fr); }
    
    .shared-banner { flex-direction: row; justify-content: space-between; align-items: center; }
    .btn-save-shared { width: auto; }

    /* IMPORT ACTIONS DESKTOP */
    #btn-detect-smart {
        width: auto;
        min-width: 200px;
        margin-left: auto;
        display: block; 
        padding: 0.75rem 2rem;
    }
    .import-actions {
        justify-content: flex-end;
    }
    #btn-reset-import {
        flex: none;
        width: auto;
        min-width: 100px;
    }
    #btn-save-import {
        flex: none;
        width: auto;
        min-width: 150px;
    }
}

@media (min-width: 1024px) {
    .cards-grid { grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
}

/* --- Toggle Switch Styles --- */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    float: left;
    margin: 0px 0px 0px auto;
}
.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #374151; 
    transition: .4s;
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: var(--primary); 
}
input:checked + .slider:before {
    transform: translateX(20px);
}

/* --- Mini Toggle for Import Preview --- */
.source-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(17, 24, 39, 0.8);
    padding: 0.25rem 0.5rem;
    border-radius: 99px;
    border: 1px solid #374151;
}

.toggle-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #4b5563; 
    transition: color 0.2s;
}

.toggle-label.active {
    color: var(--text-white); 
}
.toggle-label.active .fa-youtube {
    color: #ef4444; 
}

/* Small Switch Slider */
.toggle-switch-sm {
    position: relative;
    display: inline-block;
    width: 28px;
    height: 16px;
}
.toggle-switch-sm input { 
    opacity: 0;
    width: 0;
    height: 0;
}
.slider-sm {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #4b5563;
    transition: .4s;
    border-radius: 34px;
}
.slider-sm:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider-sm {
    background-color: var(--primary);
}
input:checked + .slider-sm:before {
    transform: translateX(12px);
}