/* ───────────────────────────── Le Portail — styles ───────────────────────────── */

:root {
  --bg: #0a0b10;
  --bg-2: #0f1118;
  --bg-3: #161826;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-2: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #eef0f6;
  --text-2: #a7adbd;
  --text-3: #6b7285;
  --accent: #8b7cff;
  --accent-2: #50d4ff;
  --accent-rgb: 139, 124, 255;
  --on-accent: #0a0b10;
  --orb-a: rgba(139, 124, 255, 0.35);
  --orb-b: rgba(80, 212, 255, 0.22);
  --grid-line: rgba(255, 255, 255, 0.035);
  --online: #3ddc84;
  --local: #ffb454;
  --file: #50d4ff;
  --html: #f472b6;
  --danger: #ff6b6b;
  --nsfw: #ff4d6d;
  --radius: 22px;
  --radius-s: 12px;
  --font-display: "Bricolage Grotesque", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --font-body: "Manrope", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", Consolas, "Cascadia Mono", monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.7);
  --accent-grad: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color-scheme: dark;
}

/* ───────────── thèmes (hérités du Portail de Kansser + Nuit) ───────────── */
[data-theme="coral"] {
  --bg: #0a0a10; --bg-2: #10101a; --bg-3: #1e1e2a; --text: #f2ece4; --text-2: #8a8493; --text-3: #55525c;
  --accent: #ff6b47; --accent-2: #ffc978; --accent-rgb: 255, 107, 71; --on-accent: #1a0f08;
  --orb-a: rgba(255, 107, 71, 0.30); --orb-b: rgba(77, 217, 196, 0.16);
}
[data-theme="mint"] {
  --bg: #07100f; --bg-2: #0d1a19; --bg-3: #1b302d; --text: #e6f2ee; --text-2: #84938e; --text-3: #4e5c58;
  --accent: #4dd9c4; --accent-2: #0ea5e9; --accent-rgb: 77, 217, 196; --on-accent: #06201c;
  --orb-a: rgba(77, 217, 196, 0.28); --orb-b: rgba(14, 165, 233, 0.16);
}
[data-theme="violet"] {
  --bg: #0c0a14; --bg-2: #14111f; --bg-3: #261f37; --text: #efeafc; --text-2: #9188a3; --text-3: #5a5168;
  --accent: #a78bfa; --accent-2: #ec4899; --accent-rgb: 167, 139, 250; --on-accent: #130a22;
  --orb-a: rgba(167, 139, 250, 0.32); --orb-b: rgba(236, 72, 153, 0.14);
}
[data-theme="midnight"] {
  --bg: #000; --bg-2: #080808; --bg-3: #1a1a1a; --text: #e8e8e8; --text-2: #8a8a8a; --text-3: #4d4d4d;
  --accent: #ffffff; --accent-2: #b8b8b8; --accent-rgb: 255, 255, 255; --on-accent: #000;
  --orb-a: rgba(255, 255, 255, 0.06); --orb-b: rgba(255, 255, 255, 0.04);
}
[data-theme="rose"] {
  --bg: #12080e; --bg-2: #1a0c14; --bg-3: #321a28; --text: #f8e8f0; --text-2: #a08a96; --text-3: #5c4e56;
  --accent: #f472b6; --accent-2: #fb923c; --accent-rgb: 244, 114, 182; --on-accent: #250a17;
  --orb-a: rgba(244, 114, 182, 0.30); --orb-b: rgba(251, 146, 60, 0.14);
}
[data-theme="paper"] {
  --bg: #f4efe5; --bg-2: #ebe4d4; --bg-3: #ffffff;
  --panel: rgba(255, 255, 255, 0.55); --panel-2: rgba(255, 255, 255, 0.85);
  --line: rgba(94, 72, 45, 0.12); --line-2: rgba(94, 72, 45, 0.24);
  --text: #1a1411; --text-2: #6b5d4f; --text-3: #a69a8b;
  --accent: #c44522; --accent-2: #d97706; --accent-rgb: 196, 69, 34; --on-accent: #fff8ef;
  --orb-a: rgba(196, 69, 34, 0.18); --orb-b: rgba(217, 119, 6, 0.14); --grid-line: rgba(94, 72, 45, 0.07);
  --shadow: 0 30px 60px -30px rgba(94, 72, 45, 0.35);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow-x: hidden;
  transition: background 0.5s var(--ease), color 0.3s;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; margin: 0; }
