@font-face {
  font-family: "Archive Signature";
  src: url("/sonotheque/assets/fonts/archive-signature.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  color: #edf2ff;
  background: #060d17;
  font-synthesis: none;
  --ink: #edf2ff;
  --muted: #8d9ab7;
  --quiet: #65728e;
  --deep: #060d17;
  --navy: #0b1528;
  --surface: #101d32;
  --line: rgba(151, 169, 207, 0.14);
  --line-strong: rgba(151, 169, 207, 0.25);
  --blue: #6b94ee;
  --blue-bright: #84a8fa;
  --gold: #d7b56d;
  --danger: #ff8b9c;
  --green: #4fd0a4;
  --header-height: 78px;
}

* { box-sizing: border-box; }
html, body, #app { width: 100%; min-width: 320px; min-height: 100%; margin: 0; }
body { min-height: 100svh; overflow: hidden; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; }
::selection { background: rgba(107, 148, 238, 0.35); }

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

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--gold);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.eyebrow svg, .trust-line svg, .field-with-icon svg, .primary-action svg, .node-icon svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.eyebrow svg { width: 15px; height: 15px; }
.trust-line svg { width: 17px; height: 17px; }

.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: block;
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  border-radius: 15px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(196, 215, 255, 0.28), 0 0 18px rgba(84, 151, 255, 0.15), 0 3px 10px rgba(0, 0, 0, 0.4);
}
.brand-lockup > div { display: grid; line-height: 1; }
.brand-lockup strong { font-size: 20px; letter-spacing: -0.025em; }
.brand-lockup span { margin-top: 6px; color: var(--muted); font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase; }

