/* =========================================================================
   Roystone — Espaces clients
   Reprise des tokens du site roystone.ch (variables.css) : « Gravure d'or ».
   ========================================================================= */

:root {
  --bg-primary: #0a0a0c;
  --bg-secondary: #111114;
  --bg-tertiary: #1a1a1e;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --text-muted: #7c7c80;
  --accent: #c4a162;
  --accent-hover: #d4b172;
  --accent-glow: rgba(196, 161, 98, 0.2);
  --border: #2a2a2e;
  --border-strong: #3d3d44;
  --raise: rgba(255, 255, 255, 0.03);

  --font-body: 'Inter', system-ui, sans-serif;
  --font-heading: 'Cinzel', serif;
  --font-mono: 'Space Mono', ui-monospace, monospace;
  --font-display: 'Playfair Display', serif;

  --radius: 4px;
  --radius-lg: 10px;
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.9);
  --container: 1120px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

[data-theme='light'] {
  --bg-primary: #f7f4ee;
  --bg-secondary: #fffdf9;
  --bg-tertiary: #efeae0;
  --text-primary: #1b1a17;
  --text-secondary: #554f43;
  --text-muted: #6b6457;
  --accent: #8a6a28;
  --accent-hover: #a27f33;
  --accent-glow: rgba(138, 106, 40, 0.16);
  --border: #e0d8c8;
  --border-strong: #cfc5b0;
  --raise: rgba(0, 0, 0, 0.02);
  --shadow: 0 24px 60px -40px rgba(60, 48, 24, 0.4);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  transition: background var(--ease) 0.4s, color var(--ease) 0.4s;
}

/* ---------- fond « régie » (repris du hero du site) ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("/assets/regie.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.30;
  filter: saturate(0.85) contrast(1.04);
  /* dégradé vertical identique au hero du site : visible en haut, fondu vers le fond en bas */
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.85) 45%, transparent 92%);
  mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.85) 45%, transparent 92%);
}
/* la teinte vient du fond de page pour rester lisible dans les deux thèmes */
.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--bg-primary) 42%, transparent) 0%,
    color-mix(in srgb, var(--bg-primary) 82%, transparent) 70%,
    var(--bg-primary) 100%
  );
}
[data-theme='light'] .backdrop { opacity: 0.22; filter: saturate(0.6) brightness(1.12); }
[data-theme='light'] .backdrop::after {
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--bg-primary) 55%, transparent) 0%,
    color-mix(in srgb, var(--bg-primary) 88%, transparent) 70%,
    var(--bg-primary) 100%
  );
}

/* grain discret, comme le site */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme='light'] .grain { opacity: 0.05; }

a { color: inherit; text-decoration: none; }

/* ---------- barre supérieure ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-primary) 82%, transparent);
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
  width: 42px; height: 42px;
  object-fit: contain;
  filter: drop-shadow(0 0 12px var(--accent-glow));
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name {
  font-family: var(--font-heading);
  font-size: 17px;
  letter-spacing: 0.34em;
  color: var(--accent);
  font-weight: 700;
}
.brand-sub {
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 5px;
}

.theme-toggle {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: border-color var(--ease) 0.25s, transform var(--ease) 0.25s;
}
.theme-toggle:hover { border-color: var(--accent); transform: rotate(20deg); }
.theme-toggle-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--accent-hover), var(--accent));
  box-shadow: 0 0 10px var(--accent-glow);
}

/* ---------- structure ---------- */
.shell {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: clamp(28px, 5vw, 56px) clamp(16px, 4vw, 32px) 72px;
}
body.is-centered .shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 200px);
}

.panel {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, var(--raise), transparent 40%),
    var(--bg-secondary);
  box-shadow: var(--shadow);
  padding: clamp(24px, 3.4vw, 44px);
}
.panel-narrow { max-width: 620px; }

/* ---------- typographie ---------- */
.eyebrow {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--accent);
}