svg { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.mono { font-family: var(--font-mono); font-size: 0.78em; }
.muted { color: var(--text-3); font-weight: 400; }
kbd { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; background: var(--panel); }

/* ───────────── fond ───────────── */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.55; animation: drift 26s var(--ease-io) infinite alternate; transition: background 0.6s; }
.bg-orb-a { width: 60vmax; height: 60vmax; left: -20vmax; top: -30vmax; background: radial-gradient(circle, var(--orb-a), transparent 65%); }
.bg-orb-b { width: 50vmax; height: 50vmax; right: -15vmax; bottom: -25vmax; background: radial-gradient(circle, var(--orb-b), transparent 65%); animation-delay: -12s; }
.bg-grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px; mask-image: radial-gradient(ellipse 70% 60% at 50% 0%, #000 20%, transparent 100%);
}
@keyframes drift { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(6vmax, 4vmax, 0) scale(1.15); } }

/* ───────────── en-tête ───────────── */
.top {
  max-width: 1440px; margin: 0 auto; padding: 44px 40px 8px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  animation: rise 0.8s var(--ease) both;
}
.brand { display: flex; align-items: center; gap: 18px; }
.brand h1 { font-size: clamp(34px, 4vw, 48px); font-weight: 700; line-height: 1; }
.brand-sub { margin: 6px 0 0; color: var(--text-3); font-size: 13px; font-family: var(--font-mono); letter-spacing: 0.02em; }
.brand-mark {
  width: 54px; height: 54px; border-radius: 16px; position: relative; flex: none; background: var(--panel-2); border: 1px solid var(--line-2);
  display: grid; place-items: center; box-shadow: inset 0 1px 0 rgba(255,255,255,0.08); cursor: pointer; transition: transform 0.4s var(--ease-spring);
}
.brand-mark:hover { transform: rotate(-6deg) scale(1.05); }
.brand-mark::before {
  content: ""; width: 26px; height: 26px; border-radius: 50%; border: 5px solid transparent; background: var(--accent-grad) border-box;
  -webkit-mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: spin 9s linear infinite;
}
.brand-mark span { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-grad); box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.9); }
@keyframes spin { to { transform: rotate(360deg); } }

.top-actions { display: flex; align-items: center; gap: 10px; }
.search {
  display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; min-width: 280px; transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
}
.search:focus-within { border-color: var(--line-2); background: var(--panel-2); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.12); }
.search svg { color: var(--text-3); flex: none; }
.search input { flex: 1; background: none; border: 0; outline: 0; min-width: 0; }
.search input::placeholder { color: var(--text-3); }

