:root {
    --primary-color: #128f94; /* Teal accent from reference */
    --primary-hover: #0e7579;
    --primary-light: #e6f4f5;
    
    --bg-color: #f5f6f8; /* Main body background */
    --surface-color: #ffffff; /* Card/Panel background */
    --sidebar-bg: #fcfcfc;
    
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --text-muted: #a0aec0;
    
    --border-color: #e2e8f0;
    --border-light: #edf2f7;
    
    --danger-color: #e53e3e;
    --danger-hover: #c53030;
    
    --sidebar-width: 260px;
    --list-width: 320px;
    --header-height: 64px;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Inter', 'Noto Sans KR', sans-serif;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

.mt-3 { margin-top: 16px; }

/* Custom Scrollbar */
.styled-scroll::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.styled-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.styled-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 10px;
}
.styled-scroll::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Auth Overlay */
.overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: #ebf0f5;
    background-image: radial-gradient(#d6e0ec 1px, transparent 1px);
    background-size: 20px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.auth-box {
    background: var(--surface-color);
    padding: 48px 40px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    width: 400px;
    text-align: center;
}

.logo {
    color: var(--primary-color);
    margin-bottom: 32px;
    font-weight: 700;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.auth-box h2 { margin-bottom: 8px; font-weight: 700; color: var(--text-primary); font-size: 22px; }
.auth-box p { color: var(--text-secondary); margin-bottom: 32px; font-size: 14px; }

.input-group {
    position: relative;
    margin-bottom: 16px;
}
.input-group i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
}
.auth-box input {
    width: 100%; 
    padding: 12px 12px 12px 40px; 
    background-color: #f7fafc;
    border: 1px solid var(--border-color); 
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.2s;
    font-family: inherit;
}
.auth-box input:focus { 
    border-color: var(--primary-color); 
    background-color: #fff;
    box-shadow: 0 0 0 3px var(--primary-light); 
    outline: none; 
}

/* Buttons */
.btn {
    padding: 10px 18px; border: none; border-radius: 8px;
    cursor: pointer; font-size: 14px; font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    transition: all 0.2s;
    font-family: inherit;
}
.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 6px rgba(18, 143, 148, 0.2); }
.btn-secondary { background-color: #edf2f7; color: var(--text-primary); }
.btn-secondary:hover { background-color: #e2e8f0; }
.btn-outline { background-color: transparent; border: 1px solid var(--border-color); color: var(--text-primary); }
.btn-outline:hover { background-color: #f7fafc; border-color: #cbd5e0; }
.btn-danger { background-color: var(--danger-color); color: white; }
.btn-danger:hover { background-color: var(--danger-hover); }
.btn-block { width: 100%; }

.btn-icon {
    background: transparent; border: none; font-size: 18px; 
    cursor: pointer; color: var(--text-secondary); 
    width: 32px; height: 32px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.btn-icon:hover { background-color: #edf2f7; color: var(--text-primary); }
.text-danger { color: var(--danger-color); }
.text-danger:hover { background-color: #fff5f5; color: var(--danger-hover); }

/* Layout */
.layout {
    display: flex; height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo-area { display: flex; align-items: center; gap: 10px; }
.sidebar-logo-text { font-size: 18px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.5px; }

.sidebar-nav-container { flex: 1; overflow-y: auto; padding: 16px 12px; }
.nav-section { margin-bottom: 24px; }
.nav-section-title { 
    font-size: 11px; font-weight: 700; color: var(--text-muted); 
    letter-spacing: 1px; margin-bottom: 8px; padding-left: 12px;
}
.sidebar-nav ul { list-style: none; }
.sidebar-nav li {
    padding: 10px 12px; cursor: pointer; color: var(--text-secondary);
    font-size: 14px; font-weight: 500; transition: all 0.2s;
    border-radius: 8px; margin-bottom: 2px;
    display: flex; align-items: center; gap: 12px;
}
.sidebar-nav li:hover { background-color: #edf2f7; color: var(--text-primary); }
.sidebar-nav li.active {
    background-color: var(--primary-light); color: var(--primary-color); font-weight: 600;
}
.nav-icon { font-size: 18px; }

.sidebar-footer { 
    padding: 16px 20px; 
    border-top: 1px solid var(--border-color); 
    display: flex; justify-content: space-between; align-items: center;
}
.user-profile { display: flex; align-items: center; gap: 12px; }
.avatar { 
    width: 36px; height: 36px; border-radius: 50%; 
    background: var(--primary-light); color: var(--primary-color);
    display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.user-info { display: flex; flex-direction: column; }
.user-name { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.user-id { color: var(--text-muted); font-size: 12px; }
.footer-actions { display: flex; gap: 4px; }


/* Main Wrapper */
.main-wrapper {
    flex: 1; display: flex; flex-direction: column; min-width: 0;
}

/* Mobile Header (Hidden on Desktop) */
.mobile-header {
    display: none;
    height: var(--header-height);
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    align-items: center; justify-content: flex-start;
    padding: 0 24px; gap: 12px;
}

.search-box { position: relative; width: 100%; }
.search-icon { 
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 18px;
}
.search-box input {
    width: 100%; padding: 10px 12px 10px 40px; 
    border: none; border-radius: 8px; font-size: 14px;
    background-color: #f1f3f5; color: var(--text-primary);
    transition: all 0.2s; font-family: inherit;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-box input:focus { 
    background-color: #fff; box-shadow: 0 0 0 2px var(--primary-light); outline: none; 
}

/* Main Content Area */
.main-content {
    flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative;
}
.view-panel {
    display: flex; flex: 1; height: 100%;
}

/* Notes View */
.notes-list-pane {
    width: var(--list-width);
    background-color: #fbfbfc;
    border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column;
    z-index: 5;
}
.list-header { 
    padding: 16px 20px; border-bottom: 1px solid var(--border-light);
    display: flex; justify-content: space-between; align-items: center;
}
.list-header h3 { font-size: 13px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

.notes-list-pane ul { list-style: none; flex: 1; overflow-y: auto; padding: 12px; }
.note-item {
    padding: 12px 14px; border-radius: 10px; margin-bottom: 4px;
    cursor: pointer; transition: all 0.2s;
    background-color: transparent; border: 1px solid transparent;
}
.note-item:hover { background-color: #edf2f7; }
.note-item.active { 
    background-color: #fff; 
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm); 
}
.note-item-title { font-weight: 600; font-size: 15px; margin-bottom: 6px; color: var(--text-primary); line-height: 1.3; }
.note-item-author { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; display: flex; align-items: center; gap: 4px; }
.note-item-date { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }

/* Note Editor */
.note-editor-pane {
    flex: 1; display: flex; flex-direction: column; background: var(--surface-color);
}
.empty-state {
    flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center;
    color: var(--text-secondary); text-align: center;
}
.empty-illustration {
    width: 80px; height: 80px; border-radius: 20px; background: var(--primary-light);
    color: var(--primary-color); display: flex; justify-content: center; align-items: center;
    font-size: 40px; margin-bottom: 24px;
}
.empty-state h3 { font-size: 20px; color: var(--text-primary); margin-bottom: 8px; }

.editor-container { flex: 1; display: block; overflow-y: auto; }

.editor-header {
    padding: 24px 40px 0; display: flex; flex-direction: column;
}
.editor-toolbar-top {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px;
}
.editor-meta { display: flex; gap: 16px; color: var(--text-secondary); font-size: 13px; }
.editor-meta span { display: flex; align-items: center; gap: 6px; }
.editor-actions { display: flex; gap: 8px; align-items: center; }
.divider { width: 1px; height: 24px; background: var(--border-color); margin: 0 4px; }

.editor-title-area { margin-bottom: 24px; }
.note-title-input {
    font-size: 32px; font-weight: 700; border: none; outline: none; width: 100%;
    color: var(--text-primary); padding: 0; background: transparent;
    font-family: inherit;
}
.note-title-input::placeholder { color: var(--border-color); }
.note-title-display { 
    font-size: 32px; font-weight: 700; color: var(--text-primary); margin: 0; 
    word-break: break-all; line-height: 1.2;
}

.editor-body { display: block; overflow: visible; position: relative; }
.note-content-display { 
    padding: 0 40px 40px; overflow: visible; font-size: 16px; 
    line-height: 1.8; color: #333; 
}
.note-content-display * { overflow-wrap: anywhere; }
.note-content-display img { max-width: 100%; height: auto; border-radius: 8px; margin: 16px 0; }
.note-content-display table { border-collapse: collapse; width: 100%; margin: 16px 0; }
.note-content-display td, .note-content-display th { border: 1px solid var(--border-color); padding: 8px 12px; }
.note-content-display th { background-color: #f7fafc; }

.editor-wrapper { display: block; padding: 0 40px 40px; }

/* Bulletproof Sticky TinyMCE Toolbar */
.tox-tinymce {
    overflow: visible !important;
}
.tox-editor-container {
    overflow: visible !important;
}
.tox-editor-header {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 0;
    z-index: 50 !important;
    background-color: #fff !important;
}

/* Admin Panels */
.admin-panel { flex-direction: column; padding: 40px; overflow-y: auto; background: var(--surface-color); }
.panel-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 32px; }
.panel-header h2 { font-size: 28px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.panel-header p { color: var(--text-secondary); }

/* Table */
.table-container { 
    background: #fff; border: 1px solid var(--border-color); 
    border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-sm);
}
.styled-table { width: 100%; border-collapse: collapse; }
.styled-table th, .styled-table td { padding: 16px; text-align: left; border-bottom: 1px solid var(--border-color); }
.styled-table th { background: #f8fafc; font-weight: 600; color: var(--text-secondary); font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; }
.styled-table tbody tr:last-child td { border-bottom: none; }
.styled-table tbody tr:hover { background-color: #f8fafc; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 24px; }
.stat-card {
    background: #fff; padding: 24px; border-radius: 16px; 
    box-shadow: var(--shadow-sm); border: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 16px;
}
.stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; justify-content: center; align-items: center; font-size: 24px;
}
.stat-info h3 { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; font-weight: 600; text-transform: uppercase; }
.stat-info p { font-size: 24px; font-weight: 700; color: var(--text-primary); line-height: 1; }

/* Settings */
.settings-container { max-width: 800px; }
.settings-card {
    background: #fff; border-radius: 12px; box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color); overflow: hidden;
}
.settings-card-header { 
    padding: 20px 24px; border-bottom: 1px solid var(--border-color); background: #f8fafc;
    display: flex; align-items: center; gap: 12px;
}
.settings-card-header i { font-size: 20px; color: var(--primary-color); }
.settings-card-header h3 { font-size: 16px; font-weight: 600; color: var(--text-primary); }

.settings-card-body { padding: 24px; }
.form-group { margin-bottom: 20px; display: flex; flex-direction: column; }
.form-group:last-child { margin-bottom: 0; }
.form-group label { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.form-control {
    padding: 12px; font-size: 14px; border: 1px solid #cbd5e0; border-radius: 8px;
    transition: all 0.2s; width: 100%; max-width: 400px; font-family: inherit; background: #fff;
}
.form-control:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px var(--primary-light); outline: none; }
.form-help { font-size: 12px; color: var(--text-muted); margin-top: 6px; display: block; }
.select-wrapper { position: relative; max-width: 400px; }
.select-wrapper select { appearance: none; width: 100%; }
.select-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--text-muted); }


.settings-card-footer {
    padding: 16px 24px; background: #f8fafc; border-top: 1px solid var(--border-color);
    display: flex; justify-content: flex-start;
}

/* Modals */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(2px);
    display: flex; justify-content: center; align-items: center; z-index: 2000;
}
.modal-content {
    background: var(--surface-color); border-radius: 16px; width: 400px;
    box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-weight: 600; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.modal-body { padding: 24px; }
.modal-body .form-control { max-width: 100%; }
.modal-body .select-wrapper { max-width: 100%; }
.modal-actions { padding: 16px 24px; background: #f8fafc; display: flex; justify-content: flex-end; gap: 12px; border-top: 1px solid var(--border-color); }

/* Mobile display classes */
.mobile-menu-toggle { display: none; }
.mobile-close-btn { display: none; }
.mobile-back-btn { display: none; margin-right: 12px; }

/* Responsive Design */
@media (max-width: 768px) {
    .layout { flex-direction: column; }
    
    .mobile-header { display: flex; padding: 0 16px; }
    .mobile-menu-toggle { display: flex; align-items: center; gap: 12px; }
    .mobile-title { font-size: 18px; font-weight: 700; }
    
    .sidebar {
        position: fixed; top: 0; left: -100%; height: 100%;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 1000;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { left: 0; }
    .mobile-close-btn { display: flex; }
    
    .main-content { flex: 1; overflow: hidden; position: relative; }
    
    .view-panel { flex-direction: column; }
    
    .notes-list-pane {
        width: 100%; height: 100%; flex: 1; border-right: none;
    }
    
    .note-editor-pane {
        position: absolute; top: 0; left: 100%; width: 100%; height: 100%;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 10;
    }
    .note-editor-pane.open { left: 0; }
    .mobile-back-btn { display: flex; }
    
    .editor-header { padding: 16px 20px 0; }
    .editor-toolbar-top { flex-wrap: wrap; gap: 16px; }
    .editor-meta { width: 100%; order: 3; }
    .note-content-display, .editor-wrapper { padding: 0 20px 20px; }
    
    .auth-box { width: 90%; padding: 32px 24px; }
    .admin-panel { padding: 20px; }
    .panel-header { flex-direction: column; gap: 16px; }
}
