/* Shared header controls for every canvas page (chat, /publish, /insights,
   /people, /levels, /forms): the header icon buttons, the "back to assistant"
   button, and the account menu (initials -> name/email, Admin links, Sign out).
   Colours come from each page's own :root tokens (fleet-standard look), so this
   file holds layout only. Behaviour: src/shell.js. Linked as /shell.css (absolute:
   /forms/<id> is a nested path). */

.hbtn {
  flex: 0 0 auto;
  height: 34px; min-width: 34px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 10px;
  font: inherit; font-size: 13px; line-height: 1;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 9px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.hbtn:hover { color: var(--ink); border-color: var(--ink-soft); }
.hbtn svg { flex: 0 0 auto; }
.hbtn.themetoggle { padding: 0; width: 34px; }

/* Account: initials button -> menu with who you are, admin pages, sign out. */
.acct { position: relative; flex: 0 0 auto; }
.acctbtn { display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 6px 0 3px;
  border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink-soft);
  cursor: pointer; font: inherit; }
.acctbtn:hover, .acctbtn[aria-expanded="true"] { border-color: var(--ink-soft); color: var(--ink); }
.acctbtn .initials { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bubble-user, var(--paper)); color: var(--ink); font-size: 11.5px; font-weight: 700; letter-spacing: .3px; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 240px;
  max-width: min(320px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px; text-align: left;
  box-shadow: 0 2px 4px rgba(16,24,40,.06), 0 12px 32px rgba(16,24,40,.14); }
:root[data-theme="dark"] .menu { box-shadow: 0 12px 32px rgba(0,0,0,.5); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .menu { box-shadow: 0 12px 32px rgba(0,0,0,.5); } }
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; line-height: 1.35; }
.menu .who b { display: block; font-size: 14px; font-weight: 650; color: var(--ink); }
.menu .who span { display: block; font-size: 12.5px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu .who:empty { display: none; }
.menu .grp { border-bottom: 1px solid var(--line); margin-bottom: 6px; padding-bottom: 6px; }
.menu .grp-h { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); padding: 4px 10px; }
/* No admin pages for this person -> no Admin section at all. */
.menu .grp.admin:not(:has(a:not([hidden]))) { display: none; }
.menu a, .menu button.signout { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px;
  border-radius: 8px; font: inherit; font-size: 14px; color: var(--ink); text-decoration: none; background: none;
  border: 0; cursor: pointer; text-align: left; }
.menu a:hover, .menu button.signout:hover, .menu a:focus-visible, .menu button.signout:focus-visible { background: var(--paper); outline: none; }
/* The page you are on: marked, not a dead link. */
.menu a[aria-current="page"] { font-weight: 650; background: var(--paper); }
.menu a[aria-current="page"]::after { content: ""; margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.menu button.signout, .menu a.help { color: var(--ink-soft); }
.menu a.help:hover { color: var(--ink); }
.menu button.signout:hover { color: var(--ink); }

@media (max-width: 640px) {
  .hbtn .lbl { display: none; }
  .hbtn.back { padding: 0; width: 34px; }
}

/* Standard header layout for the admin/form pages (header.hdr-std); the chat's
   own header in index.html follows the same rules. */
header.hdr-std { gap: 12px; padding: 12px 20px; }
.hdr-std .titles { min-width: 0; line-height: 1.25; }
.hdr-std .mark.has-logo + .titles { padding-left: 14px; border-left: 1px solid var(--line); }
.hdr-std .titles h1, .hdr-std .titles p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 820px) { .hdr-std .titles p { display: none; } }
@media (max-width: 640px) {
  header.hdr-std { gap: 8px; padding: 8px 12px; }
  .hdr-std .mark.has-logo { height: 28px !important; max-width: 27vw; }
  .hdr-std .titles h1 { font-size: 15.5px; }
  .hdr-std .mark.has-logo + .titles { padding-left: 10px; }
}

