/* ── Virtual Planetarium ───────────────────────────────────────────────────────────────
   A night-sky workspace: the map is always dark; the side panel follows the
   same night palette so photographs and star colours read well. */

.sa-app {
  --sa-bg: #060b20;
  --sa-panel: #0c1430;
  --sa-panel-2: #131d42;
  --sa-line: rgba(140, 175, 255, 0.2);
  --sa-ink: #e8eefc;
  --sa-ink-2: #aab8d8;
  --sa-accent: #72c8df;
  --sa-gold: #ffd54a;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  min-height: 560px;
  background: var(--sa-bg);
  color: var(--sa-ink);
}

.sa-app.sa-panel-open { grid-template-columns: minmax(0, 1fr) 400px; }

.sa-stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.sa-map {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
  min-height: 320px;
}

#sa-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
  outline: none;
}
#sa-canvas:active { cursor: grabbing; }
#sa-canvas:focus-visible { box-shadow: inset 0 0 0 3px var(--sa-accent); }

/* Immersive page: no site header or footer; the Back button leaves. */
body.sa-immersive .pv-header,
body.sa-immersive .pv-footer { display: none; }
body.sa-immersive .pv-main { padding: 0; margin: 0; max-width: none; }

.sa-back {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--sa-line);
  background: rgba(8, 14, 36, 0.86);
  backdrop-filter: blur(6px);
  color: var(--sa-ink);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.sa-back:hover { background: rgba(114, 200, 223, 0.25); }
.sa-back:focus-visible { outline: 2px solid var(--sa-accent); outline-offset: 1px; }

/* Top bar */
.sa-topbar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: flex-end;
  pointer-events: none;
}
.sa-topbar > * { pointer-events: auto; }


.sa-seg {
  display: inline-flex;
  border: 1px solid var(--sa-line);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(8, 14, 36, 0.86);
  backdrop-filter: blur(6px);
  flex: 0 0 auto;
}
.sa-seg button {
  padding: 0.55rem 0.9rem;
  border: 0;
  background: transparent;
  color: var(--sa-ink-2);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.sa-seg button.active { background: var(--sa-accent); color: #04122a; }
.sa-seg button:focus-visible { outline: 2px solid #fff; outline-offset: -3px; }

/* Overlays */

.sa-readout {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  background: rgba(8, 14, 36, 0.72);
  color: var(--sa-ink-2);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.sa-zoom {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sa-zoom button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--sa-line);
  background: rgba(8, 14, 36, 0.86);
  color: var(--sa-ink);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.sa-dial { position: relative; color: var(--sa-accent); padding: 0; }
.sa-dial svg { position: absolute; inset: 0; transition: transform 0.08s linear; }
.sa-dial span { position: absolute; left: 0; right: 0; bottom: 2px; font-size: 0.62rem; font-weight: 700; color: var(--sa-ink-2); line-height: 1; }
.sa-dial.tilted { border-color: var(--sa-gold); color: var(--sa-gold); }
.sa-zoom button svg { display: block; margin: 0 auto; }
.sa-zoom button[aria-pressed="true"] { border-color: var(--sa-gold); color: var(--sa-gold); }
.sa-zoom button:hover { background: rgba(114, 200, 223, 0.25); }
.sa-zoom button:focus-visible { outline: 2px solid var(--sa-accent); }

.sa-hint {
  position: absolute;
  left: 50%;
  top: 64px;
  transform: translateX(-50%);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: rgba(8, 14, 36, 0.8);
  color: var(--sa-ink-2);
  font-size: 0.82rem;
  pointer-events: none;
  transition: opacity 0.6s;
  white-space: nowrap;
}
.sa-hint.gone, .sa-loading.gone { opacity: 0; pointer-events: none; }
.sa-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--sa-bg);
  color: var(--sa-ink-2);
  transition: opacity 0.5s;
  pointer-events: none;
}

/* Time bar */
.sa-timebar[hidden] { display: none; }
.sa-timebar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: flex-end;
  padding: 0.7rem 0.9rem;
  background: #080e26;
  border-top: 1px solid var(--sa-line);
  font-size: 0.85rem;
}
.sa-tb-group { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sa-tb-group > label, .sa-tb-label { color: var(--sa-ink-2); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; }
.sa-tb-buttons { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; }
.sa-timebar input, .sa-timebar select, .sa-timebar button {
  background: #101a3d;
  color: var(--sa-ink);
  border: 1px solid var(--sa-line);
  border-radius: 8px;
  padding: 0.38rem 0.6rem;
  font-size: 0.85rem;
  font-family: inherit;
}
.sa-timebar input[type="number"] { width: 5.4rem; }
.sa-timebar button { cursor: pointer; }
.sa-timebar button:hover { background: #1a2759; }
.sa-timebar button[aria-pressed="true"] { background: var(--sa-accent); color: #04122a; }
.sa-timebar :focus-visible { outline: 2px solid var(--sa-accent); outline-offset: 1px; }
.sa-timebar input[type="datetime-local"] { color-scheme: dark; }

/* Side panel */
.sa-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--sa-panel);
  border-left: 1px solid var(--sa-line);
}
.sa-panel[hidden] { display: none; }
.sa-tabs { display: flex; border-bottom: 1px solid var(--sa-line); flex: 0 0 auto; }
.sa-tabs button {
  flex: 1;
  padding: 0.75rem 0.4rem;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--sa-ink-2);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.sa-tabs button[aria-pressed="true"] { color: var(--sa-ink); border-bottom-color: var(--sa-accent); background: rgba(114, 200, 223, 0.08); }
.sa-tabs button:hover { color: var(--sa-ink); }
.sa-tabs button:focus-visible { outline: 2px solid var(--sa-accent); outline-offset: -3px; }
.sa-pane { flex: 1 1 auto; overflow-y: auto; padding: 1rem 1.1rem 1.5rem; min-height: 0; }
.sa-pane[hidden] { display: none; }

.sa-panel h2 { margin: 0; font-size: 1.35rem; line-height: 1.2; color: var(--sa-ink); }
.sa-panel h3 { margin: 0 0 0.4rem; font-size: 1.05rem; color: var(--sa-ink); }
.sa-panel p { color: var(--sa-ink-2); line-height: 1.55; margin: 0.6rem 0; }
.sa-panel a { color: var(--sa-accent); }
.sa-panel .sa-sub { font-size: 0.9rem; }

.sa-welcome ul { padding-left: 1.1rem; color: var(--sa-ink-2); line-height: 1.6; }
.sa-link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--sa-accent);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}

