:root {
    --bg: #070c16;
    --bg-soft: #0a1220;
    --panel: #0e1829;
    --panel-2: #122137;
    --panel-3: #16283f;
    --line: #21324b;
    --line-soft: #182740;
    --text: #e9effb;
    --muted: #91a5c4;
    --faint: #647894;
    --accent: #43e0a0;
    --accent-strong: #2ec98b;
    --accent-ink: #04281c;
    --cyan: #58c7f0;
    --danger: #ff7086;
    --danger-soft: rgba(255, 112, 134, 0.12);
    --warn: #ffc857;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
    --font: "Segoe UI Variable Text", "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

body {
    background:
        radial-gradient(1100px 600px at 12% -10%, rgba(67, 224, 160, 0.10), transparent 60%),
        radial-gradient(900px 500px at 95% 0%, rgba(88, 199, 240, 0.09), transparent 55%),
        var(--bg);
}

h1, h2, h3, h4, p {
    margin: 0;
}

button, input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

a {
    color: var(--accent);
    text-decoration: none;
}

    a:hover {
        text-decoration: underline;
    }

::selection {
    background: rgba(67, 224, 160, 0.3);
}

#app, .app-root {
    min-height: 100vh;
}

.app-root {
    display: flex;
    flex-direction: column;
}

/* ---------- primitives ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    padding: 10px 15px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, color 0.15s ease;
    min-height: 40px;
    white-space: nowrap;
}

    .btn:hover {
        background: var(--panel-3);
        border-color: #2c405e;
    }

    .btn:active {
        transform: translateY(1px);
    }

    .btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .btn.primary {
        background: linear-gradient(180deg, var(--accent), var(--accent-strong));
        border-color: transparent;
        color: var(--accent-ink);
        box-shadow: 0 10px 24px rgba(67, 224, 160, 0.18);
    }

        .btn.primary:hover {
            filter: brightness(1.05);
        }

    .btn.ghost {
        background: transparent;
        border-color: transparent;
        color: var(--muted);
    }

        .btn.ghost:hover {
            background: rgba(255, 255, 255, 0.05);
            color: var(--text);
        }

    .btn.danger {
        color: var(--danger);
        border-color: rgba(255, 112, 134, 0.35);
        background: var(--danger-soft);
    }

        .btn.danger:hover {
            background: rgba(255, 112, 134, 0.2);
        }

    .btn.icon {
        padding: 0;
        width: 38px;
        height: 38px;
        min-height: 38px;
        border-radius: 9px;
        background: transparent;
        border-color: transparent;
        color: var(--muted);
        flex: 0 0 auto;
    }

        .btn.icon:hover {
            background: rgba(255, 255, 255, 0.06);
            color: var(--text);
        }

        .btn.icon.danger:hover {
            background: var(--danger-soft);
            color: var(--danger);
        }

    .btn.small {
        min-height: 32px;
        padding: 7px 11px;
        font-size: 0.82rem;
    }

    .btn.wide {
        width: 100%;
    }

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

    .field > label, .field-label {
        font-size: 0.76rem;
        text-transform: uppercase;
        letter-spacing: 0.09em;
        color: var(--faint);
        font-weight: 700;
    }

.input, .textarea, .select {
    width: 100%;
    background: rgba(7, 12, 22, 0.55);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    min-height: 42px;
}

.textarea {
    resize: vertical;
    min-height: 110px;
    line-height: 1.55;
}

.input::placeholder, .textarea::placeholder {
    color: #5b6f8c;
}

.input:focus, .textarea:focus, .select:focus {
    border-color: rgba(67, 224, 160, 0.55);
    box-shadow: 0 0 0 3px rgba(67, 224, 160, 0.12);
    background: rgba(7, 12, 22, 0.8);
}

/* Read-only entry view: the fields render as plain text instead of inputs. */
.editor.read-only .input[readonly],
.editor.read-only .textarea[readonly],
.editor.read-only .select:disabled {
    opacity: 1;
    color: var(--text);
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    padding-left: 0;
    padding-right: 0;
    cursor: default;
    resize: none;
}

.editor.read-only .input-wrap .input[readonly] {
    padding-right: 46px;
}

.editor.read-only .input-wrap.two-actions .input[readonly] {
    padding-right: 82px;
}

.editor.read-only .select:disabled {
    background-image: none;
}

