:root {
    --bg: #070b1d;
    --panel: rgba(15, 23, 42, 0.64);
    --panel-strong: rgba(28, 36, 68, 0.78);
    --border: rgba(220, 225, 255, 0.16);
    --border-strong: rgba(168, 85, 247, 0.46);
    --text: #f4f6ff;
    --muted: #a7b0ca;
    --dim: #6f7894;
    --purple: #a855f7;
    --purple-dark: #7c3aed;
    --cyan: #22d3ee;
    --yellow: #facc15;
    --danger: #fb7185;
    --radius-lg: 28px;
    --radius-md: 18px;
    --radius-sm: 12px;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background-color: var(--bg);
    background-image: linear-gradient(rgba(4, 7, 20, 0.28), rgba(4, 7, 20, 0.74)), url("../img/app-background.png");
    background-position: center;
    background-size: cover;
    background-attachment: fixed;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.glass-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(22px) saturate(130%);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(440px, 100%);
    padding: 34px;
}

.login-card h1 {
    margin: 10px 0 8px;
    font-size: clamp(2.4rem, 8vw, 4rem);
    letter-spacing: -0.06em;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border-radius: 15px;
    color: white;
    font-weight: 800;
    background: linear-gradient(135deg, var(--purple), var(--cyan));
    box-shadow: 0 0 28px rgba(168, 85, 247, 0.42);
}

.eyebrow,
.section-label {
    margin: 0 0 10px;
    color: var(--dim);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.muted,
.form-status {
    color: var(--muted);
}

.login-form,
.description-field,
.markdown-editor {
    display: grid;
    gap: 10px;
    color: var(--muted);
    font-size: 0.84rem;
}

.login-form {
    margin-top: 26px;
    gap: 16px;
}

input,
textarea {
    width: 100%;
    color: var(--text);
    background: rgba(6, 10, 26, 0.48);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    outline: none;
}

input {
    min-height: 42px;
    padding: 0 13px;
}

textarea {
    min-height: 430px;
    padding: 16px;
    resize: vertical;
    line-height: 1.6;
}

input:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
    border-color: rgba(34, 211, 238, 0.55);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.16);
    outline: none;
}

.primary-button,
.secondary-button,
.icon-button,
.logout-button,
.toolbar button,
.tabs button,
.side-tabs button {
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.07);
}

.primary-button {
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    background: linear-gradient(135deg, var(--purple), var(--purple-dark));
    box-shadow: 0 12px 32px rgba(168, 85, 247, 0.34);
    font-weight: 750;
}

.secondary-button,
.logout-button {
    width: 100%;
    min-height: 40px;
    padding: 0 13px;
    text-align: left;
}

.app-shell {
    width: min(1780px, calc(100vw - 44px));
    min-height: calc(100vh - 44px);
    margin: 22px auto;
    display: grid;
    grid-template-columns: 260px 320px minmax(420px, 1fr) 240px;
    grid-template-rows: 72px minmax(0, 1fr);
    gap: 14px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-lg);
    background: rgba(7, 11, 29, 0.42);
    box-shadow: 0 35px 110px rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(16px);
}

.topbar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0 6px;
}

.brand,
.global-search,
.sidebar-search,
.workspace-card,
.list-header,
.title-row,
.editor-footer,
.attachment-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand {
    min-width: 220px;
    font-size: 1.1rem;
    font-weight: 800;
}

.global-search,
.sidebar-search {
    flex: 1;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
}

.global-search input,
.sidebar-search input {
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

kbd {
    color: var(--dim);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 7px;
    padding: 3px 7px;
    font-size: 0.72rem;
}

.left-sidebar,
.note-list,
.editor,
.right-sidebar {
    min-width: 0;
    min-height: 0;
    padding: 16px;
    overflow: auto;
}

.workspace-card {
    padding: 14px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.06);
}

.workspace-card small,
.note-card small {
    display: block;
    color: var(--dim);
}

.workspace-dot,
.status-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: var(--cyan);
    box-shadow: 0 0 18px rgba(34, 211, 238, 0.65);
}

.nav-section,
.action-card,
.ai-card {
    margin-top: 20px;
}

.nav-row {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    align-items: center;
    min-height: 38px;
    padding: 0 10px;
    color: var(--muted);
    border-radius: 12px;
}

.nav-row.active,
.nav-row:hover,
.note-card.active {
    color: var(--text);
    background: rgba(168, 85, 247, 0.12);
    border-color: var(--border-strong);
}

.tag-cloud,
.tag-row,
.mini-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-cloud span,
.tag-cloud button,
.tag-row span,
.mini-tags span {
    color: #dec7ff;
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 999px;
    background: rgba(168, 85, 247, 0.13);
    padding: 5px 9px;
    font-size: 0.78rem;
}

.tag-cloud button {
    cursor: pointer;
}

.tag-cloud button.active,
.tag-cloud button:hover {
    color: var(--text);
    border-color: var(--border-strong);
    background: rgba(168, 85, 247, 0.24);
}

