:root {
    --bg-color: #0d1117;
    --panel-bg: #161b22;
    --text-color: #c9d1d9;
    --accent-color: #58a6ff;
    --border-color: #30363d;
    --header-height: 50px;
    --footer-height: 30px;
    --editor-font: 'JetBrains Mono', 'Cascadia Code', 'Fira Mono', 'Menlo', 'Consolas', monospace;
    --ui-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --editor-font-size: 1.1rem;
    --editor-line-height: 1.6;
}

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

body {
    font-family: var(--ui-font);
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

#sidebar {
    width: 250px;
    background-color: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
    z-index: 101;
}

#sidebar.hidden {
    margin-left: -250px;
}

.sidebar-header {
    height: var(--header-height);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
}

.sidebar-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
}

#new-note-btn {
    padding: 4px 10px;
    font-size: 1.2rem;
    line-height: 1;
}

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

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

.file-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.file-item.active {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: var(--accent-color);
}

.file-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-name {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.file-date {
    font-size: 0.75rem;
    color: #8b949e;
    margin-top: 4px;
}

.delete-btn {
    background: transparent;
    color: #8b949e;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
}

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

.delete-btn:hover {
    color: #f85149;
    background: transparent;
    filter: none;
}

#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    transition: width 0.3s ease;
}

header {
    height: var(--header-height);
    background-color: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.icon-btn {
    background: transparent;
    color: var(--text-color);
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

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

.logo {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.5px;
}

.logo span {
    color: var(--accent-color);
}

.actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #8b949e;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #30363d;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--accent-color);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 20px;
}

.slider.round:before {
    border-radius: 50%;
}

button {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: filter 0.2s;
}

button:hover {
    filter: brightness(1.1);
}

main#editor-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg-color);
}

#editor,
#preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 40px;
    overflow-y: auto;
    border: none;
    outline: none;
    word-wrap: break-word;
}

#editor {
    font-family: var(--editor-font);
    font-size: var(--editor-font-size);
    line-height: var(--editor-line-height);
    background: transparent;
    color: transparent;
    caret-color: #fff;
    resize: none;
    z-index: 2;
    white-space: pre-wrap;
}

#preview {
    font-family: var(--editor-font);
    font-size: var(--editor-font-size);
    line-height: var(--editor-line-height);
    z-index: 1;
    color: var(--text-color);
    pointer-events: none;
    background: var(--bg-color);
    white-space: normal;
}

/* Edit Mode Highlighting - PrismJS Overrides */

/* Target the specific generated structure */
#preview code.language-markdown {
    display: block;
    /* Ensure it behaves like a block for the container */
    font-family: var(--editor-font) !important;
    font-size: var(--editor-font-size) !important;
    line-height: var(--editor-line-height) !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    color: var(--text-color);
    /* Default text color */
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
}

/* Ensure Prism styles don't override our alignment critical properties on the code block */
:not(pre)>code[class*="language-"],
pre[class*="language-"] {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

/* Specific Markdown Tokens for better visibility */
.token.title,
.token.header {
    font-weight: bold;
    color: var(--accent-color);
}

.token.bold {
    font-weight: bold;
    color: #fff;
}

.token.italic {
    font-style: italic;
    color: #fff;
}

.token.code {
    color: #ffa657;
    background: rgba(48, 54, 61, 0.5);
    border-radius: 4px;
    padding: 0.1em 0.3em;
    /* Optional: adds a bit of padding like in View mode */
}

/* Handle block code specially if needed, mostly for background color */
.token.block-code {
    background: rgba(48, 54, 61, 0.5);
    border-radius: 4px;
}

/* Preview Mode Styles */
.preview-mode #preview {
    font-family: var(--ui-font);
    pointer-events: auto;
    z-index: 5;
    background: var(--bg-color);
    line-height: 1.6;
    white-space: normal;
}

.preview-mode #editor {
    display: none;
}

.preview-mode #preview h1,
.preview-mode #preview h2 {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3em;
    margin-top: 24px;
    margin-bottom: 16px;
    color: #fff;
}

.preview-mode #preview p {
    margin-bottom: 16px;
}

.preview-mode #preview ul,
.preview-mode #preview ol {
    margin-bottom: 16px;
    padding-left: 2em;
}

.preview-mode #preview code {
    background: #30363d;
    padding: 0.2em 0.4em;
    border-radius: 6px;
}

.preview-mode #preview pre {
    background: #161b22;
    padding: 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    overflow-x: auto;
}

/* Reset inline code style inside code blocks */
.preview-mode #preview pre>code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-family: var(--editor-font);
    font-size: 0.95em;
    white-space: pre;
}

footer {
    height: var(--footer-height);
    background: var(--panel-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    font-size: 0.8rem;
    color: #8b949e;
}

#editor::-webkit-scrollbar {
    width: 10px;
}

#editor::-webkit-scrollbar-track {
    background: var(--bg-color);
}

#editor::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

#preview::-webkit-scrollbar {
    width: 10px;
}

#preview::-webkit-scrollbar-track {
    background: var(--bg-color);
}

#preview::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.visible {
    display: flex;
}

.modal-content {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 24px;
    width: 90%;
    max-width: 350px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.2s ease-out forwards;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h3 {
    margin-bottom: 12px;
    font-size: 1.1rem;
    color: var(--text-color);
}

.modal-content p {
    color: #8b949e;
    font-size: 0.9rem;
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
}

.btn-danger {
    background: #da3633;
}

.btn-danger:hover {
    background: #f85149;
}

/* Dropdown styles */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: filter 0.2s;
}

.dropdown-toggle .arrow-icon {
    transition: transform 0.2s ease;
}

.dropdown.open .dropdown-toggle .arrow-icon {
    transform: rotate(180deg);
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    min-width: 200px;
    z-index: 1000;
    padding: 6px;
    flex-direction: column;
    gap: 2px;
}

.dropdown.open .dropdown-menu {
    display: flex;
    animation: dropdownFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    background: transparent;
    border: none;
    color: var(--text-color);
    padding: 8px 12px;
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    filter: none;
}

.dropdown-item svg {
    color: #8b949e;
    transition: color 0.2s;
    flex-shrink: 0;
}

.dropdown-item:hover svg {
    color: var(--accent-color);
}

/* Mobile responsive fixes */
@media (max-width: 580px) {
    header {
        padding: 0 10px;
    }
    .actions {
        gap: 10px;
    }
    .toggle-container {
        font-size: 0.8rem;
        gap: 4px;
    }
    #copy-link, .dropdown-toggle {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    .dropdown-toggle .btn-text,
    .dropdown-toggle .arrow-icon {
        display: none; /* Hide text and arrow on mobile, keep only download icon */
    }
    .dropdown-toggle {
        padding: 6px;
        border-radius: 50%; /* Make it a circular icon button */
        width: 32px;
        height: 32px;
        justify-content: center;
    }
    .logo {
        font-size: 1rem;
    }
}

@media (max-width: 420px) {
    .logo {
        display: none; /* Hide logo completely on extremely small screens */
    }
}