/* ==========================================================================
   Glassy Bookmarks — light Glassmorphism design system
   Bright surfaces, layered translucent panels, controlled blur, subtle
   edge highlights, restrained cool indigo accents. No dark glass.
   ========================================================================== */

:root {
    /* Bright, cool backdrops */
    --bg-1: #eaf2ff;
    --bg-2: #f4f0ff;
    --bg-3: #eefaf6;
    --ink: #1c2540;
    --ink-soft: #4c5a78;
    --ink-faint: #7d8aa5;

    /* Cool restrained accent */
    --accent: #3b5bdb;
    --accent-deep: #2f4bc0;
    --accent-soft: #dde5ff;
    --danger: #c0392b;
    --ok: #1d8a5f;
    --warn: #9a6b15;

    /* Glass tokens */
    --glass: rgba(255, 255, 255, 0.62);
    --glass-strong: rgba(255, 255, 255, 0.78);
    --glass-border: rgba(255, 255, 255, 0.75);
    --edge: inset 0 1px 0 rgba(255, 255, 255, 0.85), inset 0 0 0 1px rgba(255, 255, 255, 0.35);
    --shadow-sm: 0 2px 8px rgba(28, 37, 64, 0.06), 0 12px 28px rgba(59, 91, 219, 0.07);
    --shadow-lift: 0 6px 16px rgba(28, 37, 64, 0.08), 0 20px 44px rgba(59, 91, 219, 0.12);

    --blur: 16px;
    --radius: 18px;
    --radius-sm: 12px;
    --speed: 180ms;
    --font: "Inter", "SF Pro Text", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    background: linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 46%, var(--bg-3) 100%) fixed;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Background decoration (soft blurred orbs) ---------- */