.editor.read-only .input[readonly]:focus,
.editor.read-only .textarea[readonly]:focus {
    border-color: transparent;
    box-shadow: none;
    background: transparent;
}

.editor .entry-id,
.editor.read-only .input.entry-id {
    color: var(--faint);
}

.mode-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border: 1px solid transparent;
    line-height: 1.5;
}

.mode-chip.readonly {
    color: var(--faint);
    background: rgba(145, 165, 196, 0.09);
    border-color: var(--line-soft);
}

.mode-chip.editing {
    color: var(--accent);
    background: rgba(67, 224, 160, 0.12);
    border-color: rgba(67, 224, 160, 0.4);
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

    .input-wrap .input {
        padding-right: 46px;
    }

    .input-wrap.two-actions .input {
        padding-right: 82px;
    }

    .input-wrap .inline-action {
        position: absolute;
        right: 4px;
        top: 50%;
        transform: translateY(-50%);
    }

    .input-wrap .inline-actions {
        position: absolute;
        right: 4px;
        top: 50%;
        transform: translateY(-50%);
        display: flex;
        align-items: center;
        gap: 2px;
    }

    .input-wrap .inline-actions .inline-action {
        position: static;
        right: auto;
        top: auto;
        transform: none;
    }

.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2391a5c4' stroke-width='2.4'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.hint {
    font-size: 0.8rem;
    color: var(--faint);
    line-height: 1.5;
}

.error {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: var(--danger-soft);
    border: 1px solid rgba(255, 112, 134, 0.35);
    color: #ffc0ca;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 0.86rem;
    line-height: 1.45;
}

.warn-box {
    display: flex;
    gap: 10px;
    background: rgba(255, 200, 87, 0.08);
    border: 1px solid rgba(255, 200, 87, 0.25);
    color: #ffe2a6;
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    font-size: 0.83rem;
    line-height: 1.5;
}

/* Slim usage meter used for plan limits in Settings. */
.progress {
    height: 6px;
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
    margin: 4px 0 6px;
}

.progress span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #6ee7b7, #38bdf8);
    transition: width .25s ease;
}

.progress span.full,
.progress span[data-over="true"] {
    background: linear-gradient(90deg, #fbbf24, #fb7185);
}

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- brand / auth ---------- */

.auth-shell {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(380px, 0.95fr);
    align-items: stretch;
    min-height: 100vh;
}

.auth-hero {
    padding: 64px clamp(32px, 7vw, 96px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 26px;
    position: relative;
    overflow: hidden;
    border-right: 1px solid var(--line-soft);
}

    .auth-hero::after {
        content: "";
        position: absolute;
        width: 520px;
        height: 520px;
        border-radius: 50%;
        background: radial-gradient(circle, rgba(67, 224, 160, 0.16), transparent 65%);
        right: -180px;
        top: -120px;
        pointer-events: none;
    }

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-size: 1.12rem;
}

    .brand .logo {
        width: 38px;
        height: 38px;
        border-radius: 11px;
        display: grid;
        place-items: center;
        background: linear-gradient(145deg, rgba(67, 224, 160, 0.2), rgba(88, 199, 240, 0.14));
        border: 1px solid rgba(67, 224, 160, 0.45);
        color: var(--accent);
        box-shadow: inset 0 0 22px rgba(67, 224, 160, 0.12);
        flex: 0 0 auto;
    }

.auth-hero h1 {
    font-size: clamp(2.1rem, 4vw, 3.35rem);
    line-height: 1.06;
    letter-spacing: -0.035em;
    font-weight: 800;
    max-width: 13ch;
}

    .auth-hero h1 em {
        font-style: normal;
        background: linear-gradient(90deg, var(--accent), var(--cyan));
        -webkit-background-clip: text;
        background-clip: text;
        color: transparent;
    }

.auth-hero .lede {
    color: var(--muted);
    max-width: 46ch;
    line-height: 1.7;
    font-size: 1rem;
}

.feature-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 6px;
    max-width: 460px;
}

.feature {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

    .feature .tick {
        width: 24px;
        height: 24px;
        border-radius: 8px;
        display: grid;
        place-items: center;
        background: rgba(67, 224, 160, 0.12);
        color: var(--accent);
        flex: 0 0 auto;
        margin-top: 1px;
    }

    .feature strong {
        color: var(--text);
        font-weight: 650;
    }

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 28px;
}

