:root {
    --navy: #10102b;
    --navy-2: #191942;
    --purple: #7167f0;
    --purple-soft: #eceaff;
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #202339;
    --muted: #737892;
    --border: #e7e9f2;
    --danger: #e34557;
    --success: #28b487;
    --shadow: 0 16px 45px rgba(31, 35, 68, .10);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}
button, input, textarea, select { font: inherit; }

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 20% 20%, #dfddff, transparent 32%), var(--bg);
}
.login-card {
    width: min(420px, calc(100vw - 32px));
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 34px;
    box-shadow: var(--shadow);
}
.login-card h1 { margin: 14px 0 6px; }
.login-card p { margin: 0 0 26px; color: var(--muted); }
.login-card label { display: block; margin: 14px 0 7px; font-weight: 700; font-size: 14px; }
.login-card input, .modal input, .modal textarea, .modal select, .prompt-panel textarea, .quick-jump {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 13px;
    background: #fff;
    outline: none;
}
.login-card input:focus, .modal input:focus, .modal textarea:focus, .modal select:focus, .prompt-panel textarea:focus, .quick-jump:focus {
    border-color: var(--purple);
    box-shadow: 0 0 0 4px rgba(113,103,240,.12);
}

.brand-mark {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 900;
    background: linear-gradient(145deg, #8179ff, #23234d);
    box-shadow: inset 0 0 0 8px rgba(255,255,255,.16);
}
.brand-mark.small { width: 32px; height: 32px; border-radius: 9px; font-size: 13px; }
.sidebar-logo {
    width: min(240px, 88%);
    height: auto;
    max-height: 240px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.app-shell { display: flex; min-height: 100vh; align-items: flex-start; }
.sidebar {
    width: 340px;
    background: var(--navy);
    color: #fff;
    padding: 30px 16px 22px;
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
}
.sidebar-brand {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    margin-bottom: 22px;
    padding: 0 0 8px;
    flex: 0 0 auto;
}
.sidebar-section-title {
    color: rgba(255,255,255,.45);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin: 20px 8px 8px;
}
.quick-jump { background: var(--navy-2); color: #fff; border-color: rgba(255,255,255,.08); }
.category-tree { display: grid; gap: 4px; }
.cat-node { margin-left: calc(var(--depth) * 13px); }
.cat-row {
    display: grid;
    grid-template-columns: 1fr 34px;
    align-items: center;
    gap: 4px;
    border-radius: 10px;
}
.cat-row:hover, .cat-row.active { background: rgba(113,103,240,.20); color: #fff; }
.cat-btn {
    width: 100%;
    min-width: 0;
    border: 0;
    color: rgba(255,255,255,.75);
    background: transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 10px;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
}
.cat-row:hover .cat-btn, .cat-row.active .cat-btn { color: #fff; }
.cat-btn span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cat-delete-btn {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: rgba(255,255,255,.38);
    cursor: pointer;
    display: grid;
    place-items: center;
    opacity: .25;
}
.cat-row:hover .cat-delete-btn { opacity: 1; }
.cat-delete-btn:hover {
    background: rgba(227,69,87,.18);
    color: #ff8d9a;
}
.cat-count { opacity: .65; font-size: 12px; flex: 0 0 auto; }
.sidebar-actions { display: grid; gap: 10px; margin-top: 22px; }

.main { margin-left: 340px; padding: 24px; width: calc(100% - 340px); }
.topbar {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 8px 26px rgba(31,35,68,.05);
}
.topbar h1 { font-size: 24px; margin: 0 0 4px; }
.topbar p { margin: 0; color: var(--muted); }
.icon-btn, .mini-btn {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 10px;
    cursor: pointer;
    padding: 8px 10px;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin: 20px 0;
}
.stat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 8px 26px rgba(31,35,68,.05);
}
.stat-card span { color: var(--muted); font-weight: 700; font-size: 13px; }
.stat-card strong { display: block; font-size: 30px; margin-top: 8px; }
.content-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 8px 26px rgba(31,35,68,.05);
    padding: 20px;
}
.content-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.content-header h2 { margin: 0 0 5px; }
.content-header p { margin: 0; color: var(--muted); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.btn {
    border: 0;
    border-radius: 10px;
    padding: 11px 14px;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--purple); color: #fff; }
.btn-soft { background: var(--purple-soft); color: #4d47b8; }
.btn-danger { background: #ffe9ec; color: var(--danger); }
.full { width: 100%; }
.alert { padding: 12px; border-radius: 10px; margin-bottom: 16px; font-weight: 700; }
.alert-error { background: #ffe9ec; color: var(--danger); }
.snippet-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding-top: 18px;
}
.snippet-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    background: #fff;
}
.snippet-card h3 { margin: 0 0 8px; }
.snippet-card p { color: var(--muted); white-space: pre-wrap; line-height: 1.45; }
.snippet-badge { display: inline-block; margin-bottom: 10px; color: var(--success); background: #e9fff7; border-radius: 8px; padding: 5px 8px; font-weight: 800; font-size: 12px; }
.empty-state { display: block; color: var(--muted); }

.prompt-bubble {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 50;
    border: 0;
    background: var(--purple);
    color: #fff;
    border-radius: 16px;
    padding: 15px 18px;
    font-weight: 900;
    box-shadow: var(--shadow);
    cursor: pointer;
}
.prompt-panel {
    position: fixed;
    right: 22px;
    bottom: 82px;
    z-index: 60;
    width: min(520px, calc(100vw - 32px));
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.prompt-panel.minimised .prompt-panel-body, .prompt-panel.minimised .prompt-panel-footer { display: none; }
.prompt-panel-header, .prompt-panel-footer {
    padding: 14px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.prompt-panel-footer { border-top: 1px solid var(--border); border-bottom: 0; }
.prompt-panel-body { padding: 14px; display: grid; gap: 10px; }
.prompt-panel textarea { min-height: 85px; resize: vertical; }
#promptOutput { min-height: 170px; }
.prompt-items { display: grid; gap: 8px; max-height: 160px; overflow-y: auto; }
.prompt-item {
    border: 1px solid var(--border);
    background: #fafbff;
    border-radius: 10px;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}
.prompt-item span { font-weight: 800; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 9, 28, .55);
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 20px;
}
.modal {
    width: min(680px, 100%);
    background: #fff;
    border-radius: 18px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.modal-header {
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; }
.modal-body { padding: 18px; display: grid; gap: 12px; }
.modal textarea { min-height: 180px; resize: vertical; }
.danger-modal-icon {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: #ffe9ec;
    color: var(--danger);
    font-size: 30px;
    font-weight: 900;
}
.modal-warning-title {
    margin: 0;
    font-size: 20px;
    font-weight: 900;
    color: var(--text);
}
.modal-warning-text {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}
.modal-actions-split { justify-content: space-between; }
.checkbox-row { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.checkbox-row input { width: auto; }

.modal-help-text {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}
.category-check-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.category-check-list {
    display: grid;
    gap: 8px;
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;
    background: #fafbff;
}
.category-check-row {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid var(--border);
    font-weight: 800;
}
.category-check-row input {
    width: auto;
}
.category-check-row.is-disabled {
    opacity: .58;
}
.category-check-note {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 200;
    background: #181936;
    color: #fff;
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: var(--shadow);
}
.hidden { display: none !important; }

@media (max-width: 980px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: translateX(0); z-index: 80; }
    .main { margin-left: 0; width: 100%; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .snippet-grid { grid-template-columns: 1fr; }
    .content-header { flex-direction: column; }
}
@media (max-width: 560px) {
    .stats-grid { grid-template-columns: 1fr; }
}

.type-filter {
    width: auto;
    min-width: 190px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 13px;
    background: #fff;
    outline: none;
    font-weight: 800;
    color: var(--text);
}
.type-filter:focus {
    border-color: var(--purple);
    box-shadow: 0 0 0 4px rgba(113,103,240,.12);
}
.snippet-card {
    position: relative;
    padding-top: 44px;
}
.snippet-type-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--type-colour) 16%, white);
    color: var(--type-colour);
    border: 1px solid color-mix(in srgb, var(--type-colour) 35%, white);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.snippet-type-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--type-colour);
}
.type-manager-list {
    display: grid;
    gap: 10px;
    max-height: 360px;
    overflow-y: auto;
}
.type-manager-row {
    display: grid;
    grid-template-columns: 18px 1fr 110px auto auto;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;
    background: #fafbff;
}
.type-manager-row small {
    color: var(--muted);
    font-weight: 800;
}
.type-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--type-colour);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--type-colour) 18%, transparent);
}

@media (min-width: 981px) {
    .stats-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
    .type-manager-row { grid-template-columns: 18px 1fr; }
    .type-manager-row small,
    .type-manager-row button { grid-column: 2; }
    .type-filter { width: 100%; }
}

/* v6 icon action buttons + stylish collapsible category tree */
.cat-row {
    grid-template-columns: 28px 1fr 34px;
    position: relative;
}
.cat-toggle {
    width: 26px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: rgba(255,255,255,.48);
    display: grid;
    place-items: center;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: transform .18s ease, background .18s ease, color .18s ease;
}
.cat-toggle:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}
.cat-toggle.no-children {
    cursor: default;
    opacity: .28;
    font-size: 12px;
}
.cat-toggle.no-children:hover {
    background: transparent;
    color: rgba(255,255,255,.48);
}
.cat-node.is-expanded > .cat-row .cat-toggle:not(.no-children) {
    transform: rotate(90deg);
    color: #fff;
}
.cat-children {
    display: grid;
    gap: 4px;
    margin-top: 4px;
    border-left: 1px solid rgba(255,255,255,.08);
    margin-left: 13px;
    padding-left: 4px;
}
.cat-node.is-collapsed > .cat-children {
    display: none;
}
.cat-node.has-children > .cat-row::after {
    content: '';
    position: absolute;
    left: 14px;
    bottom: -5px;
    width: 1px;
    height: 6px;
    background: rgba(255,255,255,.08);
}
.cat-btn {
    padding-left: 4px;
}
.cat-delete-btn.action-icon {
    width: 30px;
    height: 30px;
    min-width: 30px;
    padding: 0;
    border: 0;
}

.snippet-card {
    padding-bottom: 62px;
    min-height: 220px;
}
.snippet-actions {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
}
.action-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border: 1px solid var(--border);
    border-radius: 12px;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    position: relative;
    padding: 0;
    background: #fff;
    color: var(--muted);
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease, color .16s ease, border-color .16s ease;
}
.action-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}
.action-icon:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(31,35,68,.10);
}
.primary-icon {
    background: var(--purple);
    border-color: var(--purple);
    color: #fff;
}
.soft-icon {
    background: var(--purple-soft);
    border-color: #dedaff;
    color: #4d47b8;
}
.danger-icon {
    background: #ffe9ec;
    border-color: #ffd0d7;
    color: var(--danger);
}
.action-icon[data-tooltip]::before,
.action-icon[data-tooltip]::after {
    position: absolute;
    left: 50%;
    opacity: 0;
    pointer-events: none;
    transition: opacity .14s ease, transform .14s ease;
    z-index: 500;
}
.action-icon[data-tooltip]::before {
    content: attr(data-tooltip);
    bottom: calc(100% + 10px);
    transform: translate(-50%, 6px);
    background: #181936;
    color: #fff;
    padding: 7px 9px;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    box-shadow: 0 10px 24px rgba(8,9,28,.20);
}
.action-icon[data-tooltip]::after {
    content: '';
    bottom: calc(100% + 5px);
    transform: translate(-50%, 6px);
    border: 6px solid transparent;
    border-top-color: #181936;
}
.action-icon[data-tooltip]:hover::before,
.action-icon[data-tooltip]:hover::after {
    opacity: 1;
    transform: translate(-50%, 0);
}
.cat-delete-btn[data-tooltip]::before {
    left: auto;
    right: 0;
    transform: translate(0, 6px);
}
.cat-delete-btn[data-tooltip]::after {
    left: auto;
    right: 10px;
    transform: translate(0, 6px);
}
.cat-delete-btn[data-tooltip]:hover::before,
.cat-delete-btn[data-tooltip]:hover::after {
    transform: translate(0, 0);
}
.type-manager-row {
    grid-template-columns: 18px 1fr 110px 38px 38px;
}
.type-manager-row .action-icon {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 10px;
}
.type-manager-row .action-icon svg {
    width: 16px;
    height: 16px;
}