.bg-decor { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-decor span {
    position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55;
    background: radial-gradient(circle at 30% 30%, #cfe0ff, transparent 70%);
}
.bg-decor span:nth-child(1) { width: 44vw; height: 44vw; top: -12vw; left: -8vw; }
.bg-decor span:nth-child(2) { width: 36vw; height: 36vw; top: 30vh; right: -12vw; background: radial-gradient(circle at 30% 30%, #e6dcff, transparent 70%); }
.bg-decor span:nth-child(3) { width: 30vw; height: 30vw; bottom: -10vw; left: 28vw; background: radial-gradient(circle at 30% 30%, #d2f4e8, transparent 70%); }

/* ---------- Glass primitives ---------- */
.glass {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--edge), var(--shadow-sm);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(1.35);
    backdrop-filter: blur(var(--blur)) saturate(1.35);
}

/* ---------- Layout ---------- */
.app { min-height: 100vh; }
.topbar {
    position: sticky; top: 12px; z-index: 40;
    margin: 12px 18px 0; padding: 10px 16px;
    display: flex; align-items: center; gap: 14px;
}
.sidebar {
    position: fixed; top: 86px; left: 18px; bottom: 18px; width: 232px;
    padding: 16px 12px; display: flex; flex-direction: column; gap: 8px; z-index: 30;
}
.main {
    margin-left: 274px; margin-top: 22px; margin-right: 22px; margin-bottom: 56px;
    max-width: 1180px;
    display: flex; flex-direction: column; gap: 18px;
}

/* ---------- Top bar ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
    width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
    color: var(--accent); background: linear-gradient(145deg, #fff, var(--accent-soft));
    box-shadow: var(--edge), 0 4px 10px rgba(59, 91, 219, 0.22);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-weight: 700; letter-spacing: -0.01em; font-size: 16px; }

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

.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 999px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: rgba(255,255,255,.55); }
.avatar {
    width: 32px; height: 32px; border-radius: 999px; display: grid; place-items: center;
    font-weight: 700; font-size: 14px; color: #fff;
    background: linear-gradient(145deg, var(--accent), #7a8ff0);
    box-shadow: var(--edge);
}
.avatar-name { font-weight: 600; font-size: 13.5px; color: var(--ink-soft); }
.menu {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 160px; padding: 6px; z-index: 50;
    animation: pop var(--speed) ease;
}
.menu-item {
    width: 100%; text-align: left; background: none; border: 0; font: inherit; cursor: pointer;
    padding: 9px 12px; border-radius: var(--radius-sm); color: var(--ink);
}
.menu-item:hover { background: var(--accent-soft); }

/* ---------- Sidebar nav ---------- */
.sidenav { display: flex; flex-direction: column; gap: 6px; }
.sidenav-item {
    display: flex; align-items: center; gap: 12px; text-decoration: none;
    padding: 10px 12px; border-radius: 14px; color: var(--ink-soft); font-weight: 600; font-size: 14px;
    border: 1px solid transparent; transition: background var(--speed), color var(--speed), transform var(--speed);
}
.sidenav-item:hover { background: rgba(255,255,255,.65); color: var(--ink); transform: translateX(2px); }
.sidenav-item.active {
    color: var(--accent-deep);
    background: linear-gradient(145deg, rgba(255,255,255,.9), var(--accent-soft));
    border-color: rgba(255,255,255,.9);
    box-shadow: var(--edge), 0 6px 14px rgba(59,91,219,.14);
}
.nav-icon { width: 20px; height: 20px; display: grid; place-items: center; flex: 0 0 auto; }
.nav-icon svg { width: 19px; height: 19px; }
.sidebar-footnote { margin: auto 8px 4px; font-size: 11.5px; color: var(--ink-faint); }

.menu-toggle { display: none; }
.sidebar-scrim { display: none; }

/* ---------- Page scaffolding ---------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; padding: 4px 4px 0; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.page-sub { margin: 4px 0 0; color: var(--ink-faint); font-size: 14px; }
.crumb {
    font-size: 12.5px; font-weight: 600; color: var(--accent); text-decoration: none;
    display: inline-block; margin-bottom: 6px;
}
.crumb:hover { text-decoration: underline; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
    padding: 10px 18px; border-radius: 13px; text-decoration: none; border: 1px solid transparent;
    transition: transform var(--speed), box-shadow var(--speed), background var(--speed);
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary {
    color: #fff; background: linear-gradient(145deg, var(--accent), var(--accent-deep));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 8px 20px rgba(59,91,219,.28);
}
.btn-primary:hover { box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 10px 26px rgba(59,91,219,.38); transform: translateY(-1px); }
.btn-ghost {
    color: var(--accent-deep); background: rgba(255,255,255,.6);
    border-color: rgba(255,255,255,.85); box-shadow: var(--edge);
}
.btn-ghost:hover { background: rgba(255,255,255,.85); transform: translateY(-1px); }
.btn-danger { color: var(--danger); background: rgba(255, 236, 232, .8); border-color: rgba(255,255,255,.8); }
.btn-danger:hover { background: rgba(255, 224, 218, .95); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; margin-top: 6px; }
.btn svg { width: 17px; height: 17px; }

.icon-btn {
    display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
    color: var(--ink-soft); background: transparent; border: 0; cursor: pointer;
    transition: background var(--speed), color var(--speed);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: rgba(255,255,255,.8); color: var(--ink); }
.icon-btn.danger:hover { color: var(--danger); background: rgba(255, 236, 232, .9); }
.fav-btn:hover, .fav-btn.on { color: #dea911; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field label { font-size: 13px; font-weight: 700; color: var(--ink-soft); letter-spacing: .01em; }
.field-hint { margin: 0; font-size: 12.5px; color: var(--ink-faint); }
.field input, .field select, .field textarea, select, input[type="text"], input[type="search"], input[type="url"], input[type="password"], textarea {
    font: inherit; color: var(--ink);
    padding: 10px 14px; border-radius: 12px; border: 1px solid rgba(158, 175, 214, .45);
    background: rgba(255,255,255,.72); min-width: 0;
    transition: border-color var(--speed), box-shadow var(--speed), background var(--speed);
}
.field input:focus, .field select:focus, .field textarea:focus, select:focus, input:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 91, 219, .18);
    background: #fff;
}
.field.invalid input, .field.invalid textarea, .field.invalid select { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(192,57,43,.12); }
textarea { resize: vertical; }
.check-row { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; color: var(--ink-soft); margin: 4px 0 16px; cursor: pointer; }
.check-row input { width: 17px; height: 17px; accent-color: var(--accent); }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.form-alert { border-radius: 14px; padding: 12px 16px; margin-bottom: 14px; font-size: 14px; }
.form-alert.error {
    background: rgba(255, 236, 232, .85); border: 1px solid rgba(192,57,43,.25); color: #7c2d20;
}
.form-alert ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Panels / sections ---------- */
.panel { padding: 22px 24px; }
.panel h2, .comments h2 { margin: 0 0 10px; font-size: 17px; letter-spacing: -0.01em; }
.narrow { max-width: 720px; }

/* ---------- Flash messages ---------- */
.flash {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 16px; border-radius: 14px; font-size: 14px; font-weight: 500;
    background: var(--glass-strong); box-shadow: var(--edge), var(--shadow-sm);
    border: 1px solid var(--glass-border);
    -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur));
    animation: slide-in 240ms ease;
}
.flash-success { border-color: rgba(29,138,95,.35); color: #14573b; }
.flash-error   { border-color: rgba(192,57,43,.35); color: #7c2d20; }
.flash-notice  { border-color: rgba(59,91,219,.3); color: var(--accent-deep); }
.flash-close { background: none; border: 0; font-size: 17px; cursor: pointer; color: inherit; opacity: .7; }
.flash-close:hover { opacity: 1; }

/* ---------- Library toolbar ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; }
.search-field { position: relative; flex: 1 1 260px; }
.search-field svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-faint); }
.search-field input { width: 100%; padding-left: 36px; }
.toolbar select { width: auto; }
.fav-toggle { display: inline-flex; gap: 8px; align-items: center; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.fav-toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- Bookmark cards ---------- */
.bulk-form { display: flex; flex-direction: column; gap: 14px; }
.bulk-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px 14px; }
.select-all { display: inline-flex; gap: 8px; align-items: center; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.select-all input { width: 16px; height: 16px; accent-color: var(--accent); }
.bulk-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.bulk-actions select { font-size: 13.5px; padding: 8px 10px; }

.library.grid {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px;
}
.bookmark-card {
    padding: 16px 18px 14px; display: flex; flex-direction: column; gap: 8px;
    transition: transform var(--speed), box-shadow var(--speed);
    transform-style: preserve-3d;
}
.bookmark-card:hover { transform: translateY(-3px); box-shadow: var(--edge), var(--shadow-lift); }
.card-top { display: flex; align-items: center; gap: 10px; }
.bulk-check { width: 16px; height: 16px; accent-color: var(--accent); }
.bulk-bar.has-selection { border-color: rgba(59, 91, 219, .4); }

/* Favicon stack: the letter sits underneath; the icon image covers it when it loads */
.favicon {
    position: relative;
    width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto; display: grid; place-items: center;
    background: linear-gradient(145deg, #fff, var(--accent-soft));
    box-shadow: var(--edge); color: var(--accent-deep); font-weight: 700; font-size: 13px;
}
.favicon::before { content: attr(data-initial); }
.favicon img { position: absolute; inset: 0; margin: auto; width: 17px; height: 17px; border-radius: 4px; z-index: 1; }
.favicon-lg { width: 46px; height: 46px; border-radius: 13px; font-size: 18px; }
.favicon-lg img { width: 26px; height: 26px; }
.card-top .spacer-fav { margin-left: auto; }
.pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; letter-spacing: .02em; }
.pill-ok { background: rgba(29,138,95,.12); color: var(--ok); }
.pill-warn { background: rgba(154,107,21,.14); color: var(--warn); }
.pill-danger { background: rgba(192,57,43,.12); color: var(--danger); }

.card-title { margin: 0; font-size: 15.5px; line-height: 1.35; letter-spacing: -0.01em; }
.card-title a { color: var(--ink); text-decoration: none; }
.card-title a:hover { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.card-url { margin: 0; font-size: 12.5px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-notes { margin: 0; font-size: 13.5px; color: var(--ink-soft); }
.card-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.chip {
    font-size: 12px; font-weight: 600; color: var(--accent-deep);
    background: rgba(221, 229, 255, .55); border: 1px solid rgba(255,255,255,.8);
    padding: 3px 10px; border-radius: 999px; text-decoration: none;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
    transition: background var(--speed);
}
.chip:hover { background: var(--accent-soft); }
.chip-folder { color: #0e6e63; background: rgba(209, 244, 232, .6); }
.chip.subtle { color: var(--ink-faint); background: rgba(255,255,255,.55); }

.card-actions { display: flex; align-items: center; gap: 4px; margin-top: auto; padding-top: 4px; border-top: 1px solid rgba(255,255,255,.65); }
.card-date { font-size: 12px; color: var(--ink-faint); }
.card-actions .spacer { flex: 1; }

/* ---------- Empty state ---------- */
.empty { padding: 40px 28px; text-align: center; }
.empty h2 { margin: 0 0 6px; font-size: 20px; }
.empty p { margin: 0 auto 16px; max-width: 560px; color: var(--ink-soft); }
.empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- Detail page ---------- */
.detail { padding: 24px 26px; display: flex; flex-direction: column; gap: 20px; }
.detail-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.detail-head-meta { flex: 1 1 260px; min-width: 0; }
.detail-title { margin: 0; font-size: 24px; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.detail-link { display: inline-block; font-size: 13.5px; color: var(--accent-deep); text-decoration: none; overflow-wrap: anywhere; }
.detail-link:hover { text-decoration: underline; }
.detail-link svg { width: 13px; height: 13px; }
.detail-meta { margin: 6px 0 0; font-size: 13px; color: var(--ink-faint); }
.fav-big { border-radius: 999px; }
.fav-big svg { width: 16px; height: 16px; }
.detail-facts { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; padding: 16px 18px; border-radius: 14px; background: rgba(255,255,255,.45); box-shadow: var(--edge); }
.detail-facts dt { font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 6px; }
.detail-facts dd { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-check { display: inline-flex; }
.detail-notes h2, .detail-actions h2 { font-size: 16px; margin: 0 0 8px; }
.detail-notes p { margin: 0; color: var(--ink-soft); }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 4px; }
.muted { color: var(--ink-faint); }
.muted a { color: var(--accent-deep); }

/* ---------- Comments ---------- */
.comments { padding: 22px 24px; }
.count-pill { font-size: 12px; color: var(--accent-deep); background: var(--accent-soft); border-radius: 999px; padding: 2px 9px; vertical-align: 2px; }
.comment-form { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin: 14px 0 6px; }
.comment-form textarea { flex: 1 1 300px; }
.comments-empty { margin: 8px 0 0; }
.comment-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.comment { padding: 12px 16px; border-radius: 14px; background: rgba(255,255,255,.55); box-shadow: var(--edge); }
.comment-body { margin: 0; color: var(--ink-soft); overflow-wrap: anywhere; }
.comment footer { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.comment time { font-size: 12px; color: var(--ink-faint); }
.comment footer form { margin-left: auto; }

/* ---------- Entity lists (folders / tags) ---------- */
.entity-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; max-width: 860px; }
.entity { display: flex; align-items: center; gap: 14px; padding: 12px 16px; flex-wrap: wrap; }
.icon-chip { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; box-shadow: var(--edge); background: linear-gradient(145deg, #fff, var(--accent-soft)); color: var(--accent-deep); flex: 0 0 auto; }
.icon-chip svg { width: 18px; height: 18px; }
.folder-accent { color: #0e6e63; background: linear-gradient(145deg, #fff, #d2f4e8); }
.entity .tag-accent { color: #8b52c9; background: linear-gradient(145deg, #fff, #e6dcff); }
.entity-slot { display: flex; align-items: center; gap: 10px; flex: 1 1 320px; min-width: 260px; }
.entity-slot input { flex: 1; font-weight: 600; }
.entity-actions { display: flex; gap: 8px; position: relative; }
.entity-actions form { position: relative; }

/* ---------- Import page ---------- */
.import-layout { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 18px; align-items: start; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; color: var(--ink-soft); }
.howto-note { margin: 14px 0 0; font-size: 12.5px; color: var(--ink-faint); }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form input { flex: 1 1 240px; }

/* ---------- Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 2px; transition: transform var(--speed), box-shadow var(--speed); }
.stat:hover { transform: translateY(-2px); box-shadow: var(--edge), var(--shadow-lift); }
.stat-num { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }
.stat-label { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-faint); }
.stat-link { margin-top: 8px; font-size: 12.5px; font-weight: 600; color: var(--accent-deep); text-decoration: none; }
.stat-link:hover { text-decoration: underline; }
.stat-warn .stat-num { color: var(--warn); }
.dash-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.mini-list li { display: flex; align-items: center; gap: 10px; }
.mini-title { flex: 1; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-title:hover { text-decoration: underline; }
.mini-date { font-size: 12px; color: var(--ink-faint); flex: 0 0 auto; }
.mini-note { margin: 2px 0 0; font-size: 13px; color: var(--ink-faint); flex-basis: 100%; }
.comments-mini li { flex-wrap: wrap; }
.mini-footnote { margin: 12px 0 0; font-size: 12.5px; color: var(--ink-faint); }
.bar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.bar-list li { display: flex; align-items: center; gap: 10px; }
.bar-list-name { flex: 0 0 34%; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-list-name:hover { color: var(--accent-deep); }
.bar-track { flex: 1; height: 8px; border-radius: 999px; background: rgba(221, 229, 255, .4); overflow: hidden; box-shadow: var(--edge); }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), #7a8ff0); }
.bar-num { flex: 0 0 34px; text-align: right; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.panel-cta p { color: var(--ink-soft); font-size: 14px; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 40px 18px; }
.auth-card { width: 100%; max-width: 430px; padding: 34px 34px 28px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.02em; }
.auth-sub { margin: 0 0 18px; font-size: 14px; color: var(--ink-faint); }
.auth-note { margin: 18px 0 0; font-size: 12.5px; color: var(--ink-faint); }
.error-card { text-align: center; }
.error-code { margin: 0; font-size: 44px; font-weight: 800; letter-spacing: -.03em; color: var(--accent); }

/* ---------- Animation & accessibility ---------- */
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Responsive: tablet & phone ---------- */
@media (max-width: 1024px) {
    .main { margin-left: 22px; }
    .sidebar { display: none; }
    .menu-toggle { display: inline-grid; }
    /* Drawer sidebar for small screens */
    .sidebar.open {
        display: flex; top: 80px; left: 12px; right: 12px; bottom: auto; width: auto; max-width: 360px;
        position: fixed; z-index: 60; padding: 14px;
    }
    .sidebar.open .sidebar-footnote { display: none; }
    .sidebar-scrim.show { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(28, 37, 64, .18); }
    .sidebar-scrim { background: rgba(28,37,64,.18); }
    .topbar { margin: 10px 12px 0; }
}

@media (min-width: 1025px) {
    .sidebar-scrim { display: none !important; }
}

@media (max-width: 720px) {
    .main { margin: 16px 12px 48px; }
    .library.grid { grid-template-columns: 1fr; }
    .dash-grid { grid-template-columns: 1fr; }
    .field-row { grid-template-columns: 1fr; }
    .import-layout { grid-template-columns: 1fr; }
    .detail-head { align-items: flex-start; }
    .avatar-name { display: none; }
    .page-head .btn { width: 100%; }
    .bulk-actions { margin-left: 0; width: 100%; }
    .bulk-actions select, .bulk-actions .btn { flex: 1 1 auto; }
}

/* ---------- Print: keep the library readable ---------- */
@media print {
    body { background: #fff; }
    .glass { box-shadow: none; background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; }
    .topbar, .sidebar, .toolbar, .bulk-bar, .flash, .bg-decor { display: none !important; }
    .main { margin: 0; }
}

/* ==========================================================================
   v1.1 — import preview, pager, toasts, command palette, mobile bottom nav
   ========================================================================== */

/* ---------- Small utilities ---------- */
.skip-link {
    position: absolute; left: 12px; top: -60px; z-index: 80;
    padding: 10px 16px; border-radius: 12px; background: #fff; color: var(--ink);
    font-weight: 700; text-decoration: none; box-shadow: var(--shadow-lift);
    transition: top var(--speed) ease;
}
.skip-link:focus { top: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.card-spacer { margin-left: auto; }
.indent-hint { margin: -8px 0 16px 26px; }

/* ---------- Topbar quick-jump ---------- */
.cmdk-trigger {
    display: inline-flex; align-items: center; gap: 9px; margin-left: 18px;
    padding: 8px 12px; border-radius: 12px; cursor: pointer; font: inherit; font-size: 13px;
    color: var(--ink-faint); background: rgba(255, 255, 255, .55);
    border: 1px solid rgba(255, 255, 255, .8); box-shadow: var(--edge);
    transition: background var(--speed), color var(--speed);
}
.cmdk-trigger:hover { background: rgba(255, 255, 255, .9); color: var(--ink); }
.cmdk-trigger svg { width: 15px; height: 15px; }
.cmdk-trigger kbd, .cmdk kbd {
    font: 600 10.5px/1 var(--font); padding: 3px 5px; border-radius: 5px;
    background: rgba(28, 37, 64, .07); color: var(--ink-faint);
}

/* ---------- Command palette ---------- */
.cmdk {
    width: min(560px, calc(100vw - 32px)); margin-top: 12vh; padding: 10px;
    border: 1px solid var(--glass-border); color: var(--ink); overflow: hidden;
}
.cmdk::backdrop { background: rgba(28, 37, 64, .32); backdrop-filter: blur(3px); }
.cmdk-search { display: flex; align-items: center; gap: 10px; padding: 6px 8px 12px; border-bottom: 1px solid rgba(120, 136, 190, .2); }
.cmdk-search svg { width: 18px; height: 18px; color: var(--ink-faint); flex: 0 0 auto; }
.cmdk-search input {
    flex: 1; border: 0 !important; box-shadow: none !important; background: transparent !important;
    padding: 8px 2px !important; font-size: 15px;
}
.cmdk-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: min(52vh, 420px); overflow-y: auto; }
.cmdk-list a {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 11px 12px; border-radius: 12px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px;
}
.cmdk-list a:hover, .cmdk-list a.active { background: var(--accent-soft); color: var(--accent-deep); }
.cmdk-list li[hidden] { display: none; }
.cmdk-list em { font-style: normal; color: var(--accent-deep); }
.cmdk-empty { padding: 14px 12px; color: var(--ink-faint); font-size: 14px; }

/* ---------- Toasts ---------- */
.toasts {
    position: fixed; right: 18px; bottom: 18px; z-index: 70;
    display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
    pointer-events: auto; padding: 11px 16px; border-radius: 13px; font-size: 13.5px; font-weight: 600;
    background: var(--glass-strong); border: 1px solid var(--glass-border); color: var(--ink);
    box-shadow: var(--shadow-lift); -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur));
    animation: slide-in 200ms ease;
}
.toast.ok { color: #14573b; }
.toast.err { color: #7c2d20; }

/* ---------- Import upload ---------- */
.import-form { display: flex; flex-direction: column; gap: 4px; }
.dropzone {
    position: relative; display: flex; flex-direction: column; align-items: center; text-align: center;
    gap: 6px; padding: 30px 20px; margin-bottom: 18px; cursor: pointer;
    border: 1.5px dashed rgba(120, 136, 190, .55); border-radius: var(--radius);
    background: rgba(255, 255, 255, .4);
    transition: border-color var(--speed), background var(--speed), transform var(--speed);
}
.dropzone:hover, .dropzone:focus-within { border-color: var(--accent); background: rgba(255, 255, 255, .7); }
.dropzone.is-dragging { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.01); }
.dropzone input[type="file"] {
    position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer;
    border: 0; padding: 0; background: transparent;
}
.dropzone-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
    color: var(--accent); background: linear-gradient(145deg, #fff, var(--accent-soft)); box-shadow: var(--edge); }
.dropzone-icon svg { width: 22px; height: 22px; }
.dropzone-title { font-weight: 700; font-size: 15px; }
.dropzone-sub { font-size: 12.5px; color: var(--ink-faint); }
.dropzone-file { margin-top: 6px; font-size: 12.5px; font-weight: 700; color: var(--accent-deep);
    background: var(--accent-soft); padding: 4px 10px; border-radius: 999px; word-break: break-all; }
.upload-limits { margin-top: 12px; }

/* ---------- Import preview ---------- */
.preview-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(290px, .85fr); gap: 18px; align-items: start; }
.preview-summary, .preview-options { display: flex; flex-direction: column; gap: 6px; }
.stat-grid-sm { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat-grid-sm .stat { padding: 14px 16px; }
.stat-grid-sm .stat-num { font-size: 24px; }
.preview-subhead { margin: 20px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
.preview-dates { margin: 14px 0 0; font-size: 13px; color: var(--ink-soft); }
.folder-preview { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.folder-preview li { display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, .5); font-size: 13.5px; }
.folder-path { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-count { font-weight: 700; color: var(--accent-deep); background: var(--accent-soft);
    border-radius: 999px; padding: 1px 9px; font-size: 12px; }
.sample-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sample-list li { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sample-title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sample-url { font-size: 12px; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Import history ---------- */
.import-history .panel-head { margin-bottom: 14px; }
.import-history h2 { margin: 0; }
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.history-item { display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 12px 14px; border-radius: 14px; background: rgba(255, 255, 255, .55); box-shadow: var(--edge); }
.history-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
    color: var(--accent-deep); background: linear-gradient(145deg, #fff, var(--accent-soft)); box-shadow: var(--edge); flex: 0 0 auto; }
.history-icon svg { width: 17px; height: 17px; }
.history-main { display: flex; flex-direction: column; gap: 2px; flex: 1 1 220px; min-width: 0; }
.history-main strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-meta { font-size: 12.5px; color: var(--ink-faint); }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; }
.pager-step { font-size: 13.5px; font-weight: 600; color: var(--accent-deep); text-decoration: none; padding: 6px 10px; border-radius: 10px; }
.pager-step:hover { background: var(--accent-soft); }
.pager-step.disabled { color: var(--ink-faint); opacity: .55; }
.pager-pages { display: flex; align-items: center; gap: 4px; flex: 1; justify-content: center; flex-wrap: wrap; }
.pager-pages a, .pager-current, .pager-gap {
    min-width: 34px; text-align: center; padding: 6px 8px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
    text-decoration: none; color: var(--ink-soft);
}
.pager-pages a:hover { background: var(--accent-soft); color: var(--accent-deep); }
.pager-current { background: var(--accent); color: #fff; box-shadow: 0 6px 14px rgba(59, 91, 219, .28); }
.pager-gap { color: var(--ink-faint); }

/* ---------- Entity rows after the nested-form fix ---------- */
.entity-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.entity-actions form { display: inline-flex; }
.entity-slot { flex: 1 1 260px; min-width: 220px; display: flex; align-items: center; gap: 8px; }

/* ---------- Bottom nav (mobile only) ---------- */
.bottom-nav { display: none; }

/* ---------- Fine-grained glass flourish ---------- */
.bookmark-card { position: relative; overflow: hidden; }
.bookmark-card::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
    background: linear-gradient(115deg, rgba(255,255,255,.55), rgba(255,255,255,0) 42%);
    transition: opacity var(--speed);
}
.bookmark-card:hover::after { opacity: 1; }

@media (max-width: 1024px) {
    .cmdk-trigger { display: none; }
    .bottom-nav {
        display: flex; position: fixed; left: 12px; right: 12px; z-index: 45;
        bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        padding: 6px; justify-content: space-around; gap: 2px;
        border-radius: 18px;
    }
    .bottom-nav-item {
        flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
        padding: 8px 4px 7px; border-radius: 13px; text-decoration: none;
        color: var(--ink-faint); font-weight: 600;
    }
    .bottom-nav-item .nav-icon svg { width: 20px; height: 20px; }
    .bottom-nav-label { font-size: 10.5px; letter-spacing: .01em; }
    .bottom-nav-item.active { color: var(--accent-deep); background: linear-gradient(145deg, rgba(255,255,255,.92), var(--accent-soft)); }
    .main { padding-bottom: 92px; }
    .toasts { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
    .preview-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .topbar { gap: 8px; }
    .brand-name { display: none; }
    .add-btn { padding-inline: 12px; }
    .page-head { gap: 10px; }
    .page-head h1 { font-size: 22px; }
    .toolbar { gap: 8px; padding: 10px; }
    .toolbar select { flex: 1 1 calc(50% - 8px); width: auto; min-width: 0; }
    .toolbar .btn { flex: 1 1 auto; }
    .search-field { flex-basis: 100%; }
    .detail { padding: 18px; }
    .detail-title { font-size: 20px; }
    .pager-pages { order: 3; flex-basis: 100%; }
    .history-item { flex-direction: column; align-items: flex-start; }
    .history-item form { width: 100%; }
    .history-item .btn { width: 100%; }
    .stat-grid-sm { grid-template-columns: 1fr 1fr; }
    .toasts { left: 12px; right: 12px; }
    .toast { text-align: center; }
}

@media (max-width: 420px) {
    .stat-grid-sm { grid-template-columns: 1fr; }
    .bulk-bar { gap: 8px; }
}