/* ───────────── boutons ───────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 13px; border: 1px solid var(--line);
  background: var(--panel); font-weight: 600; white-space: nowrap;
  transition: transform 0.25s var(--ease), background 0.25s, border-color 0.25s, box-shadow 0.25s, opacity 0.25s;
}
.btn:hover { background: var(--panel-2); border-color: var(--line-2); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-primary { border: 0; color: var(--on-accent); background: var(--accent-grad); position: relative; overflow: hidden; box-shadow: 0 10px 30px -12px rgba(var(--accent-rgb), 0.8); }
.btn-primary::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.45) 50%, transparent 70%); transform: translateX(-120%); transition: transform 0.7s var(--ease); }
.btn-primary:hover::after { transform: translateX(120%); }
.btn-primary:hover { box-shadow: 0 14px 34px -12px rgba(var(--accent-rgb), 1); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: rgba(255,107,107,0.3); background: rgba(255,107,107,0.06); }
.btn-danger:hover { background: rgba(255,107,107,0.14); border-color: rgba(255,107,107,0.5); }
.btn-sm { height: 36px; padding: 0 13px; font-size: 13px; border-radius: 10px; }
.btn.is-busy { pointer-events: none; }
.btn.is-busy svg { animation: spin 0.9s linear infinite; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; border: 1px solid var(--line);
  background: var(--panel); color: var(--text-2); transition: transform 0.2s var(--ease), background 0.2s, color 0.2s, border-color 0.2s;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); border-color: var(--line-2); transform: translateY(-2px); }
.icon-btn.act-delete:hover { color: var(--danger); border-color: rgba(255,107,107,0.5); }
.icon-btn.act-launch { color: var(--online); }
.icon-btn.is-busy svg { animation: spin 0.9s linear infinite; }
.icon-btn.big { width: 46px; height: 46px; border-radius: 14px; }
.icon-btn.nsfw-on { background: linear-gradient(135deg, var(--nsfw), #ff7a99); color: #fff; border-color: transparent; box-shadow: 0 8px 20px -6px rgba(255, 77, 109, 0.6); }
.card-actions .icon-btn { background: rgba(12, 13, 20, 0.7); backdrop-filter: blur(10px); color: #d8dbe6; }
[data-theme="paper"] .card-actions .icon-btn { background: rgba(255,255,255,0.85); color: #3a2f27; }

/* ───────────── filtres ───────────── */
.filters {
  max-width: 1440px; margin: 0 auto; padding: 20px 40px 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  animation: rise 0.8s 0.08s var(--ease) both;
}
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--text-2); font-weight: 600; font-size: 13.5px;
  transition: background 0.25s, color 0.25s, border-color 0.25s, transform 0.25s var(--ease);
}
.chip:hover { background: var(--panel-2); color: var(--text); transform: translateY(-1px); }
.chip.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-online { background: var(--online); } .dot-local { background: var(--local); } .dot-file { background: var(--file); } .dot-html { background: var(--html); }
.filters-hint { margin-left: auto; color: var(--text-3); font-size: 12.5px; opacity: 0; transition: opacity 0.3s; }
.filters:hover .filters-hint { opacity: 1; }

/* ───────────── grille & catégories ───────────── */
main { max-width: 1440px; margin: 0 auto; padding: 14px 40px 80px; }
.groups { display: flex; flex-direction: column; gap: 26px; }
.group { animation: rise 0.6s var(--ease) both; }
.group-head {
  display: flex; align-items: center; gap: 10px; padding: 4px 6px 12px; cursor: pointer; user-select: none; border-radius: 10px;
  transition: background 0.25s;
}
.group-head:hover { background: var(--panel); }
.group-head .chev { width: 20px; height: 20px; color: var(--text-3); transition: transform 0.3s var(--ease); }
.group.is-collapsed .group-head .chev { transform: rotate(-90deg); }
.group-head .gdot { width: 10px; height: 10px; border-radius: 50%; background: var(--gcolor, var(--accent)); box-shadow: 0 0 12px var(--gcolor, var(--accent)); }
.group-head h2 { font-size: 15px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.group-head .gcount { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); background: var(--panel-2); padding: 2px 8px; border-radius: 6px; }
.group-head.is-over { background: rgba(var(--accent-rgb), 0.15); outline: 1px dashed var(--accent); }
.group.is-collapsed .grid { display: none; }
.grid { display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.card {
  --mx: 50%; --my: 50%;
  position: relative; display: flex; flex-direction: column; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line);
  overflow: hidden; isolation: isolate; will-change: transform;
  transition: transform 0.45s var(--ease), border-color 0.35s, box-shadow 0.45s var(--ease), background 0.35s, opacity 0.35s;
  animation: rise 0.7s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms);
}
.card::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 0; transition: opacity 0.4s;
  background: radial-gradient(420px circle at var(--mx) var(--my), rgba(var(--accent-rgb), 0.16), transparent 45%);
}
.card::after {
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none; border-radius: inherit; opacity: 0; padding: 1px; transition: opacity 0.4s;
  background: radial-gradient(360px circle at var(--mx) var(--my), rgba(var(--accent-rgb), 0.9), rgba(var(--accent-rgb), 0.3) 40%, transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}
.card:hover { transform: translateY(-8px); border-color: var(--line-2); background: var(--panel-2); box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,0.03); }
.card:hover::before, .card:hover::after { opacity: 1; }
.card.is-dragging { opacity: 0.35; transform: scale(0.97); }
.card.is-over { border-color: var(--accent); }
.card.is-leaving { opacity: 0; transform: scale(0.94); }

