:root {
  --accent: #75b5e4;
  --background: #eaeaeb;
  --surface: #ffffff;
  --surface-soft: #f5f7fa;
  --text: #002c3f;
  --muted: #7a8792;
  --border: rgba(0, 44, 63, 0.14);
  --header-height: 82px;
  --footer-height: 38px;
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-width: 320px; height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.reader-shell {
  height: 100dvh;
  display: grid;
  grid-template-rows: var(--header-height) minmax(0, 1fr) var(--footer-height);
  background:
    radial-gradient(circle at 50% -15%, rgba(117, 181, 228, 0.22), transparent 38%),
    linear-gradient(180deg, #f6f9fc 0%, var(--background) 100%);
}

.reader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(18px, 3vw, 42px);
  border-bottom: 1px solid var(--border);
  background: #002c3f;
  backdrop-filter: blur(16px);
  z-index: 20;
}
.brand-block, .header-actions, .share-url-row { display: flex; align-items: center; }
.brand-block { min-width: 0; gap: 14px; }
.brand-mark {
  display: grid;
  place-items: center;
  min-width: 58px;
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-weight: 900;
  letter-spacing: .08em;
  border-radius: 10px;
  background: white;
}
.brand-logo { max-width: 180px; max-height: 52px; object-fit: contain; }
.document-meta { min-width: 0; }
.document-kicker, .share-kicker {
  margin: 0 0 3px;
  color: #5770b4;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .16em;
}
.document-title {
  max-width: 60vw;
  margin: 0;
  overflow: hidden;
  color: #ffffff;
  font-size: clamp(1rem, 1.8vw, 1.35rem);
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-actions { gap: 10px; }
.action-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.action-button:hover { transform: translateY(-1px); }
.action-button--quiet { background: white; color: var(--text); }
.action-button--quiet:hover { border-color: rgba(0,44,63,.26); background: rgba(117,181,228,.12); }
.action-button--accent { border-color: var(--accent); background: var(--accent); color: #002c3f; font-weight: 800; }

.reader-stage { position: relative; min-height: 0; overflow: hidden; background: #eaeaeb; }
.PDFFlip { width: 100%; height: 100%; }
.loading-panel, .error-panel {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px;
  text-align: center;
  background: #eaeaeb;
  transition: opacity .25s ease, visibility .25s ease;
}
.loading-panel.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-panel span, .error-panel span { color: var(--muted); }
.loading-spinner {
  width: 38px;
  height: 38px;
  margin-bottom: 8px;
  border: 3px solid rgba(0,44,63,.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-panel[hidden] { display: none; }
.error-panel button, .native-share-button, .share-url-row button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #002c3f;
  font-weight: 800;
  cursor: pointer;
}
.error-panel button { margin-top: 10px; padding: 11px 18px; }

.reader-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(18px, 3vw, 42px);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .78rem;
  background: rgba(255,255,255,.72);
}
.footer-help { opacity: .85; }

.share-modal[hidden] { display: none; }
.share-modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; }
.share-backdrop { position: absolute; inset: 0; background: rgba(0,27,39,.45); backdrop-filter: blur(8px); }
.share-dialog {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100dvh - 40px);
  overflow: auto;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 28px 90px rgba(0,0,0,.18);
  text-align: center;
}
.share-dialog h2 { margin: 0; font-size: 1.55rem; color: var(--text); }
.share-description { margin: 10px 0 22px; color: var(--muted); line-height: 1.55; }
.share-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(0,44,63,.07);
  color: var(--text);
  cursor: pointer;
  font-size: 1.45rem;
}
.qr-frame {
  width: min(250px, 75vw);
  margin: 0 auto 22px;
  padding: 15px;
  border-radius: 16px;
  background: white;
  border: 1px solid rgba(0,44,63,.08);
}
.qr-frame canvas,
.qr-frame img { display: block; width: 100% !important; height: auto !important; }
.share-url-label { display: block; margin: 0 0 8px; color: var(--muted); font-size: .78rem; text-align: left; }
.share-url-row { gap: 8px; }
.share-url-row input {
  min-width: 0;
  flex: 1;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: 0;
  background: #f5f7fa;
  color: var(--text);
}
.share-url-row input:focus { border-color: var(--accent); }
.share-url-row button { height: 44px; padding: 0 15px; }
.native-share-button { width: 100%; margin-top: 10px; padding: 12px 16px; }
.copy-feedback { min-height: 20px; margin: 12px 0 0; color: #5770b4; font-size: .82rem; }
body.share-open { overflow: hidden; }

.df-ui-wrapper { font-family: inherit !important; }
.df-ui-controls { backdrop-filter: blur(10px); }

@media (max-width: 720px) {
  :root { --header-height: 68px; --footer-height: 32px; }
  .reader-header { gap: 10px; padding: 10px 12px; }
  .brand-block { gap: 9px; }
  .brand-mark { min-width: 48px; height: 36px; font-size: .78rem; }
  .document-kicker { display: none; }
  .document-title { max-width: 42vw; font-size: .92rem; }
  .action-button { min-width: 42px; min-height: 42px; padding: 0 12px; }
  .action-button span:last-child { display: none; }
  .reader-footer { padding: 0 12px; font-size: .68rem; }
  .footer-help { display: none; }
  .share-dialog { padding: 26px 18px 20px; }
}

@media (max-width: 520px) {
  .document-kicker { display: none; }

  .document-title {
    display: block;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 15px;
  }

  .df-ui-next,
  .df-ui-prev {
    transform: scale(0.85);
  }

  .df-ui-prev {
    left: 8px !important;
  }

  .df-ui-next {
    right: 8px !important;
  }

  .share-dialog {
    width: calc(100% - 28px);
    max-height: calc(100vh - 28px);
    padding: 24px 18px;
    overflow-y: auto;
  }

  .share-dialog h2 {
    font-size: 26px;
    line-height: 1.15;
  }

  .share-description {
    font-size: 16px;
    line-height: 1.45;
    margin-bottom: 20px;
  }

  .qr-frame {
    width: 220px;
    max-width: 70vw;
    margin: 0 auto 20px;
  }

  .share-url-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .share-url-row button {
    width: 100%;
  }

  .native-share-button {
    width: 100%;
  }
}


/* =========================================================
   RUBEIN — mobile final
   Masquer le titre pour préserver les actions
   ========================================================= */

@media screen and (max-width: 768px) {

  .document-meta {
    display: none;
  }

  .brand-block {
    flex: 0 0 auto;
    min-width: auto;
  }

  .header-actions {
    flex: 0 0 auto;
    margin-left: auto;
  }
}


@media screen and (max-width: 768px) {

  .action-button {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    gap: 4px;
    padding: 0;

    border: 0;
    background: transparent;
  }

  .action-button span:first-child {
    width: 42px;
    height: 42px;

    display: grid;
    place-items: center;

    border-radius: 50%;
  }

  .action-button span:last-child {
    display: block;
    color: #ffffff;
    font-size: 10px;
    line-height: 1.1;
    white-space: nowrap;
  }

  .action-button--quiet span:first-child {
    border: 1px solid rgba(255,255,255,.35);
    background: rgba(255,255,255,.08);
    color: #ffffff;
  }

  .action-button--accent span:first-child {
    background: var(--accent);
    color: #ffffff;
  }
}