/* Theme variables */
:root {
    --bg: #fafafa;
    --text: #333333;
    --muted: #666666;

    --button-bg: #333333;
    --button-text: #ffffff;

    --note-bg: #ffffff;
    --note-border: #dddddd;
    --note-hover: #f5f5f5;

    --accent: #0b63d6;

    --modal-bg: #ffffff;
    --modal-overlay: rgba(0, 0, 0, 0.45);

    --active-bg: #e6f0ff;
    --active-border: #a6c8ff;
}

/* Dark theme overrides */
body.dark {
    --bg: #0b1220;
    --text: #e6eef8;
    --muted: #9aa6b2;

    --button-bg: #1f2937;
    --button-text: #ffffff;

    --note-bg: #071022;
    --note-border: #263046;
    --note-hover: #092033;

    --accent: #3b82f6;

    --modal-bg: #0b1220;
    --modal-overlay: rgba(0, 0, 0, 0.6);

    --active-bg: rgba(59, 130, 246, 0.14);
    --active-border: #60a5fa;
}

/* Base */
body {
    font-family: monospace;
    background: var(--bg);
    padding: 40px;
    color: var(--text);
    transition:
        background 200ms ease,
        color 200ms ease;
}

.top-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.top-nav a,
.top-nav .theme-toggle {
    background: var(--button-bg);
    color: var(--button-text);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 14px;
    border: none;
    cursor: pointer;
}

.top-nav a:hover,
.top-nav .theme-toggle:hover {
    background: #555;
}

.top-nav a.active {
    background: var(--accent);
}

h1::after {
    content: " 🦅";
    font-size: 1.5rem;
}

.container {
    max-width: 600px;
    margin: 0 auto;
}

#noteTitle {
    width: 100%;
    padding: 10px;
    margin-bottom: 8px;
    font-family: monospace;
    color: var(--text);
    background: var(--note-bg);
    border: 1px solid var(--note-border);
}

textarea {
    width: 100%;
    height: 150px;
    padding: 10px;
    margin-bottom: 10px;
    font-family: monospace;
    color: var(--text);
    background: var(--note-bg);
    border: 1px solid var(--note-border);
}

button {
    background: var(--button-bg);
    color: var(--button-text);
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-family: monospace;
}

button:hover {
    background: #555;
}

#notesContainer {
    margin-top: 10px;
    border-top: 1px solid var(--note-border);
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.note-item {
    padding: 8px;
    border: 1px solid var(--note-border);
    cursor: pointer;
    background: var(--note-bg);
}

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

.note-item.active {
    background: var(--active-bg);
    border-color: var(--active-border);
}

.no-notes {
    color: var(--muted);
    font-style: italic;
    padding: 6px;
}

/* Note list layout */
.note-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.note-left {
    flex: 1 1 auto;
    padding-right: 10px;
    cursor: pointer;
}

.note-title {
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-preview {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}

.note-controls button {
    background: transparent;
    border: none;
    padding: 6px 8px;
    cursor: pointer;
    font-family: monospace;
    border-radius: 4px;
    color: var(--text);
}

.note-controls button:hover {
    background: rgba(255, 255, 255, 0.03);
}

.note-item.drag-over {
    border-style: dashed;
}

.note-item.drag-after {
    box-shadow: inset 0 -3px 0 0 rgba(0, 123, 255, 0.25);
}

.note-item.dragging {
    opacity: 0.5;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--modal-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--modal-bg);
    padding: 16px;
    border-radius: 8px;
    width: 92%;
    max-width: 720px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    position: relative;
}

.modal .modal-close {
    position: absolute;
    right: 8px;
    top: 8px;
    border: none;
    background: transparent;
    font-size: 16px;
    cursor: pointer;
}

.modal input,
.modal textarea {
    width: 100%;
    padding: 8px;
    margin-bottom: 8px;
    font-family: monospace;
    color: var(--text);
    background: var(--note-bg);
    border: 1px solid var(--note-border);
}

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

@media (min-width: 800px) {
    .container {
        max-width: 900px;
    }
}

.notes-hint {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
}

/* Editor toolbar & preview */
.editor-toolbar {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.editor-toolbar button {
    background: transparent;
    border: 1px solid var(--note-border);
    color: var(--text);
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 4px;
    font-family: monospace;
}

.editor-toolbar button:hover {
    background: var(--note-hover);
}

/* active toolbar button */
.editor-toolbar button.active {
    background: var(--accent);
    color: var(--button-text);
}

.editor-wrap {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.editor-wrap textarea {
    flex: 1 1 60%;
    min-height: 160px;
}

.preview {
    flex: 1 1 40%;
    border: 1px solid var(--note-border);
    background: var(--note-bg);
    padding: 10px;
    border-radius: 4px;
    overflow: auto;
    max-height: 320px;
}

.hidden {
    display: none;
}

.editor-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.save-status {
    margin-left: 8px;
    font-size: 13px;
    color: var(--muted);
    min-width: 80px;
}

/* Rendered markdown styles */
.preview h1,
.preview h2,
.preview h3 {
    margin: 6px 0;
}
.preview pre {
    background: rgba(0, 0, 0, 0.04);
    padding: 8px;
    overflow: auto;
}
.preview code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 4px;
    border-radius: 4px;
}

@media (max-width: 800px) {
    .editor-wrap {
        flex-direction: column;
    }
    .preview {
        max-height: 240px;
    }
}

footer {
    margin-top: 16px;
    text-align: center;
    font-size: 13px;
    color: var(--muted);
}