.auth-card {
    width: min(430px, 100%);
    background: rgba(14, 24, 41, 0.72);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 30px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

    .auth-card h2 {
        font-size: 1.5rem;
        letter-spacing: -0.025em;
        font-weight: 750;
    }

    .auth-card .sub {
        color: var(--muted);
        font-size: 0.9rem;
        line-height: 1.55;
        margin-top: 6px;
    }

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

.auth-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.82rem;
    color: var(--faint);
}

.strength {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: -2px;
}

.strength-bar {
    height: 5px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.07);
    overflow: hidden;
}

    .strength-bar > span {
        display: block;
        height: 100%;
        border-radius: 99px;
        transition: width 0.25s ease, background 0.25s ease;
    }

.strength-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.74rem;
    color: var(--faint);
}

.vault-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 99px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.74rem;
    color: var(--muted);
    white-space: nowrap;
}

    .chip.good {
        color: var(--accent);
        border-color: rgba(67, 224, 160, 0.3);
        background: rgba(67, 224, 160, 0.08);
    }

    .chip.bad {
        color: var(--danger);
        border-color: rgba(255, 112, 134, 0.3);
        background: rgba(255, 112, 134, 0.08);
    }

/* ---------- workspace ---------- */

.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
}

.topbar {
    height: 64px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 18px;
    border-bottom: 1px solid var(--line-soft);
    background: rgba(8, 14, 25, 0.82);
    backdrop-filter: blur(16px);
    z-index: 50;
}

    .topbar .brand {
        font-size: 1rem;
        min-width: 168px;
    }

    .topbar .brand .logo {
        width: 30px;
        height: 30px;
        border-radius: 9px;
    }

.nav-toggle {
    display: none !important;
}

.search {
    position: relative;
    flex: 1;
    max-width: 520px;
    display: flex;
    align-items: center;
}

    .search .icon-left {
        position: absolute;
        left: 12px;
        color: var(--faint);
        pointer-events: none;
        display: flex;
    }

    .search .input {
        padding-left: 39px;
        background: rgba(255, 255, 255, 0.035);
        min-height: 38px;
        height: 38px;
    }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.sync-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    border-radius: 99px;
    padding: 7px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    min-height: 34px;
    max-width: 260px;
}

    .sync-chip:hover {
        border-color: #2e4464;
        color: var(--text);
    }

    .sync-chip .label {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sync-chip.success {
        color: var(--accent);
        border-color: rgba(67, 224, 160, 0.3);
        background: rgba(67, 224, 160, 0.07);
    }

    .sync-chip.error {
        color: var(--danger);
        border-color: rgba(255, 112, 134, 0.35);
        background: var(--danger-soft);
    }

    .sync-chip.syncing .spin {
        animation: spin 1s linear infinite;
    }

@keyframes spin {
    to { transform: rotate(360deg); }
}

.workspace-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 250px 340px minmax(0, 1fr);
}

.sidebar {
    border-right: 1px solid var(--line-soft);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    overflow-y: auto;
    background: rgba(9, 15, 26, 0.55);
}

.new-entry {
    justify-content: flex-start;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.side-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 550;
    text-align: left;
}

    .side-row:hover {
        background: rgba(255, 255, 255, 0.04);
        color: var(--text);
    }

    .side-row.active {
        background: linear-gradient(90deg, rgba(67, 224, 160, 0.14), rgba(67, 224, 160, 0.04));
        border-color: rgba(67, 224, 160, 0.22);
        color: var(--text);
    }

        .side-row.active svg {
            color: var(--accent);
        }

    .side-row .count {
        margin-left: auto;
        font-size: 0.72rem;
        color: var(--faint);
        background: rgba(255, 255, 255, 0.05);
        border-radius: 99px;
        padding: 2px 7px;
        font-variant-numeric: tabular-nums;
    }

.side-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px 0 10px;
    color: var(--faint);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}

.folder-row {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 9px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-size: 0.86rem;
    text-align: left;
    position: relative;
}

    .folder-row:hover {
        background: rgba(255, 255, 255, 0.04);
        color: var(--text);
    }

    .folder-row.active {
        background: rgba(88, 199, 240, 0.09);
        border-color: rgba(88, 199, 240, 0.22);
        color: var(--text);
    }

        .folder-row.active svg {
            color: var(--cyan);
        }

    .folder-row .name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .folder-row .count {
        margin-left: auto;
        font-size: 0.7rem;
        color: var(--faint);
        font-variant-numeric: tabular-nums;
    }