.display {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: clamp(28px, 4.4vw, 44px);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.display em {
  font-style: italic;
  color: var(--accent);
  background: linear-gradient(100deg, var(--accent-hover), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.lede {
  margin: 0 0 22px;
  max-width: 60ch;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 300;
}

.meta-line,
.sort-note {
  margin: 18px 0 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* ---------- accueil / porte ---------- */
.hint {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 13px;
}
.hint .ico { width: 18px; height: 18px; flex: none; color: var(--accent); margin-top: 2px; }
.hint-inline { margin: 16px 0 4px; font-size: 12.5px; }

.gate-form { display: flex; flex-direction: column; gap: 16px; margin-top: 6px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.input {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 300;
  transition: border-color var(--ease) 0.2s, box-shadow var(--ease) 0.2s;
}
.input::placeholder { color: var(--text-secondary); opacity: 0.8; }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.field-error {
  margin: 0;
  color: #e08a7a;
  font-size: 13px;
}
[data-theme='light'] .field-error { color: #a8402c; }

/* ---------- boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 22px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: var(--font-heading);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--ease) 0.22s;
  white-space: nowrap;
}
.btn .ico { width: 15px; height: 15px; }

.btn-gold {
  background: linear-gradient(140deg, var(--accent-hover), var(--accent));
  color: #14120d;
  font-weight: 700;
  align-self: flex-start;
  box-shadow: 0 10px 30px -12px var(--accent-glow);
}
.btn-gold:hover { filter: brightness(1.08); transform: translateY(-1px); }

.btn-quiet {
  border-color: var(--border-strong);
  color: var(--text-secondary);
  background: transparent;
}
.btn-quiet:hover { border-color: var(--accent); color: var(--accent); }
.btn-quiet:disabled {
  opacity: 1;
  cursor: not-allowed;
  border-color: var(--border);
  color: var(--text-muted);
  background: var(--raise);
}

.ghost-btn {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--ease) 0.2s;
}
.ghost-btn .ico { width: 17px; height: 17px; }
.ghost-btn:hover { color: var(--accent); border-color: var(--border-strong); background: var(--bg-tertiary); }

/* ---------- en-tête de partage ---------- */
.share-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--border);
}
.share-head .display { margin-bottom: 8px; }
.share-head .lede { margin-bottom: 0; }

.share-stats {
  display: flex;
  gap: 26px;
  margin: 0;
  padding: 0;
}
.share-stats div { display: flex; flex-direction: column; gap: 4px; }
.share-stats dt {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.share-stats dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent);
}

/* ---------- barre d'outils ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0 6px;
}
.toolbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.input-search { width: 180px; padding: 9px 13px; font-size: 13px; }

.crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  min-width: 0;
}
.crumb {
  color: var(--text-secondary);
  padding: 4px 6px;
  border-radius: 3px;
  transition: color var(--ease) 0.18s, background var(--ease) 0.18s;
  max-width: 30ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.crumb:hover { color: var(--accent); background: var(--bg-tertiary); }
.crumb.is-current { color: var(--accent); }
.crumb-sep { color: var(--text-muted); display: grid; place-items: center; }
.crumb-sep .ico { width: 12px; height: 12px; }

/* ---------- liste ---------- */
.list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  position: relative;
  transition: background var(--ease) 0.18s;
}
.row::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--ease) 0.18s;
}
.row:hover { background: var(--bg-tertiary); }
.row:hover::before { opacity: 1; }
.row.is-hidden { display: none; }

.row-link {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.row-icon {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  flex: none;
  color: var(--text-muted);
  transition: color var(--ease) 0.18s;
}
.row-icon .ico { width: 20px; height: 20px; }
.row.is-folder .row-icon { color: var(--accent); }
.row:hover .kind-audio { color: #9db4d0; }
.row:hover .kind-image { color: #b9a7c9; }
.row:hover .kind-video { color: #c9a7a0; }
.row:hover .kind-doc { color: var(--text-secondary); }

.row-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.row-name {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 7px;
  align-items: center;
  white-space: nowrap;
}
.row-meta .dot { opacity: 0.5; }
.row-go { display: grid; place-items: center; color: var(--text-muted); }
.row-go .ico { width: 14px; height: 14px; }
.row:hover .row-go { color: var(--accent); }

.row-actions { display: flex; align-items: center; gap: 2px; flex: none; }

/* case à cocher */
.row-check { flex: none; width: 18px; height: 18px; position: relative; cursor: pointer; }
.row-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.row-check span {
  position: absolute;
  inset: 0;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  transition: all var(--ease) 0.18s;
}
.row-check input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.row-check input:checked + span::after {
  content: '';
  position: absolute;
  left: 5px; top: 1px;
  width: 5px; height: 10px;
  border: solid #14120d;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}
.row-check input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-glow); }

.empty {
  padding: 48px 10px;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  font-family: var(--font-display);
  font-size: 17px;
}

/* ---------- lecteur audio ---------- */
.player {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(680px, calc(100vw - 32px));
  padding: 12px 14px 12px 20px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-secondary) 94%, transparent);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.85);
}
.player[hidden] { display: none; }
.player-name {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  max-width: 34%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player audio { flex: 1; height: 34px; min-width: 0; accent-color: var(--accent); }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 40px;
  background: rgba(6, 6, 8, 0.94);
  backdrop-filter: blur(6px);
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius);
  box-shadow: 0 40px 100px -40px rgba(0, 0, 0, 1);
}
.lightbox-close {
  position: absolute;
  top: 20px; right: 24px;
  width: 40px; height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: transparent;
  color: #eee;
  font-size: 16px;
  cursor: pointer;
}
.lightbox-close:hover { border-color: var(--accent); color: var(--accent); }

