/* Dashboard: the O-03 shell, the account menu, O-04, the SaveStatus and the S-08 reconnect overlay */
.bh-account { position: relative; }

/* Dashboard shell (O-03): app bar and bottom tabs on phones; the 256 px sidebar from 1024 px */
.bh-appbar {
  display: flex; align-items: center; gap: var(--space-1); min-height: var(--shell-appbar-h);
  padding: 0 var(--space-1) 0 var(--space-2); background: var(--card); border-bottom: 1px solid var(--line);
}
.bh-appbar > .bh-wordmark { margin-right: auto; padding: 0 var(--space-2); }
.bh-sidebar { display: none; }
.bh-main { padding-bottom: calc(var(--shell-tabbar-h) + env(safe-area-inset-bottom, 0px)); }
.bh-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--card); border-top: 1px solid var(--line);
}
.bh-tabbar-item {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0;
  min-height: var(--shell-tabbar-h); padding: 6px 0; color: var(--ink-2); text-align: center; text-decoration: none;
  font-size: var(--text-label); line-height: var(--leading-label); overflow-wrap: normal; hyphens: manual;
}
.bh-tabbar-item:hover { background: var(--sunken); color: var(--ink-1); }
.bh-tabbar-item[aria-current="page"] { color: var(--primary); }
.bh-tabbar-item[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 50%; width: 32px; height: 3px; margin-left: -16px;
  border-radius: 0 0 var(--radius-pill) var(--radius-pill); background: var(--primary);
}
.bh-tabbar-item:focus-visible { box-shadow: none; outline: 2px solid var(--primary); outline-offset: -4px; }

.bh-nav { display: grid; gap: 2px; }
.bh-nav-item {
  display: flex; align-items: center; gap: var(--space-3); min-height: var(--target-min); padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-control); color: var(--ink-2); text-decoration: none; font-size: var(--text-small); line-height: var(--leading-small);
}
.bh-nav-item:hover { background: var(--sunken); color: var(--ink-1); }
.bh-nav-item[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: var(--weight-bold); }
.bh-nav-label { flex: 1 1 auto; min-width: 0; text-align: left; }

.bh-avatar {
  display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: var(--radius-pill);
  background: var(--primary); color: var(--on-primary); font-size: var(--text-small); line-height: var(--leading-small); font-weight: var(--weight-bold);
}
.bh-account-btn { display: grid; place-items: center; width: var(--target-min); height: var(--target-min); border-radius: var(--radius-control); }
.bh-account-btn:hover { background: var(--sunken); }
.bh-account-head { display: grid; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line); margin-bottom: var(--space-1); }
.bh-account-text { display: grid; flex: 1 1 auto; min-width: 0; text-align: left; }
.bh-account-name { font-size: var(--text-small); line-height: var(--leading-small); font-weight: var(--weight-bold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bh-account-email { color: var(--ink-3); font-size: var(--text-label); line-height: var(--leading-label); overflow-wrap: anywhere; }
.bh-account--wide .bh-account-btn { display: flex; align-items: center; gap: var(--space-2); width: 100%; height: auto; min-height: var(--target-min); padding: var(--space-2) var(--space-3); }
.bh-account--wide .bh-account-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Dashboard content: O-04 and the language setting with its SaveStatus */
.bh-dash { display: grid; gap: var(--space-6); width: 100%; max-width: var(--shell-content-max); padding: var(--space-4) var(--page-pad) var(--space-8); }
.bh-dash-head { display: grid; gap: var(--space-1); }
.bh-first { display: grid; gap: var(--space-3); padding: var(--space-6) var(--space-4); }
.bh-thumb { display: grid; place-items: center; width: 56px; height: 56px; border-radius: var(--radius-card); background: var(--primary-soft); color: var(--primary); }
.bh-setting { display: grid; gap: var(--space-4); }
.bh-save-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.bh-save-slot { display: flex; align-items: center; min-height: var(--target-min); }
.bh-save {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-height: 24px; color: var(--ink-2);
  font-size: var(--text-small); line-height: var(--leading-small); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums;
}
.bh-save.is-saved { color: var(--success-ink); }
.bh-save.is-error { color: var(--danger-ink); }
.bh-save.is-offline { display: none; color: var(--warning-ink); }
.bh-offline .bh-save[data-save-status] { display: none; }
.bh-offline .bh-save.is-offline { display: inline-flex; }

/* S-08 reconnect overlay: covers the content and the navigation, never the environment strip */
#components-reconnect-modal { display: none; }
#components-reconnect-modal[data-state] { display: block; position: fixed; inset: 0; z-index: 20; }
.bh-reconnect-scrim { position: absolute; inset: 0; background: var(--scrim); }
.bh-reconnect-slot { position: absolute; left: var(--space-4); right: var(--space-4); bottom: calc(var(--shell-tabbar-h) + var(--space-4) + env(safe-area-inset-bottom, 0px)); }
.bh-reconnect {
  display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-4);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-overlay);
}
.bh-reconnect > .bh-icon { color: var(--primary); }
.bh-reconnect.is-failed > .bh-icon { color: var(--danger-ink); }
.bh-reconnect-body { display: grid; flex: 1 1 auto; gap: var(--space-2); min-width: 0; }
.bh-reconnect-title { font-weight: var(--weight-bold); }
.bh-reconnect-text { color: var(--ink-2); font-size: var(--text-small); line-height: var(--leading-small); }
.bh-reconnect[data-reconnect="failed"] { display: none; }
#components-reconnect-modal:is([data-state="failed"], [data-state="resume-failed"], [data-state="paused"]) [data-reconnect="retrying"] { display: none; }
#components-reconnect-modal:is([data-state="failed"], [data-state="resume-failed"], [data-state="paused"]) [data-reconnect="failed"] { display: flex; }

/* Blazor shows this when a dashboard circuit fails */
#blazor-error-ui {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; padding: var(--space-3) var(--space-4);
  background: var(--surface-inverse); color: var(--on-inverse);
}
#blazor-error-ui a { color: var(--on-inverse); }

@media (min-width: 1024px) {
  .bh-env:has(+ .bh-shell) { position: sticky; top: 0; }
  .bh-env + .bh-shell { --bh-env-h: var(--shell-env-h); }
  .bh-shell { display: grid; grid-template-columns: var(--shell-sidebar-w) minmax(0, 1fr); align-items: start; }
  .bh-appbar, .bh-tabbar { display: none; }
  .bh-sidebar {
    position: sticky; top: var(--bh-env-h, 0px); display: flex; flex-direction: column; gap: 2px;
    height: calc(100dvh - var(--bh-env-h, 0px)); padding: var(--space-3); background: var(--card); border-right: 1px solid var(--line);
  }
  .bh-sidebar > .bh-wordmark { flex: none; padding: var(--space-1) var(--space-3) var(--space-2); }
  .bh-sidebar-mid { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 0 calc(var(--space-3) * -1); padding: var(--space-1) var(--space-3); }
  .bh-sidebar-foot { flex: none; display: grid; gap: var(--space-1); padding-top: var(--space-3); border-top: 1px solid var(--line); }
  .bh-sidebar-foot .bh-menu-pop { top: auto; bottom: calc(100% + var(--space-1)); left: 0; right: auto; }
  .bh-main { padding-bottom: 0; }
  .bh-dash { padding-top: var(--space-10); }
  .bh-reconnect-slot { left: calc(var(--shell-sidebar-w) + var(--page-pad)); right: auto; bottom: auto; top: calc(var(--bh-env-h, 0px) + var(--space-6)); width: min(480px, calc(100% - var(--shell-sidebar-w) - 2 * var(--page-pad))); }
}