.folder-actions {
    display: none;
    margin-left: auto;
    gap: 2px;
}

.folder-row:hover .folder-actions {
    display: flex;
}

.folder-row:hover .count {
    display: none;
}

.folder-actions .btn.icon {
    width: 26px;
    height: 26px;
    min-height: 26px;
}

.folder-input {
    display: flex;
    gap: 6px;
    padding: 4px 6px;
}

    .folder-input .input {
        min-height: 34px;
        padding: 7px 9px;
        font-size: 0.84rem;
    }

.side-foot {
    margin-top: auto;
    padding: 12px 4px 2px;
    border-top: 1px solid var(--line-soft);
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.74rem;
    color: var(--faint);
}

/* ---------- entry list ---------- */

.entry-list {
    border-right: 1px solid var(--line-soft);
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: rgba(10, 17, 30, 0.4);
}

.list-head {
    padding: 16px 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--line-soft);
}

    .list-head h2 {
        font-size: 1.02rem;
        font-weight: 700;
        letter-spacing: -0.01em;
        display: flex;
        align-items: baseline;
        gap: 8px;
    }

        .list-head h2 span {
            font-size: 0.76rem;
            color: var(--faint);
            font-weight: 500;
        }

    .list-head .select {
        width: auto;
        min-height: 32px;
        padding: 6px 30px 6px 10px;
        font-size: 0.78rem;
        background-color: transparent;
        border-color: transparent;
        color: var(--muted);
    }

        .list-head .select:hover {
            border-color: var(--line);
            background-color: var(--panel);
        }

.list-scroll {
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 0;
}

.entry-row {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 11px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
    position: relative;
}

    .entry-row:hover {
        background: rgba(255, 255, 255, 0.04);
    }

    .entry-row.active {
        background: linear-gradient(90deg, rgba(67, 224, 160, 0.13), rgba(67, 224, 160, 0.03));
        border-color: rgba(67, 224, 160, 0.25);
    }

.entry-avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border-radius: 9px;
    display: grid;
    place-items: center;
    font-size: 0.82rem;
    font-weight: 750;
    color: var(--cyan);
    background: rgba(88, 199, 240, 0.1);
    border: 1px solid rgba(88, 199, 240, 0.2);
    text-transform: uppercase;
}

.entry-row.active .entry-avatar {
    color: var(--accent);
    background: rgba(67, 224, 160, 0.12);
    border-color: rgba(67, 224, 160, 0.28);
}

.entry-main {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.entry-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

    .entry-title .star {
        color: var(--warn);
        margin-left: 4px;
        display: inline-block;
        vertical-align: -2px;
    }

.entry-sub {
    font-size: 0.76rem;
    color: var(--faint);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entry-tools {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.12s ease;
}

.entry-row:hover .entry-tools,
.entry-row.active .entry-tools {
    opacity: 1;
}

    .entry-tools .btn.icon {
        width: 28px;
        height: 28px;
        min-height: 28px;
    }

.empty-list {
    padding: 40px 20px;
    text-align: center;
    color: var(--faint);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-size: 0.86rem;
    line-height: 1.5;
}

    .empty-list .big-icon {
        width: 48px;
        height: 48px;
        border-radius: 13px;
        display: grid;
        place-items: center;
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid var(--line);
        color: var(--muted);
    }

/* ---------- detail / editor ---------- */

.detail {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    background:
        radial-gradient(800px 380px at 80% -10%, rgba(88, 199, 240, 0.05), transparent 60%),
        transparent;
}

.detail-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px;
    text-align: center;
    color: var(--faint);
}

    .detail-empty .orb {
        width: 74px;
        height: 74px;
        border-radius: 22px;
        display: grid;
        place-items: center;
        background: linear-gradient(145deg, rgba(67, 224, 160, 0.13), rgba(88, 199, 240, 0.08));
        border: 1px solid rgba(67, 224, 160, 0.24);
        color: var(--accent);
        box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    }

    .detail-empty h3 {
        color: var(--text);
        font-size: 1.05rem;
        font-weight: 650;
    }

    .detail-empty p {
        max-width: 38ch;
        font-size: 0.88rem;
        line-height: 1.6;
    }

.editor {
    padding: 26px clamp(20px, 4vw, 40px) 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 620px;
    width: 100%;
    margin: 0 auto;
}

.editor-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line-soft);
}

