.explorer-dashboard {
    --explorer-ink: #28251f;
    --explorer-soft-ink: #6c665d;
    --explorer-gold: #b77b22;
    --explorer-gold-dark: #895a18;
    --explorer-cream: #fbf8f0;
    --explorer-line: #ded5c5;
    --explorer-panel: #ffffff;
    display: grid;
    gap: 20px;
    padding-bottom: 32px;
}

.explorer-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 26px 30px;
    border: 1px solid var(--explorer-line);
    border-radius: 18px;
    background:
        radial-gradient(circle at top right, rgba(183, 123, 34, .20), transparent 33%),
        linear-gradient(135deg, #171511, #29251e);
    color: #fff;
    box-shadow: 0 14px 34px rgba(45, 37, 24, .15);
}

.explorer-eyebrow {
    margin: 0 0 6px;
    color: var(--explorer-gold);
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.explorer-hero h1,
.workspace-heading h2,
.resource-library h2 {
    margin: 0;
}

.explorer-hero h1 {
    color: #fff;
    font-size: clamp(2rem, 4vw, 3.1rem);
    letter-spacing: -.035em;
}

.explorer-intro {
    margin: 8px 0 0;
    color: #d9d3c8;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.explorer-dashboard button {
    border: 1px solid var(--explorer-gold-dark);
    border-radius: 8px;
    padding: 9px 14px;
    background: var(--explorer-gold);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform .12s ease, filter .12s ease;
}

.explorer-dashboard button:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.explorer-dashboard .secondary-button {
    border-color: rgba(255,255,255,.25);
    background: rgba(255,255,255,.10);
}

.explorer-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 14px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 16px 18px;
    border: 1px solid var(--explorer-line);
    border-radius: 13px;
    background: var(--explorer-panel);
    box-shadow: 0 7px 20px rgba(58, 45, 27, .06);
}

.stat-icon {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 11px;
    background: #f3ead8;
    font-size: 1.25rem;
}

.stat-card strong,
.stat-card span {
    display: block;
}

.stat-card strong {
    color: var(--explorer-ink);
    font-size: 1.35rem;
}

.stat-card div span {
    color: var(--explorer-soft-ink);
    font-size: .82rem;
}

.collections-panel,
.knowledge-workspace {
    border: 1px solid var(--explorer-line);
    border-radius: 16px;
    background: var(--explorer-panel);
    box-shadow: 0 9px 26px rgba(58, 45, 27, .07);
    overflow: hidden;
}

.collections-panel > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 22px;
    background: var(--explorer-cream);
    cursor: pointer;
    list-style: none;
}

.collections-panel > summary::-webkit-details-marker {
    display: none;
}

.collections-panel > summary > div {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.summary-icon {
    color: var(--explorer-gold);
    font-size: 1.2rem;
    transition: transform .18s ease;
}

.collections-panel[open] .summary-icon {
    transform: rotate(90deg);
}

.summary-subtitle {
    color: var(--explorer-soft-ink);
    font-size: .88rem;
}

.summary-action {
    color: var(--explorer-gold-dark);
    font-size: .82rem;
    font-weight: 800;
}

.collections-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-top: 1px solid var(--explorer-line);
    border-bottom: 1px solid var(--explorer-line);
}

.resource-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.resource-tab {
    border-color: var(--explorer-line) !important;
    background: #fff !important;
    color: var(--explorer-soft-ink) !important;
}

.resource-tab.active {
    border-color: var(--explorer-gold) !important;
    background: #f5ead6 !important;
    color: var(--explorer-gold-dark) !important;
}

.resource-search,
.topic-search {
    display: grid;
    gap: 4px;
    min-width: min(320px, 100%);
    color: var(--explorer-soft-ink);
    font-size: .75rem;
    font-weight: 700;
}

.resource-search input,
.topic-search input,
.youtube-upload-card input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbc2b4;
    border-radius: 8px;
    padding: 9px 11px;
    background: #fff;
    color: var(--explorer-ink);
    font: inherit;
}

.upload-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(210px, 1fr));
    gap: 14px;
    padding: 20px;
    background: #fcfaf5;
}

.upload-card {
    padding: 17px;
    border: 1px solid var(--explorer-line);
    border-radius: 13px;
    background: #fff;
}

.upload-card-icon {
    font-size: 1.6rem;
}

.upload-card h2 {
    margin: 8px 0 3px;
    color: var(--explorer-ink);
    font-size: 1.05rem;
}

.upload-card > p {
    min-height: 34px;
    margin: 0 0 12px;
    color: var(--explorer-soft-ink);
    font-size: .8rem;
}

.drop-zone {
    display: grid;
    gap: 7px;
    place-items: center;
    min-height: 112px;
    padding: 13px;
    border: 2px dashed #d3c4aa;
    border-radius: 10px;
    background: #fffcf6;
    color: var(--explorer-soft-ink);
    text-align: center;
}

.drop-zone.drag-over {
    border-color: var(--explorer-gold);
    background: #f7ecd8;
}

.drop-zone small {
    color: #999083;
}

