html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: var(--rz-text-font-family, system-ui, sans-serif);
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.shell-root {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/*
 * RadzenSpreadsheet layout:
 *   column flex → toolbar + formula bar + VirtualGrid(style="flex:1") + sheet tabs
 * VirtualGrid height is 0 unless .rz-spreadsheet has a definite height.
 * (Do not use scoped ::deep(.class) — Blazor emits invalid "(.class)" selectors.)
 */
.ss-editor-fill > .rz-spreadsheet,
.editor-plugin-host .rz-spreadsheet {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    overflow: hidden;
    box-sizing: border-box;
}

.ss-editor-fill .rz-spreadsheet > .rz-tabview,
.ss-editor-fill .rz-spreadsheet-formula-editor,
.ss-editor-fill .rz-spreadsheet-sheet-tabs,
.editor-plugin-host .rz-spreadsheet > .rz-tabview,
.editor-plugin-host .rz-spreadsheet-formula-editor,
.editor-plugin-host .rz-spreadsheet-sheet-tabs {
    flex: 0 0 auto !important;
}

.ss-editor-fill .rz-virtual-grid,
.editor-plugin-host .rz-virtual-grid {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    width: 100% !important;
    position: relative !important;
    overflow: hidden !important;
}

.ss-editor-fill .rz-virtual-grid-content,
.ss-editor-fill .rz-virtual-grid-scroller,
.editor-plugin-host .rz-virtual-grid-content,
.editor-plugin-host .rz-virtual-grid-scroller {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #512bd4;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

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

#blazor-error-ui .reload {
    color: inherit;
}

/* ── Unlock / Claim shared (must be global: isolated layout CSS does not
   fill #app's flex column, so the card sat at the top-left). ── */

.unlock-layout {
    width: 100%;
    min-height: 100%;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    justify-content: safe center;
    padding: 1.5rem;
    box-sizing: border-box;
    overflow-y: auto;
    background: linear-gradient(160deg, #f4f2fb 0%, #fafafa 45%, #eef6f4 100%);
}

.unlock-card {
    width: 100%;
    max-width: 22rem;
    margin: 0 auto;
    padding: 1.75rem 1.5rem 1.25rem;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 8px 32px rgba(40, 30, 80, 0.08), 0 1px 0 rgba(0, 0, 0, 0.04);
    box-sizing: border-box;
}

.unlock-brand {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    height: 30px;
    color: #3d2f6b;
}

.unlock-brand-mark {
    display: block;
    box-sizing: border-box;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 6px;
    object-fit: cover;
    object-position: center;
    /* Prevent descender/baseline gap on replaced elements */
    align-self: center;
}

.unlock-brand-text {
    display: block;
    box-sizing: border-box;
    height: 30px;
    margin: 0;
    padding: 0;
    border: 0;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.04em;
    line-height: 30px; /* same box height as logo → true vertical center */
    white-space: nowrap;
}

.unlock-host {
    margin-top: 0.15rem;
    font-size: 0.8rem;
    color: #666;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    word-break: break-all;
}

.unlock-muted {
    margin: 0.5rem 0;
    font-size: 0.8rem;
    color: #777;
}

.unlock-name-hint {
    margin: 0.4rem 0 0;
    font-size: 0.8rem;
    line-height: 1.4;
    color: #666;
}

.unlock-name-hint--error {
    color: #a05a20;
}

.unlock-preview {
    margin-top: 0.35rem;
    margin-bottom: 1rem;
}

.unlock-library-link {
    color: #4a3d8f;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}

.unlock-library-link:hover {
    color: #3d3278;
}

.unlock-taken-hint {
    color: #a05a20;
    font-size: 0.85em;
}

.unlock-preview code,
.unlock-lead code,
.unlock-footer code {
    font-size: 0.85em;
}

.unlock-title {
    margin: 1.25rem 0 0.35rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1a1a1a;
}

.unlock-lead {
    margin: 0 0 0.35rem;
    font-size: 0.85rem;
    line-height: 1.45;
    color: #555;
}

.unlock-tip {
    margin: 1.1rem 0 0;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    background: #f7f5fc;
    border: 1px solid #e8e4f4;
}

.unlock-tip-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #6b5bb8;
    margin-bottom: 0.25rem;
}

.unlock-tip-body {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.45;
    color: #3a3458;
}

.unlock-ula {
    margin: 0.85rem 0 0.35rem;
    padding: 0.75rem 0.85rem;
    border-radius: 10px;
    background: #faf9f6;
    border: 1px solid #e8e4d8;
}

.unlock-ula-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #6a5a3a;
    margin-bottom: 0.35rem;
}

.unlock-ula-body {
    margin: 0 0 0.65rem;
    font-size: 0.78rem;
    line-height: 1.45;
    color: #4a4538;
}

.unlock-label {
    display: block;
    margin: 0.75rem 0 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.unlock-optional {
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: #888;
    font-size: 0.72rem;
}

.unlock-email-hint {
    margin: 0.35rem 0 0;
    font-size: 0.78rem;
    line-height: 1.4;
}

.unlock-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.55rem 0.65rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
}

.unlock-input:focus {
    outline: none;
    border-color: #6b5bb8;
    box-shadow: 0 0 0 3px rgba(107, 91, 184, 0.15);
}

.unlock-check {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.65rem;
    font-size: 0.8rem;
    color: #555;
    cursor: pointer;
    user-select: none;
}

.unlock-btn {
    display: block;
    width: 100%;
    margin-top: 1.1rem;
    padding: 0.65rem 1rem;
    border: none;
    border-radius: 8px;
    background: #4a3d8f;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.unlock-btn:hover:not(:disabled) {
    background: #3d3278;
}

.unlock-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.unlock-error {
    margin: 0.65rem 0 0;
    font-size: 0.85rem;
    color: #b00020;
}

.unlock-wait {
    margin: 0.85rem 0 0;
    padding: 0.85rem 0.9rem;
    border-radius: 8px;
    background: #fdf6f6;
    border: 1px solid #f0d0d0;
    text-align: left;
}

.unlock-wait-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #8b1a1a;
}