/* Cards */
.sa-fig { margin: 0 0 0.8rem; border-radius: 12px; overflow: hidden; background: #000; }
.sa-fig img { display: block; width: 100%; max-height: 300px; object-fit: contain; background: #000; }
.sa-fig figcaption { padding: 0.3rem 0.6rem; font-size: 0.72rem; background: #070c20; }
.sa-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sa-chip {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--chip, #fff);
  color: var(--chip, #fff);
  white-space: nowrap;
}
.sa-panel .sa-blurb { margin-top: 0.3rem; color: var(--sa-ink); font-style: italic; }
.sa-facts { margin: 0.8rem 0; display: grid; gap: 0.5rem; }
.sa-fact {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 8px;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--sa-line);
  font-size: 0.88rem;
}
.sa-fact dt { color: var(--sa-ink-2); }
.sa-fact dd { margin: 0; color: var(--sa-ink); }
.sa-panel .sa-note {
  padding: 0.6rem 0.8rem;
  border-left: 3px solid var(--sa-gold);
  background: rgba(255, 213, 74, 0.08);
  color: var(--sa-ink);
  font-size: 0.9rem;
  border-radius: 0 8px 8px 0;
}
.sa-panel .sa-summary { color: var(--sa-ink); font-size: 0.93rem; }
.sa-panel .sa-src { font-size: 0.78rem; }
.sa-history {
  margin-top: 1rem;
  padding: 0.8rem;
  border: 1px solid var(--sa-line);
  border-radius: 12px;
  background: var(--sa-panel-2);
}
.sa-history img { display: block; width: 100%; max-height: 220px; object-fit: contain; border-radius: 8px; background: #000; }
.sa-history p { font-size: 0.9rem; }

.sa-orb {
  width: 120px;
  height: 120px;
  margin: 0.2rem auto 1rem;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, #fff 0%, var(--star) 38%, transparent 72%);
  box-shadow: 0 0 60px 12px var(--star);
  opacity: 0.95;
}

.sa-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 1rem; }
.sa-btn {
  padding: 0.5rem 0.95rem;
  border-radius: 9px;
  border: 1px solid var(--sa-accent);
  background: var(--sa-accent);
  color: #04122a;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}
.sa-btn.secondary { background: transparent; color: var(--sa-ink); border-color: var(--sa-line); }
.sa-btn:disabled { opacity: 0.4; cursor: default; }
.sa-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Tours */
.sa-tour {
  padding: 0.9rem 1rem;
  margin: 0.8rem 0;
  border: 1px solid var(--sa-line);
  border-radius: 12px;
  background: var(--sa-panel-2);
}
.sa-tour p { margin: 0.3rem 0 0.7rem; font-size: 0.9rem; }
.sa-panel .sa-tour-title { margin: 0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--sa-accent); }
.sa-panel .sa-tour-count { margin: 0.1rem 0 0.6rem; font-size: 0.8rem; }
.sa-panel .sa-tour-text { color: var(--sa-ink); font-size: 0.95rem; }
.sa-panel .sa-tour-ask { margin: 0.6rem 0 0; padding: 0.5rem 0.7rem; border-left: 3px solid var(--sa-gold); background: var(--sa-panel-2); color: var(--sa-gold); font-weight: 600; font-size: 0.95rem; }
.sa-panel .sa-tour-ask.done { border-left-color: var(--sa-accent); color: var(--sa-accent); }

/* Browse and layers */
.sa-search { margin-bottom: 0.9rem; }
.sa-search-label { display: block; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sa-ink-2); margin-bottom: 0.3rem; }
.sa-search input {
  width: 100%; box-sizing: border-box; padding: 0.55rem 0.7rem; border-radius: 10px; font: inherit;
  background: var(--sa-panel-2); color: var(--sa-ink); border: 1px solid var(--sa-line);
}
.sa-search input:focus-visible { outline: 2px solid var(--sa-accent); outline-offset: 1px; }
.sa-search-results { list-style: none; margin: 0.35rem 0 0; padding: 0; display: grid; gap: 2px; }
.sa-search-results[hidden] { display: none; }
.sa-search-results .sa-item[aria-selected="true"] { background: rgba(114, 200, 223, 0.2); }
.sa-search-empty { color: var(--sa-ink-2); font-size: 0.85rem; padding: 0.3rem 0.4rem; }
.sa-group { border-bottom: 1px solid var(--sa-line); padding: 0.4rem 0; }
.sa-group summary { cursor: pointer; font-weight: 600; padding: 0.4rem 0; color: var(--sa-ink); }
.sa-group ul { list-style: none; margin: 0; padding: 0 0 0.4rem; }
.sa-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0.4rem 0.4rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--sa-ink);
  text-align: left;
  font-size: 0.9rem;
  cursor: pointer;
}
.sa-item:hover { background: rgba(114, 200, 223, 0.15); }
.sa-item:focus-visible { outline: 2px solid var(--sa-accent); }
.sa-item small { color: var(--sa-ink-2); margin-left: auto; font-size: 0.75rem; }
.sa-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.sa-layers { border: 0; padding: 0; margin: 0; display: grid; gap: 0.7rem; }
.sa-layers legend { font-weight: 700; margin-bottom: 0.6rem; padding: 0; }
.sa-layers label { display: flex; align-items: center; gap: 0.6rem; color: var(--sa-ink); }
.sa-credits-title { margin: 0.2rem 0 0.3rem; font-size: 1.1rem; color: var(--sa-ink); }
.sa-credits-intro { margin: 0 0 0.8rem; color: var(--sa-ink-2); font-size: 0.85rem; line-height: 1.5; }
.sa-credits-list { margin: 0; }
.sa-credits-list dt { margin-top: 0.9rem; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--sa-accent); }
.sa-credits-list dd { margin: 0.2rem 0 0; font-size: 0.85rem; line-height: 1.5; color: var(--sa-ink-2); }

