:root {
    color-scheme: light;
    --bg: #f7f8fa;
    --panel: #ffffff;
    --ink: #20242a;
    --muted: #667085;
    --line: #d8dde5;
    --primary: #1b6b5f;
    --danger: #a83a3a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: var(--primary);
}

button,
.button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--primary);
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    padding: 0 14px;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

button.ghost,
.button.secondary {
    background: transparent;
    color: var(--primary);
}

button.danger {
    border-color: var(--danger);
    background: var(--danger);
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    font: inherit;
}

textarea {
    min-height: 360px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.brand {
    color: var(--ink);
    font-size: 20px;
    font-weight: 700;
    text-decoration: none;
}

.page {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 18px 16px 48px;
}

.auth-panel {
    max-width: 420px;
    margin: 48px auto;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.stack {
    display: grid;
    gap: 14px;
}

.toolbar,
.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.search {
    display: flex;
    flex: 1;
    gap: 8px;
}

.note-list {
    display: grid;
    gap: 8px;
}

.note-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
    text-decoration: none;
}

.note-row span,
.meta,
.status,
.empty {
    color: var(--muted);
}

.editor-form {
    display: grid;
    gap: 14px;
}

.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px;
    gap: 14px;
    align-items: start;
}

.editor-main,
.attach-panel,
.note-view {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 14px;
}

.edit-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.tab {
    background: transparent;
    color: var(--primary);
}

.tab.active {
    background: var(--primary);
    color: #fff;
}

.attach-panel {
    position: sticky;
    top: 72px;
    display: grid;
    gap: 8px;
}

.preview,
.rendered {
    line-height: 1.65;
}

.hidden {
    display: none;
}

.attachment {
    margin: 14px 0;
}

.attachment img,
.attachment video {
    width: min(100%, 720px);
    max-height: 70vh;
    border-radius: 6px;
    border: 1px solid var(--line);
    object-fit: contain;
    background: #111;
}

.attachment audio {
    width: min(100%, 720px);
}

.attachment figcaption {
    margin-top: 6px;
    color: var(--muted);
    font-size: 14px;
}

.error {
    color: var(--danger);
}

@media (max-width: 760px) {
    .page {
        padding: 12px 10px 36px;
    }

    .toolbar,
    .form-actions,
    .note-row {
        align-items: stretch;
        flex-direction: column;
    }

    .search {
        width: 100%;
    }

    .editor-layout {
        grid-template-columns: 1fr;
    }

    .attach-panel {
        position: static;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

