* { margin: 0; padding: 0; box-sizing: border-box; }

/* ---------- Metronic-inspired theme tokens ----------
   Palette and proportions modelled on Metronic's default admin theme:
   a neutral grey-blue surface system, a saturated-but-not-loud primary
   blue accent, Inter as the body font, and conservative 6/8px radii
   with soft 1-to-3px shadows. Values are our own; we're not redistributing
   Metronic assets. */
:root {
    --bg: #f9f9f9;
    --surface: #ffffff;
    --surface2: #f4f4f5;
    --border: #e1e3ea;
    --border-strong: #dbdfe9;
    --text: #252f4a;
    --text-muted: #4b5675;
    --text-soft: #78829d;
    --primary: #1b84ff;
    --primary-hover: #056ee9;
    --primary-dim: rgba(27, 132, 255, 0.10);
    --primary-soft: #e9f3ff;
    --danger: #f1416c;
    --danger-hover: #d9214e;
    --danger-dim: rgba(241, 65, 108, 0.10);
    --success: #17c653;
    --success-dim: rgba(23, 198, 83, 0.10);
    --warning: #f6c000;
    --info: #7239ea;
    --info-dim: rgba(114, 57, 234, 0.10);
    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 10px;
    --shadow-sm: 0 1px 2px rgba(24, 39, 75, 0.04), 0 1px 1px rgba(24, 39, 75, 0.03);
    --shadow: 0 2px 6px rgba(24, 39, 75, 0.06), 0 1px 2px rgba(24, 39, 75, 0.03);
    --shadow-lg: 0 12px 32px rgba(24, 39, 75, 0.10), 0 4px 8px rgba(24, 39, 75, 0.04);
    --sidebar-w: 240px;
    --sidebar-collapsed: 60px;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-feature-settings: "cv11", "ss01", "ss03";
    -webkit-font-smoothing: antialiased;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-top: 38px; /* leave space for fixed E2E top bar */
    font-size: 13.5px;
    line-height: 1.55;
}
input, textarea, select, button { font-family: inherit; }

/* Baseline heading + link tweaks to match the new density */
h1, h2, h3, h4 { letter-spacing: -0.2px; color: var(--text); }
h1 { font-weight: 700; }
h2 { font-weight: 700; }
h3, h4 { font-weight: 600; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

/* Form inputs take on the Metronic "floating-ish" look: 1px border, soft
   focus ring, subtle surface. */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="number"],
textarea,
select {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 8px 12px;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-dim);
}

/* ---------- Full-width Zero-Knowledge Top Bar ---------- */

.e2e-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 38px;
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    gap: 10px;
    padding: 0 16px;
    background: linear-gradient(90deg, #0f3d2e 0%, #134e3a 50%, #0f3d2e 100%);
    color: #d7fbe8;
    font-size: 12.5px;
    letter-spacing: 0.2px;
    border-bottom: 1px solid rgba(46,204,113,0.35);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    text-align: center;
}
.e2e-topbar-icon { font-size: 14px; }
.e2e-topbar-text { line-height: 1.3; }
.e2e-topbar-text strong { color: #9ff0c4; font-weight: 700; }
@media (max-width: 640px) {
    body { padding-top: 56px; }
    .e2e-topbar { height: 56px; font-size: 11px; line-height: 1.35; padding: 6px 12px; }
}

/* ---------- Lock Screen (legacy centered card — kept for intake/other flows) ---------- */

.lock-card {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 48px 40px;
    width: 420px;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.lock-icon { color: var(--primary); margin-bottom: 16px; }

.lock-card h1 { font-size: 28px; font-weight: 700; margin-bottom: 8px; }

.subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

/* ---------- Split-screen Login (Metronic-style) ---------- */

/* Lock screen reclaims the full viewport — the e2e topbar is redundant with
   the brand panel's messaging, so hide it while locked. */
body:has(#lock-screen[style*="display: block"]) { padding-top: 0; }
body:has(#lock-screen[style*="display: block"]) .e2e-topbar { display: none; }
/* Default state before JS runs: lock-screen is visible */
body:has(#lock-screen:not([style*="display: none"])) { padding-top: 0; }
body:has(#lock-screen:not([style*="display: none"])) .e2e-topbar { display: none; }

.login-split {
    position: fixed;
    inset: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    background: var(--bg);
    overflow: auto;
}

/* Brand panel */
.login-brand {
    background: linear-gradient(135deg, #0b1220 0%, #16223d 45%, #1e3876 100%);
    color: #e1e8f5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 56px;
    position: relative;
    overflow: hidden;
}
.login-brand::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 18% 22%, rgba(27,132,255,0.28), transparent 42%),
        radial-gradient(circle at 82% 82%, rgba(114,57,234,0.22), transparent 45%);
    pointer-events: none;
}
.login-brand::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: radial-gradient(ellipse at center, #000 0%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse at center, #000 0%, transparent 70%);
    pointer-events: none;
}
.login-brand-inner {
    position: relative;
    z-index: 1;
    max-width: 440px;
    width: 100%;
}
.login-brand-logo {
    width: 56px; height: 56px;
    border-radius: 14px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 32px;
    backdrop-filter: blur(8px);
}
.login-brand-title {
    font-size: 42px;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.1;
    color: #fff;
    margin-bottom: 14px;
}
.login-brand-tagline {
    font-size: 17px;
    color: #a7b3cc;
    line-height: 1.5;
    margin-bottom: 40px;
    font-weight: 400;
}
.login-brand-features {
    list-style: none;
    padding: 0;
    margin: 0 0 40px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.login-brand-features li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 13.5px;
    color: #cbd4e6;
    line-height: 1.5;
}
.login-brand-features li strong {
    color: #fff;
    font-weight: 600;
}
.lb-dot {
    flex: 0 0 auto;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #17c653;
    box-shadow: 0 0 0 3px rgba(23,198,83,0.18);
    margin-top: 7px;
}
.login-brand-footnote {
    font-size: 12.5px;
    color: #7e8aa8;
    line-height: 1.55;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 22px;
}

/* Form panel */
.login-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    background: var(--surface);
    overflow: auto;
}
.login-form-inner {
    width: 100%;
    max-width: 380px;
}
.login-heading {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
    margin: 0 0 6px;
}
.login-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0 0 32px;
}
.login-form-inner .form-group { margin-bottom: 16px; }
.login-form-inner label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}
.login-form-inner label .label-hint {
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-soft);
    font-weight: 500;
    margin-left: 6px;
    font-size: 11px;
}
.login-btn {
    margin-top: 10px;
    height: 44px;
    font-size: 14px;
    letter-spacing: 0.1px;
}

/* Collapsible "How is my data protected?" — replaces old zero-knowledge hero */
.login-security-details {
    margin-top: 28px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    overflow: hidden;
    /* Override legacy zero-knowledge-hero visual treatment */
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-muted);
    text-align: left;
}
.login-security-details summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    user-select: none;
}
.login-security-details summary::-webkit-details-marker { display: none; }
.login-security-details .lsd-icon {
    font-size: 14px;
    line-height: 1;
}
.login-security-details .lsd-chev {
    margin-left: auto;
    font-size: 18px;
    color: var(--text-soft);
    transition: transform 0.15s ease;
    line-height: 1;
}
.login-security-details[open] .lsd-chev { transform: rotate(90deg); }
.login-security-details .lsd-body {
    padding: 4px 14px 14px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}
.login-security-details .lsd-body p {
    margin: 10px 0 0;
    font-size: 12.5px;
    color: var(--text-muted);
}
.login-security-details .lsd-body strong { color: var(--text); }

/* Responsive: tighten padding on medium screens so side-by-side still fits */
@media (max-width: 1100px) {
    .login-brand { padding: 48px 36px; }
    .login-form-panel { padding: 40px 32px; }
    .login-brand-title { font-size: 36px; }
}
/* Below ~720px CSS pixels we stack — phones and very narrow tablets */
@media (max-width: 720px) {
    .login-split {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        position: relative;
        min-height: 100vh;
    }
    .login-brand {
        padding: 40px 28px 32px;
    }
    .login-brand-logo { width: 44px; height: 44px; margin-bottom: 20px; border-radius: 12px; }
    .login-brand-title { font-size: 28px; margin-bottom: 8px; }
    .login-brand-tagline { font-size: 14px; margin-bottom: 20px; }
    .login-brand-features { display: none; }
    .login-brand-footnote { display: none; }
    .login-form-panel { padding: 32px 24px 48px; }
    .login-heading { font-size: 22px; }
}

/* ---------- Inputs & Buttons ---------- */

.input-group { position: relative; margin-bottom: 16px; }
.input-group input { width: 100%; padding-right: 44px; }

input, textarea, select {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 14px;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-dim); }
input::placeholder, textarea::placeholder { color: #adb5bd; }

.toggle-pw {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px;
}
.toggle-pw:hover { color: var(--text); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px; border: 1px solid transparent; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s ease;
    letter-spacing: -0.1px;
    line-height: 1.4;
}
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:active { transform: translateY(0.5px); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface2); border-color: var(--text-soft); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-full { width: 100%; padding: 11px; }

.btn-icon {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 6px; border-radius: 6px; transition: all 0.2s; display: inline-flex; align-items: center;
}
.btn-icon:hover { color: var(--primary); background: var(--primary-dim); }

.error { color: var(--danger); font-size: 13px; margin-top: 12px; }

/* ---------- Sidebar ---------- */

.sidebar {
    position: fixed; left: 0; top: 38px; bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 20;
    transition: width 0.25s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.04);
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-header h2,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-footer span { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px; }
.sidebar.collapsed .sidebar-header { justify-content: center; }
/* Extra hides when the whole sidebar is collapsed — scope tabs stay as icons */
.sidebar.collapsed .sidebar-top-actions { display: none; }
.sidebar.collapsed .tree-quickadd-trigger { padding: 10px 0; }
.sidebar.collapsed .tqa-plus { margin: 0 auto; }
.sidebar.collapsed .tree-node-row .tree-label,
.sidebar.collapsed .tree-node-row .tree-actions { display: none; }
.sidebar.collapsed .tree-node-row { justify-content: center; padding: 8px 6px; }
.sidebar.collapsed .tree-node-row .tree-toggle { display: none; }

.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 16px; border-bottom: 1px solid var(--border);
}

