/* ============ Fixed layout shell ============ */
/* Replaces the old docking engine: the layout is declared as data in
   js/app.js, laid out by these rules, and never dragged or resized.
   Every class is prefixed sh- so nothing here can collide with view CSS.

   Depth is read from tone, not from borders: the page is the darkest surface
   and a panel with tabs is the lightest. The open tab is filled with its
   panel's tone and merges into the body through a concave fillet, so there is
   no tab strip bar. The nested level inside a panel is a different, quieter
   treatment — a plain underlined row — because a second fold in a narrow rail
   would leave the fillet nowhere to sit. */

:root {
  --sh-bg: #141414;          /* the page, and the header sitting on it */
  --sh-inset: #1c1c1c;       /* a labelled frame, which is an inset surface */
  --sh-nested: #262626;      /* a section body inside a panel */
  --sh-panel: #333333;       /* a panel that has tabs */
  --sh-line: #3d3d3d;        /* hairline drawn on the page background */
  --sh-line-on-panel: #4a4a4a; /* hairline drawn on the panel tone */

  --sh-header-height: 38px;
  --sh-gap: 10px;
  --sh-radius: 14px;         /* panel / frame corners */
  --sh-tab-radius: 9px;      /* tab top corners, which the body then matches */

  --sh-tab-text: #b4b4b4;
  --sh-tab-text-active: #e8e8e8;
  --sh-tab-underline: #c8c8c8;
}

/* ============ Header ============ */
/* Just a label row on the page background — no bar, no rule. */

#sh-header {
  display: flex;
  align-items: center;
  gap: 18px;
  height: var(--sh-header-height);
  padding: 0 14px;
  /* Same surface as the layout area below it, so the two read as one page. */
  background: var(--sh-bg);
  flex-shrink: 0;
  /* The account menu hangs out of the header, so it has to paint over the
     layout host that follows it. */
  position: relative;
  z-index: 100;
}

.sh-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sh-logo {
  width: 20px;
  height: 20px;
  display: block;
}

.sh-brand-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}

/* ============ Account menu ============ */
/* The one thing on the header's right end. It is pushed there rather than
   sized, so the search keeps its own column and the icon sits at the page's
   edge at any width. */

.sh-user-wrap {
  position: relative;
  margin-left: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.sh-user-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
}

.sh-user-btn .material-symbols-outlined { font-size: 22px; }

/* Once the local profile has a photo, the header shows the picture in place of
   the generic glyph. The class is set from the account record. */