@media (max-width: 680px) {
    .snippet-actions {
        position: static;
        margin-top: 14px;
        justify-content: flex-start;
    }
    .snippet-card {
        padding-bottom: 16px;
    }
}

/* v7 copied-text emphasis, compact toolbar icons, footer */
.snippet-copy-text {
    color: var(--text);
    white-space: pre-wrap;
    line-height: 1.5;
    background: #f7f8ff;
    border: 1px solid #e5e7fb;
    border-left: 4px solid var(--purple);
    border-radius: 12px;
    padding: 12px 13px;
    margin: 8px 0 0;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.85);
}
.snippet-card p {
    margin: 0;
}
.button-row {
    align-items: center;
}
.toolbar-icon {
    font-size: 18px;
    font-weight: 900;
}
.toolbar-icon:disabled {
    opacity: .38;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}
.toolbar-icon[data-tooltip]::before {
    bottom: calc(100% + 10px);
}
.site-footer {
    margin-left: 340px;
    padding: 18px 24px 24px;
    color: var(--muted);
    text-align: center;
    font-size: 13px;
    font-weight: 800;
}
.footer-made {
    margin-left: 8px;
}
.animated-heart {
    display: inline-block;
    transform-origin: center;
    animation: heartBeat 1.15s ease-in-out infinite;
}
@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    18% { transform: scale(1.22); }
    32% { transform: scale(.96); }
    48% { transform: scale(1.16); }
}
@media (max-width: 980px) {
    .site-footer {
        margin-left: 0;
    }
}
@media (max-width: 560px) {
    .footer-made {
        display: block;
        margin-left: 0;
        margin-top: 6px;
    }
}