.sidebar-header h2 { font-size: 18px; font-weight: 700; white-space: nowrap; color: var(--primary); }

/* Sidebar top actions */
.sidebar-top-actions {
    padding: 8px 8px 4px; display: flex; gap: 6px; align-items: center;
}
.btn-sm { padding: 6px 12px; font-size: 12px; }
.search-box-sm { flex: 1; }
.search-box-sm input {
    width: 100%; padding: 6px 10px; font-size: 12px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); outline: none;
}
.search-box-sm input:focus { border-color: var(--primary); }

/* Category tree */
.sidebar-tree {
    flex: 1; overflow-y: auto; padding: 4px 4px;
    min-height: 200px;
}

.tree-node { user-select: none; }
.tree-node-row {
    display: flex; align-items: center; gap: 4px;
    padding: 5px 8px; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 13px; color: var(--text-muted);
    transition: all 0.12s;
}
.tree-node-row:hover { background: var(--surface2); color: var(--text); }
.tree-node-row.active { background: var(--primary-dim); color: var(--primary); font-weight: 600; }
.tree-toggle {
    width: 16px; height: 16px; display: inline-flex; align-items: center;
    justify-content: center; flex-shrink: 0; font-size: 10px; color: var(--text-muted);
}
.tree-icon { flex-shrink: 0; font-size: 14px; }
.tree-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-actions {
    display: none; gap: 2px;
}
.tree-node-row:hover .tree-actions { display: flex; }
.tree-actions button {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 2px; font-size: 14px; line-height: 1; border-radius: 4px;
}
.tree-actions button:hover { color: var(--primary); background: var(--primary-dim); }

/* Inline quick-add row below the tree */
.tree-quickadd {
    padding: 8px 12px 12px;
    border-top: 1px dashed var(--border);
    margin-top: 4px;
}
.tree-quickadd-trigger {
    width: 100%;
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 500;
    transition: all 0.12s ease;
}
.tree-quickadd-trigger:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-dim);
}
.tqa-plus {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--surface2);
    font-weight: 700;
    line-height: 1;
}
.tree-quickadd-trigger:hover .tqa-plus { background: var(--primary); color: #fff; }

.tree-quickadd-form {
    display: flex; align-items: center; gap: 6px;
}
.tree-quickadd-form input {
    flex: 1;
    padding: 7px 10px;
    font-size: 13px;
    border: 1px solid var(--primary);
    border-radius: 6px;
    background: var(--surface);
}
.tqa-cancel {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 4px 8px; font-size: 14px; border-radius: 6px;
}
.tqa-cancel:hover { color: var(--danger); background: var(--surface2); }

.sidebar.collapsed .tree-quickadd { padding: 8px 6px; }
.sidebar.collapsed .tqa-label { display: none; }

/* Drag & drop states */
.tree-node-row[draggable="true"] { position: relative; }
.tree-node-row.dragging { opacity: 0.4; }
.tree-node-row.drop-into {
    background: var(--primary-dim);
    outline: 2px dashed var(--primary);
    outline-offset: -2px;
}
.tree-node-row.drop-above { box-shadow: inset 0 2px 0 0 var(--primary); }
.tree-node-row.drop-below { box-shadow: inset 0 -2px 0 0 var(--primary); }

/* Section header: drag handle + drop states */
.ws-panel-header[draggable="true"] { cursor: grab; }
.ws-panel-header[draggable="true"]:active { cursor: grabbing; }
.ws-panel-header.dragging { opacity: 0.4; }
.ws-panel-header.drop-section {
    background: var(--primary-dim) !important;
    box-shadow: inset 0 2px 0 0 var(--primary);
}
.ws-panel-header.drop-record {
    background: var(--primary-dim) !important;
    outline: 2px dashed var(--primary);
    outline-offset: -2px;
}

/* Record rows / cards: drag affordance */
[data-record-id][draggable="true"] { cursor: grab; }
[data-record-id][draggable="true"]:active { cursor: grabbing; }
[data-record-id].dragging { opacity: 0.4; }

/* Merge picker */
.merge-candidate {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.1s ease, color 0.1s ease;
}
.merge-candidate:last-child { border-bottom: none; }
.merge-candidate:hover { background: var(--primary-dim); color: var(--primary); }
.tree-children { padding-left: 16px; }
.tree-empty { padding: 16px; text-align: center; font-size: 12px; color: var(--text-muted); }

.sidebar-nav { padding: 4px 8px; overflow-y: auto; }

/* Bottom collapsed section */
.sidebar-bottom-section {
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.bottom-toggle {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 14px; cursor: pointer;
    font-size: 11px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
    transition: color 0.15s;
}
.bottom-toggle:hover { color: var(--text); }
.bottom-toggle-arrow { font-size: 9px; transition: transform 0.2s; }
.bottom-toggle-arrow.open { transform: rotate(90deg); }

.sidebar-nav-collapsed {
    padding: 0 6px 6px; max-height: 200px; overflow-y: auto;
}

.nav-item-sm {
    display: flex; align-items: center; gap: 6px;
    width: 100%; padding: 5px 10px;
    background: none; border: none; color: var(--text-muted);
    border-radius: 4px; cursor: pointer;
    font-size: 12px; text-align: left;
    transition: all 0.12s; white-space: nowrap;
}
.nav-item-sm:hover { color: var(--text); background: var(--surface2); }
.nav-item-sm.active { color: var(--primary); background: var(--primary-dim); font-weight: 600; }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 10px 14px;
    background: none; border: none; color: var(--text-muted);
    border-radius: var(--radius-sm); cursor: pointer;
    font-size: 14px; text-align: left;
    transition: all 0.15s; white-space: nowrap;
}
.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--primary); background: var(--primary-dim); font-weight: 600; }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
    padding: 10px 8px; border-top: 1px solid var(--border);
    position: relative;
}

/* ---------- User menu trigger + popup ---------- */

.user-menu-wrap { position: relative; }

.user-menu-trigger {
    width: 100%;
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.user-menu-trigger:hover {
    background: var(--surface2);
    border-color: var(--border);
}
.user-menu-trigger[aria-expanded="true"] {
    background: var(--primary-dim);
    border-color: var(--primary);
}
.user-menu-trigger .user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary); color: white;
    font-weight: 700; font-size: 13px;
    flex-shrink: 0;
}
.user-menu-trigger .user-meta { flex: 1; min-width: 0; }
.user-menu-trigger .user-name {
    font-weight: 600; color: var(--text); font-size: 13px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-menu-trigger .user-role {
    font-size: 10px; color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.5px;
}
.user-menu-caret {
    color: var(--text-muted); font-size: 12px; flex-shrink: 0;
    transition: transform 0.15s ease;
}
.user-menu-trigger[aria-expanded="true"] .user-menu-caret { transform: rotate(180deg); }

.user-menu {
    position: absolute;
    left: 8px; right: 8px;
    bottom: calc(100% + 6px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 -6px 24px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
    z-index: 50;
    animation: userMenuIn 0.12s ease-out;
}
@keyframes userMenuIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}

.user-menu-item {
    width: 100%;
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: background 0.1s ease, color 0.1s ease;
}
.user-menu-item:hover { background: var(--primary-dim); color: var(--primary); }
.user-menu-item.user-menu-lock:hover { background: rgba(231,76,60,0.1); color: var(--danger); }
.user-menu-item .umi-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.user-menu-divider {
    height: 1px; background: var(--border);
    margin: 4px 2px;
}

/* Collapsed sidebar variant */
.sidebar.collapsed .user-menu-trigger { justify-content: center; padding: 8px 4px; }
.sidebar.collapsed .user-menu-trigger .user-meta,
.sidebar.collapsed .user-menu-trigger .user-menu-caret { display: none; }

/* ---------- Content Area ---------- */

.content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    transition: margin-left 0.25s ease;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.content .main { flex: 1; }

.sidebar.collapsed ~ .content { margin-left: var(--sidebar-collapsed); }

.content-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.content-header h1 { font-size: 20px; font-weight: 700; }

.header-right { display: flex; align-items: center; gap: 12px; }

.search-box {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 0 12px;
}
.search-box input { background: transparent; border: none; width: 220px; padding: 10px 0; }
.search-box input:focus { border: none; box-shadow: none; }
.search-box svg { color: var(--text-muted); flex-shrink: 0; }

/* ---------- List View ---------- */

.main { padding: 20px 32px; }

.records-list {
    display: flex; flex-direction: column; gap: 0;
}

.list-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.list-table thead th {
    background: var(--surface2);
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky; top: 0; z-index: 1;
}

.list-table thead th.sortable-th:hover {
    color: var(--primary); background: var(--primary-dim);
}

.list-table tbody tr {
    transition: background 0.15s;
}
.list-table tbody tr:hover { background: var(--surface2); }

.list-table tbody td {
    padding: 10px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}
.list-table tbody tr:last-child td { border-bottom: none; }

.list-table .col-name {
    font-weight: 600;
    display: flex; align-items: center; gap: 8px;
}

.list-avatar {
    width: 28px; height: 28px; border-radius: 6px;
    background: var(--primary); color: white;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 11px; flex-shrink: 0;
}

.list-badge {
    font-size: 10px; padding: 2px 8px; border-radius: 12px;
    background: var(--primary-dim); color: var(--primary); border: 1px solid rgba(108,92,231,0.2);
    font-weight: 600; white-space: nowrap;
}

.list-table a { color: var(--primary); text-decoration: none; }
.list-table a:hover { text-decoration: underline; }

.list-actions { display: flex; gap: 2px; white-space: nowrap; }

.secret-cell {
    display: inline-flex; align-items: center; gap: 4px;
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

.secret-masked {
    letter-spacing: 3px; color: #adb5bd; font-size: 12px;
}

.secret-revealed {
    color: var(--text);
    font-size: 13px;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.mono {
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 13px;
}

/* ---------- Copy Toast ---------- */

.copy-toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--success); color: white;
    padding: 10px 24px; border-radius: 8px; font-size: 13px; font-weight: 600;
    z-index: 999; opacity: 0; transition: opacity 0.3s; pointer-events: none;
    box-shadow: 0 4px 12px rgba(46,204,113,0.3);
}
.copy-toast.show { opacity: 1; }

/* ---------- Modal ---------- */

.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
}

.modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 28px;
    width: 600px; max-width: 95vw; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

.modal-sm { width: 400px; }

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
    gap: 12px;
}
.modal-header h2 { font-size: 18px; }
.modal-header-actions {
    display: flex; align-items: center; gap: 6px;
}
.modal-copy-btn {
    padding: 5px 10px;
    font-size: 12px;
    display: inline-flex; align-items: center; gap: 5px;
    color: var(--text-muted);
}
.modal-copy-btn:hover { color: var(--primary); border-color: var(--primary); }
.modal-copy-btn svg { width: 13px; height: 13px; }

.modal-save-btn {
    padding: 5px 14px;
    font-size: 12px;
    height: 28px;
}

/* ---------- Authenticator (TOTP) tiles ---------- */
.totp-toolbar {
    display: flex; gap: 8px; align-items: center;
    padding: 8px 12px 4px;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
}
.totp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    padding: 14px;
}
.totp-card {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.totp-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.totp-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
    min-height: 32px;
}
.totp-issuer {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
    line-height: 1.25;
    letter-spacing: -0.1px;
    word-break: break-word;
}
.totp-account {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 1px;
    word-break: break-word;
}
.totp-code-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.totp-code {
    flex: 1;
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--primary);
    transition: color 0.15s ease;
}
.totp-card.totp-warn .totp-code { color: var(--warning); }
.totp-copy { color: var(--text-muted); flex-shrink: 0; }
.totp-copy:hover { color: var(--primary); background: var(--primary-dim); }
.totp-countdown {
    position: relative;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}
.totp-countdown-bar {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.95s linear, background 0.15s ease;
    width: 100%;
}
.totp-card.totp-warn .totp-countdown-bar { background: var(--warning); }
.totp-card.totp-invalid { border-color: var(--danger); background: var(--danger-dim); }
.totp-card.totp-invalid .totp-code { color: var(--danger); }
.totp-card.totp-invalid .totp-copy { display: none; }
.totp-countdown-text {
    position: absolute;
    right: 0; top: -16px;
    font-size: 10px;
    color: var(--text-soft);
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

/* ---------- GA QR drop zone (import modal) ---------- */
.ga-qr-drop {
    border: 2px dashed var(--border-strong);
    background: var(--surface2);
    border-radius: var(--radius-sm);
    padding: 22px 18px;
    text-align: center;
    transition: border-color 0.15s ease, background 0.15s ease;
    outline: none;
}
.ga-qr-drop:hover,
.ga-qr-drop:focus,
.ga-qr-drop.drag { border-color: var(--primary); background: var(--primary-dim); }
.ga-qr-drop.busy { border-color: var(--warning); }
.ga-qr-drop.ok { border-color: var(--success); background: var(--success-dim); }
.ga-qr-drop-icon { font-size: 26px; margin-bottom: 6px; }
.ga-qr-drop-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}
.ga-qr-drop-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.access-action {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1px;
    line-height: 1.5;
}
.access-action.access-info { background: var(--primary-dim); color: var(--primary); }
.access-action.access-warn { background: rgba(246,192,0,0.16); color: #ab7c00; }
.access-action.access-danger { background: var(--danger-dim); color: var(--danger); }
.access-action.access-success { background: var(--success-dim); color: var(--success); }

/* ---------- Vault switcher / management ---------- */
.user-menu-vault {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 8px 12px 4px;
    letter-spacing: 0.2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.vault-list { display: flex; flex-direction: column; gap: 8px; }
.vault-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.12s ease, background 0.12s ease;
    text-align: left;
    width: 100%;
    font: inherit;
}
.vault-row:hover { border-color: var(--primary); background: var(--primary-dim); }
.vault-row.active { border-color: var(--primary); background: var(--primary-soft); }
.vault-row-icon { font-size: 18px; }
.vault-row-meta { flex: 1; min-width: 0; }
.vault-row-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.vault-row-name .vault-row-active { color: var(--primary); font-weight: 500; font-size: 12px; }
.vault-row-role { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.vault-row-arrow { font-size: 18px; color: var(--text-soft); }

/* Create-vault modal polish */
.modal-hero-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary-soft), var(--primary-dim));
    border: 1px solid var(--primary-dim);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.vault-create-callout {
    display: flex;
    gap: 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin: 8px 0 18px;
}
.vcc-icon { font-size: 18px; line-height: 1; padding-top: 1px; }
.vcc-title {
    font-size: 12.5px; font-weight: 700; color: var(--text);
    letter-spacing: 0.2px;
    margin-bottom: 2px;
}
.vcc-body { font-size: 12.5px; color: var(--text-muted); line-height: 1.55; }
.vault-create-reminder {
    display: flex; gap: 10px; align-items: flex-start;
    background: rgba(246,192,0,0.10);
    border: 1px solid rgba(246,192,0,0.35);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin: 14px 0 8px;
    font-size: 12.5px;
    color: var(--text);
    line-height: 1.5;
}
.vcr-dot { color: var(--warning); font-size: 15px; line-height: 1.1; }

.pw-strength-bar {
    position: relative;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    margin-top: 6px;
    overflow: hidden;
}
.pw-strength-bar > span {
    position: absolute;
    inset: 0 auto 0 0;
    background: var(--danger);
    width: 0;
    transition: width 0.18s ease, background 0.18s ease;
}
.pw-strength-bar[data-score="0"] > span { background: var(--danger); }
.pw-strength-bar[data-score="1"] > span { background: var(--danger); }
.pw-strength-bar[data-score="2"] > span { background: var(--warning); }
.pw-strength-bar[data-score="3"] > span { background: var(--warning); }
.pw-strength-bar[data-score="4"] > span { background: var(--success); }
.pw-strength-bar[data-score="5"] > span { background: var(--success); }

.btn-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 24px; cursor: pointer;
}
.btn-close:hover { color: var(--text); }

.form-group { margin-bottom: 16px; flex: 1; }

.form-group label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.5px; margin-bottom: 6px;
}

.form-row { display: flex; gap: 16px; }

.modal-footer {
    display: flex; justify-content: flex-end; gap: 12px;
    margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border);
}

/* ---------- Global Search ---------- */

.global-search-box input { width: 260px; }

.global-search-results {
    padding: 0 32px 20px;
}

.gs-result {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px; border-radius: var(--radius-sm);
    cursor: pointer; transition: background 0.15s;
}
.gs-result:hover { background: var(--surface2); }

.gs-result-section {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--primary);
    background: var(--primary-dim); padding: 2px 8px; border-radius: 4px;
    white-space: nowrap; flex-shrink: 0;
}

.gs-result-title { font-weight: 600; font-size: 14px; }

.gs-result-matches {
    font-size: 12px; color: var(--text-muted); margin-top: 2px;
}

.gs-result-matches mark {
    background: rgba(108,92,231,0.15); color: var(--primary);
    padding: 0 2px; border-radius: 2px;
}

.gs-empty { text-align: center; color: var(--text-muted); padding: 24px; font-size: 14px; }

.gs-close {
    text-align: right; margin-bottom: 8px;
}

/* ---------- File Cards ---------- */

.file-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 20px;
    display: flex; align-items: center; gap: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.file-card:hover { border-color: var(--primary); box-shadow: 0 4px 16px rgba(108,92,231,0.1); }