.sh-user-img {
  display: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.sh-user-btn.has-photo .material-symbols-outlined { display: none; }
.sh-user-btn.has-photo .sh-user-img { display: block; }

.sh-user-btn:hover,
.sh-user-btn[aria-expanded="true"] {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sh-user-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

.sh-user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 1;
  min-width: 190px;
  padding: 4px;
  background: var(--bg-light);
  border: 1px solid var(--cardBorders);
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

/* The attribute is the state; the class only exists so the panel never shows
   as an empty box before the first toggle. */
.sh-user-menu[hidden] { display: none; }

.sh-user-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.sh-user-item .material-symbols-outlined {
  font-size: 17px;
  color: var(--text-secondary);
}

.sh-user-item:hover {
  background: var(--bg-hover);
}

.sh-user-item:hover .material-symbols-outlined { color: var(--accent); }

.sh-user-item:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

/* ============ Layout host ============ */

#sh-host {
  flex: 1;
  min-height: 0;
  display: flex;
  padding: var(--sh-gap);
  background: var(--sh-bg);
}

.sh-node {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.sh-node-row {
  flex-direction: row;
  gap: var(--sh-gap);
}

.sh-node-col {
  flex-direction: column;
  gap: var(--sh-gap);
}

/* A cell a view has asked the shell to collapse. Nothing is drawn: the column
   leaves the row, the gap with it, and the cells beside it take the width. */
.sh-cell.is-collapsed {
  display: none;
}

/* Cells are sized by grow weight with a zero basis, so the fixed gaps are
   subtracted from the free space first and the proportions stay exact. */
.sh-cell {
  display: flex;
  min-width: 0;
  min-height: 0;
}

/* ---------- A joined row ---------- */
/* Two panels that are really one board. The gap closes and the corners where
   they meet square off, so the pair reads as one surface rather than two. The
   right half takes the left half's tone: a view that paints its own canvas —
   the skill tree does — would otherwise leave the seam the join was meant to
   remove. */
.sh-node--join {
  gap: 0;
}

.sh-node--join > .sh-cell:first-child > .sh-panel--frame {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.sh-node--join > .sh-cell:last-child > .sh-panel--frame {
  background: var(--bg-dark);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* ============ Panel ============ */

.sh-panel {
  position: relative;   /* a panel is where a full-panel page can be drawn */
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  border-radius: var(--sh-radius);
}

/* A panel with tabs has no surface of its own: the active tab and the body are
   the same fill, so nothing clips the fillet that joins them. */
.sh-panel--tabs {
  --tab-fill: var(--sh-panel);
  overflow: visible;
}

/* A labelled frame draws no surface of its own: the view inside sits on the
   page, and only what the view paints — its own panels and controls — carries a
   tone. A frame is a boundary, not a slab, which is what keeps an area like the
   transport or the rack from reading as a brighter band across the window. */
.sh-panel--frame {
  background: none;
  overflow: hidden;
}

.sh-panel-head {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 12px;
  border-bottom: 1px solid var(--sh-line);
  color: var(--sh-tab-text);
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
}

/* The view's half of the label row. A frame that sets `headExtra` gets this
   slot, and the view inside fills it; taking the free space keeps the frame's
   own close at the far edge. */
.sh-panel-head-extra {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* The way out of an expanded pane, heading the frame it opens into. Only the
   expanded layouts carry one; a pane reached from the main layout has nowhere
   to go back to that a tab does not already cover. */
.sh-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: -5px;
  padding: 0;
  flex-shrink: 0;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--sh-tab-text);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.sh-back .material-symbols-outlined {
  font-size: 16px;
  line-height: 1;
}

.sh-back:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* The way out of a panel that is only there while another one is expanded.
   It sits at the far end of the label row, opposite the expanded pane's own
   way back, so the two exits never read as the same control. */
.sh-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: auto;
  margin-right: -5px;
  padding: 0;
  flex-shrink: 0;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--sh-tab-text);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.sh-close .material-symbols-outlined {
  font-size: 16px;
  line-height: 1;
}

.sh-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* ============ Tabs ============ */

/* Tab rows wrap rather than run past the panel edge on a narrow window.
   js/app.js drops the merge for a row that has wrapped. */
/* The labels are the only thing in the shell that has to fit four across a
   rail, so they run tighter than the rest: the strip and the tabs are sized to
   hold Lessons / Chat / History / Community on one line rather than wrapping,
   which is what keeps the open tab sitting on the body's corner. */
.sh-tabstrip {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 4px;
  flex-shrink: 0;
}

.sh-tab {
  position: relative;
  display: flex;
  align-items: center;
  height: 30px;
  padding: 0 6px;
  background: transparent;
  border: none;
  border-radius: var(--sh-tab-radius) var(--sh-tab-radius) 0 0;
  color: var(--sh-tab-text);
  font-family: inherit;
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.sh-tab:hover {
  color: var(--text-primary);
}

/* The open tab is filled with its panel's tone and meets the body below it at a
   plain corner, so the two read as one surface. Its top corners are the only
   rounding. */
.sh-tab.is-active,
.sh-tab.is-active:hover {
  background: var(--tab-fill);
  color: var(--sh-tab-text-active);
}

/* A tab whose label is a glyph rather than text. The icon is sized to the tab's
   own rhythm — the same 18px the expand circle uses — and the tab holds it on
   its own line, so an icon tab is the height of a worded one and only as wide
   as the glyph needs. */
.sh-tab--icon {
  justify-content: center;
  padding: 0 9px;
}

.sh-tab--icon .material-symbols-outlined {
  font-size: 18px;
  line-height: 1;
}

/* The one tab of a rail that has no others to sit beside: it takes the row's
   whole width, and the close that would otherwise head a frame of its own rides
   at its end. Its fill is the panel's, so the panel below still reads as the
   surface this tab opens onto. */
.sh-tab--solo {
  flex: 1;
  padding-right: 6px;
}

.sh-tab--solo .sh-close {
  margin-right: 0;
}

/* A per-tab shortcut into another layout. It sits inside the tab, after the
   label, so the open tab's fill carries it and it reads as part of the same
   chip rather than a control floating in the row. */
.sh-tab--expandable {
  padding-right: 5px;
}

.sh-tab-expand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 3px;
  border-radius: 50%;
  color: inherit;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.sh-tab-expand .material-symbols-outlined {
  font-size: 18px;
  line-height: 1;
}

/* A white wash rather than a new colour, so the circle reads as the same chip
   tinting up wherever it sits. */
.sh-tab-expand:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* ---------- Nested level: a quieter, underlined row ---------- */
/* Sections rather than folds. Text-only labels fit several into a narrow rail,
   and there is no fillet to place. The row scrolls sideways when the sections
   still do not all fit. */

.sh-tabstrip--sub {
  flex-wrap: nowrap;
  gap: 0;
  border-bottom: 1px solid var(--sh-line-on-panel);
  overflow-x: auto;
  overflow-y: hidden;
}

/* The rail cannot hold five sections at once, so the row scrolls. The bar is
   kept visible and light enough to read against the panel tone — it is the
   only hint that there are more sections off the edge. */
.sh-tabstrip--sub::-webkit-scrollbar {
  height: 4px;
}

.sh-tabstrip--sub::-webkit-scrollbar-track {
  background: transparent;
}

.sh-tabstrip--sub::-webkit-scrollbar-thumb {
  background: #6a6a6a;
  border-radius: 4px;
}

.sh-tab--sub {
  height: 26px;
  padding: 0 10px;
  border-radius: 0;
  font-size: 11px;
  color: #8a8a8a;
}

/* A row nested two deep gets the same treatment a step quieter, so the two
   levels still read as a hierarchy rather than two identical strips. */
.sh-tabstrip--sub-deep {
  border-bottom-color: rgba(255, 255, 255, 0.05);
}

.sh-tab--sub-deep {
  height: 22px;
  padding: 0 9px;
  font-size: 10px;
  color: #7e7e7e;
}

/* None of the fold styling above applies here: the open section is marked by
   an underline sitting on the row's hairline. */
.sh-tab--sub.is-active,
.sh-tab--sub.is-active:hover {
  background: transparent;
  color: var(--sh-tab-text-active);
  box-shadow: inset 0 -2px 0 0 var(--sh-tab-underline);
}

.sh-tab--sub.is-active::before,
.sh-tab--sub.is-active::after {
  display: none;
}

/* ============ Body / panes ============ */

.sh-body {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Only the corner the open tab is sitting on stays square, so the tab and the
   body read as one shape. */
.sh-panel--tabs > .sh-body {
  background: var(--tab-fill);
  border-radius: var(--sh-tab-radius) var(--sh-tab-radius) var(--sh-radius) var(--sh-radius);
}

.sh-panel--tabs > .sh-body--merge-l {
  border-top-left-radius: 0;
}

/* The same corner rule at the other end, for a row whose open tab reaches the
   body's right edge — a rail with nothing left to tab to. */
.sh-panel--tabs > .sh-body--merge-r {
  border-top-right-radius: 0;
}

/* A wrapped row puts a second row of tabs between the active tab and the body,
   so no tab is sitting on the body's corner and all four stay rounded. */
.is-wrapped.sh-panel--tabs > .sh-body {
  border-top-left-radius: var(--sh-tab-radius);
}

.is-wrapped.sh-panel--tabs > .sh-body--merge-l,
.is-wrapped.sh-panel--tabs > .sh-body--merge-r {
  border-top-left-radius: var(--sh-tab-radius);
  border-top-right-radius: var(--sh-tab-radius);
}

.sh-pane {
  display: none;
}

.sh-pane.is-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

/* Nested tab group (the Browser's Samples / Presets / ... row). Its row sits on
   the panel tone; the section body below steps one level back down, so the
   ladder stays page < frame < section < panel. */

.sh-group {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.sh-group > .sh-body {
  background: var(--sh-nested);
}

/* ============ Placeholder panels ============ */
/* These sit on either tone — a labelled frame or the rail's panel — so the
   text is kept bright enough for the lighter of the two. */

.sh-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-secondary);
  text-align: center;
  padding: 20px;
}

.sh-placeholder-icon {
  font-size: 28px;
  line-height: 1;
  opacity: 0.7;
}

.sh-placeholder-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.sh-placeholder-note {
  font-size: 11px;
  color: var(--text-secondary);
}
