/* ═══════════════════════════════════════════════════════════════════════════
   v28.8.3 — shared interface layer
   Toasts, global search, offline bar, draft notices, skeletons, empty states,
   breadcrumbs, consent banner, skip link, focus rings, text size, reduced motion.
   Colours come from the theme variables only, so light, dark and Rose Night
   all work without separate rules.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Accessibility basics ─────────────────────────────────────────────────── */
.akk-skip { position: fixed; left: 12px; top: -60px; z-index: 100000; background: var(--navy-brand, #1D1B4E);
            color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 700; text-decoration: none;
            transition: top 150ms ease; }
.akk-skip:focus { top: 12px; outline: 3px solid #FFD93D; outline-offset: 2px; }
:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; border-radius: 6px; }
.input:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }
main:focus { outline: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
           clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ── Toasts ───────────────────────────────────────────────────────────────── */
.akk-toasts { position: fixed; z-index: 10100; right: 18px; bottom: 18px; display: flex; flex-direction: column;
              gap: 10px; max-width: min(380px, calc(100vw - 36px)); pointer-events: none; }
.akk-toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 12px; padding: 13px 14px 13px 16px;
             background: var(--bg); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--purple);
             border-radius: 14px; box-shadow: var(--shadow-lg); font-size: 14px; line-height: 1.5;
             animation: akkToastIn 240ms cubic-bezier(0.22,1,0.36,1); }