.unlock-wait-body {
    margin: 0.4rem 0 0;
    font-size: 0.8rem;
    line-height: 1.45;
    color: #5c3030;
}

.unlock-wait-timer {
    margin: 0.65rem 0 0;
    font-size: 0.95rem;
    color: #2a2450;
}

.unlock-wait-timer strong {
    font-variant-numeric: tabular-nums;
    color: #6b5bb8;
}

.unlock-footer {
    margin: 0 0 1rem;
    font-size: 0.72rem;
    line-height: 1.4;
    color: #888;
    text-align: left;
}

.unlock-free {
    margin: 0 0 0.85rem;
    padding: 0.7rem 0.85rem;
    font-size: 0.82rem;
    line-height: 1.45;
    color: #2a2450;
    background: #f0ecfa;
    border: 1px solid #e4dff0;
    border-radius: 8px;
    text-align: left;
}

.unlock-free strong {
    color: #4a3d8f;
}

.unlock-progress {
    margin-top: 1rem;
    padding: 0.85rem 0.75rem;
    border-radius: 8px;
    background: #f7f5fc;
    border: 1px solid #e8e4f4;
}

.unlock-progress-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #2a2450;
}

.unlock-progress-hint {
    margin: 0.35rem 0 0.75rem;
    font-size: 0.78rem;
    line-height: 1.4;
    color: #666;
}

.unlock-progress-track {
    height: 6px;
    border-radius: 999px;
    background: #e0dcf0;
    overflow: hidden;
}