/* Narrow screens: map on top, panel below */
@media (max-width: 900px) {
  /* The panel and the chat are bottom sheets on a phone, so the map keeps the whole screen. */
  .sa-app { grid-template-columns: 1fr; min-height: 0; }
  .sa-app.sa-panel-open { grid-template-columns: 1fr; }
  .sa-panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    height: min(62vh, 560px); height: min(62dvh, 560px);
    border-left: 0; border-top: 1px solid var(--sa-line); border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 36px rgba(0, 0, 0, 0.6);
  }
  .sa-topbar { flex-wrap: wrap; }
}
@media (max-width: 520px) {
  .sa-fact { grid-template-columns: 1fr; gap: 2px; }
  .sa-timebar { gap: 8px 12px; padding: 0.55rem 0.7rem; }
}
@media (prefers-reduced-motion: reduce) {
  .sa-hint, .sa-loading { transition: none; }
}

/* ── Chat with Astra ───────────────────────────────────────────────────────── */
.sa-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sa-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--sa-line);
  font-size: 0.9rem;
}
.sa-chat-head span { color: var(--sa-ink-2); margin-left: 0.4rem; }
.sa-chat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem 1.1rem 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-height: 0;
}
.sa-msg { max-width: 92%; padding: 0.6rem 0.85rem; border-radius: 14px; line-height: 1.5; font-size: 0.93rem; }
.sa-chat-window .sa-msg p { margin: 0; color: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
.sa-msg.user { align-self: flex-end; background: var(--sa-accent); color: #04122a; border-bottom-right-radius: 4px; }
.sa-msg.bot { align-self: flex-start; background: var(--sa-panel-2); color: var(--sa-ink); border-bottom-left-radius: 4px; }
.sa-msg.typing { color: var(--sa-ink-2); font-style: italic; }
.sa-msg.error { background: rgba(255, 120, 120, 0.12); border: 1px solid rgba(255, 120, 120, 0.4); }
.sa-action {
  display: block;
  margin-top: 0.5rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--sa-accent);
  border-radius: 999px;
  background: transparent;
  color: var(--sa-accent);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
}
.sa-action:hover { background: rgba(114, 200, 223, 0.15); }
.sa-action:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.sa-action.static { cursor: default; border-color: var(--sa-line); color: var(--sa-ink-2); }
.sa-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0.4rem 1.1rem; }
.sa-chips[hidden] { display: none; }
.sa-chip-btn {
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--sa-line);
  border-radius: 999px;
  background: transparent;
  color: var(--sa-ink);
  font-size: 0.82rem;
  cursor: pointer;
}
.sa-chip-btn:hover { background: rgba(114, 200, 223, 0.15); }
.sa-chip-btn:focus-visible { outline: 2px solid var(--sa-accent); }
.sa-chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 0.6rem 1.1rem 0.3rem; }
.sa-chat-form textarea {
  flex: 1;
  resize: none;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--sa-line);
  background: #101a3d;
  color: var(--sa-ink);
  font: inherit;
  font-size: 0.92rem;
  max-height: 120px;
}
.sa-chat-form textarea:focus-visible { outline: 2px solid var(--sa-accent); outline-offset: 1px; }
.sa-chat-form textarea:disabled, .sa-chat-form .sa-btn:disabled { opacity: 0.55; }
.sa-chat-window .sa-chat-note { margin: 0; padding: 0.2rem 1.1rem 0.8rem; font-size: 0.72rem; color: var(--sa-ink-2); }
.sa-tabs button { padding-left: 0.2rem; padding-right: 0.2rem; font-size: 0.85rem; }


/* Astra avatar, bottom left of the map; it opens the right-hand panel */
.sa-astra { position: absolute; left: 12px; bottom: 12px; z-index: 6; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; max-width: calc(100% - 24px); }
.sa-astra-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 1rem 0 0.7rem;
  border: 1px solid rgba(114, 200, 223, 0.6);
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #1d3a78, #0b1433 75%);
  color: var(--sa-accent);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5), 0 0 14px rgba(114, 200, 223, 0.25);
}
.sa-astra-row { display: flex; align-items: center; gap: 10px; }
.sa-astra-row[hidden] { display: none; }
.sa-tour-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 44px; padding: 0 1rem 0 0.8rem;
  border: 1px solid rgba(255, 226, 170, 0.55); border-radius: 999px;
  background: rgba(11, 20, 51, 0.88); color: #ffe2aa;
  font: inherit; font-size: 0.88rem; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}
.sa-tour-btn:hover { background: rgba(255, 226, 170, 0.18); }
.sa-tour-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.sa-astra-btn:hover { background: radial-gradient(circle at 30% 30%, #26498f, #101c42 75%); }
.sa-astra-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.sa-astra-label { color: var(--sa-ink); }
.sa-astra-dot { position: absolute; top: 4px; right: 4px; width: 12px; height: 12px; border-radius: 50%; background: #ff6b8b; border: 2px solid #0b1433; }
.sa-astra-dot[hidden] { display: none; }
.sa-chat-head-btns { display: flex; align-items: center; gap: 0.6rem; }
.sa-icon-btn {
  min-width: 30px; height: 30px; padding: 0 6px; border-radius: 8px; border: 1px solid var(--sa-line);
  background: transparent; color: var(--sa-ink); font-size: 1rem; line-height: 1; cursor: pointer;
}
.sa-icon-btn[hidden] { display: none; }
.sa-icon-btn:hover { background: rgba(114, 200, 223, 0.15); }
.sa-icon-btn:focus-visible { outline: 2px solid var(--sa-accent); }
.sa-icon-btn[aria-pressed="true"] { background: var(--sa-accent); color: #04122a; border-color: var(--sa-accent); }
@media (max-width: 900px) {
}
@media (max-width: 520px) {
  .sa-astra-label { display: none; }
  .sa-astra-btn { padding: 0 0.75rem 0 0.7rem; }
  .sa-astra-row { gap: 6px; }
  .sa-tour-btn { height: 40px; padding: 0 0.7rem 0 0.6rem; gap: 5px; font-size: 0.8rem; }
  .sa-tour-btn svg { width: 16px; height: 16px; }
}


/* Tappable lists inside a chat reply */
.sa-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 0.55rem; }
.sa-list-title { flex: 1 0 100%; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--sa-ink-2); }
.sa-msg .sa-action.static { display: block; }


/* Show or hide the bottom bar */
.sa-tb-toggle {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  z-index: 5;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--sa-line);
  background: rgba(8, 14, 36, 0.86);
  color: var(--sa-ink-2);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.sa-tb-toggle:hover { color: var(--sa-ink); background: rgba(114, 200, 223, 0.2); }
.sa-tb-toggle:focus-visible { outline: 2px solid var(--sa-accent); outline-offset: 1px; }
@media (max-width: 900px) {
  .sa-tb-toggle { left: auto; right: 64px; bottom: 12px; transform: none; }
  .sa-readout { max-width: calc(100% - 130px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Floating chat window, bottom left; it takes the avatar's place while open */
.sa-chat-window {
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 24px));
  max-height: min(540px, calc(100vh - 140px));
  background: rgba(8, 14, 38, 0.96);
  border: 1px solid var(--sa-line);
  border-radius: 16px;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.sa-chat-window[hidden] { display: none; }
.sa-chat-window .sa-chat-log { min-height: 120px; }
@media (prefers-reduced-motion: no-preference) {
  .sa-chat-window { animation: sa-chat-in 0.18s ease-out; }
  @keyframes sa-chat-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
}

/* Information panel header and the quick buttons that open it */
.sa-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 0.7rem 1.1rem; border-bottom: 1px solid var(--sa-line); font-size: 0.95rem; flex: 0 0 auto; }
.sa-info-btns { position: absolute; right: 12px; top: 62px; z-index: 5; display: flex; flex-direction: column; gap: 6px; }
.sa-info-btns[hidden] { display: none; }
.sa-info-btns button {
  padding: 0.4rem 0.8rem; border-radius: 10px; border: 1px solid var(--sa-line);
  background: rgba(8, 14, 36, 0.86); color: var(--sa-ink); font: inherit; font-size: 0.85rem; cursor: pointer;
  backdrop-filter: blur(6px); text-align: left;
}
.sa-info-btns button:hover { background: rgba(114, 200, 223, 0.22); }
.sa-info-btns button:focus-visible { outline: 2px solid var(--sa-accent); outline-offset: 1px; }
@media (max-width: 900px) {
  .sa-chat-window {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; width: auto;
    height: min(62vh, 560px); height: min(62dvh, 560px); max-height: none; border-radius: 16px 16px 0 0;
  }
  .sa-info-btns { top: 56px; flex-direction: row; right: 12px; }
}

/* First visit: an offer of the highlights tour, with a way to opt out */
.sa-welcome-card {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 7;
  width: min(420px, calc(100% - 24px)); box-sizing: border-box; padding: 1rem 1.2rem 1.1rem;
  background: rgba(8, 14, 38, 0.94); border: 1px solid var(--sa-line); border-radius: 16px;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.6); color: var(--sa-ink);
}
.sa-welcome-card[hidden] { display: none; }
.sa-welcome-card h2 { margin: 0 0 0.3rem; font-size: 1.2rem; color: var(--sa-ink); }
.sa-welcome-card p { margin: 0 0 0.8rem; color: var(--sa-ink-2); line-height: 1.5; font-size: 0.92rem; }
.sa-welcome-card .sa-welcome-offer { color: var(--sa-ink); font-weight: 600; }
.sa-welcome-btns { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 900px) {
  .sa-welcome-card { padding: 0.8rem 0.9rem 0.9rem; }
  .sa-welcome-card p { font-size: 0.85rem; margin-bottom: 0.6rem; }
}
@media (max-width: 900px) {
  .sa-hint { display: none; }   /* it describes mouse gestures */
}

.sa-sources { margin-top: 1.1rem; font-size: 0.85rem; color: var(--sa-ink-2); }
.sa-sources summary { cursor: pointer; color: var(--sa-accent); }
.sa-sources ul { padding-left: 1.1rem; margin: 0.4rem 0 0; line-height: 1.6; }

.sa-panel .sa-advisory, .sa-welcome-card .sa-advisory { margin: 0.4rem 0; padding: 0.45rem 0.7rem; border-left: 3px solid var(--sa-gold); background: var(--sa-panel-2); color: var(--sa-ink); font-size: 0.85rem; }

/* Share confirmation */
.sa-toast {
  position: absolute;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: rgba(8, 14, 36, 0.92);
  border: 1px solid var(--sa-accent);
  color: var(--sa-ink);
  font-size: 0.88rem;
  text-align: center;
  z-index: 30;
  pointer-events: none;
}
.sa-toast[hidden] { display: none; }

/* Tour quiz */
.sa-quiz-start { margin-top: 0.8rem; }
.sa-quiz-q { margin: 0.4rem 0 0.8rem; font-size: 1.05rem; line-height: 1.4; color: var(--sa-ink); }
.sa-quiz-q:focus { outline: none; }
.sa-quiz-choices { display: grid; gap: 8px; margin-bottom: 0.8rem; }
.sa-quiz-choice {
  display: block;
  width: 100%;
  padding: 0.65rem 0.9rem;
  text-align: left;
  border-radius: 9px;
  border: 1px solid var(--sa-line);
  background: var(--sa-panel-2);
  color: var(--sa-ink);
  font: inherit;
  line-height: 1.35;
  cursor: pointer;
}
.sa-quiz-choice:hover { border-color: var(--sa-accent); }
.sa-quiz-choice:focus-visible { outline: 2px solid var(--sa-accent); outline-offset: 2px; }
.sa-quiz-choices.answered .sa-quiz-choice { cursor: default; }
.sa-quiz-choices.answered .sa-quiz-choice:hover { border-color: var(--sa-line); }
.sa-quiz-choice.right, .sa-quiz-choices.answered .sa-quiz-choice.right:hover { border-color: #5fd38d; background: rgba(95, 211, 141, 0.16); }
.sa-quiz-choice.wrong, .sa-quiz-choices.answered .sa-quiz-choice.wrong:hover { border-color: #ff8a80; background: rgba(255, 138, 128, 0.14); }
.sa-quiz-why { margin: 0 0 0.9rem; color: var(--sa-ink-2); line-height: 1.5; }