.akk-toast.is-success { border-left-color: #2E9E5B; }
.akk-toast.is-error   { border-left-color: #D6336C; }
.akk-toast.is-info    { border-left-color: #2A7FD4; }
.akk-toast-icon { width: 22px; height: 22px; flex: 0 0 22px; border-radius: 50%; display: flex; align-items: center;
                  justify-content: center; font: 800 13px var(--font-nunito, sans-serif); color: #fff; background: var(--purple); margin-top: 1px; }
.is-success .akk-toast-icon { background: #2E9E5B; } .is-error .akk-toast-icon { background: #D6336C; } .is-info .akk-toast-icon { background: #2A7FD4; }
.akk-toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.akk-toast-x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1;
               padding: 2px 4px; border-radius: 6px; }
.akk-toast-x:hover { background: var(--surface); color: var(--text); }
.akk-toast.is-leaving { animation: akkToastOut 180ms ease forwards; }
@keyframes akkToastIn  { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes akkToastOut { to { opacity: 0; transform: translateY(8px); } }
@media (max-width: 600px) { .akk-toasts { left: 12px; right: 12px; bottom: 86px; max-width: none; } }

/* ── Offline bar ──────────────────────────────────────────────────────────── */
.akk-offline { position: fixed; z-index: 10200; left: 0; right: 0; top: 0; padding: 9px 16px; text-align: center;
               background: #3B2A00; color: #FFE9A8; font-size: 13.5px; font-weight: 700;
               transform: translateY(-100%); transition: transform 220ms ease; }
.akk-offline.show { transform: none; }

/* ── Global search ────────────────────────────────────────────────────────── */
.akk-search-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; margin: 0 0 12px;
                  background: var(--surface); color: var(--muted); border: 1px solid var(--border); border-radius: 12px;
                  font: 600 13.5px var(--font-nunito, sans-serif); cursor: pointer; text-align: left; }
.akk-search-btn:hover { border-color: var(--purple); color: var(--text); }
.akk-search-btn kbd { margin-left: auto; font: 700 11px var(--font-nunito, sans-serif); padding: 2px 6px; border-radius: 6px;
                      border: 1px solid var(--border); background: var(--bg); color: var(--muted); }
.akk-search-icon-btn { background: none; border: none; color: var(--purple); cursor: pointer; padding: 6px; display: inline-flex; }
.akk-search { position: fixed; inset: 0; z-index: 10060; display: none; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; }
.akk-search.open { display: flex; }
.akk-search-backdrop { position: absolute; inset: 0; background: rgba(29,27,78,.45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.akk-search-card { position: relative; width: 100%; max-width: 620px; max-height: 70vh; max-height: 70dvh; display: flex; flex-direction: column;
                   background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 18px;
                   box-shadow: 0 30px 70px rgba(0,0,0,.3); overflow: hidden; animation: akkModalIn 200ms cubic-bezier(0.22,1,0.36,1); }
.akk-search-input { width: 100%; border: none; border-bottom: 1px solid var(--border); background: transparent; color: var(--text);
                    padding: 18px 20px; font: 600 16px var(--font-nunito, sans-serif); outline: none; }
.akk-search-list { overflow-y: auto; overscroll-behavior: contain; padding: 8px; flex: 1 1 auto; }
.akk-search-group { font: 800 10.5px var(--font-nunito, sans-serif); letter-spacing: .09em; text-transform: uppercase;
                    color: var(--muted); padding: 10px 12px 4px; }
.akk-search-item { display: flex; align-items: baseline; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--text);
                   text-decoration: none; cursor: pointer; }
.akk-search-item .lbl { font-weight: 700; font-size: 14.5px; }
.akk-search-item .hint { font-size: 12.5px; color: var(--muted); margin-left: auto; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; }
.akk-search-item[aria-selected="true"], .akk-search-item:hover { background: var(--surface); box-shadow: inset 3px 0 0 var(--purple); }
.akk-search-empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.akk-search-foot { display: flex; gap: 16px; padding: 9px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
@media (max-width: 600px) { .akk-search { padding-top: 6vh; } .akk-search-foot { display: none; } }

/* ── Skeletons and the navigation progress bar ────────────────────────────── */
.skeleton { position: relative; overflow: hidden; background: var(--surface); border-radius: 10px; min-height: 14px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
                   background: linear-gradient(90deg, transparent, rgba(150,140,190,.18), transparent); animation: akkShimmer 1.3s infinite; }
@keyframes akkShimmer { to { transform: translateX(100%); } }
.akk-progress { position: fixed; z-index: 10300; left: 0; top: 0; height: 3px; width: 0; opacity: 0;
                background: linear-gradient(90deg, var(--purple), var(--pink)); transition: width 400ms ease, opacity 200ms ease; }
.akk-progress.run { opacity: 1; width: 78%; transition: width 6s cubic-bezier(.1,.7,.2,1); }
.akk-nav-skeleton { position: absolute; inset: 0; z-index: 5; padding: 32px; background: var(--surface); display: none; }
.akk-nav-skeleton.show { display: block; animation: akkFade 160ms ease; }
@keyframes akkFade { from { opacity: 0; } to { opacity: 1; } }
.dash-main { position: relative; }
button.is-busy, .btn-primary.is-busy { opacity: .7; pointer-events: none; }

/* ── Empty states ─────────────────────────────────────────────────────────── */
.akk-empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.akk-empty-icon { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; display: flex; align-items: center;
                  justify-content: center; font-size: 28px; background: var(--surface); border: 1px dashed var(--border); }
.akk-empty h3 { margin: 0 0 6px; font-size: 17px; color: var(--navy); }
.akk-empty p { margin: 0 auto 16px; max-width: 420px; font-size: 14px; line-height: 1.6; }

/* ── Breadcrumbs ──────────────────────────────────────────────────────────── */
.akk-crumbs { margin: -8px 0 14px; font-size: 13px; }
.akk-crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; list-style: none; margin: 0; padding: 0; }
.akk-crumbs li { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.akk-crumbs li + li::before { content: "›"; color: var(--muted); }
.akk-crumbs a { color: var(--muted); text-decoration: none; font-weight: 600; }
.akk-crumbs a:hover { color: var(--purple); text-decoration: underline; }
.akk-crumbs [aria-current] { color: var(--text); font-weight: 700; }

/* ── Draft notice ─────────────────────────────────────────────────────────── */
.akk-draft { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0 0 14px; padding: 11px 14px;
             background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--purple);
             border-radius: 12px; font-size: 13.5px; color: var(--text); }
.akk-draft button { font: 700 13px var(--font-nunito, sans-serif); border-radius: 9px; padding: 6px 12px; cursor: pointer;
                    border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.akk-draft button.primary { background: var(--purple); border-color: var(--purple); color: #fff; }

/* ── Consent banner ───────────────────────────────────────────────────────── */
.akk-consent { position: fixed; z-index: 10090; left: 16px; right: 16px; bottom: 16px; max-width: 640px; margin: 0 auto;
               display: none; gap: 14px; align-items: center; flex-wrap: wrap; padding: 16px 18px;
               background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 16px;
               box-shadow: 0 20px 50px rgba(0,0,0,.25); font-size: 13.5px; line-height: 1.55; }
.akk-consent.show { display: flex; animation: akkToastIn 260ms ease; }
.akk-consent p { margin: 0; flex: 1 1 260px; }
.akk-consent a { color: var(--purple); font-weight: 700; }
.akk-consent-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.akk-consent button { font: 700 13.5px var(--font-nunito, sans-serif); border-radius: 10px; padding: 9px 16px; cursor: pointer; min-height: 40px;
                      border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.akk-consent button.primary { background: var(--purple); border-color: var(--purple); color: #fff; }
@media (max-width: 600px) { .akk-consent { bottom: 78px; } }

/* ── Text size and motion (settings menu) ─────────────────────────────────── */
.settings-size { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; }
.settings-size > span { font-size: 13.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.size-group { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.size-group button { background: var(--bg); color: var(--text); border: none; padding: 5px 10px; cursor: pointer;
                     font-family: var(--font-nunito, sans-serif); font-weight: 800; line-height: 1.2; }
.size-group button + button { border-left: 1px solid var(--border); }
.size-group button[aria-pressed="true"] { background: var(--purple); color: #fff; }
.size-group button:nth-child(1) { font-size: 12px; } .size-group button:nth-child(2) { font-size: 14px; } .size-group button:nth-child(3) { font-size: 16px; }

/* Text size scales the content (zoom is supported by Chrome, Edge, Safari and
   current Firefox; where it is not, nothing changes). The dashboard frame keeps
   its fixed height, so only what is inside it grows. */
html[data-textsize="lg"]  :is(.dash-main > *, .sidebar-nav, .sidebar-pinned, body:not(.dash-app) > main, body:not(.dash-app) > footer) { zoom: 1.25; }
html[data-textsize="xl"]  :is(.dash-main > *, .sidebar-nav, .sidebar-pinned, body:not(.dash-app) > main, body:not(.dash-app) > footer) { zoom: 1.5; }

html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important;
  transition-duration: .001ms !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important;
                           transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .skeleton::after { display: none; }
}

/* ── Contrast (WCAG AA) ───────────────────────────────────────────────────────
   Measured against white: secondary grey text was 4.25:1 (AA needs 4.5) and
   white text on the brand pink was 3.26:1. The pink itself is unchanged for
   decoration; text and buttons that carry words use a slightly deeper pink
   (4.8:1). To revert, set --pink-ink back to #FF3E9E. */
:root { --pink-ink: #D81B7A; --muted: #5F6673; --accent-text: #FFFFFF; }
html[data-theme="dark"] { --accent-text: #14131F; }
html[data-theme="dark"][data-palette="rose"] { --accent-text: #1A1226; }
.btn-pink, .btn-primary { background: var(--pink-ink); }
.text-pink { color: var(--pink-ink); }
html[data-theme="dark"] .text-pink { color: var(--pink); }
html[data-theme="dark"] .btn-pink, html[data-theme="dark"] .btn-primary { background: var(--pink-ink); }
.akk-consent button.primary, .akk-draft button.primary, .size-group button[aria-pressed="true"] { color: var(--accent-text); }

/* ── Document viewer ──────────────────────────────────────────────────────── */
.akk-viewer { position: fixed; inset: 0; z-index: 10070; display: none; align-items: center; justify-content: center; padding: 3vh 3vw; }
.akk-viewer.open { display: flex; }
.akk-viewer-backdrop { position: absolute; inset: 0; background: rgba(15,13,40,.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.akk-viewer-card { position: relative; width: 100%; max-width: 1100px; height: 100%; display: flex; flex-direction: column;
                   background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 18px;
                   box-shadow: 0 30px 80px rgba(0,0,0,.4); overflow: hidden; animation: akkModalIn 200ms cubic-bezier(0.22,1,0.36,1); }
.akk-viewer-head { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 20px; border-bottom: 1px solid var(--border); }
.akk-viewer-title { flex: 1; min-width: 0; font-weight: 800; font-size: 16px; color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.akk-viewer-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.akk-viewer-btn { display: inline-flex; align-items: center; padding: 7px 13px; border-radius: 10px; border: 1px solid var(--border);
                  background: var(--surface); color: var(--text); font: 700 13px var(--font-nunito, sans-serif); text-decoration: none; cursor: pointer; }
.akk-viewer-btn:hover { border-color: var(--purple); }
.akk-viewer-btn.primary { background: var(--purple); border-color: var(--purple); color: var(--accent-text); }
.akk-viewer-x { background: none; border: none; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; width: 36px; height: 36px; border-radius: 50%; }
.akk-viewer-x:hover { background: var(--surface); color: var(--text); }
.akk-viewer-body { flex: 1 1 auto; min-height: 0; overflow: auto; background: var(--surface); position: relative; }
.akk-viewer-frame { width: 100%; height: 100%; border: 0; background: #fff; display: block; }
.akk-viewer-img { display: block; max-width: 100%; max-height: 100%; margin: 0 auto; object-fit: contain; padding: 14px; box-sizing: border-box; }
.akk-viewer-video { display: block; width: 100%; max-height: 100%; background: #000; }
.akk-viewer-media { padding: 40px 24px; }
.akk-viewer-text { margin: 0; padding: 20px; white-space: pre-wrap; word-break: break-word; font: 13.5px/1.6 ui-monospace, Menlo, Consolas, monospace; color: var(--text); }
.akk-viewer-loading { padding: 28px; max-width: 700px; }
.akk-viewer-msg { max-width: 460px; margin: 12vh auto 0; padding: 0 24px; text-align: center; line-height: 1.7; }
.akk-viewer-msg p { margin: 0 0 16px; }
/* Word documents are shown as a page: white paper with dark ink, in every theme. */
.akk-viewer-paper { max-width: 820px; margin: 22px auto; padding: 48px 56px; background: #fff; color: #1b1b1f; border-radius: 6px;
                    box-shadow: 0 6px 28px rgba(0,0,0,.18); line-height: 1.65; font-size: 15px; overflow-wrap: anywhere; }
.akk-viewer-paper h1, .akk-viewer-paper h2, .akk-viewer-paper h3, .akk-viewer-paper h4 { color: #1D1B4E; margin: 1.1em 0 .4em; line-height: 1.3; }
.akk-viewer-paper p { margin: 0 0 .8em; } .akk-viewer-paper ul { padding-left: 24px; margin: 0 0 .8em; list-style: disc; } .akk-viewer-paper li { display: list-item; }
.akk-viewer-paper table { border-collapse: collapse; width: 100%; margin: .6em 0 1em; }
.akk-viewer-paper td { border: 1px solid #cfcfd8; padding: 6px 10px; vertical-align: top; }
.akk-viewer-paper img { max-width: 100%; height: auto; }
html.akk-viewer-lock .dash-main { overflow: hidden; }
@media (max-width: 700px) {
  .akk-viewer { padding: 0; }
  .akk-viewer-card { border-radius: 0; border: none; }
  .akk-viewer-btn { padding: 7px 10px; font-size: 12.5px; }
  .akk-viewer-paper { margin: 0; padding: 22px 18px; border-radius: 0; box-shadow: none; }
}

/* View / Download / Remove links beside a document */
.mat-act { display: inline-flex; align-items: center; gap: 4px; background: none; border: none; padding: 4px 2px; margin-right: 10px;
           font: 700 13px var(--font-nunito, sans-serif); color: var(--purple); cursor: pointer; text-decoration: none; }
.mat-act:hover { text-decoration: underline; }
.mat-act--del { color: #c0392b; }
html[data-theme="dark"] .mat-act--del { color: #FF8F83; }

/* A bigger text size needs a wider menu, or every label wraps. */
@media (min-width: 901px) {
  html[data-textsize="lg"] .sidebar { width: 320px; }
  html[data-textsize="xl"] .sidebar { width: 380px; }
}
/* Mobile bottom bar and top bar grow with the text too. */
html[data-textsize="lg"] .mtab { font-size: 11.5px; }
html[data-textsize="xl"] .mtab { font-size: 13px; }

/* ── Fixed page header (set up by initPageHead in akk-ui.js) ──────────────────
   The page's breadcrumbs, title and action buttons stay put; only what is
   beneath them scrolls. The margins cancel the page padding so the bar runs
   edge to edge, and --z undoes the text-size zoom so the maths stays right. */
body.dash-app .dash-main { --pg-y: 32px; --pg-x: 32px; --z: 1;
  padding-top: var(--pg-y);
  padding-left: max(var(--pg-x), env(safe-area-inset-left, 0px));
  padding-right: max(var(--pg-x), env(safe-area-inset-right, 0px)); }
html[data-textsize="lg"] body.dash-app .dash-main { --z: 1.25; }
html[data-textsize="xl"] body.dash-app .dash-main { --z: 1.5; }
@media (max-width: 900px) { body.dash-app .dash-main { --pg-y: 20px; --pg-x: 14px; } }
@media (max-height: 520px) and (orientation: landscape) and (max-width: 1000px) { body.dash-app .dash-main { --pg-y: 14px; --pg-x: 16px; } }

.akk-pagehead { position: sticky; top: calc(-1 * var(--pg-y) / var(--z)); z-index: 30; background: var(--surface);
  margin: calc(-1 * var(--pg-y) / var(--z)) calc(-1 * var(--pg-x) / var(--z)) calc(18px) ;
  padding: calc(var(--pg-y) / var(--z)) calc(var(--pg-x) / var(--z)) 12px;
  transition: box-shadow 160ms ease; }
.akk-pagehead.is-stuck { box-shadow: 0 1px 0 var(--border), 0 8px 18px -12px rgba(20,16,60,.28); }
.akk-pagehead > * { margin-bottom: 0; }
.akk-pagehead .akk-crumbs { margin: 0 0 8px; }
.akk-pagehead .dash-header { position: static; border-bottom: none; padding: 0; margin-bottom: 0; }
.dash-main [id] { scroll-margin-top: calc(var(--head-h, 0px) + 12px); }
@media (max-width: 900px) { .akk-pagehead { padding-bottom: 10px; } }
@media (max-width: 600px) { .akk-pagehead .akk-crumbs { display: none; } }