.nav-empty {
    margin: 8px 0 0;
    color: var(--dim);
    font-size: 0.78rem;
}

.list-header {
    justify-content: space-between;
}

.list-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.icon-button {
    width: 40px;
    height: 40px;
}

.tabs,
.side-tabs,
.toolbar {
    display: flex;
    gap: 8px;
    margin: 16px 0;
}

.tabs button,
.side-tabs button,
.toolbar button {
    min-height: 34px;
    padding: 0 10px;
    color: var(--muted);
}

.tabs .active,
.side-tabs .active {
    color: var(--text);
    background: rgba(168, 85, 247, 0.18);
}

.note-card {
    position: relative;
    margin: 12px 0;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.055);
}

.note-card h3 {
    margin: 6px 0;
    font-size: 1rem;
}

.note-card p {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.88rem;
}

.note-card .status-dot {
    position: absolute;
    top: 18px;
    right: 16px;
    background: var(--purple);
}

.note-card.is-deleted {
    border-color: rgba(251, 113, 133, 0.28);
    background: rgba(251, 113, 133, 0.08);
}

.note-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.note-flags span {
    color: var(--muted);
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 999px;
    padding: 3px 7px;
    font-size: 0.68rem;
}

.breadcrumb {
    margin: 0 0 12px;
    color: var(--dim);
    font-size: 0.84rem;
}

.title-row {
    justify-content: space-between;
    align-items: flex-start;
}

.title-input {
    height: auto;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: clamp(2rem, 4vw, 2.35rem);
    font-weight: 800;
    letter-spacing: -0.04em;
}

.description-field {
    margin-top: 16px;
}

.editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.85fr);
    gap: 16px;
}

.preview-pane {
    min-height: 430px;
    padding: 22px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    background: rgba(7, 11, 29, 0.38);
    line-height: 1.65;
}

.preview-pane h1,
.preview-pane h2,
.preview-pane h3 {
    color: #d7b7ff;
    letter-spacing: -0.02em;
}

.editor-footer {
    justify-content: space-between;
    margin-top: 14px;
    color: var(--dim);
    font-size: 0.82rem;
}

.action-card,
.ai-card {
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.055);
}

.action-card .secondary-button + .secondary-button {
    margin-top: 9px;
}

.attachment-row {
    min-height: 38px;
    color: var(--muted);
}

.attachment-row span {
    min-width: 38px;
    color: var(--cyan);
    font-weight: 800;
    font-size: 0.75rem;
}

.ai-card {
    border-color: rgba(34, 211, 238, 0.22);
    background: linear-gradient(145deg, rgba(34, 211, 238, 0.12), rgba(168, 85, 247, 0.12));
}

.ai-card p:last-child {
    color: var(--muted);
    font-size: 0.86rem;
}

.logout-button {
    margin-top: 18px;
    color: var(--danger);
}

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

.restore-button {
    color: var(--cyan);
}

.js-eintrag-wiederherstellen {
    display: none;
}

.is-favorite {
    color: var(--yellow);
    border-color: rgba(250, 204, 21, 0.38);
    background: rgba(250, 204, 21, 0.1);
}

.meta-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.note-card {
    width: 100%;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.note-empty {
    margin: 12px 0;
    padding: 16px;
    color: var(--muted);
    border: 1px dashed rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.04);
}

.mobile-nav {
    display: none;
}

@media (max-width: 1180px) {
    .app-shell {
        grid-template-columns: 230px 300px minmax(420px, 1fr);
    }

    .right-sidebar {
        display: none;
    }
}

@media (max-width: 860px) {
    body {
        background-attachment: scroll;
    }

    .app-shell {
        width: 100%;
        min-height: 100vh;
        margin: 0;
        padding: 12px 12px 88px;
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        border-radius: 0;
    }

    .topbar {
        gap: 10px;
    }

    .brand {
        min-width: 0;
    }

    .global-search,
    .left-sidebar,
    .note-list,
    .right-sidebar {
        display: none;
    }

    .editor {
        padding: 18px;
        border-radius: 22px;
    }

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

    .meta-fields {
        grid-template-columns: 1fr;
    }

    .preview-pane {
        min-height: 260px;
    }

    textarea {
        min-height: 300px;
    }

    .mobile-nav {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: 12px;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        align-items: center;
        gap: 8px;
        min-height: 62px;
        padding: 8px;
        border: 1px solid rgba(255, 255, 255, 0.14);
        border-radius: 24px;
        background: rgba(15, 23, 42, 0.78);
        backdrop-filter: blur(18px);
        box-shadow: var(--shadow);
    }

    .mobile-nav a,
    .mobile-nav button {
        color: var(--muted);
        text-align: center;
        border: 0;
        background: transparent;
        font-size: 0.78rem;
    }

    .mobile-nav button {
        width: 50px;
        height: 50px;
        margin: -22px auto 0;
        color: white;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--purple), var(--purple-dark));
        box-shadow: 0 12px 32px rgba(168, 85, 247, 0.45);
        font-size: 1.5rem;
    }
}