.share-list {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.share-card a {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  transition: border-color var(--ease) 0.2s, transform var(--ease) 0.2s, background var(--ease) 0.2s;
}
.share-card a:hover {
  border-color: var(--accent);
  background: var(--bg-secondary);
  transform: translateY(-1px);
}
.share-card-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 21px;
  color: var(--text-primary);
}
.share-card-note { font-size: 12.5px; color: var(--text-secondary); }
.share-card-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-secondary);
}
.share-card-meta .ico { width: 12px; height: 12px; }

/* ---------- administration ---------- */
.admin-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.admin-top form { margin: 0; }

.admin-h2 {
  font-family: var(--font-heading);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 34px 0 16px;
}

.admin-form {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--bg-tertiary);
}
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px 18px;
  margin-bottom: 18px;
}
.field-grow { grid-column: span 2; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px;
  border-bottom: 1px solid var(--border-strong);
  font-weight: 400;
  white-space: nowrap;
}
.admin-table td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.cell-title { color: var(--text-primary); }
.cell-sub { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); margin-top: 3px; }
.cell-dirs { color: var(--text-secondary); max-width: 280px; word-break: break-word; }
.cell-exp { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); white-space: nowrap; }
.cell-actions { white-space: nowrap; }
.cell-actions form { display: flex; gap: 4px; flex-wrap: nowrap; margin: 0; }
.field-hint { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}
.tag-live { color: #8fbf9a; border: 1px solid rgba(143, 191, 154, 0.45); }
.tag-draft { color: #cbb27a; border: 1px solid rgba(203, 178, 122, 0.45); }
.tag-warn { color: #e08a7a; border: 1px solid rgba(224, 138, 122, 0.45); }
[data-theme='light'] .tag-live { color: #2f6b41; }
[data-theme='light'] .tag-draft { color: #7a5f21; }
[data-theme='light'] .tag-warn { color: #a8402c; }
.muted { color: var(--text-muted); }

.mini {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 5px 9px;
  border-radius: 3px;
  cursor: pointer;
  margin: 0 3px 3px 0;
  transition: all var(--ease) 0.18s;
}
.mini:hover { border-color: var(--accent); color: var(--accent); }
.mini.danger:hover { border-color: #e08a7a; color: #e08a7a; }

.flash {
  margin: 18px 0 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  border-left: 2px solid var(--accent);
  background: var(--bg-tertiary);
  font-size: 13px;
  color: var(--text-secondary);
}
.flash-err { border-left-color: #e08a7a; }
.flash code { font-family: var(--font-mono); color: var(--accent); font-size: 13.5px; }

@media (max-width: 720px) {
  .field-grow { grid-column: span 1; }
  .admin-table { display: block; overflow-x: auto; white-space: nowrap; }
  .cell-dirs { max-width: none; }
}

/* ---------- pied ---------- */
.footer {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 26px 16px 34px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.footer a { color: var(--text-secondary); }
.footer a:hover { color: var(--accent); }
.footer .dot { opacity: 0.5; }

/* ---------- focus visible global ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .share-head { flex-direction: column; align-items: flex-start; gap: 18px; }
  .share-stats { gap: 20px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-actions { justify-content: space-between; }
  .input-search { flex: 1; width: auto; }
  .row-meta { font-size: 10px; }
  .player-name { display: none; }
  .brand-name { font-size: 15px; letter-spacing: 0.26em; }
}

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