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

body {
    background-color: #000;
    min-height: 100vh;
    color: #e5e7eb;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    font-size: clamp(18px, 1.1vw, 20px);
    tab-size: 2;
}

.nav {
    position: relative;
    margin: 4vh 0;
    height: 60px;
}

.nav-left {
    position: absolute;
    left: 2rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    align-items: center;
    height: 100%;
}

.nav-right {
    position: absolute;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
}

.file-name {
    color: #94a3b8;
    user-select: none;
}

.nav .unsaved-indicator {
    font-size: 12px;
    padding: 0;
    margin-left: 0.4rem;
    transition: opacity 0.2s ease;
    border: none;
}

.nav span {
    padding: 6px 14px;
    cursor: pointer;
    border: 1px solid #334155;
    border-radius: 999px;
    background: #020617;
    color: #cbd5e1;
    transition: all 0.2s ease;
}

.nav span:hover {
    background: #0f172a;
    border-color: #60a5fa;
}

.nav span.active {
    background: #60a5fa;
    color: #0f172a;
    border-color: #60a5fa;
    box-shadow: 0 0 12px rgba(96,165,250,0.5);
}

.menu-btn {
    cursor: pointer;
    font-size: 20px;
    padding: 6px 10px;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.menu-btn:hover {
    background: #0f172a;
}

.menu-dropdown {
    position: absolute;
    right: 0;
    top: 45px;
    background: #020617;
    border: 1px solid #1f2937;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    min-width: 160px;
    overflow: hidden;
    z-index: 1000;
    animation: dropdownFade 0.15s ease;
}

@keyframes dropdownFade {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.menu-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.menu-item:hover {
    background: #0f172a;
}

.hidden {
    display: none;
}

.nav span,
.menu-item {
    -webkit-tap-highlight-color: transparent;
}

.editor,
.preview {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 6vh 2rem;
    font-size: 1rem;
    line-height: 1.75;
    min-height: calc(100vh - 100px);
    overflow-y: auto;
}

.editor {
    cursor: text;
    tab-size: 4;
    white-space: pre-wrap;
    word-break: break-word;
    background-image: repeating-linear-gradient(
        to right,
        transparent,
        transparent 31px,
        rgba(255,255,255,0.04) 32px
    );
}

.editor:focus {
    outline: none;
}

.preview h1,
.preview h2,
.preview h3,
.preview h4,
.preview h5,
.preview h6 {
    margin: 1.2em 0 0.6em;
    font-weight: 600;
}

.preview p {
    margin: 0.8em 0;
}

.preview blockquote {
    margin: 1em 0;
    padding: 0.6em 1em;
    border-left: 3px solid #60a5fa;
    background: #020617;
    border-radius: 4px;
}

.preview pre {
    background: #020617;
    padding: 1.1em;
    border-radius: 10px;
    overflow-x: auto;
    margin: 1.2em 0;
    border: 1px solid #1f2937;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.preview pre code {
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 14px;
}

.preview code:not(pre code) {
    background: #111827;
    color: #93c5fd;
    padding: 2px 6px;
    border-radius: 5px;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 14px;
}

.preview ul,
.preview ol {
    margin: 0.8em 0 0.8em 1.5em;
    padding-left: 1.2em;
}

.preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2em 0;
    background: #020617;
    border: 1px solid #1f2937;
    border-radius: 8px;
    overflow: hidden;
}

.preview td,
.preview th {
    padding: 10px 14px;
    border-bottom: 1px solid #1f2937;
}

.preview a {
    color: #60a5fa;
    text-decoration: none;
    border-bottom: 1px solid rgba(96,165,250,0.4);
}

.preview img {
    max-width: 100%;
    display: block;
    margin: 1em 0;
    border-radius: 8px;
    border: 1px solid #1f2937;
}

.preview hr {
    border: none;
    height: 2px;
    margin: 2em 0;
    background: linear-gradient(
        to right,
        #020617 0%,
        #1f2937 20%,
        #475569 50%,
        #1f2937 80%,
        #020617 100%
    );
}

@media (max-width: 768px) {

    .nav {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 1rem;
        height: 56px;
    }

    .nav-left,
    .nav-center,
    .nav-right {
        position: static;
        transform: none;
    }

    .nav span {
        padding: 5px 10px;
        font-size: 14px;
    }

    .file-name {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .editor,
    .preview {
        padding: 4vh 1.5rem;
        min-height: calc(100vh - 80px);
    }
}

@media (max-width: 480px) {

    .nav {
        margin: 2vh 0;
    }

    .editor,
    .preview {
        padding: 3vh 1rem;
    }

    .preview table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}