/* ============================================================
   shell.css — the top bar shared by Collect, Recognize and Train.
   Loaded after each page's stylesheet; uses that page's :root tokens.
   ============================================================ */

:root { --topbar-h: 52px; }

html, body { height: 100%; }
body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.scroll-page { overflow: auto; display: block; }   /* Train: a normal scrolling page */

/* The page below the bar fills what's left (pages used 100dvh before) */
#app { flex: 1 1 auto; min-height: 0; height: auto; }
@media (min-width: 768px) and (orientation: landscape) {
  #app { height: auto; min-height: 0; }
  #control-panel, #canvas-panel { height: 100%; }
}

/* ── Bar ─────────────────────────────────────────────────────────────────── */
.topbar {
  flex: 0 0 var(--topbar-h);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: flex-start;         /* page stylesheets still style bare <header> */
  order: 0;
  gap: 18px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 60;
}
body.scroll-page .topbar { position: sticky; top: 0; }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: "Noto Sans Myanmar", sans-serif;
  font-size: 15px;
  line-height: 1;
  padding-top: 0.076em;   /* the glyph's ink sits 0.04em above the line box centre (measured) */
}
.brand-name { font-size: 13px; font-weight: 700; letter-spacing: 0.01em; }

/* Pages */
.mode-switch { display: flex; gap: 2px; }
.mode-tab {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 8px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.mode-tab:hover { color: var(--text); background: var(--surface2); }
/* Tabs your role can't open stay hidden: guest → Recognize; user → + Collect; admin → all */
.mode-tab[data-need] { display: none; }
:root.role-user .mode-tab[data-need="user"],
:root.role-admin .mode-tab[data-need] { display: block; }
.mode-tab.active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.mode-tab:focus-visible, .topbar button:focus-visible, .brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Right side */
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .icon-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: none;
  color: var(--text2);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.topbar .icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.topbar .icon-btn.on { border-color: var(--accent); color: var(--accent); }
.topbar-sep { width: 1px; height: 22px; background: var(--border); }

.writer-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  max-width: 220px;
  padding: 0 12px 0 4px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.writer-chip:hover { border-color: var(--accent); }
.writer-avatar {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}
.writer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.writer-chip.signed-out { padding: 0 14px; color: var(--accent); border-color: var(--accent); }
.writer-chip.signed-out .writer-avatar { display: none; }

.theme-btn .icon-sun { display: none; }
:root.light .theme-btn .icon-sun { display: block; }
:root.light .theme-btn .icon-moon { display: none; }

/* Desktop-only page actions (e.g. canvas side) */
.desktop-only { display: none !important; }
@media (min-width: 768px) and (orientation: landscape) {
  .topbar .desktop-only { display: flex !important; }
}

/* Phones: the bar keeps the page tabs and actions; brand text and your name step aside */
@media (max-width: 640px) {
  :root { --topbar-h: 48px; }
  .topbar { gap: 10px; padding: 0 10px; }
  .brand-name, .topbar-sep { display: none; }
  .brand-mark { width: 26px; height: 26px; font-size: 14px; }
  .mode-tab { font-size: 11px; padding: 6px 8px; }
  .writer-chip { padding: 0 3px; max-width: none; }
  .writer-chip .writer-name { display: none; }
  .writer-chip.signed-out { padding: 0 10px; }
  .writer-chip.signed-out .writer-name { display: inline; }
  .topbar .icon-btn { width: 32px; height: 32px; }
  .topbar-actions { gap: 6px; }
}
@media (max-width: 380px) {
  .brand { display: none; }
}
.topbar-actions > .topbar-sep:first-child { display: none; }   /* no page actions before it */

/* ── Account chip menu ─────────────────────────────────────────────────── */
.account { position: relative; }
.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 12px;
  box-shadow: 0 10px 30px color-mix(in srgb, #000 18%, transparent);
  z-index: 70;
}
.account-menu[hidden] { display: none; }
.account-menu-who {
  font-size: 11px;
  color: var(--muted);
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  line-height: 1.6;
}
.account-menu-who strong { color: var(--text); font-size: 12px; }
#account-menu-email { overflow-wrap: anywhere; }
.account-menu .role-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0 5px;
  margin-left: 4px;
  vertical-align: 1px;
}
.account-menu .role-badge[hidden] { display: none; }
.account-menu a,
.account-menu button {
  display: block;
  text-decoration: none;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 9px 10px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.account-menu a:hover, .account-menu a:focus-visible,
.account-menu button:hover, .account-menu button:focus-visible { background: var(--surface2); outline: none; }
