:root {
    --bg: #090d14;
    --bg-soft: #0f1520;
    --panel: rgba(18, 25, 38, 0.88);
    --panel-hover: rgba(26, 35, 51, 0.98);
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.15);
    --text: #f4f7fb;
    --muted: #96a2b5;
    --subtle: #657188;
    --accent: #7b82ff;
    --accent-strong: #969bff;
    --accent-soft: rgba(123, 130, 255, 0.13);
    --success: #63d7b3;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
    --radius: 18px;
    --radius-small: 12px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 15% -10%, rgba(123, 130, 255, 0.16), transparent 30rem),
        radial-gradient(circle at 100% 25%, rgba(71, 164, 255, 0.08), transparent 28rem),
        var(--bg);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
}

button,
input,
select {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

svg {
    display: block;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.hidden {
    display: none !important;
}

/* Landing / racine masquée */

.landing-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
}

.landing-card {
    width: min(100%, 600px);
    text-align: center;
    padding: 58px 38px;
    border: 1px solid var(--border);
    border-radius: 28px;
    background: linear-gradient(145deg, rgba(19, 27, 41, 0.96), rgba(12, 17, 26, 0.96));
    box-shadow: var(--shadow);
}

.brand-mark {
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
    margin: 0 auto 24px;
    border-radius: 22px;
    color: white;
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.08em;
    background: linear-gradient(145deg, #9095ff, #565dde);
    box-shadow: 0 18px 44px rgba(95, 102, 232, 0.28);
}

.brand-mark-small {
    width: 44px;
    height: 44px;
    margin: 0;
    border-radius: 13px;
    font-size: 21px;
}

.eyebrow {
    margin: 0 0 9px;
    color: var(--accent-strong);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.16em;
}

.landing-card h1 {
    margin: 0;
    font-size: clamp(2rem, 6vw, 3.25rem);
    letter-spacing: -0.045em;
}

.landing-text {
    max-width: 440px;
    margin: 18px auto 0;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.7;
}

/* App */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid var(--border);
    background: rgba(9, 13, 20, 0.84);
    backdrop-filter: blur(18px);
}

.topbar-inner {
    width: min(1180px, calc(100% - 36px));
    min-height: 76px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 0.86rem;
    letter-spacing: 0.14em;
}

.brand small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.77rem;
}

.topbar-note {
    padding: 8px 12px;
    color: var(--success);
    border: 1px solid rgba(99, 215, 179, 0.2);
    border-radius: 999px;
    background: rgba(99, 215, 179, 0.08);
    font-size: 0.78rem;
    font-weight: 700;
}

.app-shell {
    width: min(1180px, calc(100% - 36px));
    margin: 0 auto;
    padding: 38px 0 72px;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    margin-bottom: 36px;
    color: var(--muted);
    font-size: 0.86rem;
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
}

.breadcrumbs::-webkit-scrollbar {
    display: none;
}

.breadcrumbs a {
    color: var(--muted);
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--text);
}

.breadcrumb-separator {
    color: var(--subtle);
}

.folder-heading {
    margin-bottom: 30px;
}

.folder-title-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.folder-title-row h1 {
    max-width: 820px;
    margin: 0;
    font-size: clamp(2.1rem, 5vw, 4.1rem);
    line-height: 1;
    letter-spacing: -0.055em;
    overflow-wrap: anywhere;
}

.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 24px;
}

.stats span {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.025);
    font-size: 0.8rem;
}

.stats strong {
    color: var(--text);
}

.toolbar {
    position: sticky;
    top: 93px;
    z-index: 10;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto;
    gap: 10px;
    margin: 0 0 22px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 17px;
    background: rgba(12, 17, 26, 0.8);
    backdrop-filter: blur(18px);
}

.search-box {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 13px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.045);
}

.search-box:focus-within {
    border-color: rgba(123, 130, 255, 0.55);
    box-shadow: 0 0 0 3px rgba(123, 130, 255, 0.1);
}

.search-box svg {
    width: 18px;
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.8;
}

.search-box input {
    width: 100%;
    min-width: 0;
    height: 45px;
    padding: 0;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
}

.search-box input::placeholder {
    color: var(--subtle);
}

.sort-box select {
    height: 47px;
    padding: 0 38px 0 13px;
    border: 1px solid var(--border);
    border-radius: 11px;
    color: var(--text);
    background: #121925;
    outline: none;
}

.view-switch {
    display: flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.025);
}

.view-button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}

.view-button.active,
.view-button:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

.view-button svg {
    width: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 13px;
}

.file-item {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 185px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(145deg, rgba(19, 26, 39, 0.95), rgba(14, 19, 29, 0.95));
    overflow: hidden;
    transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.file-item:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    background: var(--panel-hover);
}

.item-main {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px;
}

.item-link {
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.item-icon {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    color: #b8bdff;
    background: var(--accent-soft);
}

.item-icon svg {
    width: 25px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.5;
}

.icon-folder {
    color: #99a0ff;
}

.icon-image {
    color: #66d7c0;
    background: rgba(102, 215, 192, 0.1);
}

.icon-pdf {
    color: #ff8585;
    background: rgba(255, 133, 133, 0.1);
}

.icon-audio {
    color: #e299ff;
    background: rgba(226, 153, 255, 0.1);
}

.icon-video {
    color: #77b7ff;
    background: rgba(119, 183, 255, 0.1);
}

.icon-archive {
    color: #ffc66f;
    background: rgba(255, 198, 111, 0.1);
}

.item-copy {
    min-width: 0;
    flex: 1;
}

.item-name {
    display: block;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.item-meta {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.75rem;
    line-height: 1.45;
}

.item-arrow {
    align-self: center;
    color: var(--subtle);
    font-size: 1.4rem;
}

.item-actions {
    display: flex;
    gap: 8px;
    padding: 0 14px 14px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 39px;
    padding: 0 13px;
    border: 1px solid transparent;
    border-radius: 10px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 750;
    cursor: pointer;
    transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    color: white;
    background: linear-gradient(145deg, #7f85ff, #6269e8);
}

.button-secondary {
    color: var(--text);
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.04);
}

.button-secondary:hover {
    border-color: var(--border-strong);
    background: rgba(255, 255, 255, 0.075);
}

.item-actions .button {
    flex: 1;
}

/* Vue liste */

.items-grid.view-list {
    grid-template-columns: 1fr;
}

.view-list .file-item {
    min-height: 0;
    flex-direction: row;
    align-items: center;
}

.view-list .item-main {
    flex: 1;
    align-items: center;
    padding: 13px 16px;
}

.view-list .item-icon {
    width: 39px;
    height: 39px;
    border-radius: 11px;
}

.view-list .item-icon svg {
    width: 21px;
}

.view-list .item-meta {
    margin-top: 4px;
}

.view-list .item-actions {
    flex: 0 0 auto;
    min-width: 245px;
    padding: 11px 12px;
}

.view-list .is-folder .item-main {
    width: 100%;
}

/* Empty */

.empty-state {
    display: grid;
    place-items: center;
    min-height: 320px;
    padding: 40px;
    text-align: center;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    color: var(--muted);
}

.empty-state h2 {
    margin: 14px 0 5px;
    color: var(--text);
}

.empty-state p {
    margin: 0;
}

.empty-icon {
    width: 60px;
    height: 60px;
    display: grid;
    place-items: center;
    border-radius: 17px;
    color: var(--accent-strong);
    background: var(--accent-soft);
}

.empty-icon svg {
    width: 30px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Modal preview */

.modal[hidden] {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.74);
    backdrop-filter: blur(10px);
}

.modal-dialog {
    position: relative;
    width: min(1100px, 100%);
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-strong);
    border-radius: 22px;
    background: #0e141e;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.55);
    overflow: hidden;
}

.modal-header,
.modal-footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    max-width: 800px;
    margin: 0;
    font-size: 1.05rem;
    overflow-wrap: anywhere;
}

.modal-header .eyebrow {
    margin-bottom: 4px;
}

.modal-footer {
    justify-content: flex-end;
    border-top: 1px solid var(--border);
    border-bottom: 0;
}

.modal-close {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 11px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.preview-content {
    min-height: 320px;
    flex: 1 1 auto;
    display: grid;
    place-items: center;
    padding: 18px;
    overflow: auto;
    background:
        linear-gradient(45deg, rgba(255,255,255,.025) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255,255,255,.025) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255,255,255,.025) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.025) 75%);
    background-size: 22px 22px;
    background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

.preview-content img,
.preview-content video {
    max-width: 100%;
    max-height: 72vh;
    border-radius: 10px;
}

.preview-content audio {
    width: min(600px, 100%);
}

.preview-content iframe {
    width: 100%;
    height: min(72vh, 760px);
    border: 0;
    border-radius: 10px;
    background: white;
}

body.modal-open {
    overflow: hidden;
}

.footer {
    width: min(1180px, calc(100% - 36px));
    display: flex;
    justify-content: center;
    gap: 9px;
    margin: -38px auto 0;
    padding: 0 0 30px;
    color: var(--subtle);
    font-size: 0.74rem;
    text-align: center;
}

@media (max-width: 900px) {
    .items-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .toolbar {
        top: 86px;
        grid-template-columns: 1fr auto;
    }

    .search-box {
        grid-column: 1 / -1;
    }

    .folder-title-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .view-list .item-actions {
        min-width: 220px;
    }
}

@media (max-width: 640px) {
    .topbar-inner,
    .app-shell,
    .footer {
        width: min(100% - 24px, 1180px);
    }

    .topbar-inner {
        min-height: 68px;
    }

    .topbar-note {
        display: none;
    }

    .app-shell {
        padding-top: 26px;
    }

    .breadcrumbs {
        margin-bottom: 26px;
    }

    .folder-title-row h1 {
        font-size: clamp(2.2rem, 12vw, 3.2rem);
    }

    .toolbar {
        position: static;
        grid-template-columns: 1fr;
    }

    .sort-box select {
        width: 100%;
    }

    .view-switch {
        display: none;
    }

    .items-grid {
        grid-template-columns: 1fr;
    }

    .file-item {
        min-height: 0;
    }

    .view-list .file-item {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .view-list .item-actions {
        min-width: 0;
    }

    .item-actions {
        flex-wrap: wrap;
    }

    .modal {
        padding: 8px;
    }

    .modal-dialog {
        max-height: calc(100vh - 16px);
        border-radius: 16px;
    }

    .preview-content {
        min-height: 240px;
        padding: 8px;
    }

    .footer {
        flex-wrap: wrap;
    }
}


/* V1.1 : navigation client + dépôt */

.folder-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 9px;
}

.upload-dialog {
    width: min(760px, 100%);
}

.upload-form {
    padding: 20px;
}

.upload-dropzone {
    min-height: 245px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 34px 24px;
    border: 1px dashed rgba(123, 130, 255, 0.45);
    border-radius: 18px;
    color: var(--muted);
    background: rgba(123, 130, 255, 0.055);
    text-align: center;
    cursor: pointer;
    transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.upload-dropzone:hover,
.upload-dropzone.is-dragging {
    border-color: var(--accent-strong);
    background: rgba(123, 130, 255, 0.11);
}

.upload-dropzone.is-dragging {
    transform: scale(1.005);
}

.upload-dropzone input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.upload-dropzone strong {
    color: var(--text);
    font-size: 1.05rem;
}

.upload-dropzone span:not(.upload-icon) {
    font-size: 0.86rem;
}

.upload-icon {
    width: 60px;
    height: 60px;
    display: grid;
    place-items: center;
    margin-bottom: 6px;
    border-radius: 17px;
    color: var(--accent-strong);
    background: var(--accent-soft);
}

.upload-icon svg {
    width: 30px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.upload-selection {
    max-height: 190px;
    margin-top: 14px;
    border: 1px solid var(--border);
    border-radius: 13px;
    overflow: auto;
}

.upload-file-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.82rem;
}

.upload-file-row:last-child {
    border-bottom: 0;
}

.upload-file-row strong {
    min-width: 0;
    color: var(--text);
    font-weight: 650;
    overflow-wrap: anywhere;
}

.upload-file-row span {
    flex: 0 0 auto;
}

.upload-progress-wrap {
    margin-top: 16px;
}

.upload-progress-track {
    height: 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    overflow: hidden;
}

.upload-progress-bar {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #6e75ed, #9ca1ff);
    transition: width 100ms linear;
}

#uploadProgressText {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    font-size: 0.78rem;
}

.upload-message {
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.035);
    line-height: 1.5;
    white-space: pre-line;
}

.upload-message.is-success {
    color: var(--success);
    border-color: rgba(99, 215, 179, 0.22);
    background: rgba(99, 215, 179, 0.07);
}

.upload-message.is-error {
    color: #ff9b9b;
    border-color: rgba(255, 130, 130, 0.22);
    background: rgba(255, 130, 130, 0.07);
}

.upload-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 18px;
}

@media (max-width: 640px) {
    .folder-actions {
        width: 100%;
        justify-content: stretch;
    }

    .folder-actions .button {
        flex: 1 1 auto;
    }

    .upload-form {
        padding: 12px;
    }

    .upload-dropzone {
        min-height: 190px;
        padding: 24px 16px;
    }

    .upload-actions {
        flex-direction: column-reverse;
    }

    .upload-actions .button {
        width: 100%;
    }
}


/* V1.2 : état d'écriture explicitement autorisé */

.topbar-note-write {
    color: #9ea3ff;
    border-color: rgba(123, 130, 255, 0.28);
    background: rgba(123, 130, 255, 0.10);
}


/* V1.3 : arborescence verticale + métadonnées audio */

.folder-path-panel {
    min-width: 0;
    flex: 1 1 auto;
}

.path-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    margin-top: 2px;
}

.path-stack-row {
    --indent-step: 18px;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 9px;
    padding-left: min(calc(var(--path-depth) * var(--indent-step)), 108px);
    color: var(--muted);
}

.path-stack-branch {
    flex: 0 0 12px;
    width: 12px;
    color: rgba(150, 155, 255, 0.55);
    font-size: 0.74rem;
    text-align: center;
}

.path-stack-row a {
    max-width: min(72vw, 760px);
    color: var(--muted);
    font-size: 0.94rem;
    font-weight: 650;
    line-height: 1.45;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.path-stack-row a:hover {
    color: var(--text);
}

.path-stack-row.is-current {
    margin-top: 1px;
    color: var(--text);
}

.path-stack-current {
    max-width: min(78vw, 850px);
    display: block;
    color: var(--text);
    font-size: clamp(2.15rem, 5vw, 4rem);
    font-weight: 790;
    line-height: 1.03;
    letter-spacing: -0.055em;
    overflow-wrap: anywhere;
}

.preview-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.018);
}

.preview-metadata.hidden {
    display: none;
}

.preview-metadata-item {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.035);
    white-space: nowrap;
}

.preview-metadata-item strong {
    color: var(--subtle);
    font-size: 0.67rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.preview-metadata-item span {
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 700;
}

@media (max-width: 640px) {
    .path-stack-row {
        --indent-step: 13px;
        padding-left: min(calc(var(--path-depth) * var(--indent-step)), 65px);
    }

    .path-stack-current {
        max-width: 78vw;
        font-size: clamp(2rem, 11vw, 3.15rem);
    }

    .preview-metadata {
        padding: 10px 12px;
    }

    .preview-metadata-item {
        white-space: normal;
    }
}


/* V1.4 : pages HTML exécutables dans leur contexte serveur */

.icon-web {
    color: #78c8ff;
    background: rgba(120, 200, 255, 0.10);
}

.item-actions-web {
    flex-wrap: wrap;
}

.item-actions-web .button-primary {
    flex: 1 1 100%;
}

.item-actions-web .button-secondary {
    flex: 1 1 auto;
}

.view-list .item-actions-web {
    min-width: 290px;
    display: grid;
    grid-template-columns: 1fr;
}

@media (max-width: 640px) {
    .view-list .item-actions-web {
        min-width: 0;
    }
}
