:root {
    /* Paleta de Colores Inspirada en Kioko */
    --bg-main: #1a1b26;
    --bg-sidebar: #16161e;
    --bg-input: #1f2335;
    --accent: #7aa2f7;      /* Azul brillante */
    --accent-hover: #5d85d4;
    --text-main: #c0caf5;
    --text-muted: #565f89;
    --border: #292e42;
    --code-bg: #24283b;
    
    --header-height: 60px;
    --sidebar-width: 280px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

/* --- Layout Principal --- */
.app-container {
    display: flex;
    height: 100%;
    width: 100%;
}

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

.sidebar-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1.2rem;
    color: var(--accent);
    font-weight: 700;
}

.search-box {
    margin: 0 15px 15px;
    background: var(--bg-input);
    padding: 8px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box input {
    background: transparent;
    border: none;
    color: var(--text-main);
    width: 100%;
    outline: none;
}

.file-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

.file-item {
    padding: 12px 20px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-item:hover {
    background-color: rgba(122, 162, 247, 0.1);
}

.file-item.active {
    background-color: rgba(122, 162, 247, 0.15);
    border-left-color: var(--accent);
    color: #fff;
}

.file-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
}

/* Toolbar */
.toolbar {
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg-main);
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

#note-title {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.1rem;
    font-weight: 600;
    outline: none;
    width: 200px;
}

.status-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Botones */
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.icon-btn:hover {
    background-color: rgba(255,255,255,0.1);
}

.primary-btn {
    background-color: var(--accent);
    color: #fff;
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.primary-btn:hover {
    background-color: var(--accent-hover);
}

.btn-text {
    font-weight: 600;
}

/* Workspace (Editor & Preview) */
.workspace {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.editor-container, .preview-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    overflow-y: auto;
    padding: 20px 40px;
}

/* Ocultar elementos */
.hidden {
    display: none !important;
}

textarea {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 16px;
    line-height: 1.6;
    resize: none;
    outline: none;
    font-family: 'Fira Code', monospace; /* Fuente monoespaciada opcional */
}

/* --- Markdown Renderizado (Estilos tipo GitHub Dark / Kioko) --- */
.markdown-body {
    line-height: 1.7;
    max-width: 800px;
    margin: 0 auto;
    padding-bottom: 50px;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    color: var(--accent);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.markdown-body h1 { border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }

.markdown-body p { margin-bottom: 1em; }

.markdown-body a { color: var(--accent); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }

.markdown-body blockquote {
    border-left: 4px solid var(--accent);
    background: rgba(122, 162, 247, 0.1);
    padding: 10px 15px;
    margin: 1em 0;
    color: #cfc9c2;
    border-radius: 0 5px 5px 0;
}

.markdown-body img, .markdown-body video {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    margin: 10px 0;
}

.markdown-body code {
    background-color: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.9em;
}

.markdown-body pre {
    background-color: var(--code-bg) !important; /* Forza override de Prism si es necesario */
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1em 0;
}

/* --- Responsividad (Móvil) --- */
@media (max-width: 768px) {
    .app-container {
        position: relative;
    }

    .sidebar {
        position: absolute;
        height: 100%;
        transform: translateX(-100%);
        box-shadow: 5px 0 15px rgba(0,0,0,0.5);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .editor-container, .preview-container {
        padding: 15px;
    }
    
    #note-title {
        width: 140px;
    }
    
    .btn-text {
        display: none; /* Solo mostrar iconos en móvil */
    }
}