/* MarkSync — interface web
   Identité : un ruban de marque-page jaune sur un papier gris-bleu froid, encre bleu nuit. */

:root {
    --paper: #EEF1F4;
    --surface: #FFFFFF;
    --ink: #1E2A44;
    --ink-soft: #4A5672;
    --muted: #6B7689;
    --line: #D5DBE3;
    --hover: #E3E8EF;
    --ribbon: #F2C230;
    --ribbon-ink: #3A2E00;
    --danger: #B3261E;
    --focus: #2F6FEB;
    --radius-s: 6px;
    --radius-m: 10px;
    --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
    --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #141A26;
        --surface: #1B2331;
        --ink: #E6EAF0;
        --ink-soft: #B5BFCE;
        --muted: #8792A5;
        --line: #2C3648;
        --hover: #242E40;
        --ribbon-ink: #2A2100;
        --danger: #FF8A80;
        --focus: #7BA7FF;
    }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--paper);
    color: var(--ink);
    font: 15px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Marque ---------- */
.brand {
    display: inline-flex; align-items: center; gap: 10px;
    font: 650 18px/1 var(--font-display);
    letter-spacing: -0.01em;
    text-decoration: none;
}
.ribbon {
    width: 14px; height: 22px;
    background: var(--ribbon);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 74%, 0 100%);
}

/* ---------- Boutons & champs ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 36px; padding: 0 14px;
    border: 1px solid var(--line); border-radius: var(--radius-s);
    background: var(--surface); color: var(--ink);
    font-weight: 550; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.primary:hover { filter: brightness(1.15); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--danger); }
.icon-btn {
    display: inline-grid; place-items: center;
    width: 32px; height: 32px; padding: 0;
    border: 0; border-radius: var(--radius-s);
    background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }

.form { display: grid; gap: 14px; }
.form.narrow { max-width: 520px; }
.form label { display: grid; gap: 6px; font-weight: 550; font-size: 14px; }
.form input[type=text], .form input[type=email], .form input[type=password], .form select {
    min-height: 40px; padding: 0 12px;
    border: 1px solid var(--line); border-radius: var(--radius-s);
    background: var(--paper); font-weight: 400;
}
.form input:focus, .form select:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.form .check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.choices { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.hint { color: var(--muted); font-weight: 400; font-size: 13px; }
.error { color: var(--danger); margin: 0; font-size: 14px; }
.muted { color: var(--muted); }

/* ---------- Pages de connexion ---------- */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius-m);
    padding: 32px 28px;
}
.auth-card h1 { font: 600 24px/1.25 var(--font-display); letter-spacing: -0.015em; margin: 22px 0 24px; text-wrap: balance; }
.auth-card .btn.primary { min-height: 42px; margin-top: 4px; }
.auth-card p.muted { margin: 20px 0 0; font-size: 14px; }

/* ---------- Application ---------- */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 16px;
    padding: 10px 20px;
    background: var(--surface); border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; }
.search {
    flex: 1; max-width: 520px;
    display: flex; align-items: center; gap: 8px;
    padding: 0 12px; min-height: 38px;
    background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
    color: var(--muted);
}
.search:focus-within { border-color: var(--focus); }
.search input { flex: 1; border: 0; background: transparent; outline: none; color: var(--ink); min-width: 0; }
.tabs { display: flex; gap: 2px; margin-left: auto; }
.tab {
    border: 0; background: transparent; cursor: pointer;
    padding: 8px 12px; border-radius: var(--radius-s);
    color: var(--muted); font-weight: 550;
}
.tab:hover { color: var(--ink); background: var(--hover); }
.tab.is-active { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ribbon); border-radius: var(--radius-s) var(--radius-s) 0 0; }
.logout { margin: 0; }

.layout { display: grid; grid-template-columns: 280px 1fr; min-height: calc(100vh - 59px); }
.sidebar {
    border-right: 1px solid var(--line);
    padding: 16px 10px;
    position: sticky; top: 59px; height: calc(100vh - 59px); overflow: auto;
}
.main { padding: 24px 32px 64px; min-width: 0; }
.main h2 { font: 600 20px/1.3 var(--font-display); margin: 0 0 6px; }
.main h2 + .lede { margin-top: 0; }
.lede { max-width: 64ch; margin-bottom: 18px; }
.view h2:not(:first-child) { margin-top: 40px; }

/* Arbre des dossiers */
.folder-tree ul { list-style: none; margin: 0; padding: 0; }
.folder-tree ul ul { padding-left: 14px; }
.folder-row {
    position: relative;
    display: flex; align-items: center; gap: 4px;
    min-height: 32px; padding: 0 8px 0 2px;
    border-radius: var(--radius-s);
    cursor: pointer; user-select: none;
    color: var(--ink-soft);
}
.folder-row:hover { background: var(--hover); color: var(--ink); }
.folder-row.is-current { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
.folder-row.is-current::before {
    content: ""; position: absolute; left: -10px; top: 6px;
    width: 4px; height: 20px; background: var(--ribbon); border-radius: 0 2px 2px 0;
}
.folder-row.is-drop { background: color-mix(in srgb, var(--ribbon) 35%, transparent); }
.folder-row .twisty { width: 20px; height: 20px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; }
.folder-row .twisty svg { width: 14px; height: 14px; transition: transform .15s; }
.folder-row .twisty.is-open svg { transform: rotate(90deg); }
.folder-row .twisty.is-empty { visibility: hidden; }
.folder-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-row .count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.tree-root + .tree-root { margin-top: 6px; }

/* Barre d'outils de la liste */
.toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.breadcrumb { flex: 1; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font: 600 20px/1.3 var(--font-display); }
.breadcrumb button { border: 0; background: none; padding: 2px 4px; border-radius: 4px; color: var(--muted); cursor: pointer; font: inherit; }
.breadcrumb button:hover { color: var(--ink); background: var(--hover); }
.breadcrumb .sep { color: var(--line); font-weight: 400; }
.breadcrumb .here { padding: 2px 4px; }
.breadcrumb .result-count { font: 400 14px var(--font); color: var(--muted); margin-left: 8px; }
.actions { display: flex; gap: 8px; }

/* Liste des favoris */
.list {
    list-style: none; margin: 0; padding: 0;
    background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius-m);
    overflow: hidden;
}
.item {
    display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 12px;
    padding: 8px 10px 8px 14px; min-height: 52px;
    border-top: 1px solid var(--line);
}
.item:first-child { border-top: 0; }
.item:hover { background: var(--hover); }
.item.is-dragging { opacity: .4; }
.item.drop-before { box-shadow: inset 0 2px 0 var(--ribbon); }
.item.drop-into { background: color-mix(in srgb, var(--ribbon) 30%, transparent); }
.item .ico {
    width: 28px; height: 28px; border-radius: 6px;
    display: grid; place-items: center;
    background: var(--paper); color: var(--ink-soft);
    font-weight: 650; font-size: 13px; overflow: hidden;
}
.item .ico img { width: 18px; height: 18px; }
.item .ico.folder { background: color-mix(in srgb, var(--ribbon) 28%, var(--paper)); color: var(--ribbon-ink); }
.item .text { min-width: 0; }
.item .title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; text-decoration: none; }
a.title:hover { text-decoration: underline; text-underline-offset: 3px; }
button.title { border: 0; background: none; padding: 0; text-align: left; cursor: pointer; max-width: 100%; }
.item .sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.item .row-actions { display: flex; gap: 2px; opacity: 0; }
.item:hover .row-actions, .item:focus-within .row-actions { opacity: 1; }
@media (hover: none) { .item .row-actions { opacity: 1; } }

.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font: 600 17px var(--font-display); margin-bottom: 6px; }

/* Appareils */
.devices { list-style: none; padding: 0; margin: 0; max-width: 720px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.device { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-top: 1px solid var(--line); }
.device:first-child { border-top: 0; }
.device .text { flex: 1; min-width: 0; }
.device .name { font-weight: 600; }
.device .sub { color: var(--muted); font-size: 13px; }

/* Dialogue d'édition */
.editor {
    width: min(480px, calc(100vw - 32px));
    border: 1px solid var(--line); border-radius: var(--radius-m);
    background: var(--surface); color: var(--ink);
    padding: 24px;
}
.editor::backdrop { background: rgb(15 20 30 / .45); }
.editor h2 { margin: 0 0 4px; font: 600 19px var(--font-display); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* Message de confirmation */
.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    background: var(--ink); color: var(--paper);
    padding: 10px 14px 10px 16px; border-radius: var(--radius-s);
    display: flex; align-items: center; gap: 12px;
    box-shadow: 0 8px 24px rgb(0 0 0 / .2);
    z-index: 50;
}
.toast button { border: 0; background: none; color: var(--ribbon); font-weight: 650; cursor: pointer; padding: 4px; }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
    .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
    .menu-btn { display: inline-grid; }
    .search { order: 3; flex-basis: 100%; max-width: none; }
    .tabs { margin-left: auto; }
    .tab { padding: 6px 8px; font-size: 14px; }
    .logout { display: none; }
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; z-index: 20; top: 0; left: 0; bottom: 0; height: 100vh;
        width: min(300px, 85vw);
        background: var(--surface);
        transform: translateX(-100%); visibility: hidden;
        transition: transform .2s, visibility .2s;
    }
    body.sidebar-open .sidebar { transform: none; visibility: visible; box-shadow: 0 0 40px rgb(0 0 0 / .25); }
    .main { padding: 16px 16px 48px; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .actions .btn { flex: 1; }
}

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