/* A header logo of ANY shape fits the mark's height (a curator can upload a tall
   or square logo, site-settings.md). The mark is a grid box, where an image's
   height:100% does not resolve — a flex box makes it definite. */
.mark.has-logo { display: flex !important; align-items: center; overflow: hidden; }
.mark.has-logo img { height: 100% !important; max-height: 100% !important; width: auto !important; max-width: 100% !important; object-fit: contain; }

/* ---- Live demo bar + end card (live-demo.md; only on the livedemo client) ---- */
.demo-bar { flex: 0 0 auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 6px 14px; font-size: 13.5px; line-height: 1.3;
  background: #14304a; color: #fff; }
.demo-bar .demo-tag { font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 11.5px; background: #f59f00; color: #1b1f24; border-radius: 4px; padding: 2px 6px; }
.demo-bar .demo-text { opacity: .9; }
.demo-bar .demo-left { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.demo-bar.soon .demo-left { color: #ffd27a; }
.demo-bar .demo-link { color: #fff; text-decoration: underline; margin-left: auto; }
.demo-ended { position: fixed; inset: 0; z-index: 1000; background: rgba(10, 20, 30, .72); display: grid; place-items: center; padding: 16px; }
.demo-ended-card { max-width: 440px; width: 100%; background: var(--surface, #fff); color: var(--ink, #1b1f24); border-radius: 14px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.demo-ended-card h2 { margin: 0 0 10px; font-size: 22px; }
.demo-ended-card p { margin: 0 0 10px; }
.demo-ended-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.demo-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line, #c9d3dd);
  background: transparent; color: inherit; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.demo-btn.primary { background: var(--accent, #1f6fb2); border-color: transparent; color: #fff; }

/* ---- "Things to try" — the live demo's in-app guide (src/tour.js) ---- */
/* Its own step-box and hint colours, light and dark: not every page defines --field / --warn-soft,
   and a light fallback under dark text made the steps unreadable in dark mode (Patrick, 28 Sept). */
.tour, .tour-modal-card { --tour-field: var(--field, var(--surface, #fff)); --tour-warn: var(--warn-soft, #fff4d6); }
:root[data-theme="dark"] .tour, :root[data-theme="dark"] .tour-modal-card { --tour-warn: #2b2616; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tour, :root:not([data-theme="light"]) .tour-modal-card { --tour-warn: #2b2616; }
}
.demo-bar .demo-tour { font: inherit; font-size: 13px; font-weight: 600; color: #14304a; background: #ffd27a; border: 0; border-radius: 999px;
  padding: 4px 12px; min-height: 30px; cursor: pointer; }
.demo-bar .demo-tour:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.demo-bar .demo-tour.tour-flash { animation: tourFlash 1.2s ease-out 2; }
@keyframes tourFlash { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 210, 122, .9); } 50% { box-shadow: 0 0 0 7px rgba(255, 210, 122, 0); } }
.tour { position: fixed; z-index: 900; top: 0; right: 0; bottom: 0; width: 340px; display: flex; flex-direction: column;
  background: var(--surface, #fff); color: var(--ink, #1b1f24); border-left: 1px solid var(--line, #dce1e7);
  box-shadow: -8px 0 24px rgba(0, 0, 0, .08); font-size: 14.5px; line-height: 1.4; }
.tour[hidden] { display: none !important; }
body.tour-docked { padding-right: 340px; }
.tour.sheet { top: auto; left: 0; width: auto; max-height: 62vh; border-left: 0; border-top: 1px solid var(--line, #dce1e7);
  border-radius: 16px 16px 0 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, .18); }
.tour-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; }
.tour-head b { font-size: 16px; }
.tour-count { color: var(--ink-soft, #56606e); font-variant-numeric: tabular-nums; }
.tour-x { margin-left: auto; width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line, #dce1e7); background: transparent;
  color: var(--ink-soft, #56606e); font-size: 20px; line-height: 1; cursor: pointer; }
.tour-bar { height: 4px; margin: 0 14px 6px; border-radius: 4px; background: var(--paper, #eaedf1); overflow: hidden; }
.tour-bar i { display: block; height: 100%; background: var(--accent, #2458c6); transition: width .4s; }
.tour-body { overflow-y: auto; padding: 0 14px 16px; -webkit-overflow-scrolling: touch; }
.tour-ch { margin: 14px 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft, #56606e); }
.tour-step { border: 1px solid var(--line, #dce1e7); border-radius: 12px; margin: 6px 0; background: var(--tour-field); }
.tour-step.open { border-color: var(--accent, #2458c6); }
.tour-step.flash { animation: tourStep 2.4s ease-out 1; }
@keyframes tourStep { 0% { background: var(--accent-soft, #e1e8f7); } 100% { background: var(--tour-field); } }
.tour-step-h { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 12px; border: 0; background: transparent;
  color: inherit; font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.tour-step.done .tour-step-h { color: var(--ink-soft, #56606e); font-weight: 500; }
.tour-check { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line, #c9d3dd); display: inline-grid; place-items: center; }
.tour-check.sm { width: 16px; height: 16px; margin-top: 2px; }
.done > .tour-check, .tour-step.done > .tour-step-h .tour-check { background: #2f8a4c; border-color: #2f8a4c; }
.done > .tour-check::after, .tour-step.done > .tour-step-h .tour-check::after { content: ""; width: 5px; height: 9px; margin-top: -2px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.tour-check.sm::after { width: 4px !important; height: 7px !important; }
.tour-step-b { padding: 0 12px 12px 42px; }
.tour-step-b p { margin: 0 0 8px; color: var(--ink-soft, #56606e); }
.tour-parts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tour-part { display: flex; gap: 8px; align-items: flex-start; }
.tour-part.done { color: var(--ink-soft, #56606e); }
.tour-part.done .tour-part-t > span { text-decoration: line-through; text-decoration-color: rgba(127, 127, 127, .5); }
.tour-part-t { min-width: 0; }
.tour-q { display: block; margin-top: 2px; font-style: italic; color: var(--ink-soft, #56606e); }
.tour-hint { margin: 8px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--tour-warn); color: var(--ink, #1b1f24);
  border-left: 3px solid #f59f00; font-size: 14px; }
.tour-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.tour-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line, #c9d3dd); background: transparent; color: inherit; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.tour-btn.primary { background: var(--accent, #2458c6); border-color: transparent; color: #fff; }
.tour-fin { margin: 14px 2px 0; color: var(--ink-soft, #56606e); }
.tour-pulse { animation: tourPulse 1.5s ease-out infinite; position: relative; z-index: 1; }
@keyframes tourPulse { 0% { box-shadow: 0 0 0 0 rgba(245, 159, 0, .85); } 70% { box-shadow: 0 0 0 10px rgba(245, 159, 0, 0); } 100% { box-shadow: 0 0 0 0 rgba(245, 159, 0, 0); } }
.tour-modal { position: fixed; inset: 0; z-index: 950; background: rgba(10, 20, 30, .55); display: grid; place-items: center; padding: 16px; }
.tour-modal-card { max-width: 460px; width: 100%; background: var(--surface, #fff); color: var(--ink, #1b1f24); border-radius: 16px; padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.tour-modal-card h2 { margin: 0 0 12px; font-size: 22px; }
.tour-modal-card p { margin: 0 0 10px; }
.tour-modal-acts { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.tour-modal-acts .tour-btn { min-height: 44px; }
@media (prefers-reduced-motion: reduce) { .tour-pulse, .tour-step.flash, .demo-bar .demo-tour.tour-flash { animation: none; } .tour-pulse { outline: 3px solid #f59f00; } }

/* Native controls follow the page's theme: the calendar icon of a date / time field (the
   demo-admin custom start, the Notice end date), select arrows and scrollbars are drawn by the
   browser, which draws them dark-on-dark unless told the page is dark. Same rule as the theme
   tokens: the saved choice, else the device setting. */
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }
