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

:root {
    --sidebar-bg: #1e1e2e;
    --sidebar-text: #cdd6f4;
    --sidebar-hover: #313244;
    --sidebar-active: #45475a;
    --sidebar-border: #313244;
    --editor-bg: #ffffff;
    --header-bg: #f8f9fa;
    --header-border: #e9ecef;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --text-primary: #1a1a2e;
    --text-secondary: #6c757d;
    --danger: #e74c3c;
    --danger-hover: #c0392b;
    --success: #27ae60;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    height: 100vh;
    display: flex;
    overflow: hidden;
    background: var(--editor-bg);
    color: var(--text-primary);
}

/* ── SIDEBAR ── */
#sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--sidebar-border);
    height: 100vh;
}

#sidebar-header {
    padding: 16px 14px 12px;
    border-bottom: 1px solid var(--sidebar-border);
}

#sidebar-header h2 {
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 10px;
    opacity: 0.7;
}

#search-box {
    width: 100%;
    padding: 7px 10px;
    background: #313244;
    border: 1px solid #45475a;
    border-radius: 6px;
    color: var(--sidebar-text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

#search-box::placeholder {
    color: #6c7086;
}

#search-box:focus {
    border-color: var(--accent);
}

#new-btn {
    width: 100%;
    margin-top: 8px;
    padding: 7px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

#new-btn:hover {
    background: var(--accent-hover);
}

#file-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

#file-list::-webkit-scrollbar {
    width: 4px;
}

#file-list::-webkit-scrollbar-track {
    background: transparent;
}

#file-list::-webkit-scrollbar-thumb {
    background: #45475a;
    border-radius: 2px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    cursor: pointer;
    border-radius: 0;
    transition: background 0.15s;
    border-left: 3px solid transparent;
}

.file-item:hover {
    background: var(--sidebar-hover);
}

.file-item.active {
    background: var(--sidebar-active);
    border-left-color: var(--accent);
}

.file-item-title {
    color: var(--sidebar-text);
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.file-item.active .file-item-title {
    color: #ffffff;
    font-weight: 500;
}

.file-item-time {
    color: #6c7086;
    font-size: 11px;
    margin-left: 8px;
    white-space: nowrap;
}

.file-delete-btn {
    background: none;
    border: none;
    color: #6c7086;
    font-size: 15px;
    cursor: pointer;
    padding: 0 0 0 6px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.file-item:hover .file-delete-btn {
    opacity: 1;
}

.file-delete-btn:hover {
    color: var(--danger);
}

#empty-msg {
    color: #6c7086;
    font-size: 13px;
    text-align: center;
    margin-top: 40px;
    padding: 0 20px;
}

/* ── EDITOR AREA ── */
#editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

#editor-header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

#filename-input {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    outline: none;
    padding: 4px 0;
    transition: border-color 0.2s;
}

#filename-input:focus {
    border-bottom-color: var(--accent);
}

#filename-input::placeholder {
    color: #adb5bd;
}

#save-status {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 80px;
    text-align: right;
}

#save-status.saving {
    color: #f39c12;
}

#save-status.saved {
    color: var(--success);
}

#save-status.error {
    color: var(--danger);
}

#shortcuts-hint {
    font-size: 11px;
    color: #adb5bd;
}

#editor {
    flex: 1;
    width: 100%;
    padding: 24px 32px;
    font-size: 15px;
    line-height: 1.8;
    font-family: 'Consolas', 'Courier New', monospace;
    color: var(--text-primary);
    background: var(--editor-bg);
    border: none;
    outline: none;
    resize: none;
    overflow-y: auto;
}

#editor::placeholder {
    color: #ced4da;
}

/* No file selected */
#no-file-msg {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    gap: 8px;
}

#no-file-msg .icon {
    font-size: 48px;
    opacity: 0.3;
}

#no-file-msg p {
    font-size: 15px;
    opacity: 0.6;
}

#no-file-msg small {
    font-size: 12px;
    opacity: 0.4;
}

/* ── MODAL ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: #fff;
    border-radius: 10px;
    padding: 24px 28px;
    width: 340px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.modal h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.modal p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-cancel {
    padding: 8px 18px;
    border: 1px solid #dee2e6;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
}

.btn-cancel:hover {
    background: #f8f9fa;
}

.btn-delete {
    padding: 8px 18px;
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.btn-delete:hover {
    background: var(--danger-hover);
}

/* Responsive */
@media (max-width: 600px) {
    #sidebar {
        width: 200px;
        min-width: 200px;
    }
    #editor {
        padding: 16px;
    }
}