.card-media { position: relative; aspect-ratio: 16 / 10; overflow: hidden; z-index: 1; background: linear-gradient(160deg, var(--bg-3), var(--bg-2)); }
.card-shot { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; transform: scale(1.001); opacity: 0; transition: transform 0.9s var(--ease), opacity 0.6s; }
.card-shot.is-loaded { opacity: 1; }
.card:hover .card-shot { transform: scale(1.06); }
.card-media::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(to top, rgba(10,11,16,0.55), transparent 45%); opacity: 0.8; transition: opacity 0.4s; }
[data-theme="paper"] .card-media::after { background: linear-gradient(to top, rgba(60,40,20,0.25), transparent 45%); }
.card:hover .card-media::after { opacity: 0.4; }

.card-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--text-3); font-size: 12.5px; font-family: var(--font-mono); }
.card-placeholder.is-shimmer::before { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,0.06) 50%, transparent 80%); background-size: 200% 100%; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.card-monogram {
  width: 72px; height: 72px; border-radius: 20px; display: grid; place-items: center; font-family: var(--font-display); font-size: 30px; font-weight: 800; color: #fff;
  background: var(--pcolor, var(--panel-2)); border: 1px solid rgba(255,255,255,0.15); transition: transform 0.5s var(--ease); text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.card:hover .card-monogram { transform: scale(1.08) rotate(-3deg); }
.card-monogram img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

.card-kind, .card-status, .card-nsfw {
  position: absolute; z-index: 2; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em; background: rgba(10,11,16,0.6); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.1); color: #d8dbe6;
}
[data-theme="paper"] .card-kind, [data-theme="paper"] .card-status, [data-theme="paper"] .card-nsfw { background: rgba(255,255,255,0.8); color: #3a2f27; border-color: rgba(94,72,45,0.15); }
.card-kind { top: 12px; left: 12px; }
.card-kind::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.card-kind.online { color: var(--online); } .card-kind.local { color: var(--local); } .card-kind.file { color: var(--file); } .card-kind.html { color: var(--html); }
.card-status { bottom: 12px; left: 12px; }
.card-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.card-status.is-up i { background: var(--online); animation: pulse 2s infinite; }
.card-status.is-up { color: var(--online); }
.card-nsfw { bottom: 12px; right: 12px; color: var(--nsfw); }
.card-nsfw::before { content: "●"; font-size: 9px; text-shadow: 0 0 8px var(--nsfw); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(61,220,132,0.55); } 70% { box-shadow: 0 0 0 7px rgba(61,220,132,0); } 100% { box-shadow: 0 0 0 0 rgba(61,220,132,0); } }

.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; position: relative; z-index: 1; }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-icon { width: 32px; height: 32px; border-radius: 10px; flex: none; display: grid; place-items: center; overflow: hidden; background: var(--pcolor, var(--panel-2)); border: 1px solid var(--line); font-size: 17px; }
.card-icon img { width: 100%; height: 100%; object-fit: cover; }
.card-icon.is-favicon { background: var(--panel-2); }
.card-icon.is-favicon img { width: 18px; height: 18px; object-fit: contain; }
.card-icon b { font-family: var(--font-display); font-size: 13px; font-weight: 800; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,0.3); }
.card-title { font-size: 18px; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-arrow { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; color: var(--text-3); border: 1px solid transparent; transition: all 0.4s var(--ease); }
.card-arrow svg { transition: transform 0.4s var(--ease); }
.card:hover .card-arrow { color: var(--on-accent); background: var(--accent-grad); }
.card:hover .card-arrow svg { transform: translate(2px, -2px); }
.card-desc { margin: 0; color: var(--text-2); font-size: 13.5px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.card-desc:empty::before { content: "Pas encore de description."; color: var(--text-3); font-style: italic; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 6px; }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text-2); transition: background 0.25s, border-color 0.25s; }
.card:hover .tag { background: rgba(var(--accent-rgb), 0.1); border-color: rgba(var(--accent-rgb), 0.3); }
.card-host { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.card-link { position: absolute; inset: 0; z-index: 2; border-radius: inherit; outline-offset: -3px; }
.card-link:focus-visible { outline: 2px solid var(--accent); }
.card-actions { position: absolute; top: 12px; right: 12px; z-index: 4; display: flex; gap: 6px; opacity: 0; transform: translateY(-6px); transition: opacity 0.3s, transform 0.4s var(--ease); }
.card:hover .card-actions, .card:focus-within .card-actions { opacity: 1; transform: translateY(0); }

/* ───────────── état vide ───────────── */
.empty { text-align: center; padding: 80px 20px; color: var(--text-2); animation: rise 0.6s var(--ease) both; }
.empty h2 { font-size: 28px; color: var(--text); margin-bottom: 8px; }
.empty p { margin: 0 0 24px; }
.empty-art { width: 120px; height: 120px; margin: 0 auto 24px; border-radius: 36px; background: var(--panel); border: 1px dashed var(--line-2); position: relative; }
.empty-art::after { content: "+"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 48px; font-family: var(--font-display); color: var(--text-3); }
.no-result { grid-column: 1 / -1; color: var(--text-3); padding: 30px; text-align: center; }

/* ───────────── modales ───────────── */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5,6,10,0.7); backdrop-filter: blur(8px); animation: fade 0.3s both; }
[data-theme="paper"] .modal-backdrop { background: rgba(60,45,30,0.45); }
.modal-panel {
  position: relative; width: min(980px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: 26px; box-shadow: 0 40px 100px -20px rgba(0,0,0,0.8); animation: pop 0.45s var(--ease) both; scrollbar-width: thin;
}
.modal-panel.narrow { width: min(560px, 100%); }
.modal-panel.tiny { width: min(440px, 100%); }
@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }
.modal-panel.is-shaking { animation: shake 0.32s ease-out; }