.youtube-upload-card {
    display: flex;
    flex-direction: column;
}

.youtube-upload-card input {
    margin-bottom: 8px;
}

.youtube-upload-card button {
    margin-top: auto;
}

.resource-library {
    padding: 20px;
}

.resource-library-heading {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.resource-library-heading p {
    margin: 5px 0 0;
    color: var(--explorer-soft-ink);
    font-size: .84rem;
}

.resource-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.resource-card {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 11px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--explorer-line);
    border-radius: 11px;
    background: #fff;
}

.resource-card-icon {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 10px;
    background: #f3ead8;
    font-size: 1.25rem;
}

.resource-card-body {
    min-width: 0;
}

.resource-card a {
    display: block;
    overflow: hidden;
    color: var(--explorer-ink);
    font-weight: 750;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resource-card small {
    display: block;
    margin-top: 4px;
    color: var(--explorer-soft-ink);
}

.resource-delete {
    width: 32px;
    height: 32px;
    padding: 0 !important;
    border-color: #e5c4c4 !important;
    background: #fff4f4 !important;
    color: #9b1c1c !important;
}

.resource-empty {
    grid-column: 1 / -1;
    padding: 26px;
    border: 1px dashed var(--explorer-line);
    border-radius: 11px;
    color: var(--explorer-soft-ink);
    text-align: center;
}

.resource-uploading {
    opacity: .58;
    pointer-events: none;
}

.knowledge-workspace {
    padding: 20px;
}

.workspace-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
}

.explorer {
    display: grid;
    grid-template-columns: 280px 280px 280px minmax(340px, 1fr);
    min-height: 570px;
    max-height: calc(100vh - 210px);
    border: 1px solid var(--explorer-line);
    border-radius: 12px;
    background: #fff;
    overflow-x: auto;
}

.pane {
    border-right: 1px solid var(--explorer-line);
    overflow-y: auto;
    background: white;
}

.pane:last-child {
    border-right: 0;
}

.pane-title {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 13px;
    background: #1c1915;
    color: #e6c27b;
    font-weight: 800;
}

.pane-count {
    display: inline-grid;
    min-width: 25px;
    height: 25px;
    place-items: center;
    border-radius: 999px;
    background: rgba(255,255,255,.11);
    font-size: .75rem;
}

.pane-body {
    padding: 8px;
}

.editor-title {
    display: flex;
}

.item,
.knowledge-item-small {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee8de;
    border-radius: 7px;
}

.item {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.item:hover,
.knowledge-item-small:hover {
    background: #f7ecd6;
}

.item.selected {
    background: rgba(183, 123, 34, .13);
    box-shadow: inset 3px 0 0 var(--explorer-gold);
}

.item strong {
    cursor: text;
}

.item span,
.muted {
    color: var(--explorer-soft-ink);
    font-size: .9rem;
}

.knowledge-item-small p {
    margin: 6px 0 0;
    font-size: .86rem;
    color: var(--explorer-soft-ink);
}

.inline-rename-input {
    width: calc(100% - 58px);
    min-width: 80px;
    box-sizing: border-box;
    border: 1px solid var(--explorer-gold);
    border-radius: 5px;
    padding: 5px 7px;
    font: inherit;
    font-weight: 700;
    background: #fffdf7;
    outline: 2px solid rgba(183, 123, 34, .18);
}

.explorer-toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 10000;
    max-width: min(520px, calc(100vw - 48px));
    padding: 12px 16px;
    border-radius: 7px;
    background: #244d2d;
    color: #fff;
    box-shadow: 0 5px 22px rgba(0, 0, 0, .25);
}

.explorer-toast.error {
    background: #8d2424;
}

.explorer-error {
    padding: 12px;
    color: #8d2424;
}

/* Modal and editor */

.modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .68);
}

.modal.hidden,
.hidden {
    display: none;
}

.modal-content {
    position: relative;
    width: min(850px, 92vw);
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid var(--explorer-line);
    border-radius: 14px;
    padding: 24px;
    background: #fff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .35);
}

.editor-modal-content {
    width: min(1100px, 94vw);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 30px;
    height: 30px;
    padding: 0 !important;
    border: none !important;
    border-radius: 999px !important;
    background: #777 !important;
    color: white !important;
}

.editor-modal-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    padding-right: 40px;
}

.shortcut-help {
    margin-left: auto;
    align-self: center;
    color: var(--explorer-soft-ink);
    font-size: .85rem;
}

.editor-empty,
.knowledge-editor {
    padding: 18px;
}

.knowledge-editor h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--explorer-gold-dark);
}

.knowledge-editor h3 {
    margin-top: 28px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--explorer-line);
    color: var(--explorer-gold-dark);
}

.editor-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 16px 22px;
}

.knowledge-editor label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 14px;
    color: var(--explorer-gold-dark);
    font-weight: 650;
}

.knowledge-editor input,
.knowledge-editor select,
.knowledge-editor textarea {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 8px 10px;
    border: 1px solid #cfcfcf;
    border-radius: 6px;
    background: white;
    font-size: .95rem;
}