.unlock-progress-bar {
    height: 100%;
    width: 40%;
    border-radius: 999px;
    background: linear-gradient(90deg, #6b5bb8, #9b8fd4);
    animation: unlock-progress-slide 1.2s ease-in-out infinite;
}

@keyframes unlock-progress-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

@media (prefers-reduced-motion: reduce) {
    .unlock-progress-bar {
        width: 100%;
        animation: none;
        opacity: 0.7;
    }
}

/* Workspace chrome (global — isolated Home.razor.css can miss after rebuilds) */
.workspace {
    display: grid !important;
    grid-template-rows: auto 1fr auto !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
    background: #f7f7f8;
    color: #1a1a1a;
}

.workspace-menubar {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 0.5rem !important;
    min-height: 2.5rem !important;
    padding: 0 0.5rem 0 0.75rem !important;
    border-bottom: 1px solid #ddd !important;
    background: #fff !important;
    position: relative !important;
    z-index: 40 !important;
}

.workspace-brand {
    display: flex !important;
    align-items: center !important;
    flex: 0 0 auto !important;
    gap: 0.4rem;
    padding-right: 0.55rem;
    border-right: 1px solid #ddd;
    margin-right: 0.25rem;
}

.workspace-brand-mark {
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 0.35rem;
    object-fit: cover;
    flex-shrink: 0;
}

.workspace-menu.rz-menu,
.workspace-menu {
    flex: 0 0 auto !important;
    width: auto !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

.workspace-menubar-spacer {
    flex: 1 1 auto !important;
    min-width: 0.5rem !important;
}

.workspace-toolbar {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 0.15rem !important;
    flex: 0 0 auto !important;
    padding: 0.15rem 0.15rem 0.15rem 0.35rem;
    margin-left: 0.25rem;
}

.toolbar-section {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 0.1rem;
}

.toolbar-sep {
    width: 1px;
    height: 1.35rem;
    margin: 0 0.35rem;
    background: #d5d5da;
    flex-shrink: 0;
}

.toolbar-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.25rem;
    width: auto !important;
    min-width: 1.85rem;
    height: 1.85rem;
    padding: 0 0.35rem;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: #333;
    cursor: pointer;
    font: inherit;
    font-size: 0.75rem;
    line-height: 1;
}

.toolbar-btn .rzi,
.toolbar-btn .rz-icon {
    font-size: 1.15rem !important;
}

.toolbar-btn:hover:not(:disabled) {
    background: #f0f0f4;
    border-color: #e0e0e6;
}

.toolbar-btn:disabled {
    opacity: 0.38;
    cursor: default;
}

.toolbar-btn--accent {
    background: #f3f0fb;
    border-color: #d9d2f0;
    color: #3d3278;
    padding: 0 0.55rem;
}

.toolbar-btn-label {
    white-space: nowrap;
    font-weight: 500;
}

.workspace-statusbar {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 1.55rem;
    padding: 0 0.65rem;
    border-top: 1px solid #d0d0d4;
    background: #ebebef;
    font-size: 0.72rem;
    color: #444;
}

/* Library panel resize splitter (global fallback + visibility) */
.workspace-body {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
}
.workspace-sidebar {
    flex: 0 0 var(--sidebar-w, 260px) !important;
    width: var(--sidebar-w, 260px) !important;
    max-width: var(--sidebar-w, 260px) !important;
}
.workspace-splitter {
    flex: 0 0 8px !important;
    width: 8px !important;
    min-width: 8px !important;
    cursor: col-resize !important;
    touch-action: none !important;
    z-index: 1 !important;
    background-color: #e8e6f0 !important;
    border-left: 1px solid #c8c8d0 !important;
    border-right: 1px solid #c8c8d0 !important;
}
/* Radzen popup menus must sit above workspace chrome */
.rz-menu,
.rz-navigation-menu,
.rz-popup,
.rz-context-menu {
    z-index: 50 !important;
}
.workspace-splitter:hover {
    background-color: #d4cef0 !important;
    border-color: #6b5bb8 !important;
}
.workspace-editor {
    flex: 1 1 auto !important;
    min-width: 0 !important;
}
.workspace-resize-overlay {
    position: fixed !important;
    inset: 0 !important;
    z-index: 5000 !important;
    cursor: col-resize !important;
}

/* Hidden file picker (InputFile) */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Drag-drop: file upload + tree node rearrange */
.workspace-sidebar-tree {
    position: relative;
}
.workspace-sidebar-tree.workspace-sidebar-tree--dragover {
    outline: 2px dashed #6b5bb8;
    outline-offset: -4px;
    background: rgba(107, 91, 184, 0.06);
}
/* Highlight the specific folder/note row under the cursor while dragging */
.tree-node--drop-target {
    outline: 2px solid #6b5bb8 !important;
    outline-offset: 1px;
    background: rgba(107, 91, 184, 0.18) !important;
    border-radius: 4px;
}
.workspace-sidebar-tree.workspace-sidebar-tree--dragover::after {
    content: "Drop on a folder to upload into it (max 25 MiB)";
    position: absolute;
    left: 50%;
    bottom: 0.75rem;
    top: auto;
    transform: translateX(-50%);
    padding: 0.45rem 0.75rem;
    background: rgba(30, 28, 40, 0.92);
    color: #f5f4f8;
    border-radius: 6px;
    font-size: 0.8rem;
    pointer-events: none;
    z-index: 5;
    white-space: nowrap;
}
.workspace-sidebar-tree.workspace-sidebar-tree--dragover.workspace-sidebar-tree--node-drag::after {
    content: "Drop before/after to reorder · middle of folder to nest";
}

/* type.note.file hex viewer */
.file-viewer {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
}
.file-viewer-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
}
.file-viewer-name {
    font-weight: 600;
}
.file-viewer-detail {
    color: var(--rz-text-secondary-color, #666);
    font-size: 0.85rem;
}
.file-viewer-hint {
    font-size: 0.8rem;
    color: var(--rz-text-secondary-color, #666);
}
.file-viewer-error {
    color: #b00020;
    padding: 0.5rem 0;
}
.file-hex {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 0.75rem;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.4;
    background: #1e1c28;
    color: #e8e6f0;
    border-radius: 6px;
    white-space: pre;
}
.tree-node--file .tree-node-icon {
    opacity: 0.9;
}
