/* ============================================================
   shell.css — the Toolshed's one top bar, on every page.
   Uses each page's palette tokens (--bg, --surface, --text,
   --accent …) with safe fallbacks, so it sits naturally on the hub
   and on every tool. Everything is prefixed ts- to stay out of the
   tools' own styles.
   ============================================================ */

.ts-bar {
  --ts-surface: var(--surface, #fff);
  --ts-text: var(--text, #33414d);
  --ts-dim: var(--text-dim, #5d6d7a);
  --ts-border: var(--border, #d5dfe6);
  --ts-accent: var(--accent, #457695);
  --ts-soft: var(--surface-2, #e9eff3);
  position: sticky; top: 0; z-index: 900;
  display: flex; align-items: center; gap: 14px;
  min-height: 58px; padding: 6px max(14px, env(safe-area-inset-right)) 6px max(14px, env(safe-area-inset-left));
  box-sizing: border-box; width: 100vw; max-width: none;
  margin: 0 calc(50% - 50vw);   /* full width even when a page centers its body */
  background: color-mix(in srgb, var(--ts-surface) 94%, transparent);
  -webkit-backdrop-filter: saturate(1.2) blur(8px); backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--ts-border);
  color: var(--ts-text);
  font: 500 15px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: normal; text-align: left;
}
.ts-bar *, .ts-bar *::before, .ts-bar *::after { box-sizing: border-box; }
.ts-bar a { color: inherit; text-decoration: none; }
.ts-bar button { font: inherit; color: inherit; }

.ts-brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; white-space: nowrap; border-radius: 10px; padding: 4px 6px; }
.ts-brand svg { flex: none; }

.ts-nav { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.ts-nav a {
  padding: 9px 13px; border-radius: 999px; color: var(--ts-dim); white-space: nowrap;
  transition: background-color .15s ease, color .15s ease;
}
.ts-nav a:hover { background: var(--ts-soft); color: var(--ts-text); }
.ts-nav a[aria-current="page"] { background: color-mix(in srgb, var(--ts-accent) 16%, transparent); color: var(--ts-text); font-weight: 650; }

.ts-tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.ts-pop-wrap { position: relative; }
.ts-icon-btn, .ts-signin {
  display: inline-flex; align-items: center; gap: 7px; min-height: 42px; padding: 8px 12px;
  border-radius: 999px; border: 1px solid var(--ts-border); background: var(--ts-surface);
  cursor: pointer; white-space: nowrap; color: var(--ts-text);
}
.ts-icon-btn:hover, .ts-signin:hover { background: var(--ts-soft); }
.ts-bar .ts-signin { background: var(--ts-accent); border-color: transparent; color: var(--ts-surface); font-weight: 650; }
.ts-signin:hover { background: var(--ts-accent); filter: brightness(1.06); }
.ts-avatar {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--ts-accent); color: var(--ts-surface); font-weight: 700; font-size: 14px; margin-left: -4px;
}
.ts-account-wait { display: inline-block; width: 42px; height: 42px; }
.ts-menu-btn { display: none; }

.ts-bar a:focus-visible, .ts-bar button:focus-visible, .ts-skip:focus-visible, .ts-toast button:focus-visible {
  outline: 3px solid var(--ts-accent, #457695); outline-offset: 2px;
}

/* Popovers */
.ts-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 950;
  min-width: 250px; max-width: min(340px, calc(100vw - 24px)); max-height: min(70vh, 560px); overflow: auto;
  padding: 8px; border-radius: 16px; border: 1px solid var(--ts-border);
  background: var(--ts-surface); color: var(--ts-text);
  box-shadow: 0 14px 40px rgba(20, 30, 40, .18);
}
.ts-pop[hidden] { display: none; }
.ts-pop-title { margin: 4px 8px 8px; font-weight: 700; }
.ts-pop-note { margin: 8px; font-size: 13px; color: var(--ts-dim); }
.ts-theme {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px; border: 2px solid transparent;
  border-radius: 12px; background: none; cursor: pointer; text-align: left;
}
.ts-theme:hover { background: var(--ts-soft); }
.ts-theme[aria-pressed="true"] { border-color: var(--ts-accent); background: var(--ts-soft); }
.ts-chips { display: inline-flex; flex: none; }
.ts-chips i { display: block; width: 18px; height: 26px; border: 1px solid rgba(0,0,0,.12); margin-left: -1px; }
.ts-chips i:first-child { border-radius: 6px 0 0 6px; }
.ts-chips i:last-child { border-radius: 0 6px 6px 0; }
.ts-theme-name { display: flex; flex-direction: column; font-weight: 600; }
.ts-theme-name small { font-weight: 400; font-size: 13px; color: var(--ts-dim); }

.ts-menu a, .ts-signout {
  display: block; width: 100%; padding: 11px 12px; border-radius: 10px; border: 0; background: none; text-align: left; cursor: pointer;
}
.ts-menu a:hover, .ts-signout:hover { background: var(--ts-soft); }
.ts-signout { border-top: 1px solid var(--ts-border); border-radius: 0 0 10px 10px; margin-top: 4px; color: var(--ts-dim); }
.ts-who { display: flex; flex-direction: column; gap: 2px; margin: 4px 12px 8px; overflow-wrap: anywhere; }
.ts-who span { font-size: 13px; color: var(--ts-dim); }

/* Tool cards (tools page) */
.ts-lock, .ts-open-badge { display: inline-flex; align-items: center; gap: .35em; width: fit-content; margin-top: .6rem; padding: .25rem .7rem;
  border-radius: 999px; font-size: .85rem; font-weight: 600; background: var(--surface-2, #e9eff3); color: var(--text, #33414d); }
.ts-open-badge { background: color-mix(in srgb, var(--accent2, #628f5d) 18%, transparent); }
.ts-card-wrap { position: relative; display: grid; }
.ts-card-wrap > .card { padding-right: 3rem; }
.ts-star { position: absolute; top: 8px; right: 8px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: transparent;
  color: var(--text-dim, #62727f); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.ts-star:hover { background: var(--surface-2, #e9eff3); }
.ts-star[aria-pressed="true"] { color: var(--accent, #457695); }
.ts-star:focus-visible { outline: 3px solid var(--accent, #457695); outline-offset: 1px; }

/* Skip link + toast */
.ts-skip { position: absolute; left: 12px; top: -60px; z-index: 1000; padding: 10px 14px; border-radius: 10px; background: var(--surface, #fff); color: var(--text, #33414d); }
.ts-skip:focus { top: 8px; }
.ts-toast {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 990;
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 24px);
  padding: 10px 10px 10px 16px; border-radius: 14px; border: 1px solid var(--border, #d5dfe6);
  background: var(--surface, #fff); color: var(--text, #33414d); box-shadow: 0 10px 30px rgba(20, 30, 40, .18);
  font: 500 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.ts-toast-act { border: 0; border-radius: 999px; padding: 8px 14px; background: var(--accent, #457695); color: var(--surface, #fff); font: inherit; font-weight: 650; cursor: pointer; }
.ts-toast-x { border: 0; background: none; font-size: 22px; line-height: 1; padding: 4px 8px; cursor: pointer; color: inherit; }

/* Phones and narrow windows: links fold into the Menu button */
@media (max-width: 860px) {
  .ts-bar { flex-wrap: wrap; gap: 8px; }
  .ts-btn-label { display: none; }
  .ts-icon-btn { padding: 8px 10px; }
  .ts-me { padding: 4px 8px 4px 8px; }
  .ts-menu-btn { display: inline-flex; }
  .ts-nav { display: none; order: 10; flex-basis: 100%; flex-direction: column; align-items: stretch; padding: 4px 0 6px; }
  .ts-bar.ts-open .ts-nav { display: flex; }
  .ts-nav a { padding: 12px 14px; border-radius: 12px; }
}
@media (max-width: 400px) { .ts-brand span { font-size: 15px; } .ts-signin span { display: none; } }

@media (prefers-reduced-motion: reduce) { .ts-nav a { transition: none; } }
@media print { .ts-bar, .ts-skip, .ts-toast { display: none !important; } }

/* Fullscreen classroom screens hide the bar */
html.ts-bar-off .ts-bar, :fullscreen .ts-bar { display: none; }

/* ---------- Tool bars under the shell ----------
   Each tool keeps its own row (its name, its pages and the hold
   buttons) beneath the Toolshed bar. The shell already carries the
   site name and the palette, so the tool row drops its copies. */
html.ts-shell { overflow-x: clip; }
html.ts-shell header.site-head .brand-sub,
html.ts-shell header.app-header .brand-sub { display: none; }
html.ts-shell header.site-head .theme-wrap,
html.ts-shell header.site-head > .theme-btn { display: none; }
