:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --ink: #1b1e25;
    --muted: #677083;
    --line: #d8dde7;
    --accent: #1467d6;
    --danger: #b93636;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Helvetica Neue", sans-serif;
    color: var(--ink);
    background: radial-gradient(circle at top left, #fefefe 0%, var(--bg) 60%);
}

.hidden {
    display: none !important;
}

.muted {
    color: var(--muted);
}

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

button, input, select, textarea {
    font: inherit;
}

button {
    cursor: pointer;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    padding: 6px 10px;
}

button:hover {
    border-color: #b9c4d6;
}

button.secondary {
    background: #f2f5fa;
}

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

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(420px, 92vw);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(20, 34, 56, 0.08);
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-card input {
    width: 100%;
    margin-top: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: 60px 1fr;
    grid-template-areas:
        "topbar topbar"
        "sidebar editor";
}

.topbar {
    grid-area: topbar;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 16px;
}

.brand {
    font-weight: 600;
}

.search-wrap {
    width: min(640px, 50vw);
    position: relative;
}

.search-wrap input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
}

.search-results {
    position: absolute;
    top: 42px;
    left: 0;
    right: 0;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(30, 40, 60, 0.1);
    max-height: 340px;
    overflow: auto;
    z-index: 20;
}

.search-item {
    padding: 10px;
    border-bottom: 1px solid #edf1f7;
}

.search-item:last-child {
    border-bottom: 0;
}

.search-item button {
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    padding: 0;
}

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

.user-pill {
    padding: 4px 10px;
    border-radius: 99px;
    background: #f1f4fa;
}

.sidebar {
    grid-area: sidebar;
    border-right: 1px solid var(--line);
    background: var(--panel);
    padding: 12px;
    overflow: auto;
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-tree {
    margin-top: 8px;
}

.page-node {
    margin-left: 8px;
}

.page-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border-radius: 6px;
}

.page-row:hover {
    background: #f4f7fb;
}

.page-row.active {
    background: #e8f0ff;
}

.page-title {
    border: 0;
    background: transparent;
    text-align: left;
    padding: 0;
    font-size: 14px;
}

.tiny {
    font-size: 12px;
    padding: 2px 6px;
}

.editor {
    grid-area: editor;
    padding: 20px;
    overflow: auto;
}

.empty-state {
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 24px;
    color: var(--muted);
    background: #fafcff;
}

.page-meta {
    display: flex;
    gap: 10px;
    align-items: center;
}

#page-title {
    width: min(720px, 90%);
    border: 0;
    font-size: 30px;
    font-weight: 700;
    background: transparent;
    outline: none;
    padding: 0;
}

#save-indicator {
    margin: 8px 0 14px;
    font-size: 13px;
}

.block-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.block {
    border: 1px solid #edf1f7;
    border-radius: 10px;
    padding: 8px;
    background: #fff;
}

.block-toolbar {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}

.block-content {
    min-height: 26px;
    outline: none;
    padding: 4px;
    border-radius: 6px;
}

.block-content:focus {
    background: #f7fbff;
}

.block.type-heading1 .block-content {
    font-size: 28px;
    font-weight: 700;
}

.block.type-heading2 .block-content {
    font-size: 24px;
    font-weight: 700;
}

.block.type-heading3 .block-content {
    font-size: 20px;
    font-weight: 700;
}

.block.type-quote .block-content {
    border-left: 3px solid #ccd8ee;
    padding-left: 10px;
    color: #404d68;
}

.block.type-code textarea {
    width: 100%;
    min-height: 120px;
    border: 1px solid #d8dfed;
    border-radius: 8px;
    font-family: "Cascadia Code", Consolas, monospace;
    background: #0f1420;
    color: #d8e3ff;
    padding: 10px;
}

.todo-line {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.todo-line input[type="checkbox"] {
    margin-top: 6px;
}

.divider {
    border-top: 1px solid #d3d9e5;
    margin: 8px 0;
}

.toggle-shell summary {
    list-style: none;
    cursor: pointer;
}

.toggle-shell summary::-webkit-details-marker {
    display: none;
}

.toggle-summary {
    display: flex;
    gap: 8px;
    align-items: center;
}

#slash-menu {
    position: fixed;
    z-index: 40;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(12, 23, 41, 0.14);
    min-width: 210px;
    max-height: 280px;
    overflow: auto;
}

.slash-item {
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    border-bottom: 1px solid #eff3f8;
    padding: 8px 10px;
}

.slash-item:last-child {
    border-bottom: 0;
}

.slash-item:hover {
    background: #eef4ff;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-rows: 60px 220px 1fr;
        grid-template-areas:
            "topbar"
            "sidebar"
            "editor";
    }

    .search-wrap {
        width: 100%;
    }
}