.file-icon {
    width: 42px; height: 42px; border-radius: 10px;
    background: var(--primary-dim); color: var(--primary);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.file-info { flex: 1; min-width: 0; }
.file-info h4 { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.file-actions { display: flex; gap: 4px; }

/* ---------- Workspace Panels ---------- */

.workspace-welcome {
    text-align: center; padding: 80px 20px; color: var(--text-muted);
}
.workspace-welcome h2 { font-size: 20px; color: var(--text); margin-bottom: 8px; }
.workspace-welcome p { font-size: 14px; }

/* ---------- Home (welcome) recently-opened block ---------- */

.home-header {
    padding: 4px 2px 16px;
}
.home-header h2 { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.home-header p { font-size: 13px; color: var(--text-muted); }
.home-header kbd {
    background: var(--border); padding: 2px 6px; border-radius: 4px;
    font-size: 11px; margin: 0 2px;
}

.home-recent-head {
    padding: 8px 2px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
}
.home-recent-head h3 {
    font-size: 11px; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin: 8px 0 2px;
}
.home-recent-sub {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.home-clear-link {
    color: var(--text-muted); font-size: 11px; text-decoration: none;
}
.home-clear-link:hover { color: var(--danger); text-decoration: underline; }

.home-recent { display: block; }
.home-empty {
    padding: 40px 20px; text-align: center;
}

.ws-panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.ws-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; cursor: pointer; user-select: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s;
}
.ws-panel-header.open { border-bottom-color: var(--border); }
.ws-panel-header:hover { background: var(--surface2); border-radius: var(--radius) var(--radius) 0 0; }

.ws-panel-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 15px; font-weight: 600;
}
.ws-panel-badge {
    font-size: 10px; padding: 2px 8px; border-radius: 12px;
    background: var(--primary-dim); color: var(--primary); font-weight: 600;
}
.ws-panel-actions { display: flex; gap: 4px; }
.ws-panel-body { padding: 12px 16px; }
.ws-panel-body.collapsed { display: none; }

.ws-add-section {
    display: flex; align-items: center; justify-content: center;
    padding: 24px; border: 2px dashed var(--border); border-radius: var(--radius);
    color: var(--text-muted); cursor: pointer; font-size: 14px;
    transition: all 0.15s;
}
.ws-add-section:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-dim); }

.ws-add-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ws-add-row .ws-add-section { padding: 18px; }
.ws-add-csv { font-weight: 500; }
@media (max-width: 640px) {
    .ws-add-row { grid-template-columns: 1fr; }
}

/* CSV import preview inside the modal */
.csv-preview {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin: 8px 0 4px;
}
.csv-preview-head {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.csv-preview-scroll { max-height: 220px; overflow: auto; }
.csv-preview-table {
    border-collapse: collapse;
    font-size: 12px;
    min-width: 100%;
}
.csv-preview-table th, .csv-preview-table td {
    border: 1px solid var(--border);
    padding: 4px 8px;
    text-align: left;
    white-space: nowrap;
}
.csv-preview-table th {
    background: var(--surface);
    font-weight: 600;
    color: var(--text);
    position: sticky; top: 0;
}

/* Section type picker */
.type-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0;
}
.type-card {
    padding: 16px 12px; border: 1px solid var(--border); border-radius: var(--radius);
    text-align: center; cursor: pointer; transition: all 0.15s;
    background: var(--surface);
}
.type-card:hover { border-color: var(--primary); background: var(--primary-dim); }
.type-card.selected { border-color: var(--primary); background: var(--primary-dim); box-shadow: 0 0 0 2px var(--primary); }
.type-card-icon { font-size: 24px; margin-bottom: 6px; }
.type-card-name { font-size: 13px; font-weight: 600; }
.type-card-desc { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Simple field designer */
.field-designer-row {
    display: flex; gap: 8px; align-items: center; padding: 8px 12px;
    background: var(--surface2); border-radius: var(--radius-sm); margin-bottom: 6px;
}
.field-designer-row input { flex: 1; }
.field-designer-row .lock-toggle {
    display: flex; align-items: center; gap: 4px; cursor: pointer;
    padding: 6px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface); font-size: 12px; color: var(--text-muted); transition: all 0.15s;
}
.field-designer-row .lock-toggle.active {
    background: #fff3cd; border-color: #ffc107; color: #856404;
}
.field-designer-row .lock-toggle:hover { border-color: var(--primary); }
.field-designer-row .remove-field {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 18px; padding: 0 4px;
}
.field-designer-row .remove-field:hover { color: var(--danger); }

/* ---------- Category Notes Panel ---------- */

.ws-notes-panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.ws-notes-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; cursor: pointer; font-size: 13px; font-weight: 600;
    color: var(--text-muted); border-bottom: 1px solid var(--border);
    user-select: none;
}
.ws-notes-header:hover { background: var(--surface2); border-radius: var(--radius) var(--radius) 0 0; }
.ws-notes-status { font-size: 11px; font-weight: 400; color: var(--success); }
.ws-notes-body { padding: 0; }
.ws-notes-body.collapsed { display: none; }
.ws-notes-body .ql-toolbar { border-left: none; border-right: none; border-top: none; }
.ws-notes-body .ql-container { border: none; }
.ws-notes-body .ql-editor { min-height: 80px; max-height: 300px; }

/* ---------- Rich Text Editor ---------- */

.ql-container { font-family: inherit; font-size: 14px; }
.ql-editor { min-height: 120px; max-height: 300px; overflow-y: auto; }
.ql-toolbar { background: var(--surface2); border-color: var(--border) !important; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.ql-container.ql-snow { border-color: var(--border) !important; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.ql-editor.ql-blank::before { color: var(--text-muted); }
.rich-text-display { font-size: 13px; line-height: 1.6; }
.rich-text-display p { margin-bottom: 4px; }
.rich-text-display ul, .rich-text-display ol { padding-left: 20px; }

/* ---------- Record Links ---------- */

.links-section { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.links-section h4 { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }

.link-item {
    display: flex; align-items: center; gap: 8px; padding: 6px 10px;
    background: var(--surface2); border-radius: var(--radius-sm); margin-bottom: 4px;
    font-size: 13px; cursor: pointer; transition: background 0.15s;
}
.link-item:hover { background: var(--primary-dim); }
.link-badge { font-size: 10px; padding: 2px 6px; border-radius: 4px; background: var(--border); color: var(--text-muted); }
.link-name { flex: 1; font-weight: 500; }
.link-remove { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; }
.link-remove:hover { color: var(--danger); }

.link-search-box { position: relative; margin-top: 8px; }
.link-search-box input { width: 100%; }
.link-search-results {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
    background: var(--surface); border: 1px solid var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 200px; overflow-y: auto; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.link-search-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px;
    cursor: pointer; font-size: 13px; transition: background 0.1s;
}
.link-search-item:hover { background: var(--primary-dim); }
.link-search-item .link-badge { flex-shrink: 0; }

/* ---------- Search Page (Full Screen) ---------- */

.search-page {
    position: fixed; top: 38px; right: 0; bottom: 0; left: 0;
    z-index: 150;
    background: var(--bg);
    display: flex; flex-direction: column;
    animation: searchPageIn 0.15s ease-out;
}
@media (max-width: 640px) {
    .search-page { top: 56px; }
}
@keyframes searchPageIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.search-page-header {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 32px; background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.search-page-input {
    flex: 1; font-size: 20px; font-weight: 500;
    background: transparent; border: none; outline: none;
    color: var(--text); padding: 8px 0;
}
.search-page-input::placeholder { color: #bbb; }

.search-page-close {
    background: none; border: 1px solid var(--border); border-radius: 6px;
    color: var(--text-muted); cursor: pointer; padding: 6px 14px;
    font-size: 13px; transition: all 0.15s;
}
.search-page-close:hover { background: var(--surface2); color: var(--text); }

.search-page-body {
    flex: 1; overflow-y: auto; padding: 20px 32px;
}

.search-page-status {
    text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.search-page-status h2 { font-size: 18px; color: var(--text); margin-bottom: 8px; }

/* ---------- Search landing (empty query) ---------- */

.search-landing { max-width: 900px; margin: 0 auto; }
.search-section { margin-bottom: 28px; }
.search-section-head {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 10px; padding: 0 4px;
}
.search-section-head h3 {
    font-size: 12px; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.search-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 4px; }
.search-chip {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.12s ease;
    max-width: 280px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-dim); }

.search-recent-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px;
}
.search-recent-item {
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.12s ease, transform 0.08s ease;
}
.search-recent-item:hover { border-color: var(--primary); }
.search-recent-item:active { transform: scale(0.99); }
.search-recent-item .sri-title {
    font-size: 14px; font-weight: 600; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    margin-bottom: 4px;
}
.search-recent-item .sri-meta {
    display: flex; justify-content: space-between; gap: 8px;
    font-size: 11px; color: var(--text-muted);
}
.search-recent-item .sri-section {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 70%;
    color: var(--primary);
    opacity: 0.85;
}
.search-recent-item .sri-time { flex-shrink: 0; }

.search-page-loading {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    padding: 40px;
}
.search-page-bar {
    width: 320px; height: 3px; background: var(--border); border-radius: 3px;
    overflow: hidden; position: relative;
}
.search-page-bar::after {
    content: ''; position: absolute; top: 0; left: -40%;
    width: 40%; height: 100%;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    animation: searchSlide 0.8s ease-in-out infinite;
}

.search-page-count {
    font-size: 13px; color: var(--text-muted); margin-bottom: 16px;
}

/* ---------- Search Group Header ---------- */

.search-group-header {
    font-size: 12px; color: var(--primary); text-transform: uppercase;
    margin: 20px 0 8px; padding: 6px 12px; border-radius: var(--radius-sm);
    transition: background 0.15s; display: inline-block;
}
.search-group-header:hover { background: var(--primary-dim); }
.search-group-header span { opacity: 0; transition: opacity 0.15s; }
.search-group-header:hover span { opacity: 1; }

/* ---------- Search Result Cards ---------- */

.search-result-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; margin-bottom: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    transition: border-color 0.15s;
}
.search-result-card:hover { border-color: var(--primary); }

.search-result-header {
    display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
    padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.search-result-title { flex: 1; font-size: 15px; }

.search-result-fields {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px;
}

.search-result-field {
    display: flex; flex-direction: column; gap: 1px; padding: 4px 0;
}
.search-result-label {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted);
}
.search-result-value {
    font-size: 13px; color: var(--text); word-break: break-word;
    line-height: 1.4; font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

@media (max-width: 768px) {
    .search-result-fields { grid-template-columns: 1fr; }
}

/* ---------- Search Loading ---------- */

.search-loading {
    display: flex; flex-direction: column; align-items: center; gap: 16px;
    padding: 40px 20px; color: var(--text-muted);
}

.search-loading-bar {
    width: 280px; height: 3px; background: var(--border); border-radius: 3px;
    overflow: hidden; position: relative;
}
.search-loading-bar::after {
    content: ''; position: absolute; top: 0; left: -40%;
    width: 40%; height: 100%; background: linear-gradient(90deg, transparent, var(--primary), transparent);
    animation: searchSlide 1s ease-in-out infinite;
}
@keyframes searchSlide {
    0% { left: -40%; }
    100% { left: 100%; }
}

.search-loading-text {
    font-size: 13px; font-weight: 500;
    animation: searchPulse 1.5s ease-in-out infinite;
}
@keyframes searchPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.search-loading-dots::after {
    content: ''; animation: dots 1.5s steps(3, end) infinite;
}
@keyframes dots {
    0% { content: ''; }
    33% { content: '.'; }
    66% { content: '..'; }
    100% { content: '...'; }
}

/* ---------- Dialog (replaces alert/prompt) ---------- */

.dialog-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px); display: flex; align-items: center;
    justify-content: center; z-index: 300;
}
.dialog-box {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 28px; width: 420px; max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
.dialog-box h3 { font-size: 17px; margin-bottom: 12px; }
.dialog-box p { font-size: 14px; color: var(--text-muted); margin-bottom: 16px; }
.dialog-box input { margin-bottom: 16px; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Admin panel blocks ---------- */

.admin-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 18px;
}
.admin-panel > h3 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.admin-toggle {
    display: flex; gap: 12px; align-items: flex-start;
    cursor: pointer;
}
.admin-toggle input[type="checkbox"] {
    width: 18px; height: 18px;
    margin-top: 2px;
    cursor: pointer;
    accent-color: var(--primary);
}
.admin-toggle-title {
    font-size: 13.5px; font-weight: 600;
    color: var(--text); margin-bottom: 3px;
}
.admin-toggle-desc {
    font-size: 12.5px; color: var(--text-muted);
    line-height: 1.55;
}

/* ---------- Status pills (Users admin page) ---------- */

.status-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.status-ok { background: rgba(46,204,113,0.10); border-color: rgba(46,204,113,0.35); color: var(--success); }
.status-warn { background: rgba(255,170,0,0.12); border-color: rgba(255,170,0,0.45); color: #b46800; }
.status-locked { background: rgba(231,76,60,0.12); border-color: rgba(231,76,60,0.4); color: var(--danger); }

/* ---------- Nav Divider ---------- */

.nav-divider { height: 1px; background: var(--border); margin: 8px 14px; }

/* ---------- User Info ---------- */

.user-info {
    padding: 8px 14px; font-size: 12px; color: var(--text-muted);
    display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.user-info .user-avatar {
    width: 24px; height: 24px; border-radius: 6px;
    background: var(--primary); color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 10px; flex-shrink: 0;
}
.user-info .user-name { font-weight: 600; color: var(--text); }
.user-info .user-role { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }

/* ---------- Audit Log Table ---------- */

.audit-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.audit-table th {
    text-align: left; padding: 8px 12px; background: var(--surface2);
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.audit-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.audit-table tr:hover { background: var(--surface2); }

.audit-action {
    font-size: 11px; padding: 2px 8px; border-radius: 4px;
    font-weight: 600; display: inline-block;
}
.audit-action.login { background: #d4edda; color: #155724; }
.audit-action.secret_revealed { background: #fff3cd; color: #856404; }
.audit-action.record_created, .audit-action.record_updated { background: #cce5ff; color: #004085; }
.audit-action.record_deleted, .audit-action.file_deleted { background: #f8d7da; color: #721c24; }

.pagination { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 16px; }

/* ---------- Attachment List ---------- */

.attach-item {
    display: flex; align-items: center; gap: 8px; padding: 6px 0;
    border-bottom: 1px solid var(--border); font-size: 13px;
}
.attach-item:last-child { border-bottom: none; }
.attach-name { flex: 1; }
.attach-size { color: var(--text-muted); font-size: 11px; }

/* ---------- MFA Setup ---------- */

.mfa-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }

/* ---------- Empty State ---------- */

.empty-state {
    text-align: center; padding: 80px 20px; color: var(--text-muted);
}
.empty-state svg { margin-bottom: 20px; opacity: 0.2; }
.empty-state h2 { font-size: 20px; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 14px; }

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
    .sidebar { width: var(--sidebar-collapsed); top: 56px; }
    .sidebar .sidebar-header h2, .sidebar .nav-item span, .sidebar .sidebar-footer span { display: none; }
    .sidebar .nav-item { justify-content: center; padding: 12px; }
    .sidebar .sidebar-header { justify-content: center; }
    .content { margin-left: var(--sidebar-collapsed); }
    .content-header { padding: 12px 16px; flex-wrap: wrap; gap: 12px; }
    .header-right { flex-wrap: wrap; width: 100%; }
    .search-box input { width: 140px; }
    .main { padding: 16px; }
    .records-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; gap: 0; }
    .lock-card { width: 90%; padding: 32px 24px; }
    .e2e-badge { font-size: 10.5px; padding: 4px 8px; }
}

/* ---------- Zero-Knowledge / Encryption Messaging ---------- */

.zero-knowledge-hero {
    margin: 0 0 24px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(46,204,113,0.08), rgba(108,92,231,0.08));
    border: 1px solid rgba(46,204,113,0.25);
    border-radius: 8px;
    text-align: left;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text-muted);
}
.zero-knowledge-hero .zk-title {
    font-weight: 600;
    color: var(--success);
    margin-bottom: 6px;
    font-size: 13px;
    letter-spacing: 0.2px;
}
.zero-knowledge-hero p { margin: 4px 0; }
.zero-knowledge-hero strong { color: var(--text); }

.e2e-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 10px;
    background: rgba(46,204,113,0.12);
    color: var(--success);
    border: 1px solid rgba(46,204,113,0.3);
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: help;
    white-space: nowrap;
    margin-right: 8px;
}

.encrypted-hint {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin: 4px 0 0;
    line-height: 1.4;
}

.zero-knowledge-footer {
    padding: 12px 24px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    border-top: 1px solid var(--border);
    background: var(--surface2);
    letter-spacing: 0.3px;
}

.first-login-banner {
    margin: 16px 24px 0;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(108,92,231,0.08), rgba(46,204,113,0.06));
    border: 1px solid rgba(108,92,231,0.25);
    border-radius: 8px;
}
.first-login-banner .flb-title {
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
    margin-bottom: 8px;
}
.first-login-banner .flb-list {
    margin: 0 0 12px;
    padding-left: 20px;
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.6;
}
.first-login-banner .flb-list strong { color: var(--text); }

/* ---------- Attachments Panel ---------- */

.attachments-section {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.attachments-section h4 {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex; align-items: center; gap: 10px;
    font-weight: 600;
}
.attachment-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 6px;
}
.attachment-info {
    display: flex; align-items: center; gap: 10px;
    min-width: 0; flex: 1;
}
.attachment-icon { color: var(--primary); flex-shrink: 0; }
.attachment-name {
    font-size: 13px; font-weight: 500; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 320px;
}
.attachment-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.type-card-featured {
    grid-column: 1 / -1;
    background: var(--primary-dim);
    border-color: var(--primary) !important;
}

/* ---------- Sidebar scope tabs (Secrets / Notes / Documents) ---------- */

.scope-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 4px;
    padding: 10px 12px 8px;
    border-bottom: 1px solid var(--border);
}
.scope-tab {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.scope-tab:hover { background: var(--surface2); color: var(--text); }
.scope-tab.active {
    background: var(--primary-dim);
    color: var(--primary);
    border-color: rgba(108,92,231,0.35);
}
.scope-icon { font-size: 17px; line-height: 1; }
.scope-label { letter-spacing: 0.2px; }
.sidebar.collapsed .scope-tabs { grid-template-columns: 1fr; padding: 8px 6px; }
.sidebar.collapsed .scope-label { display: none; }
.sidebar.collapsed .scope-tab { padding: 6px 4px; }

/* ---------- Scoped folder view (Notes / Documents folder contents) ---------- */

.scoped-folder { max-width: 1100px; }
.scoped-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: 2px 4px 14px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
}
.scoped-head h2 { font-size: 18px; font-weight: 600; margin: 0; color: var(--text); }
.scoped-empty {
    text-align: center; color: var(--text-muted);
    padding: 80px 20px;
}
.scoped-empty p { font-size: 14px; margin-bottom: 14px; }

/* ---------- OneNote-style layout: sections+pages + editor panes ---------- */

.onenote-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 0;
    /* Fill the remaining viewport below E2E bar + content header */
    height: calc(100vh - 38px - 60px);
    min-height: 520px;
    /* Cancel .main's 20px/32px padding so the layout hits the edges */
    margin: -20px -32px -20px -32px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}
.on-pages-pane {
    border-right: 1px solid var(--border);
    background: var(--surface2);
    display: flex; flex-direction: column;
    min-width: 0;
    min-height: 0;
}
.on-pages-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 14px 10px;
    gap: 8px;
}
.on-notebook-name {
    font-size: 15px; font-weight: 700; color: var(--text);
    letter-spacing: -0.1px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1; min-width: 0;
}
.on-add-section {
    font-size: 11.5px; padding: 5px 10px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    font-weight: 500;
}
.on-add-section:hover { border-color: var(--primary); color: var(--primary); }
.on-pages-scroll {
    flex: 1; overflow-y: auto;
    padding: 4px 6px 16px;
}
.on-empty-tree {
    color: var(--text-muted); font-size: 12px;
    padding: 24px 16px; text-align: center; line-height: 1.7;
}