.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 26px 0; gap: 12px; }
.modal-head h2 { font-size: 26px; }
.modal-head p { margin: 4px 0 0; color: var(--text-3); font-size: 13px; }
.modal-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 26px; padding: 20px 26px; }
.modal-body { padding: 18px 26px 6px; display: flex; flex-direction: column; gap: 16px; }
.modal-form { display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 16px 26px 22px; }
.modal-err { margin-right: auto; color: var(--danger); font-size: 13px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span, .seg button {
  display: block; width: 100%; text-align: center; padding: 9px 8px; border-radius: 10px; font-weight: 600; font-size: 13.5px; color: var(--text-2);
  cursor: pointer; border: 0; background: transparent; transition: background 0.25s, color 0.25s;
}
.seg span:hover, .seg button:hover { color: var(--text); }
.seg input:checked + span, .seg button.is-active { background: var(--text); color: var(--bg); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }

.field { display: flex; flex-direction: column; gap: 7px; }
.field > label, .field > summary { font-size: 13px; font-weight: 700; color: var(--text-2); }
.field input[type=text], .field input[type=url], .field input[type=password], .field textarea, .field select {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); outline: 0;
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
}
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.field select option { background: var(--bg-2); color: var(--text); }
.field textarea { height: auto; padding: 11px 14px; resize: vertical; min-height: 80px; }
.field textarea.code { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.55; min-height: 220px; max-height: 420px; white-space: pre; overflow: auto; tab-size: 2; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: rgba(var(--accent-rgb), 0.6); background: var(--panel-2); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.12); }
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.field-row { display: flex; gap: 8px; align-items: center; }
.field-row input { flex: 1; }
.field-row-tight { margin-top: 2px; }
.inline-label { font-size: 12.5px; color: var(--text-3); min-width: 76px; font-weight: 600; }
.field-msg { font-size: 12.5px; color: var(--text-3); min-height: 1.2em; }
.field-msg.ok { color: var(--online); } .field-msg.err { color: var(--danger); }
.field.is-hidden { display: none; }
.check-row { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--text-2); cursor: pointer; margin-top: 4px; }
.check-row input { margin-top: 3px; accent-color: var(--accent); }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.link-btn { background: none; border: 0; color: var(--accent); font-size: 12.5px; font-weight: 600; padding: 0; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
details.advanced summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details.advanced summary::before { content: "▸"; color: var(--text-3); transition: transform 0.25s; display: inline-block; }
details.advanced[open] summary::before { transform: rotate(90deg); }
details.advanced .field-row { margin-top: 8px; }

/* toggle */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: border-color 0.25s, background 0.25s; }
.toggle-row.is-on { border-color: rgba(255, 77, 109, 0.5); background: rgba(255, 77, 109, 0.06); }
.toggle-row strong { font-size: 14px; display: block; }
.toggle-row small { display: block; color: var(--text-3); font-size: 12px; margin-top: 2px; }
.switch { width: 44px; height: 24px; background: var(--bg-3); border-radius: 12px; position: relative; flex: none; transition: background 0.25s; border: 1px solid var(--line); }
.switch::before { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: var(--text); border-radius: 50%; transition: transform 0.3s var(--ease-spring), background 0.25s; }
.toggle-row.is-on .switch { background: var(--nsfw); border-color: transparent; }
.toggle-row.is-on .switch::before { transform: translateX(20px); background: #fff; }

/* apparence */
.appearance { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pick-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-chip, .color-dot {
  aspect-ratio: 1; border-radius: 9px; cursor: pointer; display: grid; place-items: center; font-size: 17px; border: 2px solid transparent; background: var(--panel);
  transition: transform 0.2s var(--ease-spring), border-color 0.2s, background 0.2s;
}
.emoji-chip:hover, .color-dot:hover { transform: scale(1.1); }
.emoji-chip.is-active { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.15); }
.color-dot.is-active { border-color: var(--text); transform: scale(1.1); }
.img-uploader { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.img-preview { width: 58px; height: 58px; border-radius: 14px; background: var(--pcolor, var(--panel-2)); display: grid; place-items: center; overflow: hidden; flex: none; font-size: 26px; border: 1px solid var(--line); }
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-preview.is-favicon img { width: 28px; height: 28px; object-fit: contain; }
.img-actions { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }

/* aperçu (modale lien) */
.modal-preview { display: flex; flex-direction: column; gap: 14px; }
.preview-frame { aspect-ratio: 16 / 10; border-radius: 16px; overflow: hidden; position: relative; background: linear-gradient(160deg, var(--bg-3), var(--bg-2)); border: 1px solid var(--line); }
.preview-frame img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; animation: fade 0.5s both; }
.preview-frame.is-busy::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,0.08) 50%, transparent 80%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.preview-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; color: var(--text-3); font-size: 13px; }
.preview-empty p { margin: 0; max-width: 260px; }
.preview-mono { width: 62px; height: 62px; border-radius: 18px; display: grid; place-items: center; background: var(--pcolor, var(--panel-2)); border: 1px solid var(--line-2); font-family: var(--font-display); font-size: 26px; font-weight: 800; color: #fff; overflow: hidden; }
.preview-mono img { width: 100%; height: 100%; object-fit: cover; }
.preview-meta { display: flex; align-items: center; gap: 12px; }
.preview-meta strong { display: block; font-family: var(--font-display); font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-meta > div { min-width: 0; }
.preview-meta .mono { color: var(--text-3); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-icon { width: 38px; height: 38px; border-radius: 11px; flex: none; display: grid; place-items: center; background: var(--pcolor, var(--panel-2)); border: 1px solid var(--line); overflow: hidden; font-family: var(--font-display); font-weight: 800; font-size: 19px; color: #fff; }
.preview-icon img { width: 100%; height: 100%; object-fit: cover; }
.preview-icon.is-favicon { background: var(--panel-2); }
.preview-icon.is-favicon img { width: 22px; height: 22px; object-fit: contain; }
.preview-actions { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; }

/* réglages */
.set-section { padding: 16px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.set-section:last-child { border-bottom: 0; }
.set-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-2); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.set-title.danger { color: var(--danger); }
.set-hint { font-size: 12.5px; color: var(--text-3); }
.set-row { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.theme-card { position: relative; aspect-ratio: 16 / 10; border-radius: 12px; cursor: pointer; overflow: hidden; border: 2px solid transparent; transition: transform 0.2s var(--ease-spring), border-color 0.2s; }
.theme-card:hover { transform: translateY(-2px) scale(1.03); }
.theme-card.is-active { border-color: var(--accent); }
.theme-card .tc { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 5px; padding: 10px; }
.theme-card .tc i { height: 4px; border-radius: 2px; opacity: 0.5; }
.theme-card .tc-accent { position: absolute; bottom: 8px; left: 10px; width: 12px; height: 12px; border-radius: 50%; }
.theme-card .tc-name { position: absolute; bottom: 5px; right: 9px; font-size: 11px; font-weight: 700; }
.theme-card.is-active::after { content: "✓"; position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.storage-info { font-size: 12.5px; color: var(--text-2); padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; font-family: var(--font-mono); }

/* palette de commandes */
.cmd-panel { width: min(600px, 100%); align-self: start; margin-top: 12vh; }
.cmd-input { width: 100%; padding: 20px 24px; background: transparent; border: 0; color: var(--text); font-size: 17px; outline: 0; border-bottom: 1px solid var(--line); }
.cmd-input::placeholder { color: var(--text-3); }
.cmd-list { max-height: 420px; overflow-y: auto; padding: 8px; }
.cmd-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px; cursor: pointer; transition: background 0.12s; }
.cmd-item:hover, .cmd-item.is-sel { background: var(--panel-2); }
.cmd-item .ci { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; font-size: 14px; flex: none; overflow: hidden; background: var(--pcolor, var(--panel-2)); color: #fff; }
.cmd-item .ci img { width: 100%; height: 100%; object-fit: cover; }
.cmd-item .ci.is-favicon { background: var(--panel-2); }
.cmd-item .ci.is-favicon img { width: 18px; height: 18px; object-fit: contain; }
.cmd-item .ct { flex: 1; font-size: 14px; min-width: 0; }
.cmd-item .ct small { display: block; color: var(--text-3); font-size: 11px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmd-item .ck { color: var(--text-3); font-family: var(--font-mono); font-size: 11px; }
.cmd-foot { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; gap: 16px; font-size: 11px; color: var(--text-3); }

/* menu contextuel */
.ctx {
  position: fixed; z-index: 70; min-width: 200px; padding: 6px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  animation: pop 0.2s var(--ease) both;
}
.ctx button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 8px; border: 0; background: transparent; font-size: 13.5px; font-weight: 500; text-align: left; transition: background 0.15s; }
.ctx button:hover { background: var(--panel-2); }
.ctx button.danger { color: var(--danger); }
.ctx hr { border: 0; height: 1px; background: var(--line); margin: 4px 0; }

/* confirmation */
.confirm-panel h3 { font-size: 22px; margin-bottom: 8px; }
.confirm-panel p { color: var(--text-2); margin: 0 0 20px; }
.confirm-panel { padding: 26px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* toasts */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 80; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line-2); backdrop-filter: blur(12px); font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); animation: toast-in 0.45s var(--ease) both; }
.toast.is-out { animation: toast-out 0.35s var(--ease-io) both; }
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.toast.ok::before { background: var(--online); } .toast.err::before { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

@media (max-width: 900px) {
  .top, .filters, main { padding-left: 20px; padding-right: 20px; }
  .modal-grid, .appearance { grid-template-columns: 1fr; }
  .search { min-width: 0; flex: 1; }
  .top-actions { width: 100%; flex-wrap: wrap; }
  .filters-hint { display: none; }
  .btn-add span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ───────────── mode cloud & mobile (cloud.js / login.html) ───────────── */
/* badge « PC uniquement » / « Wi-Fi » (réutilise .card-status) et carte désactivée */
.card-status.is-pc { color: #d8dbe6; }
.card-status.is-pc i { background: var(--local); }
.card-status.is-lan { color: var(--accent-2); }
.card-status.is-lan i { background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); }
.card.is-disabled .card-link { pointer-events: none; }
.card.is-disabled { cursor: default; }
.card.is-disabled .card-media { filter: saturate(0.35); opacity: 0.8; }
.card.is-disabled:hover { transform: none; box-shadow: none; }
.card.is-disabled:hover::before, .card.is-disabled:hover::after { opacity: 0; }
.card.is-disabled:hover .card-arrow { background: transparent; color: var(--text-3); }
.card.is-disabled .card-arrow { opacity: 0.35; }
/* tactile : actions toujours visibles, pas d'effet de survol */
@media (hover: none) {
  .card-actions { opacity: 1; transform: none; }
  .card:hover { transform: none; }
  .card:hover .card-shot { transform: none; }
}
/* bandeaux (hors-ligne, instantané) */
.sync-bar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 9px 16px; padding-top: calc(9px + env(safe-area-inset-top, 0px)); font-size: 13px; font-weight: 600;
  background: var(--bg-2); border-bottom: 1px solid var(--line-2); color: var(--text-2); animation: rise 0.4s var(--ease) both;
}
.sync-bar::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.sync-bar.offline { color: var(--local); background: rgba(255, 180, 84, 0.08); border-bottom-color: rgba(255, 180, 84, 0.35); }
.sync-bar.snapshot { color: var(--accent-2); }
/* état de synchronisation (PC en ligne, appairage) */
.sync-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); vertical-align: middle; flex: none; }
.sync-dot.is-up { background: var(--online); box-shadow: 0 0 8px var(--online); }
.sync-dot.is-busy { background: var(--local); }
.sync-dot.is-err { background: var(--danger); }
#pc-dot .sync-dot { margin: 0 2px 2px 0; }
/* hors ligne : écritures grisées (même liste que le blocage des clics dans cloud.js) */
.is-offline .btn-add, .is-offline .act-delete, .is-offline .act-shot,
.is-offline #btn-add-empty, .is-offline #btn-import, .is-offline #btn-import-empty,
.is-offline #btn-new-cat, .is-offline #btn-wipe, .is-offline #btn-pw-reset { opacity: 0.45; }
/* éditeur : champs réservés au PC (cloud) */
[data-pc-only].is-pc-only { opacity: 0.5; pointer-events: none; }
.seg label.is-disabled span { opacity: 0.4; cursor: not-allowed; }
.pc-only-hint { color: var(--local); }
/* Paramètres : sessions (cloud) et appairage (PC) */
.set-subtitle { font-size: 12.5px; font-weight: 700; color: var(--text-2); margin-top: 4px; }
.sessions { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-3); }
.session-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: var(--text); }
.session-row.is-current { border-color: rgba(var(--accent-rgb), 0.45); }
.session-info { min-width: 0; display: flex; flex-direction: column; }
.session-info strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-info small { color: var(--text-3); font-size: 11.5px; }
.pair-form { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.pair-form .field-row input { width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); outline: 0; }
.pair-form .field-row input:focus { border-color: rgba(var(--accent-rgb), 0.6); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.12); }
#cloud-pw-details .field-row input { width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); outline: 0; }
#cloud-pw-details .field-row input:focus { border-color: rgba(var(--accent-rgb), 0.6); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.12); }
/* page de connexion (login.html) */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; padding-top: max(24px, env(safe-area-inset-top, 0px)); padding-bottom: max(24px, env(safe-area-inset-bottom, 0px)); }
.login-box {
  width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; text-align: center; padding: 34px 28px 26px;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 26px; box-shadow: var(--shadow); animation: pop 0.5s var(--ease) both;
}
.login-box.is-shaking { animation: shake 0.32s ease-out; }
.login-mark { margin: 0 auto 4px; cursor: default; }
.login-mark:hover { transform: none; }
.login-box h1 { font-size: 32px; }
.login-sub { margin: -6px 0 6px; color: var(--text-2); font-size: 14px; }
.login-box .field { text-align: left; }
.login-btn { height: 48px; justify-content: center; }
.login-hint { color: var(--text-3); font-size: 12px; }
/* zones sûres (encoche, barre de gestes) */
.top { padding-top: calc(44px + env(safe-area-inset-top, 0px)); }
main { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 900px) {
  .top { padding-top: calc(28px + env(safe-area-inset-top, 0px)); }
}
/* téléphone : modales en feuille pleine largeur */
@media (max-width: 600px) {
  .modal { padding: 0; align-items: end; }
  .modal-panel, .modal-panel.narrow, .modal-panel.tiny { width: 100%; max-height: 100dvh; border-radius: 22px 22px 0 0; }
  .modal-panel.cmd-panel { align-self: start; margin-top: 0; border-radius: 0 0 22px 22px; }
  .modal-head, .modal-grid, .modal-body, .modal-foot, .confirm-panel { padding-left: 18px; padding-right: 18px; }
  .modal-foot { padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
  .modal-head h2 { font-size: 22px; }
  .grid { grid-template-columns: 1fr; }
  .brand h1 { font-size: 30px; }
  .toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .toast { justify-content: center; }
}