.editor-avatar {
    width: 48px;
    height: 48px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, rgba(67, 224, 160, 0.16), rgba(88, 199, 240, 0.08));
    border: 1px solid rgba(67, 224, 160, 0.28);
    color: var(--accent);
    flex: 0 0 auto;
}

.editor-head h2 {
    font-size: 1.28rem;
    letter-spacing: -0.02em;
    font-weight: 720;
    overflow-wrap: anywhere;
}

.editor-head .sub {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 5px;
    font-size: 0.78rem;
    color: var(--faint);
    flex-wrap: wrap;
}

.editor-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.span-2 {
    grid-column: 1 / -1;
}

.editor-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    padding-top: 6px;
    flex-wrap: wrap;
}

    .editor-actions .spacer {
        flex: 1;
    }

.unsaved {
    color: var(--warn);
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

    .unsaved::before {
        content: "";
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--warn);
        box-shadow: 0 0 8px var(--warn);
    }

.mobile-back {
    display: none;
}

.meta-line {
    font-size: 0.74rem;
    color: var(--faint);
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

/* ---------- modals ---------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(3, 6, 12, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 100;
    animation: fade-in 0.15s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
}

.modal {
    width: min(560px, 100%);
    max-height: min(86vh, 900px);
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    animation: modal-in 0.18s ease;
}

    .modal.narrow {
        width: min(430px, 100%);
    }

    .modal.wide {
        width: min(780px, 100%);
    }

@keyframes modal-in {
    from { opacity: 0; transform: translateY(10px) scale(0.985); }
}

.modal-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

    .modal-head h2 {
        font-size: 1.2rem;
        letter-spacing: -0.02em;
        font-weight: 720;
    }

    .modal-head p {
        color: var(--muted);
        font-size: 0.85rem;
        line-height: 1.5;
        margin-top: 5px;
    }

    .modal-head .btn.icon {
        margin-left: auto;
    }

.section {
    display: flex;
    flex-direction: column;
    gap: 13px;
    padding: 16px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.018);
}

.section-head {
    display: flex;
    align-items: center;
    gap: 9px;
}

    .section-head h3 {
        font-size: 0.94rem;
        font-weight: 700;
    }

    .section-head svg {
        color: var(--accent);
    }

    .section-head .badge {
        margin-left: auto;
        font-size: 0.7rem;
        color: var(--faint);
        border: 1px solid var(--line);
        border-radius: 99px;
        padding: 3px 8px;
    }

.divider {
    height: 1px;
    background: var(--line-soft);
    margin: 2px 0;
}

/* ---------- vault switcher ---------- */

.vault-trigger {
    background: transparent;
    border: 0;
    color: inherit;
    padding: 5px 8px 5px 5px;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

    .vault-trigger:hover {
        background: rgba(255, 255, 255, 0.05);
    }

    .vault-trigger .vault-tag {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.74rem;
        font-weight: 600;
        color: var(--muted);
        border: 1px solid var(--line);
        border-radius: 99px;
        padding: 2px 8px;
    }

    .vault-trigger .vault-caret {
        color: var(--faint);
        flex: 0 0 auto;
    }

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

.vault-row {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 12px;
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.018);
}

    .vault-row.active {
        background: linear-gradient(90deg, rgba(67, 224, 160, 0.13), rgba(67, 224, 160, 0.03));
        border-color: rgba(67, 224, 160, 0.25);
    }

.vault-avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
}

.vault-row.active .vault-avatar {
    color: var(--accent);
    background: rgba(67, 224, 160, 0.12);
    border-color: rgba(67, 224, 160, 0.28);
}

.vault-main {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.vault-name {
    font-weight: 650;
    font-size: 0.92rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vault-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

    .vault-meta .hint {
        font-size: 0.72rem;
    }

.vault-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}

    .vault-actions .btn.icon {
        width: 30px;
        height: 30px;
        min-height: 30px;
    }

    .vault-actions .btn.small {
        min-height: 30px;
        padding: 4px 10px;
        font-size: 0.78rem;
    }

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}

    .check-row input {
        accent-color: var(--accent);
        width: 16px;
        height: 16px;
    }

.range-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

    .range-row input[type=range] {
        flex: 1;
        accent-color: var(--accent);
    }

    .range-row .value {
        min-width: 42px;
        text-align: right;
        font-variant-numeric: tabular-nums;
        font-weight: 700;
        color: var(--accent);
    }

