/* bookstack - the signed-in chrome and the pieces every page shares: the top
 * bar and its menu, page frames, cards, tables, chips, stars, dialogs and
 * the toast. Each area has its own stylesheet beside this one (browse.css,
 * book.css, capture.css, shelf.css, review.css), loaded by its template;
 * colours only ever come from tokens.css. Phone rules are at the end. */

/* --- top bar ------------------------------------------------------------ */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: var(--nav-h); padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { margin: 0; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  min-width: 240px; padding: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-2);
}
.menu-who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px;
  font-size: .875rem; color: var(--ink-soft); }
.menu-who strong { display: block; color: var(--ink); font-size: .95rem; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 8px; background: none;
  color: var(--ink); font: 400 .95rem/1.2 var(--font-ui); text-align: left;
  text-decoration: none; cursor: pointer;
}
.menu-item:hover { background: var(--hover); color: var(--ink); }
.menu-sep { height: 1px; margin: 6px 0; background: var(--line); }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px; font-size: .875rem; color: var(--ink-soft); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; }
.seg button, .seg a {
  min-height: 30px; padding: 0 10px; border: 0; background: none; color: var(--ink-soft);
  font: 500 .8125rem/30px var(--font-ui); text-decoration: none; cursor: pointer;
}
.seg button + button, .seg a + a { border-left: 1px solid var(--line-strong); }
.seg [aria-pressed="true"], .seg [aria-current="true"] { background: var(--accent); color: var(--on-accent); }

/* --- page frames -------------------------------------------------------- */

.page { max-width: 1100px; margin: 0 auto; padding: 24px var(--gutter) 64px; }
.page-narrow { max-width: 720px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-1); }
.card + .card { margin-top: 16px; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.empty { padding: 32px 16px; text-align: center; color: var(--ink-soft); }

/* --- tables ------------------------------------------------------------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left;
  vertical-align: middle; }
.table th { font-size: .8125rem; font-weight: 600; color: var(--ink-soft); background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem;
  font-weight: 600; background: var(--chip-bg); color: var(--ink-soft); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* --- chips (tags) and stars ---------------------------------------------- */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 0 10px; border: 1px solid transparent; border-radius: 999px;
  background: var(--chip-bg); color: var(--ink); font: 500 .8125rem/1 var(--font-ui);
  text-decoration: none;
}
.chip[aria-pressed="true"] { background: var(--chip-on); color: var(--on-chip-on); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* Stars are a row of five glyphs, the on ones coloured. As text (★), so they
 * scale with the font and need no images. */
.stars { display: inline-flex; gap: 1px; color: var(--star-off); font-size: 1em; line-height: 1;
  letter-spacing: 0; white-space: nowrap; }
.stars .on { color: var(--star); }

/* --- dialogs and the toast ----------------------------------------------- */

dialog.sheet {
  width: min(520px, calc(100vw - 2 * var(--gutter))); max-height: calc(100dvh - 48px);
  padding: 22px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3);
}
dialog.sheet::backdrop { background: var(--scrim); }
dialog.sheet h2 { margin-top: 0; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* A popover, so it sits in the top layer above an open <dialog> (from
 * hmp-bookings). ui.js shows it with showPopover() and hides it after a few
 * seconds. */
.toast {
  position: fixed; inset: auto auto 24px 50%; transform: translateX(-50%); margin: 0;
  max-width: min(480px, calc(100vw - 32px)); padding: 12px 16px;
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-2);
  font-size: .9375rem;
}
.toast.error { background: var(--err-ink); color: var(--err-bg); border-color: var(--err-ink); }

/* --- users page --------------------------------------------------------- */

.users-add { display: grid; grid-template-columns: 1fr 160px auto; gap: 10px; align-items: end; }

/* --- phones ------------------------------------------------------------- */

@media (max-width: 720px) {
  :root { --nav-h: 52px; }
  .page { padding-top: 16px; }
  h1 { font-size: 1.45rem; }
  .users-add { grid-template-columns: 1fr; }
  .topbar .brand-word { display: none; }
}

@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-small { min-height: 38px; }
  .btn-icon { width: 44px; }
  .menu-item { padding: 12px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* --- shared libraries ---------------------------------------------------- */

.menu-label { padding: 6px 10px 2px; font-size: .75rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-faint); }
.menu-library { justify-content: space-between; }
.menu-library[aria-current="true"] { font-weight: 600; background: var(--hover); }

/* Under the top bar while the library is someone else's. */
.library-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  padding: 6px var(--gutter); font-size: .875rem;
  background: var(--accent-soft); color: var(--ink); border-bottom: 1px solid var(--line);
}
.library-banner.is-read { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }

.share-add { display: grid; grid-template-columns: 1fr 170px auto; gap: 10px; align-items: end; margin-bottom: 8px; }
.share-list { list-style: none; margin: 14px 0 0; padding: 0; }
.share-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 0;
  border-top: 1px solid var(--line); }
.share-who { flex: 1; min-width: 180px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.share-level { display: flex; gap: 6px; align-items: center; }
.share-level .select { min-height: 32px; padding-top: 4px; padding-bottom: 4px; width: auto; font-size: .875rem; }
.share-none { margin: 12px 0 0; }
@media (max-width: 720px) {
  .share-add { grid-template-columns: 1fr; }
}