/* v8 sidebar alignment and logo tidy-up */
.app-shell { align-items: flex-start; }
.sidebar {
    padding-top: 30px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
}
.sidebar-brand {
    align-items: flex-start;
    justify-content: center;
    margin-top: 0;
    margin-bottom: 22px;
    padding-top: 0;
}
.sidebar-logo {
    width: min(240px, 88%);
    height: auto;
    max-height: 240px;
    object-fit: contain;
}
.cat-row {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) 34px;
}

/* v9 view switching, stats modal, and quieter dashboard header */
.compact-topbar {
    margin-bottom: 18px;
}
.compact-topbar h1 {
    font-size: 20px;
}
.compact-topbar p {
    font-size: 13px;
}
.view-switch {
    display: inline-flex;
    gap: 6px;
    padding: 4px;
    background: #f6f5ff;
    border: 1px solid #e5e2ff;
    border-radius: 14px;
}
.view-switch .action-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 10px;
}
.view-switch .active-view {
    background: var(--purple);
    border-color: var(--purple);
    color: #fff;
    box-shadow: 0 10px 22px rgba(113,103,240,.22);
}
.snippet-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding-top: 18px;
}
.snippet-list .snippet-card {
    min-height: 0;
    padding: 14px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: stretch;
}
.snippet-list .snippet-main {
    min-width: 0;
}
.snippet-list .snippet-card h3 {
    margin: 2px 0 8px;
    font-size: 15px;
}
.snippet-list .snippet-copy-text {
    max-height: 120px;
    overflow: auto;
    margin-top: 6px;
}
.snippet-list .snippet-actions {
    position: static;
    align-self: start;
    justify-content: flex-end;
    flex-wrap: nowrap;
    min-width: max-content;
    margin-top: 58px;
}
.snippet-grid .snippet-main {
    min-width: 0;
}
.snippet-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.snippet-meta-row .snippet-type-badge,
.snippet-meta-row .snippet-badge {
    margin-bottom: 0;
}
.modal-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 14px 0 18px;
}
.modal-stats-grid .stat-card {
    box-shadow: none;
}
.modal-stats-grid .stat-card strong {
    font-size: 26px;
}
.toast {
    border: 1px solid rgba(255,255,255,.14);
    box-shadow: 0 18px 40px rgba(8,9,28,.22);
}
.modal-overlay:not(.hidden) {
    animation: modalFade .14s ease-out;
}
.modal {
    animation: modalPop .16s ease-out;
}
@keyframes modalFade {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes modalPop {
    from { transform: translateY(8px) scale(.98); opacity: .65; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
@media (max-width: 820px) {
    .snippet-list .snippet-card {
        grid-template-columns: 1fr;
    }
    .snippet-list .snippet-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    .modal-stats-grid {
        grid-template-columns: 1fr;
    }
}


/* v10 logo restore + prompt stats graphs */
.sidebar-brand {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 30px;
    margin-bottom: 20px;
}
.sidebar-logo {
    width: min(220px, 86%);
    max-width: 220px;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}
.expanded-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.stat-card .text-stat {
    font-size: 20px;
    line-height: 1.15;
    word-break: break-word;
}
.stats-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 16px 0 18px;
}
.stats-chart-card {
    background: #f8f7ff;
    border: 1px solid #e6e2ff;
    border-radius: 18px;
    padding: 16px;
}
.stats-chart-card h4 {
    margin: 0 0 14px;
    font-size: 14px;
    color: var(--navy);
}
.wide-chart {
    grid-column: 1 / -1;
}
.mini-chart {
    height: 160px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 8px 4px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #eeebff;
}
.mini-chart-bar-wrap {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    position: relative;
}
.mini-chart-bar {
    width: 100%;
    max-width: 34px;
    min-height: 8px;
    border-radius: 10px 10px 4px 4px;
    background: linear-gradient(180deg, #ff48ce, #7167f0);
    box-shadow: 0 10px 20px rgba(113,103,240,.2);
}
.mini-chart-bar-wrap span {
    font-size: 11px;
    color: #767391;
    font-weight: 800;
}
.mini-chart-empty {
    width: 100%;
    align-self: center;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
    padding: 12px;
}
@media (max-width: 900px) {
    .expanded-stats-grid,
    .stats-chart-grid {
        grid-template-columns: 1fr;
    }
    .wide-chart { grid-column: auto; }
}

/* v12 sidebar logo + category state fixes */
.sidebar {
    justify-content: flex-start !important;
    align-items: stretch !important;
    padding-top: 30px !important;
}
.sidebar-brand {
    width: 100% !important;
    min-height: 150px !important;
    max-height: 150px !important;
    height: 150px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 0 12px !important;
    flex: 0 0 150px !important;
    overflow: visible !important;
}
.sidebar-brand.logo-missing::after {
    content: "Add assets/logo.png";
    width: 130px;
    height: 130px;
    border-radius: 24px;
    border: 1px dashed rgba(255,255,255,.25);
    display: grid;
    place-items: center;
    text-align: center;
    color: rgba(255,255,255,.55);
    font-size: 12px;
    line-height: 1.3;
    padding: 12px;
}
.sidebar-logo {
    width: 150px !important;
    height: 150px !important;
    max-width: 150px !important;
    max-height: 150px !important;
    object-fit: contain !important;
    display: block !important;
    flex: 0 0 auto !important;
}
.mini-sidebar-btn {
    width: calc(100% - 16px);
    margin: 0 8px 14px;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(255,255,255,.06);
    color: rgba(255,255,255,.85);
    font-weight: 800;
    font-size: 12px;
    letter-spacing: .02em;
    cursor: pointer;
    transition: background .16s ease, transform .16s ease, border-color .16s ease;
}
.mini-sidebar-btn:hover {
    background: rgba(113,103,240,.24);
    border-color: rgba(113,103,240,.5);
    transform: translateY(-1px);
}
.category-tree {
    align-content: start;
}
.cat-node.is-collapsed > .cat-children {
    display: none;
}
.cat-node.is-expanded > .cat-children {
    display: grid;
    gap: 4px;
    animation: catExpand .14s ease-out;
}
@keyframes catExpand {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}


/* v14 wider stats dashboard modal */
.modal.modal-wide {
    width: min(1280px, calc(100vw - 48px)) !important;
    max-height: calc(100vh - 48px) !important;
    display: flex !important;
    flex-direction: column !important;
}
.modal.modal-wide .modal-header {
    flex: 0 0 auto !important;
}
.modal.modal-wide .modal-body {
    overflow-y: auto !important;
    max-height: calc(100vh - 132px) !important;
    padding: 24px !important;
}
.modal.modal-wide .modal-help-text {
    margin-bottom: 4px !important;
}
.modal.modal-wide .expanded-stats-grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(180px, 1fr)) !important;
    gap: 14px !important;
    margin: 14px 0 18px !important;
}
.modal.modal-wide .modal-stats-grid .stat-card {
    padding: 16px 18px !important;
    min-height: 92px !important;
}
.modal.modal-wide .modal-stats-grid .stat-card strong {
    font-size: 26px !important;
}
.modal.modal-wide .stats-chart-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 14px !important;
    margin: 12px 0 10px !important;
}
.modal.modal-wide .stats-chart-card {
    min-height: 245px !important;
    padding: 16px !important;
}
.modal.modal-wide .stats-chart-card.wide-chart {
    grid-column: 1 / -1 !important;
    min-height: 245px !important;
}
.modal.modal-wide .mini-chart {
    height: 170px !important;
}
@media (max-width: 980px) {
    .modal.modal-wide {
        width: calc(100vw - 24px) !important;
        max-height: calc(100vh - 24px) !important;
    }
    .modal.modal-wide .modal-body {
        max-height: calc(100vh - 108px) !important;
        padding: 18px !important;
    }
    .modal.modal-wide .expanded-stats-grid,
    .modal.modal-wide .stats-chart-grid {
        grid-template-columns: 1fr !important;
    }
    .modal.modal-wide .stats-chart-card.wide-chart {
        grid-column: auto !important;
    }
}