.knowledge-editor textarea {
    min-height: 140px;
    resize: vertical;
    line-height: 1.45;
}

.verse-preview-box {
    margin: 18px 0;
    padding: 14px;
    border: 1px solid var(--explorer-line);
    border-radius: 12px;
    background: #fff;
}

.verse-preview-box h3 {
    margin-top: 0;
}

.verse-preview-text,
.verse-preview-box p {
    font-size: 1.05rem;
    line-height: 1.7;
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
}

.mini-button {
    padding: 6px 10px !important;
    font-size: .85rem !important;
}

.danger-button {
    background: #9b1c1c !important;
}

.save-status,
.reference-validation {
    margin-left: 8px;
    font-weight: bold;
}

.save-status.saved,
.reference-validation.saved {
    color: #246b2a;
}

.save-status.failed,
.reference-validation.failed {
    color: #9b1c1c;
}

.rename-confirm-content {
    width: min(520px, calc(100vw - 32px));
    padding: 28px;
}

.rename-comparison {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 14px;
    align-items: center;
    margin: 22px 0;
}

.rename-value-box {
    min-width: 0;
    padding: 14px;
    border: 1px solid #d7c59f;
    border-radius: 6px;
    background: #faf7ef;
}

.rename-value-box small {
    display: block;
    margin-bottom: 7px;
    color: #6a6255;
    font-weight: 700;
    text-transform: uppercase;
}

.rename-value-box strong {
    display: block;
    overflow-wrap: anywhere;
}

.rename-arrow {
    color: #9a6a20;
    font-size: 24px;
}

.rename-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.rename-warning {
    color: #5f574c;
}

.highlight-red { color: #b00020; font-weight: bold; }
.highlight-father { color: #0b56b3; font-weight: bold; }
.highlight-son { color: #c56a00; font-weight: bold; }
.highlight-spirit { color: #6f2dbd; font-weight: bold; }
.highlight-earth { color: #7a4a18; font-weight: bold; }

@media (max-width: 1200px) {
    .upload-grid {
        grid-template-columns: repeat(2, minmax(220px, 1fr));
    }
}

@media (max-width: 850px) {
    .explorer-hero,
    .workspace-heading,
    .collections-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .explorer-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .summary-subtitle,
    .summary-action {
        display: none;
    }
}

@media (max-width: 600px) {
    .explorer-hero {
        padding: 20px;
    }

    .explorer-stats,
    .upload-grid,
    .editor-grid {
        grid-template-columns: 1fr;
    }

    .rename-comparison {
        grid-template-columns: 1fr;
    }

    .rename-arrow {
        justify-self: center;
        transform: rotate(90deg);
    }

    .shortcut-help {
        display: none;
    }
}

/* ==========================================================================
   Unified Knowledge Explorer
   ========================================================================== */

.explorer-hero::after {
    content: "🧠";
    align-self: center;
    margin-left: auto;
    opacity: 0.18;
    font-size: clamp(3rem, 7vw, 6rem);
    line-height: 1;
    pointer-events: none;
}

.explorer-hero .hero-actions {
    position: relative;
    z-index: 1;
}

@media (max-width: 760px) {
    .explorer-hero::after {
        display: none;
    }
}


/* Knowledge editor: verse reference and full version on one line. */
.verse-preview-heading {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 10px;
}

.verse-preview-heading h3 {
    margin: 0;
}

.verse-preview-version {
    color: var(--explorer-soft-ink);
    font-size: 0.88rem;
    font-weight: 700;
}


/* Knowledge Explorer statistics, helpful selectors, and attachments */
.helpful-dropdown-grid select { min-height: 44px; background: linear-gradient(#fff,#fffaf0); border-color: #cdbb98; font-weight: 650; }
.helpful-dropdown-grid select:focus { outline: 3px solid rgba(183,123,34,.18); border-color: var(--explorer-gold); }
.knowledge-attachments { display:grid; gap:12px; margin-bottom:18px; padding:16px; border:1px solid var(--explorer-line); border-radius:12px; background:#fcfaf5; }
.attachment-picker { display:grid; gap:7px; color:var(--explorer-ink); font-weight:800; }
.attachment-picker input { padding:11px; border:1px dashed #c7ad78; border-radius:9px; background:#fff; }
.attachment-picker small { color:var(--explorer-soft-ink); font-weight:500; }
.knowledge-attachment-list { display:grid; gap:8px; }
.knowledge-attachment-row { display:grid; grid-template-columns:minmax(0,1fr) auto auto; gap:10px; align-items:center; padding:10px 12px; border:1px solid var(--explorer-line); border-radius:9px; background:#fff; }
.knowledge-attachment-row a { overflow:hidden; color:var(--explorer-gold-dark); font-weight:800; text-overflow:ellipsis; white-space:nowrap; }
.knowledge-attachment-row span { color:var(--explorer-soft-ink); font-size:.8rem; }
@media(max-width:650px){.knowledge-attachment-row{grid-template-columns:1fr}.knowledge-attachment-row a{white-space:normal}}
