/* Command Hive application shell: ink rail, top bar, brain/admin tabs, bottom nav. */

/* The shell is exactly one viewport tall and the page itself never scrolls:
   only .shell-scroll (below the top bar and tabs) does, so its scrollbar
   starts under the header instead of at the top of the window. */
body[data-layout="shell"] { overflow: hidden; }
.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

/* ---- Rail ---- */
.rail {
  position: sticky;
  top: 0;
  height: 100%;
  background: var(--ink-900);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--sp-4) var(--sp-2);
  z-index: 30;
}
.rail-brand {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: var(--sp-4);
  border-radius: 14px;
  background: rgba(255, 107, 61, 0.12);
  border: 1px solid rgba(255, 107, 61, 0.35);
}
.rail-brand span {
  width: 34px;
  height: 28px;
  background: url("/static/images/logo.png") -26.2px 0 / 98.3px auto no-repeat;
}
.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 62px;
  padding: 9px 0;
  border-radius: 12px;
  color: var(--ink-muted);
  font-size: 10.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.hive .rail-item { color: var(--ink-muted); }
.rail-item i { font-size: 19px; line-height: 1; }
.hive .rail-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.hive .rail-item[aria-current="page"] { background: rgba(255, 107, 61, 0.16); color: #fff; }
.rail-item[aria-current="page"] i { color: var(--ember-500); }
.rail-sep { width: 40px; height: 1px; background: rgba(148, 163, 184, 0.18); margin: var(--sp-2) 0; }
.rail-spacer { flex: 1; }
.rail-avatar { margin-top: var(--sp-2); }

/* ---- Main column ---- */
.shell-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.shell-main > :not(.shell-scroll) { flex: none; }
/* position: relative makes absolutely positioned descendants clip and scroll
   here instead of stretching the page. */
.shell-scroll { position: relative; flex: 1; min-height: 0; overflow-y: auto; overflow-x: clip; display: flex; flex-direction: column; overscroll-behavior: contain; }

.topbar {
  position: relative;
  z-index: 20;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-6);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
/* The current page's title reads as the page heading: 1.5x the trail. */
.crumbs [aria-current="page"] { color: var(--text); font-weight: 650; font-size: 1.5em; letter-spacing: -0.01em; line-height: 1.2; }
.crumbs i { font-size: 11px; }
.topbar-search {
  position: relative;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: min(420px, 38vw);
  height: 38px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
}
.topbar-search:hover { border-color: var(--border-strong); }
.topbar-search:focus-within { border-color: var(--ember-500); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.topbar-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; }
.topbar-search input::placeholder { color: var(--muted); }
.topbar-search input::-webkit-search-cancel-button { display: none; }
.topbar-search .keys { margin-left: auto; display: flex; gap: 3px; }
.topbar-search:focus-within .keys { display: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  position: relative;
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--border-strong); color: var(--text); }
.icon-btn .pip {
  position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ember-500); box-shadow: 0 0 0 2px var(--surface-2);
}

/* ---- Context tabs (brain / admin) ---- */
.ctx-tabs {
  position: relative;
  z-index: 19;
  display: flex;
  gap: 2px;
  padding: 0 var(--sp-6);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.ctx-tabs::-webkit-scrollbar { display: none; }
.ctx-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 12px 12px;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.hive .ctx-tab { color: var(--muted); }
.hive .ctx-tab:hover { color: var(--text); }
.hive .ctx-tab[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--ember-500); }
.ctx-tab .count { font-size: 11px; background: var(--chip); padding: 0 6px; border-radius: var(--r-pill); color: var(--text-2); }
.ctx-title { display: flex; align-items: center; gap: var(--sp-2); padding-right: var(--sp-4); margin-right: var(--sp-2); border-right: 1px solid var(--border); font-weight: 650; white-space: nowrap; }
.ctx-title .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--ember-500); }

/* ---- Content ---- */
.content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0;
  padding: var(--sp-6) var(--sp-6) var(--sp-8);
  min-width: 0;
}
.content.flush { max-width: none; padding: 0; }

.page-head { display: flex; align-items: flex-end; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.page-head h1 { margin: 4px 0 2px; font-size: var(--fs-2xl); font-weight: 750; letter-spacing: -0.025em; }
.page-head .sub { color: var(--muted); margin: 0; }
.page-head .actions { margin-left: auto; display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ---- Bottom nav (phones) ---- */
.bottom-nav { display: none; }

/* ---- Account menu ---- */
.menu { position: relative; }
.menu-panel {
  position: absolute;
  left: calc(100% + 10px);
  bottom: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--elev-3);
  padding: var(--sp-2);
  z-index: 60;
}
.menu-panel[hidden] { display: none; }
.menu-head { padding: var(--sp-2) var(--sp-3) var(--sp-3); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-2); }
.menu-head b { display: block; }
.menu-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 8px var(--sp-3); border-radius: var(--r-sm);
  color: var(--text-2); text-decoration: none; font-size: 13.5px;
  width: 100%; background: none; border: 0; text-align: left; cursor: pointer;
}
.hive .menu-item { color: var(--text-2); }
.menu-item:hover { background: var(--surface-2); color: var(--text); }
/* Row action menus open to the left of their toggle and hold forms. */
.menu-panel.menu-right { left: auto; right: 0; bottom: auto; top: calc(100% + 4px); }
.menu-panel form { margin: 0; }
button.menu-item { width: 100%; border: 0; background: none; text-align: left; font: inherit; cursor: pointer; }
.hive .menu-item.danger { color: var(--danger); }

/* Tab bars scroll sideways on narrow screens; fade the edge so it's visible. */
@media (max-width: 900px) {
  .ctx-tabs { mask-image: linear-gradient(90deg, #000 85%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); }
}
/* Nothing in the content column may widen the page on a phone; wide content
   (tables, code) scrolls inside its own container instead. */
.shell-main { min-width: 0; overflow-x: clip; }
html:has(body.hive) { overflow-x: clip; }

/* ---- Language switcher (flag button, same size as the help icon-btn) ---- */
.lang-menu { position: relative; flex: none; }
.lang-btn .flag, .lang-item .flag { display: block; width: 22px; height: 15px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15); }
.lang-panel { min-width: 170px; }
.menu-panel.lang-panel { z-index: 70; }
.lang-item.is-current { background: var(--accent-soft); color: var(--accent-text); font-weight: 650; }
.hive .lang-item.is-current { color: var(--accent-text); }
.auth-lang { position: absolute; top: 16px; right: 16px; z-index: 5; }
.auth-main { position: relative; }