/* v15 fixes */
.page-static-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--purple);
    font-size: 21px;
    font-weight: 900;
    box-shadow: 0 8px 18px rgba(31, 35, 68, .06);
}

.prompt-panel.minimised {
    display: none;
}

.prompt-bubble.is-minimised {
    background: #18183e;
    padding-left: 46px;
    position: fixed;
}

.prompt-bubble.is-minimised::before {
    content: "↗";
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 8px;
    background: rgba(255,255,255,.16);
    display: grid;
    place-items: center;
    font-size: 13px;
}

.prompt-panel.hidden {
    display: none;
}


/* v16 OpenAI magic wand button */
.btn-ai {
    background: #fff1ff;
    color: #8b1cf6;
    border: 1px solid #efd5ff;
    min-width: 46px;
    font-size: 18px;
}

.btn-ai:hover {
    background: #f6e8ff;
    box-shadow: 0 10px 24px rgba(139, 28, 246, .14);
}

.btn-ai.is-loading {
    opacity: .65;
    cursor: wait;
}

.prompt-panel-footer {
    justify-content: flex-end;
}

.prompt-panel-footer .btn-ai {
    margin-right: auto;
}

/* v17 final polish */
#resetAiPromptBtn.hidden { display: none !important; }
#resetAiPromptBtn { min-width: 44px; padding-left: 14px; padding-right: 14px; font-size: 18px; }
@media(max-width: 900px) { .snippet-list .snippet-actions { margin-top: 8px; } }