.generated {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(7, 12, 22, 0.65);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 13px;
}

    .generated code {
        flex: 1;
        font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
        font-size: 0.95rem;
        overflow-wrap: anywhere;
        color: var(--accent);
        line-height: 1.5;
    }

/* ---------- toasts / overlay ---------- */

.toast-host {
    position: fixed;
    right: 18px;
    bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    z-index: 200;
    max-width: min(380px, calc(100vw - 36px));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(14, 24, 41, 0.96);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--text);
    animation: toast-in 0.2s ease;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
}

.toast .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cyan);
    margin-top: 5px;
    flex: 0 0 auto;
}

.toast.success .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.toast.error .dot { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

.toast .btn.icon {
    width: 24px;
    height: 24px;
    min-height: 24px;
    margin: -3px -4px 0 0;
}

.busy-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 15, 0.62);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
}

.busy-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 26px 34px;
    box-shadow: var(--shadow);
    font-size: 0.9rem;
    color: var(--muted);
}

.spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(67, 224, 160, 0.18);
    border-top-color: var(--accent);
    animation: spin 0.85s linear infinite;
}

.boot {
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    color: var(--faint);
    font-size: 0.9rem;
}

.fatal {
    flex: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

    .fatal .auth-card {
        text-align: left;
    }

/* ---------- scrollbars ---------- */

* {
    scrollbar-width: thin;
    scrollbar-color: #22344e transparent;
}

    *::-webkit-scrollbar {
        width: 9px;
        height: 9px;
    }

    *::-webkit-scrollbar-thumb {
        background: #22344e;
        border-radius: 99px;
        border: 2px solid transparent;
        background-clip: content-box;
    }

        *::-webkit-scrollbar-thumb:hover {
            background: #2d4566;
            background-clip: content-box;
        }

/* ---------- responsive ---------- */

.scrim {
    display: none;
}

@media (max-width: 1080px) {
    .workspace-body {
        grid-template-columns: 220px 300px minmax(0, 1fr);
    }
}

@media (max-width: 900px) {
    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-hero {
        display: none;
    }

    .auth-panel {
        min-height: 100vh;
        padding: 24px 18px;
    }

    .auth-card {
        padding: 24px;
    }

    .topbar .brand {
        min-width: 0;
    }

        .topbar .brand span.name {
            display: none;
        }

    .nav-toggle {
        display: inline-flex !important;
    }

    .sync-chip .label {
        display: none;
    }

    .sync-chip {
        padding: 7px 9px;
    }

    .workspace-body {
        grid-template-columns: 1fr;
        position: relative;
    }

    .sidebar {
        position: fixed;
        top: 64px;
        bottom: 0;
        left: 0;
        width: 282px;
        z-index: 60;
        background: var(--panel);
        transform: translateX(-102%);
        transition: transform 0.2s ease;
        box-shadow: 30px 0 60px rgba(0, 0, 0, 0.35);
    }

    .workspace-body.show-nav .sidebar {
        transform: none;
    }

    .workspace-body.show-nav .scrim {
        display: block;
        position: fixed;
        inset: 64px 0 0;
        background: rgba(3, 6, 12, 0.55);
        z-index: 55;
    }

    .entry-list {
        border-right: 0;
        grid-column: 1;
    }

    .detail {
        display: none;
        position: fixed;
        inset: 64px 0 0;
        z-index: 40;
        background: var(--bg);
    }

    .workspace-body.editing .detail {
        display: flex;
    }

    .workspace-body.editing .entry-list {
        display: none;
    }

    .mobile-back {
        display: inline-flex;
    }

    .editor {
        padding: 20px 18px 40px;
    }

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

    .span-2 {
        grid-column: auto;
    }
}

@media (max-width: 520px) {
    .topbar {
        padding: 0 12px;
        gap: 8px;
    }

    .search .input {
        height: 36px;
    }

    .modal {
        padding: 18px;
        max-height: 92vh;
    }

    .modal-backdrop {
        padding: 12px;
        align-items: flex-end;
    }

    .modal {
        border-radius: 16px;
    }
}

/* ---------- blazor error ui ---------- */

/* Hidden by default; Blazor's runtime switches it to display:block on an
   unhandled error. Without this rule the banner is always visible. */

#blazor-error-ui {
    color-scheme: dark only;
    background: #1d1014;
    color: #ffb3bd;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 2000;
}

    #blazor-error-ui a {
        color: var(--cyan);
    }

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }
