/* Crates — Voidlabs. Nuit violette, accents cyan. */
:root {
  --bg: #0b0918;
  --bg-2: #110e22;
  --panel: #161230;
  --panel-2: #1c1740;
  --line: rgba(160, 140, 255, 0.14);
  --line-2: rgba(160, 140, 255, 0.28);
  --text: #eeebff;
  --muted: #a39dcc;
  --faint: #6f6a99;
  --violet: #9a6cff;
  --cyan: #5fe8f0;
  --red: #ff6b7d;
  --green: #6be3a0;
  --amber: #ffc46b;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* Boutons et champs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 650; white-space: nowrap; transition: background .15s, border-color .15s, transform .08s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--violet), #6d5cff); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: rgba(255, 255, 255, .04); border-color: var(--line); }
.btn.ghost:hover { background: rgba(255, 255, 255, .08); }
.btn.danger { color: var(--red); border-color: rgba(255, 107, 125, .35); background: transparent; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.icon { width: 40px; padding: 0; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; font-size: 13px; }
.link:hover { color: var(--text); }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=url], input[type=search], textarea, select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: rgba(5, 4, 14, .6); color: var(--text); font: inherit; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--cyan); }
textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
.msg { min-height: 20px; margin: 4px 0 10px; font-size: 13px; color: var(--red); }

/* Connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(800px 500px at 80% -10%, rgba(154, 108, 255, .2), transparent), radial-gradient(600px 400px at 0% 110%, rgba(95, 232, 240, .1), transparent); }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; text-align: left; }
.login-logo { width: 52px; height: 52px; }
.login-card h1 { margin: 12px 0 2px; font-size: 26px; letter-spacing: .5px; }
.login-card p.muted { margin: 0 0 22px; }

/* Structure */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 18px 12px; background: var(--bg-2); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 800; font-size: 18px; letter-spacing: .5px; }
.brand img { width: 32px; height: 32px; }
.nav { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: none; color: var(--muted); text-align: left; font-weight: 600; }
.nav:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.nav.active { background: rgba(154, 108, 255, .16); color: var(--text); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 0 8px; }
.who { font-size: 13px; color: var(--muted); font-weight: 600; }
.usage { font-size: 12px; color: var(--faint); }
.usage b { color: var(--muted); font-weight: 600; }

.main { position: relative; min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: rgba(11, 9, 24, .86); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.crumbs { display: flex; align-items: center; gap: 4px; min-width: 0; flex: 1; overflow: hidden; }
.crumbs button { border: 0; background: none; padding: 4px 6px; border-radius: 6px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.crumbs button:hover { background: rgba(255, 255, 255, .05); color: var(--text); }
.crumbs button { flex-shrink: 0; }
.crumbs button:last-child { color: var(--text); font-size: 17px; flex-shrink: 1; min-width: 0; }
.crumbs .sep { color: var(--faint); }
.search { position: relative; width: min(320px, 34vw); }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--faint); }
.search input { padding-left: 36px; height: 40px; }
.top-actions { display: flex; gap: 8px; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 220px; padding: 6px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, .5); }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: none; text-align: left; }
.menu button:hover { background: rgba(255, 255, 255, .07); }
.menu button.danger { color: var(--red); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.ctx { position: fixed; top: 0; left: 0; }

.selbar { display: flex; align-items: center; gap: 8px; padding: 10px 24px; background: rgba(154, 108, 255, .12); border-bottom: 1px solid var(--line); }
.selbar span { margin-right: auto; font-weight: 600; }

.content { padding: 20px 24px 120px; flex: 1; }
.section-title { color: var(--faint); font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; margin: 6px 0 12px; }

/* Grille */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.card { position: relative; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); overflow: hidden; cursor: pointer; transition: border-color .15s, transform .15s; user-select: none; -webkit-user-select: none; }
.card:hover { border-color: var(--line-2); }
.card.selected { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan) inset; }
.card .thumb { aspect-ratio: 4 / 3; display: grid; place-items: center; background: var(--bg-2); overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .thumb svg { width: 44px; height: 44px; }
.card .meta { padding: 9px 11px 10px; }
.card .name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .sub { font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .more, .row .more { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 8px; border: 0; background: rgba(11, 9, 24, .72); display: grid; place-items: center; opacity: 0; transition: opacity .15s; }
.card .check, .row .check { position: absolute; top: 8px; left: 8px; width: 22px; height: 22px; border-radius: 6px; border: 2px solid rgba(255, 255, 255, .7); background: rgba(11, 9, 24, .5); opacity: 0; transition: opacity .15s; display: grid; place-items: center; }
.card:hover .more, .card:hover .check, .card.selected .check, .selecting .card .check { opacity: 1; }
.card.selected .check, .row.selected .check { background: var(--cyan); border-color: var(--cyan); }
.card.selected .check::after, .row.selected .check::after { content: ""; width: 10px; height: 5px; border: 2px solid #0b0918; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.card .more svg { width: 18px; height: 18px; }

/* Couleurs des types */
.k-dir { color: var(--violet); } .k-note { color: var(--amber); } .k-link { color: var(--cyan); }
.k-pdf { color: #ff7a7a; } .k-sheet { color: var(--green); } .k-video { color: #ff9ad5; }
.k-audio { color: #ffb46b; } .k-text { color: #9fc3ff; } .k-file { color: var(--muted); } .k-image { color: #8fd6ff; }

/* Liste */
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { position: relative; display: grid; grid-template-columns: 40px 1fr 110px 140px 40px; align-items: center; gap: 10px; padding: 8px 12px 8px 40px; background: var(--panel); border-bottom: 1px solid var(--line); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--panel-2); }
.row.selected { background: rgba(95, 232, 240, .08); }
.row .check { top: 50%; transform: translateY(-50%); left: 10px; }
.row:hover .check, .selecting .row .check, .row.selected .check { opacity: 1; }
.row .ico { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: var(--bg-2); overflow: hidden; }
.row .ico img { width: 100%; height: 100%; object-fit: cover; }
.row .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .size, .row .date { font-size: 13px; color: var(--faint); }
.row .more { position: static; opacity: .6; background: none; }
.row:hover .more { opacity: 1; }

.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty svg { width: 54px; height: 54px; color: var(--faint); margin-bottom: 10px; }
.empty h3 { color: var(--text); margin: 0 0 6px; }

.drop-hint { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(11, 9, 24, .7); backdrop-filter: blur(4px); pointer-events: none; }
.drop-hint div { padding: 40px 60px; border: 2px dashed var(--cyan); border-radius: 20px; font-size: 20px; font-weight: 700; color: var(--cyan); }

/* Corbeille */
.trash-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.trash-row:last-child { border-bottom: 0; }
.trash-row .name { font-weight: 600; }
.trash-row .sub { font-size: 12px; color: var(--faint); }
.trash-row .actions { display: flex; gap: 6px; }

/* Aperçu */
.viewer { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: #08070f; }
.viewer-top { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.v-title { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-actions { display: flex; gap: 8px; }
.viewer-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: auto; }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-body video { max-width: 100%; max-height: 100%; }
.viewer-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-body .doc { align-self: stretch; width: min(860px, 100%); margin: 0 auto; padding: 28px 24px 80px; }
.viewer-body pre { white-space: pre-wrap; word-break: break-word; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.v-nav { position: fixed; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line-2); background: rgba(22, 18, 48, .8); display: grid; place-items: center; }
.v-nav.prev { left: 14px; } .v-nav.next { right: 14px; }
.file-card { text-align: center; padding: 40px; }
.file-card svg { width: 72px; height: 72px; margin-bottom: 12px; }
.file-card h2 { margin: 0 0 6px; word-break: break-word; }
.file-card p { color: var(--muted); margin: 0 0 20px; }

/* Notes (Markdown) */
.md { line-height: 1.7; }
.md h1, .md h2, .md h3 { line-height: 1.25; margin: 1.3em 0 .5em; }
.md h1:first-child, .md h2:first-child, .md h3:first-child { margin-top: 0; }
.md a { color: var(--cyan); }
.md code { background: var(--panel); padding: 1px 6px; border-radius: 5px; font-size: .92em; }
.md blockquote { margin: 0; padding: 4px 16px; border-left: 3px solid var(--violet); color: var(--muted); }
.md ul, .md ol { padding-left: 22px; }
.md li.task { list-style: none; margin-left: -20px; }
.md hr { border: 0; border-top: 1px solid var(--line-2); margin: 24px 0; }
.note-editor { display: flex; flex-direction: column; gap: 12px; }
.note-editor input { font-size: 20px; font-weight: 700; }
.note-editor textarea { min-height: 60vh; font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
.note-editor .hint { font-size: 12px; color: var(--faint); }

/* Classeurs */
.sheet-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.sheet-tabs button { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 5px 12px; font-size: 13px; }
.sheet-tabs button.on { border-color: var(--green); color: var(--green); }
.sheet-wrap { overflow: auto; max-height: calc(100vh - 170px); border: 1px solid var(--line); border-radius: 10px; }
table.sheet { border-collapse: collapse; font-size: 13px; background: var(--panel); }
table.sheet th, table.sheet td { border: 1px solid var(--line); padding: 5px 9px; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
table.sheet th { position: sticky; top: 0; background: var(--panel-2); color: var(--muted); font-weight: 600; }
table.sheet td.n { text-align: right; font-variant-numeric: tabular-nums; }
table.sheet th.rn { position: sticky; left: 0; z-index: 1; }

/* Lien */
.link-card { width: min(560px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.link-card .domain { color: var(--cyan); font-size: 13px; font-weight: 700; }
.link-card h2 { margin: 4px 0 8px; word-break: break-word; }
.link-card .url { color: var(--faint); font-size: 13px; word-break: break-all; margin-bottom: 16px; }
.link-card .note { color: var(--muted); white-space: pre-wrap; margin-bottom: 18px; }

/* Fenêtre */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(5, 4, 12, .66); backdrop-filter: blur(6px); }
.modal-box { width: min(440px, 100%); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 16px; padding: 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, .55); }
.modal-box h3 { margin: 0 0 16px; }
.modal-box p.text { color: var(--muted); margin: 0 0 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.dir-pick { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.dir-pick button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.dir-pick button:last-child { border-bottom: 0; }
.dir-pick button.on { background: rgba(95, 232, 240, .1); color: var(--cyan); }

/* Envois en cours */
.uploads { position: fixed; right: 18px; bottom: calc(18px + var(--safe-b)); z-index: 45; width: min(340px, calc(100vw - 36px)); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 14px; padding: 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, .5); }
.uploads h4 { margin: 0 0 8px; font-size: 14px; }
.up { font-size: 13px; margin-bottom: 8px; }
.up .bar { height: 4px; border-radius: 3px; background: rgba(255, 255, 255, .08); overflow: hidden; margin-top: 4px; }
.up .bar div { height: 100%; width: 0; background: linear-gradient(90deg, var(--violet), var(--cyan)); transition: width .15s; }
.up.err { color: var(--red); }
.toasts { position: fixed; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 16px; font-size: 14px; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); animation: pop .2s; }
.toast.error { border-color: rgba(255, 107, 125, .5); color: var(--red); }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Téléphone */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 20; flex-direction: row; align-items: center; padding: 6px 10px calc(6px + var(--safe-b)); border-right: 0; border-top: 1px solid var(--line); }
  .brand, .side-foot .usage { display: none; }
  .side nav { display: flex; flex: 1; gap: 4px; }
  .nav { justify-content: center; flex-direction: column; gap: 2px; font-size: 11px; padding: 6px; }
  .side-foot { margin: 0; padding: 0; }
  .top { flex-wrap: wrap; padding: 10px 14px; gap: 8px; }
  .crumbs { order: 1; flex-basis: calc(100% - 100px); }
  .top-actions { order: 2; }
  .search { order: 3; width: 100%; }
  .top-actions .btn.primary span { display: none; }
  .top-actions .btn.primary { width: 40px; padding: 0; }
  .content { padding: 14px 14px 110px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card .more { opacity: 1; }
  .row { grid-template-columns: 40px 1fr 40px; padding-left: 12px; }
  .row .size, .row .date, .row .check { display: none; }
  .selecting .row .check { display: grid; }
  .selecting .row { padding-left: 40px; }
  .v-nav { display: none; }
  .uploads { bottom: calc(76px + var(--safe-b)); }
  .toasts { bottom: calc(80px + var(--safe-b)); }
}
.v-actions .btn .lbl { font-size: 14px; }
@media (max-width: 760px) { .v-actions .btn .lbl { display: none; } .v-actions .btn { width: 40px; padding: 0; } }

/* Dossiers : tuiles compactes */
.grid.folders { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.card.folder { display: flex; align-items: center; gap: 12px; padding: 10px 40px 10px 12px; }
.card.folder .ficon { width: 42px; height: 42px; border-radius: 10px; background: rgba(154, 108, 255, .12); display: grid; place-items: center; flex: none; }
.card.folder .ficon svg { width: 24px; height: 24px; }
.card.folder .meta { padding: 0; min-width: 0; }
.card.folder .check { top: 50%; transform: translateY(-50%); left: auto; right: 42px; }
.card.folder .more { top: 50%; transform: translateY(-50%); }
@media (max-width: 760px) { .grid.folders { grid-template-columns: 1fr 1fr; } }