.on-section { margin-bottom: 4px; }
.on-section-head {
    display: flex; align-items: center; gap: 2px;
    padding: 2px 6px 2px 4px;
    border-radius: 6px;
}
.on-section-head:hover { background: rgba(0,0,0,0.04); }
.on-section-toggle {
    flex: 1; min-width: 0;
    background: transparent; border: none;
    display: flex; align-items: center; gap: 6px;
    padding: 6px 4px;
    cursor: pointer; text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.on-caret {
    width: 10px; text-align: center; font-size: 9px;
    color: var(--text-muted);
    transition: transform 0.15s ease;
}
.on-section.collapsed .on-caret { transform: rotate(-90deg); }
.on-section-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.on-section-count {
    color: var(--text-muted); font-size: 10.5px; font-weight: 500;
    background: var(--surface); border-radius: 999px; padding: 1px 7px;
    min-width: 18px; text-align: center;
}
.on-new-section-row {
    display: flex; align-items: center; gap: 4px;
    padding: 4px 6px 4px 4px;
    margin-bottom: 6px;
    background: var(--surface);
    border: 1px solid var(--primary);
    border-radius: 6px;
    box-shadow: 0 0 0 3px var(--primary-dim);
}
.on-new-section-row input {
    flex: 1; min-width: 0;
    border: none; outline: none;
    background: transparent;
    padding: 6px 4px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text);
}
.on-new-section-row input::placeholder { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-muted); opacity: 0.7; }
.on-section-rename {
    flex: 1; min-width: 0;
    border: 1px solid var(--primary);
    background: var(--surface);
    padding: 4px 6px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
    outline: none;
    color: var(--text);
}
.on-btn-sm {
    background: transparent; border: none;
    color: var(--text-muted);
    width: 22px; height: 22px;
    border-radius: 4px; cursor: pointer;
    font-size: 12px; line-height: 1;
    opacity: 0;
    display: inline-flex; align-items: center; justify-content: center;
}
.on-section-head:hover .on-btn-sm { opacity: 1; }
.on-btn-sm:hover { background: var(--surface); color: var(--primary); }
.on-btn-sm.on-btn-danger:hover { color: var(--danger); }

.on-pages { padding-left: 14px; margin-top: 2px; }
.on-page {
    display: block; width: 100%;
    background: transparent; border: none;
    padding: 7px 10px 7px 12px;
    border-radius: 6px;
    text-align: left;
    font-size: 13.5px;
    color: var(--text);
    cursor: pointer;
    transition: background 0.1s ease, color 0.1s ease;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    position: relative;
}
.on-page:hover { background: rgba(0,0,0,0.045); }
.on-page.active {
    background: var(--surface);
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.on-page.active::before {
    content: "";
    position: absolute;
    left: 3px; top: 6px; bottom: 6px; width: 3px;
    background: var(--primary); border-radius: 2px;
}
.on-page-empty {
    color: var(--text-muted); font-style: italic;
    border: 1px dashed transparent;
}
.on-page-empty:hover { color: var(--primary); border-color: var(--primary); background: transparent; }

.on-editor-pane {
    overflow-y: auto;
    background: var(--surface);
    padding: 20px 48px 60px;
    min-width: 0;
    min-height: 0;
}
.on-editor-pane .note-editor {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0;
}
.on-editor-pane .note-editor-bar {
    justify-content: flex-end;
    padding-bottom: 6px;
    border-bottom: none;
    margin-bottom: 4px;
}
.on-editor-pane .note-title-input {
    font-size: 32px;
    font-weight: 700;
    padding: 10px 0;
    margin-bottom: 10px;
    border-bottom: 1px solid transparent;
    transition: border-color 0.12s ease;
}
.on-editor-pane .note-title-input:focus { border-bottom-color: var(--primary); }
.on-editor-pane .note-body-shell .ql-toolbar.ql-snow {
    border-top: none;
    border-left: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
    position: sticky; top: 0;
    background: var(--surface);
    backdrop-filter: none;
    z-index: 2;
}
.on-editor-pane .note-body-shell .ql-editor {
    min-height: 48vh;
    padding: 18px 0;
    font-size: 15px;
}

/* Editor.js inside the OneNote editor pane — blend it with the page.
   Editor.js renders inside the div we give it as #note-body, so scope styles
   to .note-body-shell and its codex-editor descendants. */
.on-editor-pane .note-body-shell {
    min-height: 55vh;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
}
.on-editor-pane .codex-editor {
    padding: 8px 0 40px;
}
.on-editor-pane .codex-editor__redactor {
    padding-bottom: 60px !important;
}
.on-editor-pane .ce-block__content,
.on-editor-pane .ce-toolbar__content {
    max-width: 100%;
}
.on-editor-pane .ce-paragraph,
.on-editor-pane .cdx-block { padding: 2px 0; }
.on-editor-pane .ce-header { padding: 4px 0; line-height: 1.3; letter-spacing: -0.1px; color: var(--text); }
.on-editor-pane h1.ce-header, .on-editor-pane .ce-header h1 { font-size: 28px; font-weight: 700; margin: 18px 0 6px; }
.on-editor-pane h2.ce-header, .on-editor-pane .ce-header h2 { font-size: 22px; font-weight: 700; margin: 14px 0 4px; }
.on-editor-pane h3.ce-header, .on-editor-pane .ce-header h3 { font-size: 18px; font-weight: 600; margin: 12px 0 4px; }
.on-editor-pane h4.ce-header, .on-editor-pane .ce-header h4 { font-size: 16px; font-weight: 600; margin: 10px 0 4px; }
.on-editor-pane .cdx-quote {
    border-left: 3px solid var(--primary);
    padding: 4px 0 4px 14px;
    color: var(--text-muted);
    font-style: italic;
    background: transparent;
}
.on-editor-pane .ce-code__textarea,
.on-editor-pane .cdx-code {
    background: var(--surface2) !important;
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
    padding: 10px 12px;
}
.on-editor-pane .tc-wrap { margin: 8px 0; }
.on-editor-pane .tc-table { border-collapse: collapse; }
.on-editor-pane .tc-cell { border: 1px solid var(--border); padding: 6px 10px; }
.on-editor-pane .cdx-checklist__item { padding: 4px 0; }
.on-editor-pane .cdx-checklist__item-checkbox {
    border-color: var(--border);
}
.on-editor-pane .cdx-checklist__item--checked .cdx-checklist__item-checkbox {
    background: var(--success);
    border-color: var(--success);
}
.on-editor-pane .ce-delimiter::before {
    color: var(--border);
    font-size: 24px;
    letter-spacing: 10px;
}
.on-editor-pane .ce-toolbar__plus,
.on-editor-pane .ce-toolbar__settings-btn {
    color: var(--text-muted);
}
.on-empty {
    text-align: center; padding: 80px 20px; color: var(--text-muted);
}
.on-empty p { font-size: 14px; margin-bottom: 14px; }

.note-editor-in-on .note-editor-bar {
    /* Inside the OneNote right pane, skip the left-side ← Back button. */
    justify-content: flex-end;
    padding-bottom: 6px;
    margin-bottom: 10px;
}
.note-editor-in-on .note-title-input {
    font-size: 26px;
    margin-bottom: 6px;
}

@media (max-width: 900px) {
    .onenote-layout { grid-template-columns: 220px 1fr; }
    .on-editor-pane { padding: 14px 16px 30px; }
}
@media (max-width: 640px) {
    .onenote-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .on-pages-pane { max-height: 220px; border-right: none; border-bottom: 1px solid var(--border); }
}

/* ---------- Inline note editor (Google-Docs-like) ---------- */

.note-editor {
    max-width: 840px;
    margin: 0 auto;
    padding: 8px 4px 40px;
}
.note-editor-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
}
.note-save-status {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}
.note-title-input {
    width: 100%;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.2px;
    padding: 10px 4px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    margin-bottom: 12px;
}
.note-title-input::placeholder { color: var(--text-muted); font-weight: 600; opacity: 0.55; }
.note-title-input:focus { box-shadow: none; }

.note-body-shell {
    min-height: 45vh;
}
/* Quill overrides for the inline editor — strip the box feel */
.note-body-shell .ql-toolbar.ql-snow {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 6px 0 8px;
    position: sticky; top: 38px; /* respect the E2E top bar */
    z-index: 5;
    backdrop-filter: blur(6px);
    background: rgba(255,255,255,0.85);
}
.note-body-shell .ql-container.ql-snow {
    border: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
    min-height: 40vh;
}
.note-body-shell .ql-editor { padding: 16px 4px; min-height: 40vh; }
.note-body-shell .ql-editor.ql-blank::before {
    color: var(--text-muted); opacity: 0.55; font-style: normal; left: 4px;
}

.note-att-section {
    margin-top: 28px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.note-att-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* ---------- Documents folder view (Drive-like) ---------- */

.docs-dropzone {
    position: relative;
    border: 2px dashed transparent;
    border-radius: 14px;
    padding: 2px;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.docs-dropzone.drop-hover {
    border-color: var(--primary);
    background: var(--primary-dim);
}
.docs-droptip {
    margin-top: 16px; padding: 14px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    border-radius: 10px;
    background: var(--surface2);
}
.docs-empty {
    text-align: center; color: var(--text-muted);
    padding: 80px 20px 40px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: var(--surface2);
}
.docs-empty p:first-child { font-size: 15px; color: var(--text); font-weight: 600; margin-bottom: 6px; }

.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding: 4px;
}
.drive-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.08s ease;
    overflow: hidden;
    display: flex; flex-direction: column;
}
.drive-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}
.drive-card:active { transform: scale(0.99); }
.drive-thumb {
    height: 110px;
    border-radius: 6px;
    background: var(--surface2);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 10px;
    overflow: hidden;
    position: relative;
}
.drive-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.drive-thumb-icon { font-size: 42px; opacity: 0.85; }
.drive-thumb-ext {
    position: absolute;
    bottom: 6px;
    right: 8px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--surface);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
    letter-spacing: 0.5px;
}
.drive-thumb-spinner { color: var(--text-muted); font-size: 14px; }
.drive-name {
    font-size: 13px; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 2px;
}
.drive-meta { font-size: 11px; color: var(--text-muted); }
.drive-edit, .drive-kebab {
    position: absolute;
    top: 8px; right: 8px;
    background: rgba(255,255,255,0.92);
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.12s ease, background 0.12s ease, border-color 0.12s ease;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}
.drive-card:hover .drive-edit,
.drive-card:hover .drive-kebab,
.drive-row:hover .drive-kebab { opacity: 1; }
.drive-kebab:hover,
.drive-edit:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Drive-like Documents shell ---------- */

.drive-shell { max-width: 1200px; }

.drive-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
    padding: 2px 0 14px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
}
.drive-bc {
    display: flex; align-items: center; gap: 6px;
    min-width: 0; flex: 1;
    font-size: 14px;
    color: var(--text-muted);
    overflow: hidden;
}
.drive-bc-link { color: var(--text-muted); text-decoration: none; padding: 2px 6px; border-radius: 4px; }
.drive-bc-link:hover { background: var(--surface2); color: var(--text); }
.drive-bc-current { color: var(--text); font-weight: 700; padding: 2px 6px; }
.drive-bc-sep { color: var(--text-muted); opacity: 0.5; font-size: 13px; }

.drive-toolbar-actions {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.drive-search {
    position: relative;
    display: inline-flex; align-items: center;
}
.drive-search span { position: absolute; left: 10px; color: var(--text-muted); font-size: 12px; pointer-events: none; }
.drive-search input {
    padding: 7px 12px 7px 30px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    min-width: 220px;
    max-width: 320px;
}
.drive-search input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-dim); }

.drive-sort {
    padding: 7px 28px 7px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    font-size: 13px;
    cursor: pointer;
    color: var(--text);
}

.drive-view-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface);
}
.drive-view-btn {
    background: transparent; border: none; padding: 7px 10px;
    cursor: pointer; color: var(--text-muted);
    font-size: 14px;
}
.drive-view-btn:hover { color: var(--text); }
.drive-view-btn.active { background: var(--primary-dim); color: var(--primary); }

.drive-upload-btn { padding: 7px 14px !important; cursor: pointer; }

.drive-section { margin-bottom: 22px; }
.drive-h3 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex; align-items: center; gap: 8px;
}
.drive-count {
    background: var(--surface2);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 10px;
    font-weight: 600;
}

.drive-recent-row {
    display: flex; gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.drive-recent {
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    width: 220px;
    transition: border-color 0.12s ease;
    text-align: left;
}
.drive-recent:hover { border-color: var(--primary); }
.drive-recent-icon { font-size: 18px; flex-shrink: 0; }
.drive-recent-name {
    font-size: 13px; font-weight: 600; color: var(--text);
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.drive-recent-age {
    font-size: 11px; color: var(--text-muted);
    flex-shrink: 0;
}

.drive-folders {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}
.drive-folder {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px; font-weight: 600;
    color: var(--text);
    transition: border-color 0.12s ease, background 0.12s ease;
    text-align: left;
}
.drive-folder:hover { background: var(--surface); border-color: var(--primary); }
.drive-folder-icon { font-size: 18px; }
.drive-folder-name {
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.drive-list {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.drive-list thead th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.drive-list tbody tr {
    cursor: pointer;
    transition: background 0.08s ease;
}
.drive-list tbody tr:hover { background: var(--surface2); }
.drive-list td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.drive-list .drive-cell-name {
    display: flex; align-items: center; gap: 12px;
    font-weight: 500; color: var(--text);
}
.drive-row-icon { font-size: 18px; }
.drive-row-name {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 560px;
}
.drive-cell-size, .drive-cell-date {
    color: var(--text-muted);
    font-size: 12.5px;
    width: 140px;
}
.drive-cell-actions { width: 40px; text-align: right; position: relative; }
.drive-cell-actions .drive-kebab {
    position: static;
    opacity: 0; transition: opacity 0.12s ease;
}

/* Popup menu (right-click / kebab) */
.drive-menu {
    position: fixed;
    z-index: 500;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.12);
    padding: 6px;
    width: 200px;
    animation: driveMenuIn 0.12s ease-out;
}
@keyframes driveMenuIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; } }
.drive-menu button {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    background: transparent;
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    color: var(--text);
}
.drive-menu button:hover { background: var(--primary-dim); color: var(--primary); }
.drive-menu-danger:hover { background: rgba(231,76,60,0.1) !important; color: var(--danger) !important; }
.drive-menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.drive-menu button span { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }

/* ---------- Aggregated Documents / Notes pages ---------- */

.agg-page {
    max-width: 1100px;
    margin: 0 auto;
}
.agg-toolbar {
    display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap;
    padding: 2px 4px 14px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
}
.agg-chips {
    display: flex; flex-wrap: wrap; gap: 6px;
    flex: 1;
    min-width: 0;
}
.agg-chip {
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.12s ease;
    max-width: 200px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.agg-chip:hover { color: var(--text); border-color: var(--text-muted); }
.agg-chip.active {
    background: var(--text);
    color: var(--surface);
    border-color: var(--text);
}
.agg-search { flex-shrink: 0; }
.agg-search input {
    padding: 7px 12px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    min-width: 220px;
}
.agg-search input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-dim); }

.agg-loading {
    color: var(--text-muted); font-size: 13px; padding: 40px 12px; text-align: center;
}
.agg-empty {
    text-align: center; color: var(--text-muted);
    padding: 80px 20px;
}
.agg-empty p { font-size: 14px; margin-bottom: 6px; }
.agg-empty-sub { font-size: 12px; }

.agg-crumb {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--surface2);
    border-radius: 999px;
    padding: 2px 10px;
    white-space: nowrap;
    flex-shrink: 0;
}
.agg-footer {
    display: flex; align-items: center; gap: 6px;
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}

/* Document grid — quieter than the per-category doc-grid (no surface2 fill) */
.agg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
}
.agg-doc-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    box-shadow: none;
    transition: border-color 0.12s ease, transform 0.08s ease, box-shadow 0.12s ease;
}
.agg-doc-card:hover {
    border-color: var(--text-muted);
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}

/* Notes list — reading-first, not a grid */
.agg-notes {
    display: flex; flex-direction: column; gap: 10px;
}
.agg-note {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    cursor: pointer;
    transition: border-color 0.12s ease;
}
.agg-note:hover { border-color: var(--text-muted); }
.agg-note-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.agg-note-head h3 {
    font-size: 16px; font-weight: 600; color: var(--text);
    margin: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1;
}
.agg-note-body {
    color: var(--text);
    font-size: 13.5px;
    line-height: 1.6;
    white-space: pre-wrap;
    max-height: 120px;
    overflow: hidden;
    position: relative;
}
.agg-note-body.agg-note-empty { color: var(--text-muted); font-style: italic; }

/* ---------- Documents card grid (file-thumbnail-first) ---------- */

.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
    padding: 6px;
}
.doc-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: border-color 0.12s ease, transform 0.08s ease;
}
.doc-card:hover { border-color: var(--primary); }
.doc-card:active { transform: scale(0.99); }
.doc-card-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 6px; gap: 8px;
}
.doc-card-head strong {
    font-size: 14px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    flex: 1;
}
.doc-card-desc {
    font-size: 12px; color: var(--text-muted);
    line-height: 1.5;
    white-space: pre-wrap;
    max-height: 72px;
    overflow: hidden;
    margin-bottom: 10px;
}
.doc-card-files {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}
.doc-files-loading {
    font-size: 11px; color: var(--text-muted); padding: 2px 4px;
}
.doc-file {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11.5px;
    cursor: pointer;
    transition: border-color 0.1s ease;
    max-width: 100%;
    color: var(--text);
}
.doc-file:hover { border-color: var(--primary); color: var(--primary); }
.doc-file-name {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 160px;
}
.doc-file-size { color: var(--text-muted); font-size: 10.5px; }
.doc-file-image { padding: 0; overflow: hidden; height: 44px; }
.doc-file-image img {
    height: 44px; width: 44px; object-fit: cover; display: block;
    border-right: 1px solid var(--border);
}
.doc-file-image .doc-file-name { padding: 0 8px; max-width: 140px; }
.doc-add-file, .doc-add-file-chip {
    border: 1px dashed var(--border);
    color: var(--text-muted);
    font-size: 11.5px;
}
.doc-add-file:hover, .doc-add-file-chip:hover { color: var(--primary); border-color: var(--primary); }

/* ---------- Inline file viewer ---------- */

.file-viewer {
    position: fixed; inset: 0;
    z-index: 450;
    background: rgba(0,0,0,0.88);
    display: flex; flex-direction: column;
    animation: fvFade 0.15s ease-out;
}
@keyframes fvFade { from { opacity: 0; } to { opacity: 1; } }

.fv-topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 18px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.fv-title { font-size: 13px; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fv-actions { display: flex; gap: 8px; }
.fv-actions .btn {
    color: #fff; border-color: rgba(255,255,255,0.18);
    background: rgba(255,255,255,0.06);
}
.fv-actions .btn:hover { background: rgba(255,255,255,0.14); }
.fv-body {
    flex: 1; display: flex; align-items: stretch; justify-content: center;
    overflow: hidden;
}
.fv-iframe {
    width: 100%; height: 100%;
    border: none; background: #fff;
}
.fv-text-wrap {
    width: 92vw; max-width: 1100px; height: 100%;
    display: flex; flex-direction: column;
    padding: 16px; gap: 10px;
}
.fv-text {
    flex: 1;
    background: #151515; color: #e9edf1;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    padding: 14px 16px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px; line-height: 1.55;
    resize: none;
    outline: none;
}
.fv-text-hint { color: rgba(255,255,255,0.5); font-size: 11.5px; text-align: right; }
.fv-dirty-dot {
    color: #f39c12; font-size: 16px;
    margin-left: 6px; vertical-align: middle;
    animation: fvDirtyPulse 1.2s ease-in-out infinite;
}
@keyframes fvDirtyPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.fv-save { background: var(--primary); color: #fff; border-color: var(--primary); }
.fv-save:disabled { opacity: 0.45; cursor: not-allowed; }
.fv-text[readonly] { opacity: 0.88; cursor: default; }
.fv-unsupported {
    color: #fff; text-align: center;
    padding: 60px 40px;
    display: flex; flex-direction: column; align-items: center; gap: 14px;
}

/* ---------- Intake (public recipient page) ---------- */

.intake-page {
    max-width: 720px; margin: 40px auto; padding: 0 16px;
}
.intake-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
    margin-bottom: 20px;
}
.intake-header { text-align: center; margin-bottom: 24px; }
.intake-header .lock-icon { color: var(--primary); margin-bottom: 12px; display: inline-block; }
.intake-header h1 { font-size: 22px; margin-bottom: 6px; }
.intake-subtitle { color: var(--text-muted); font-size: 13px; }
.intake-explain {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
}
.intake-explain p { margin: 0 0 6px; color: var(--text); }
.intake-explain ol { padding-left: 20px; margin: 0; }
.intake-explain li { margin-bottom: 4px; }
.intake-form .form-group { margin-bottom: 16px; }
.intake-form textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 14px; font-family: inherit;
    background: var(--surface2); color: var(--text); resize: vertical;
}
.intake-form textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-dim); }
.intake-passphrase-callout {
    background: linear-gradient(135deg, rgba(46,204,113,0.10), rgba(108,92,231,0.06));
    border: 1px solid rgba(46,204,113,0.35);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}
.intake-pp-label { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.6px; margin-bottom: 8px; }
.intake-pp-value {
    font-family: monospace; font-size: 16px;
    background: var(--surface); padding: 10px 14px; border-radius: 8px;
    border: 1px dashed var(--border);
    margin-bottom: 12px;
    word-break: break-all;
}
.intake-pp-warn {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text);
    line-height: 1.5;
}

/* ---------- Intake Inbox (owner view) ---------- */

.intake-inbox { max-width: 900px; }
.intake-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}
.intake-head h2 { font-size: 20px; margin-bottom: 4px; }
.intake-head p { color: var(--text-muted); font-size: 13px; max-width: 640px; }

.intake-section-head {
    font-size: 12px; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin: 24px 0 10px;
}
.intake-empty {
    color: var(--text-muted); font-size: 13px;
    padding: 14px; background: var(--surface2);
    border: 1px dashed var(--border); border-radius: 8px;
}

.intake-submissions, .intake-links {
    display: flex; flex-direction: column; gap: 10px;
}
.intake-submission {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.intake-submission-head {
    padding: 12px 14px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
}
.intake-sub-link { font-weight: 600; font-size: 14px; }
.intake-sub-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.intake-submission-body { padding: 12px 14px; }
.intake-passphrase-row { display: flex; gap: 8px; }
.intake-pp-input {
    flex: 1; padding: 8px 12px;
    border: 1px solid var(--border); border-radius: 6px;
    font-size: 13px; background: var(--surface2);
}
.intake-pp-error { color: var(--danger); font-size: 12px; margin: 6px 0 0; min-height: 14px; }
.intake-decoded { margin-top: 12px; }
.intake-decoded-block {
    border: 1px solid rgba(46,204,113,0.35);
    background: rgba(46,204,113,0.05);
    border-radius: 8px;
    padding: 14px;
}
.intake-decoded-title { font-size: 15px; margin-bottom: 8px; }
.intake-decoded-notes {
    font-size: 13px; color: var(--text);
    background: var(--surface); padding: 10px; border-radius: 6px;
    margin-bottom: 10px; white-space: pre-wrap;
    max-height: 260px; overflow-y: auto;
}
.intake-decoded-files ul { margin: 6px 0 12px; padding-left: 0; list-style: none; }
.intake-decoded-files li { font-size: 12px; padding: 4px 0; }
.intake-accept-row { display: flex; gap: 8px; align-items: center; }
.intake-accept-row select { flex: 1; }

.intake-link-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 14px;
}
.intake-link-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 8px;
}
.intake-link-count {
    font-size: 11px; color: var(--text-muted);
    background: var(--surface2); border-radius: 999px; padding: 2px 10px;
}
.intake-link-url {
    display: flex; gap: 8px; align-items: center;
    margin-bottom: 10px;
}
.intake-link-url input {
    flex: 1; font-family: monospace; font-size: 12px;
    padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface2); color: var(--text);
}
.intake-link-foot {
    display: flex; justify-content: space-between; align-items: center;
    color: var(--text-muted); font-size: 11px;
}

.intake-inactive-wrap { margin-top: 20px; }
.intake-inactive-wrap summary { cursor: pointer; color: var(--text-muted); font-size: 12px; padding: 8px 0; }
.intake-inactive-list { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; }
.intake-inactive-row {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 6px 10px; background: var(--surface2); border-radius: 6px;
    font-size: 12px; color: var(--text-muted);
}

.attachment-row-image {
    gap: 14px;
}
.attachment-thumb-link {
    flex-shrink: 0;
    display: block;
    line-height: 0;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg);
}
.attachment-thumb {
    display: block;
    width: 72px;
    height: 72px;
    object-fit: cover;
    transition: transform 0.15s ease;
}
.attachment-thumb-link:hover .attachment-thumb { transform: scale(1.03); }

.attachments-droppable {
    min-height: 48px;
    border-radius: 8px;
    transition: background 0.15s ease, outline-color 0.15s ease;
    outline: 2px dashed transparent;
    outline-offset: -2px;
    padding: 2px;
}
.attachments-droppable.drop-hover {
    outline-color: var(--primary);
    background: var(--primary-dim);
}

.attachment-thumb-link {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0;
    cursor: zoom-in;
    overflow: hidden;
    line-height: 0;
    flex-shrink: 0;
    transition: border-color 0.15s ease;
}
.attachment-thumb-link:hover { border-color: var(--primary); }
.attachment-thumb-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Image Lightbox ---------- */

.img-lightbox {
    position: fixed; inset: 0;
    z-index: 400;
    background: rgba(0,0,0,0.92);
    display: flex; align-items: center; justify-content: center;
    animation: ilbFade 0.15s ease-out;
    user-select: none;
}
@keyframes ilbFade { from { opacity: 0; } to { opacity: 1; } }

.img-lightbox .ilb-stage {
    max-width: 92vw; max-height: 88vh;
    display: flex; flex-direction: column;
    align-items: center; gap: 12px;
    padding: 12px;
}
.img-lightbox .ilb-img {
    max-width: 90vw; max-height: 78vh;
    object-fit: contain;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
    background: #111;
    border-radius: 6px;
}
.img-lightbox .ilb-caption {
    color: #e9edf1;
    font-size: 13px;
    background: rgba(0,0,0,0.55);
    padding: 6px 14px;
    border-radius: 999px;
    display: flex; gap: 14px; align-items: center;
    max-width: 90vw;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.img-lightbox .ilb-count { color: #9ff0c4; font-weight: 600; font-size: 12px; }
.img-lightbox .ilb-name { overflow: hidden; text-overflow: ellipsis; }

.img-lightbox .ilb-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 56px; height: 56px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    color: #fff; border: 1px solid rgba(255,255,255,0.18);
    font-size: 22px; cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    display: flex; align-items: center; justify-content: center;
}
.img-lightbox .ilb-nav:hover { background: rgba(255,255,255,0.18); }
.img-lightbox .ilb-nav:active { transform: translateY(-50%) scale(0.94); }
.img-lightbox .ilb-prev { left: 24px; }
.img-lightbox .ilb-next { right: 24px; }

.img-lightbox .ilb-close {
    position: absolute; top: 18px; right: 18px;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    color: #fff; border: 1px solid rgba(255,255,255,0.18);
    font-size: 24px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
}
.img-lightbox .ilb-close:hover { background: rgba(255,255,255,0.18); }

.img-lightbox .ilb-download {
    position: absolute; top: 18px; right: 70px;
    background: rgba(255,255,255,0.08);
    color: #fff !important;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 50%;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    text-decoration: none;
}
.img-lightbox .ilb-download:hover { background: rgba(255,255,255,0.18); }

@media (max-width: 640px) {
    .img-lightbox .ilb-nav { width: 42px; height: 42px; font-size: 18px; }
    .img-lightbox .ilb-prev { left: 8px; }
    .img-lightbox .ilb-next { right: 8px; }
    .img-lightbox .ilb-img { max-height: 70vh; }
}
