:root {
    --bg: #282a36;
    --sidebar: #21222c;
    --text: #f8f8f2;
    --accent: #bd93f9;
    --hover: #44475a;
}

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

body {
    font-family: 'Fira Code', monospace;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
#sidebar {
    width: 250px;
    background: var(--sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid #44475a;
    padding: 20px;
}

.brand {
    color: var(--accent);
    font-weight: bold;
    margin-bottom: 20px;
}

/* Search Box */
.search-box {
    margin-bottom: 10px;
}

.search-input {
    width: 100%;
    background: #44475a;
    border: none;
    color: var(--text);
    padding: 8px;
    border-radius: 4px;
    font-family: inherit;
    outline: none;
}

.search-input::placeholder {
    color: #6272a4;
}

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

.file-item {
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    opacity: 0.7;
    margin-bottom: 2px;
    min-width: 0;
}

.file-item > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.file-item:hover,
.file-item.active {
    background: var(--hover);
    opacity: 1;
}

.file-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.main-actions {
    display: flex;
    gap: 10px;
}

.util-actions {
    display: flex;
    gap: 5px;
}

.btn {
    background: var(--hover);
    border: none;
    color: var(--text);
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
    flex: 1;
    font-family: inherit;
}

.btn:hover {
    background: #6272a4;
}

.util-btn {
    font-size: 0.8rem;
    padding: 4px;
    background: #44475a;
}

.del-btn {
    color: #ff5555;
    font-weight: bold;
    margin-left: 5px;
    visibility: hidden;
    flex-shrink: 0;
}

.file-item:hover .del-btn {
    visibility: visible;
}

/* Editor */
#editor-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

#top-bar {
    padding: 10px 20px;
    background: var(--bg);
    border-bottom: 1px solid #44475a;
    font-size: 0.9em;
    opacity: 0.8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-bar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.save-status {
    font-size: 0.8em;
    color: #50fa7b;
    opacity: 0;
    transition: opacity 0.5s;
}

.preview-btn {
    background: none;
    border: 1px solid #6272a4;
    color: #6272a4;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
}

.preview-btn:hover,
.preview-btn.active {
    background: #6272a4;
    color: var(--text);
}

.share-btn {
    background: none;
    border: 1px solid #6272a4;
    color: #6272a4;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    display: none;
}

.share-btn:hover {
    background: #6272a4;
    color: var(--text);
}

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

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--sidebar);
    border: 1px solid #44475a;
    border-radius: 8px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
}

.modal h3 {
    color: var(--accent);
    margin-bottom: 12px;
}

.modal-url {
    background: var(--bg);
    border: 1px solid #44475a;
    border-radius: 4px;
    padding: 10px;
    font-size: 0.8rem;
    word-break: break-all;
    margin-bottom: 8px;
    color: #50fa7b;
}

.modal-hint {
    font-size: 0.75rem;
    color: #6272a4;
    margin-bottom: 16px;
}

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

.modal-btn {
    background: var(--hover);
    border: none;
    color: var(--text);
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.85rem;
}

.modal-btn:hover {
    background: #6272a4;
}

.modal-btn-primary {
    background: var(--accent);
    color: #282a36;
    font-weight: 500;
}

.modal-btn-primary:hover {
    background: #a87bef;
}

textarea {
    flex-grow: 1;
    background: var(--bg);
    color: var(--text);
    border: none;
    padding: 20px;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.6;
}

/* Markdown Preview Styles */
#preview-area-content {
    flex-grow: 1;
    background: var(--bg);
    color: var(--text);
    padding: 20px;
    overflow-y: auto;
    display: none;
    font-family: sans-serif;
    line-height: 1.6;
}

#preview-area-content h1,
#preview-area-content h2,
#preview-area-content h3 {
    margin-top: 1em;
    margin-bottom: 0.5em;
    border-bottom: 1px solid #44475a;
    padding-bottom: 5px;
}

#preview-area-content p {
    margin-bottom: 1em;
}

#preview-area-content ul,
#preview-area-content ol {
    margin-left: 20px;
    margin-bottom: 1em;
}

#preview-area-content code {
    background: #44475a;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Fira Code', monospace;
}

#preview-area-content pre {
    background: #21222c;
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    margin-bottom: 1em;
}

#preview-area-content pre code {
    background: transparent;
    padding: 0;
}

#preview-area-content blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 10px;
    color: #6272a4;
    margin-bottom: 1em;
}

#preview-area-content a {
    color: var(--accent);
}

#preview-area-content img {
    max-width: 100%;
    border-radius: 4px;
}

textarea::-webkit-scrollbar,
#preview-area-content::-webkit-scrollbar {
    width: 8px;
}

textarea::-webkit-scrollbar-thumb,
#preview-area-content::-webkit-scrollbar-thumb {
    background: var(--hover);
    border-radius: 4px;
}

/* Loading/Status */
#status-light {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #50fa7b;
    margin-right: 5px;
}

/* Hamburger Menu Button (hidden on desktop) */
.menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 8px 0 0;
    flex-shrink: 0;
}

/* Sidebar Overlay (hidden by default) */
#sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

#sidebar-overlay.active {
    display: block;
}

/* ===== Mobile RWD (≤768px) ===== */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }

    .menu-btn {
        display: block;
    }

    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 100;
        height: 100vh;
        width: 80vw;
        max-width: 300px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

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

    #top-bar {
        padding: 10px 12px;
    }

    #file-name-display {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
    }

    textarea {
        padding: 12px;
        font-size: 0.9rem;
    }

    #preview-area-content {
        padding: 12px;
        font-size: 0.9rem;
    }

    .del-btn {
        visibility: visible;
    }

    .file-item {
        padding: 10px 8px;
    }
}