.primary-action {
  display: inline-flex;
  min-height: 49px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 18px;
  border-radius: 11px;
  background: var(--blue);
  box-shadow: 0 10px 26px rgba(62, 101, 191, 0.24);
  color: white;
  font-weight: 700;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
.primary-action:hover:not(:disabled) { transform: translateY(-1px); background: var(--blue-bright); box-shadow: 0 14px 30px rgba(62, 101, 191, 0.32); }
.primary-action:disabled { opacity: 0.48; }

/* Connexion — structure issue de Premails Chat et adaptée à PremArchives. */
.signin-shell {
  position: relative;
  display: grid;
  min-height: 100svh;
  grid-template-columns: minmax(0, 1.3fr) minmax(360px, 0.7fr);
  overflow: hidden;
  background: radial-gradient(circle at 12% 7%, rgba(77, 113, 191, 0.22), transparent 33%), linear-gradient(145deg, #091427, #050b15 75%);
}
.signin-shell::before {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 52px 52px;
  content: "";
  mask-image: linear-gradient(to right, #000, transparent 72%);
  pointer-events: none;
}
.signin-intro {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100svh;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(34px, 6vw, 78px);
  border-right: 1px solid var(--line);
  animation: intro-reveal 650ms cubic-bezier(.2,.8,.2,1) both;
}
.signin-statement { max-width: 760px; }
.signin-statement h1 {
  max-width: 760px;
  margin: 22px 0 20px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(39px, 4.45vw, 68px);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.04em;
}
.signin-statement > p:last-child { max-width: 610px; color: #a9b6d2; font-size: 16px; line-height: 1.75; }
.trust-line { display: flex; flex-wrap: wrap; gap: 24px; color: var(--muted); font-size: 12px; }
.trust-line span { display: flex; align-items: center; gap: 8px; }
.trust-line span:first-child { color: #cbd8f5; }
.signin-panel {
  position: relative;
  z-index: 2;
  display: flex;
  min-height: 100svh;
  flex-direction: column;
  justify-content: center;
  padding: clamp(32px, 6vw, 72px);
  background: rgba(7, 15, 29, 0.72);
  backdrop-filter: blur(24px);
  animation: panel-reveal 620ms 100ms cubic-bezier(.2,.8,.2,1) both;
}
.signin-panel-heading h2 { margin: 10px 0 8px; font-size: clamp(25px, 3vw, 33px); letter-spacing: -0.035em; }
.signin-panel-heading > p:last-child { margin: 0; color: var(--muted); font-size: 14px; }
.signin-mobile-brand { display: none; }
.signin-form { display: grid; gap: 17px; margin-top: 36px; }
.signin-form label { display: grid; gap: 8px; color: #c3cee5; font-size: 12px; font-weight: 600; }
.field-with-icon {
  display: flex;
  min-height: 51px;
  align-items: center;
  gap: 11px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(4, 10, 21, 0.55);
  color: var(--quiet);
  transition: border-color 150ms ease, box-shadow 150ms ease, color 150ms ease;
}
.field-with-icon:focus-within { border-color: rgba(107, 148, 238, 0.7); box-shadow: 0 0 0 3px rgba(107, 148, 238, 0.1); color: var(--blue-bright); }
.field-with-icon input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; }
.field-with-icon input::placeholder { color: #586680; }
.password-visibility-toggle { display: grid; flex: 0 0 36px; place-items: center; width: 36px; height: 36px; border-radius: 8px; background: transparent; color: var(--quiet); }
.password-visibility-toggle:hover, .password-visibility-toggle:focus-visible { background: rgba(107, 148, 238, 0.12); color: var(--ink); outline: none; }
.signin-action { width: 100%; margin-top: 5px; }
.form-error { margin: 0; color: #ff9daf; font-size: 12px; line-height: 1.5; }
.account-note { margin: 26px 0 0; color: var(--quiet); font-size: 12px; line-height: 1.6; }
.account-note a, .signin-legal-links a { color: #c8d7f8; text-underline-offset: 3px; }
.signin-legal-links { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; color: var(--quiet); font-size: 12px; line-height: 1.6; }

/* Portail commun */
.archive-shell {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  background: #060d17;
  isolation: isolate;
}
.archive-shell::before {
  position: absolute;
  z-index: -2;
  inset: 0;
  background-image: linear-gradient(rgba(139, 170, 213, .04) 1px, transparent 1px), linear-gradient(90deg, rgba(139, 170, 213, .04) 1px, transparent 1px);
  background-size: 48px 48px;
  content: "";
}
.archive-shell::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: radial-gradient(circle at 50% 54%, rgba(68, 127, 212, .12), transparent 31%), linear-gradient(90deg, rgba(6,13,23,.25), transparent 16%, transparent 84%, rgba(6,13,23,.25));
  content: "";
  pointer-events: none;
}
.archive-header {
  position: relative;
  z-index: 20;
  display: flex;
  height: var(--header-height);
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(24px, 4.2vw, 72px);
  border-bottom: 1px solid var(--line);
  background: rgba(5, 12, 21, .82);
  backdrop-filter: blur(18px);
}
.signature-brand {
  margin: 0;
  color: #f2f5fd;
  font-family: "Archive Signature", cursive;
  font-size: clamp(42px, 4vw, 62px);
  font-weight: 400;
  line-height: 1;
  text-shadow: 0 0 28px rgba(107, 148, 238, .16);
}
.account-area { display: flex; align-items: center; gap: 18px; }
.account-copy { display: grid; gap: 4px; text-align: right; }
.account-copy strong { color: #dce6f8; font-size: 12px; }
.account-copy span { color: var(--quiet); font-size: 9px; letter-spacing: .12em; text-transform: uppercase; }
.quiet-action {
  min-height: 37px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,.025);
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  transition: color 160ms, border-color 160ms, background 160ms;
}
.quiet-action:hover { border-color: rgba(132,168,250,.45); background: rgba(107,148,238,.08); color: var(--ink); }

.archive-workspace {
  position: relative;
  height: calc(100svh - var(--header-height));
  min-height: 590px;
  overflow: hidden;
}
.archive-intro {
  position: absolute;
  z-index: 8;
  top: clamp(28px, 5vh, 58px);
  left: clamp(24px, 4.2vw, 72px);
  max-width: 460px;
  animation: map-copy-in 650ms cubic-bezier(.2,.8,.2,1) both;
}
.archive-intro h1 {
  margin: 11px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 4vw, 58px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.04em;
}
.archive-intro > p:last-child { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.library-count {
  position: absolute;
  z-index: 8;
  top: clamp(35px, 5vh, 62px);
  right: clamp(24px, 4.2vw, 72px);
  display: grid;
  justify-items: end;
  gap: 6px;
  color: var(--quiet);
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.library-count strong { color: #f0f4fc; font: 400 26px/1 Georgia, serif; letter-spacing: 0; }

.archive-map {
  --pointer-x: 0px;
  --pointer-y: 0px;
  position: absolute;
  inset: 0;
  transform: translate3d(var(--pointer-x), var(--pointer-y), 0);
  transition: transform 240ms ease-out;
}
.map-axis-x, .map-axis-y { position: absolute; z-index: 0; background: rgba(121,157,204,.1); pointer-events: none; }
.map-axis-x { top: 56%; left: 17%; width: 66%; height: 1px; }
.map-axis-y { top: 19%; left: 50%; width: 1px; height: 67%; }
.orbit {
  position: absolute;
  z-index: 0;
  top: 56%;
  left: 50%;
  border: 1px solid rgba(121, 157, 204, .13);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.orbit-one { width: 230px; height: 230px; }
.orbit-two { width: min(55vw, 640px); height: min(55vw, 640px); border-style: dashed; opacity: .62; animation: orbit-spin 70s linear infinite; }
.orbit-three { width: min(73vw, 910px); height: min(73vw, 910px); border-style: dotted; opacity: .42; }
.map-links { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.map-links path { fill: none; stroke: rgba(110, 160, 228, .22); stroke-width: 1; stroke-dasharray: 5 9; animation: link-dash 24s linear infinite; }

.archive-core {
  position: absolute;
  z-index: 5;
  top: 56%;
  left: 50%;
  width: 142px;
  height: 142px;
  transform: translate(-50%, -50%);
  animation: core-in 720ms cubic-bezier(.2,.8,.2,1) both;
}
.archive-core::before, .archive-core::after {
  position: absolute;
  border: 1px solid rgba(108, 172, 255, .34);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}
.archive-core::before { inset: -13px; border-style: dotted; animation: orbit-spin 28s linear infinite; }
.archive-core::after { inset: -24px; border-color: rgba(108, 172, 255, .12); }
.archive-core img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; filter: drop-shadow(0 0 24px rgba(68, 139, 244, .3)); }

.library-node {
  position: absolute;
  z-index: 6;
  display: grid;
  width: 230px;
  grid-template-columns: 58px 1fr;
  align-items: center;
  gap: 14px;
  padding: 13px 15px;
  border: 1px solid rgba(121, 157, 204, .2);
  border-radius: 2px;
  background: rgba(6, 14, 25, .78);
  box-shadow: 0 16px 50px rgba(0,0,0,.18);
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  backdrop-filter: blur(12px);
  transform: translate(-50%, -50%);
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease, box-shadow 180ms ease;
  animation: node-in 620ms cubic-bezier(.2,.8,.2,1) both;
}
.library-node:hover, .library-node:focus-visible {
  border-color: rgba(115, 172, 250, .58);
  background: rgba(12, 29, 50, .94);
  box-shadow: 0 20px 56px rgba(0,0,0,.32), 0 0 0 1px rgba(107,148,238,.08);
  outline: none;
  transform: translate(-50%, -50%) scale(1.025);
}
.node-icon {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid rgba(107,148,238,.28);
  background: radial-gradient(circle at 35% 25%, rgba(116,174,255,.23), rgba(9,20,36,.8));
  color: #91b7ff;
}
.node-icon svg { width: 25px; height: 25px; }
.node-copy { display: grid; gap: 5px; min-width: 0; }
.node-copy small { color: var(--gold); font-size: 8px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
.node-copy strong { font: 400 20px/1.05 Georgia, serif; }
.node-copy span { color: var(--quiet); font-size: 9px; }
.node-arrow { position: absolute; top: 11px; right: 12px; color: var(--quiet); font-size: 13px; opacity: 0; transform: translateX(-4px); transition: opacity 160ms, transform 160ms, color 160ms; }
.library-node:hover .node-arrow, .library-node:focus-visible .node-arrow { color: var(--blue-bright); opacity: 1; transform: none; }
.node-media { top: 30%; left: 50%; animation-delay: 110ms; }
.node-photo { top: 67%; left: 23%; animation-delay: 190ms; }
.node-audio { top: 67%; left: 77%; animation-delay: 270ms; }
.library-node[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }

.map-legend {
  position: absolute;
  z-index: 8;
  right: clamp(24px, 4.2vw, 72px);
  bottom: 28px;
  display: flex;
  align-items: center;
  gap: 17px;
  color: var(--quiet);
  font-size: 9px;
}
.map-legend span { display: flex; align-items: center; gap: 7px; }
.map-legend i { width: 18px; height: 1px; background: var(--blue); }
.map-legend span:last-child i { background: var(--gold); }

.preview-switch {
  position: fixed;
  z-index: 100;
  right: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: rgba(5, 12, 22, .92);
  box-shadow: 0 12px 38px rgba(0,0,0,.35);
  backdrop-filter: blur(14px);
}
.preview-switch span { padding: 0 7px; color: var(--quiet); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.preview-switch button { min-height: 30px; padding: 0 10px; border-radius: 7px; background: transparent; color: var(--muted); font-size: 10px; }
.preview-switch button.is-active { background: rgba(107,148,238,.2); color: #dce8ff; }
.toast {
  position: fixed;
  z-index: 120;
  left: 50%;
  bottom: 25px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border: 1px solid var(--line-strong);
  background: #101d32;
  box-shadow: 0 14px 45px rgba(0,0,0,.4);
  color: #dce6fa;
  font-size: 11px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms, transform 180ms;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.loading-screen {
  display: grid;
  min-height: 100svh;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: radial-gradient(circle, rgba(107,148,238,.12), transparent 29%), var(--deep);
}
.loading-screen img { filter: drop-shadow(0 0 23px rgba(107,148,238,.25)); animation: breathe 1.8s ease-in-out infinite; }
.loading-screen p { margin: 0; color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.loading-rule { width: 150px; height: 2px; margin-top: 8px; overflow: hidden; background: rgba(255,255,255,.06); }
.loading-rule i { display: block; width: 45%; height: 100%; background: linear-gradient(90deg, transparent, var(--blue), transparent); animation: loading-slide 1.2s ease infinite; }

@keyframes intro-reveal { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes panel-reveal { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes map-copy-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes core-in { from { opacity: 0; transform: translate(-50%, -50%) scale(.82); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes node-in { from { opacity: 0; transform: translate(-50%, -50%) scale(.94); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes orbit-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes link-dash { to { stroke-dashoffset: -280; } }
@keyframes loading-slide { from { transform: translateX(-100%); } to { transform: translateX(320%); } }
@keyframes breathe { 50% { transform: scale(1.035); opacity: .82; } }

@media (max-width: 980px) {
  .node-photo { left: 20%; }
  .node-audio { left: 80%; }
  .library-node { width: 210px; }
  .archive-intro { max-width: 380px; }
}

@media (max-width: 820px), (hover: none) {
  body { overflow-y: auto; }
  .signin-shell { grid-template-columns: 1fr; overflow-y: auto; }
  .signin-intro { min-height: 0; justify-content: flex-start; gap: 32px; padding: 32px 28px 28px; border-right: 0; }
  .signin-intro > .brand-lockup { display: none; }
  .signin-statement h1 { margin: 16px 0; font-size: clamp(38px, 8vw, 48px); }
  .signin-statement > p:last-child { font-size: 17px; line-height: 1.65; }
  .trust-line { display: grid; gap: 10px; font-size: 14px; }
  .signin-panel { order: -1; min-height: 0; justify-content: flex-start; padding: 30px 28px calc(34px + env(safe-area-inset-bottom)); border-bottom: 1px solid var(--line); background: rgba(7, 15, 29, .9); }
  .signin-mobile-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
  .signin-mobile-brand .brand-mark { width: 48px; height: 48px; border-radius: 14px; }
  .signin-mobile-brand > div { display: grid; line-height: 1; }
  .signin-mobile-brand strong { font-size: 20px; }
  .signin-mobile-brand span { margin-top: 5px; color: var(--muted); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; }
  .signin-panel-heading h2 { font-size: clamp(30px, 7vw, 38px); }
  .signin-panel-heading > p:last-child { font-size: 16px; line-height: 1.5; }
  .signin-form { gap: 18px; margin-top: 28px; }
  .signin-form label { gap: 9px; font-size: 14px; }
  .field-with-icon { min-height: 60px; padding: 0 16px; }
  .field-with-icon input { font-size: 16px; }
  .signin-action { min-height: 58px; font-size: 17px; }
  .account-note, .signin-legal-links { font-size: 14px; }
}

@media (max-width: 760px) {
  :root { --header-height: 68px; }
  .archive-shell { min-height: 100svh; overflow-y: auto; }
  .archive-header { position: sticky; top: 0; padding: 0 18px; }
  .signature-brand { font-size: 42px; }
  .account-copy { display: none; }
  .quiet-action { padding: 0 10px; }
  .archive-workspace { height: auto; min-height: calc(100svh - var(--header-height)); padding: 34px 18px 96px; overflow: visible; }
  .archive-intro, .library-count, .archive-map, .map-legend { position: relative; inset: auto; }
  .archive-intro { max-width: none; }
  .library-count { position: absolute; top: 38px; right: 18px; }
  .archive-intro h1 { max-width: 74%; font-size: 40px; }
  .archive-intro > p:last-child { max-width: 75%; }
  .archive-map { display: grid; gap: 10px; margin-top: 48px; transform: none !important; }
  .map-axis-x, .map-axis-y, .orbit, .map-links { display: none; }
  .archive-core { position: relative; top: auto; left: auto; width: 98px; height: 98px; margin: 0 auto 22px; transform: none; animation-name: core-in-mobile; }
  .library-node { position: relative; top: auto; left: auto; width: 100%; max-width: 520px; min-height: 88px; margin: 0 auto; transform: none; animation-name: node-in-mobile; }
  .library-node:hover, .library-node:focus-visible { transform: translateX(3px); }
  .map-legend { justify-content: center; margin-top: 30px; }
  .preview-switch { right: 8px; bottom: 8px; }
  .preview-switch span { display: none; }
}

@media (max-width: 480px) {
  .archive-intro h1, .archive-intro > p:last-child { max-width: none; }
  .library-count { display: none; }
  .archive-intro h1 { font-size: 36px; }
  .node-icon { width: 52px; height: 52px; }
  .library-node { grid-template-columns: 52px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@keyframes core-in-mobile { from { opacity: 0; transform: scale(.86); } to { opacity: 1; transform: none; } }
@keyframes node-in-mobile { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
