/* Stage 21e: tabbed settings (src/ui/settingsTabs.js). Loaded after ui.css.
   Layout: a tab bar on top (desktop, tall screens) or a compact left rail on short landscape phones (<= 500 px
   tall: height is the scarce axis there, the rail spends ~74 px of the spare width instead of ~50 px of height).
   Each tab scrolls on its own; the tab bar never scrolls away. */

#ui .settings.set-tabbed {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  height: min(660px, calc(100vh - 32px));
  max-height: calc(100vh - 32px);
}
#ui .set-tabs {
  flex: none;
  display: flex;
  gap: 2px;
  padding: 10px 12px 0;
  border-bottom: 1px solid var(--hairline);
}
#ui .set-tab {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 48px;
  padding: 6px 4px 7px;
  border: 0;
  border-radius: 3px 3px 0 0;
  background: transparent;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-family: var(--f-label);
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  letter-spacing: .08em;
  text-transform: uppercase;
  transition: background-color .12s, color .12s;
}
#ui .set-tab[hidden] { display: none; }
#ui .set-tab:hover { background: rgba(23, 20, 15, .06); color: var(--ink); }
#ui .set-tab[aria-selected='true'] { background: var(--canvas-shade); color: var(--ink); }
#ui .set-tab[aria-selected='true']::after {
  content: '';
  position: absolute;
  left: 8px; right: 8px; bottom: -1px;
  height: 3px;
  background: var(--signal);
}
#ui .set-tab:focus-visible { outline: 2px solid var(--ink); outline-offset: -3px; }
#ui .set-tab-ic { flex: none; }
#ui .set-tab-l { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#ui .set-panels { flex: 1 1 auto; min-height: 0; display: flex; }
#ui .set-panel {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 22px 18px;
  container-type: inline-size;
  scrollbar-width: thin;
  scrollbar-color: var(--ink) transparent;
  outline: none;
}
#ui .set-panel[hidden] { display: none; }
#ui .set-panel-body > .field:first-child,
#ui .set-panel-body > .set-room-note:first-child + .field { margin-top: 2px; }

/* sub heading inside a tab (e.g. "Manual sky", the controls guide) */
#ui .set-sub {
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1.5px dashed var(--stitch);
  font-family: var(--f-label);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
#ui .set-guide .legend { margin-top: 8px; }
#ui .set-guide .touch-legend { margin-top: 8px; font-size: 14px; gap: 5px; }
#ui .set-guide .touch-legend b { min-width: 104px; }
html.is-touch #ui .set-guide .touch-legend-head { display: none; }

/* one note style (Danger, Target FPS, Image, room locks) */
#ui .set-panel .set-note { margin-top: 5px; font-size: 13px; line-height: 1.35; color: var(--ink-soft); }
#ui .set-room-note { margin: 0 0 6px; padding: 7px 10px; border-left: 3px solid var(--signal); background: rgba(23, 20, 15, .05); }

/* locked by a multiplayer room (Stage 22a) */
#ui .field.is-locked { opacity: .5; }
#ui .field.is-locked .seg-btn { pointer-events: none; }

/* sliders: label | (muted icon) | value on one row, the track full width below */
#ui .field--slider { grid-template-columns: 1fr auto auto; }
#ui .field-mute { display: none; align-self: center; margin-right: 6px; color: var(--ink-soft); }
#ui .field--slider.is-zero .field-mute { display: inline-flex; }
#ui .field--slider.is-zero .field-value { color: var(--ink-soft); }
/* one thumb style everywhere: ink square; an orange ring only while dragging or keyboard-focused */
#ui .rng.is-active::-webkit-slider-thumb, #ui .rng:active::-webkit-slider-thumb,
#ui .rng:focus-visible::-webkit-slider-thumb { background: var(--ink); box-shadow: 0 0 0 3px var(--signal); }
#ui .rng.is-active::-moz-range-thumb, #ui .rng:active::-moz-range-thumb,
#ui .rng:focus-visible::-moz-range-thumb { background: var(--ink); box-shadow: 0 0 0 3px var(--signal); }
#ui .rng:focus-visible { outline: none; }

/* per-tab reset (confirm tap) */
#ui .set-reset {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
  display: flex;
  justify-content: flex-end;
}
#ui .set-reset-btn.is-armed { background: var(--signal); color: var(--signal-ink); border-color: var(--signal); }

/* wide panels: label and control on one row (segments, buttons); sliders keep the full-width track */
@container (min-width: 540px) {
  #ui .set-panel-body > .field:not(.field--slider):not(.field--report) {
    display: grid;
    grid-template-columns: minmax(150px, 32%) 1fr;
    column-gap: 18px;
    align-items: center;
  }
  #ui .set-panel-body > .field:not(.field--slider):not(.field--report) > .seg,
  #ui .set-panel-body > .field:not(.field--slider):not(.field--report) > .report-row { margin-top: 0; }
  #ui .set-panel-body > .field:not(.field--slider):not(.field--report) > .set-note { grid-column: 2; }
  #ui .set-guide .legend { grid-template-columns: 1fr 1fr 1fr; }
}

/* desktop: a wider settings column on big screens so the rows above kick in */
@media (min-width: 1400px) and (min-height: 721px) {
  #ui .settings.set-tabbed { flex-basis: 600px; }
}
@media (max-height: 720px) and (min-width: 961px) {
  #ui .settings.set-tabbed { height: calc(100vh - 32px); }
  #ui .set-panel { padding-top: 8px; }
}
/* narrow desktop window (<= 960 wide): the menu is one column that scrolls as a page */
@media (max-width: 960px) {
  #ui .settings.set-tabbed { height: auto; max-height: none; overflow: visible; }
  #ui .set-tabs { position: sticky; top: 0; z-index: 2; background: var(--canvas); }
  #ui .set-panel { overflow: visible; }
}

/* touch: the menu columns fill the visual viewport */
html.is-touch #ui .set-tab { min-height: 48px; }
html.is-touch #ui .set-panel { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
@media (max-height: 500px), (max-width: 900px) {
  html.is-touch #ui .settings.set-tabbed { height: calc(100% - 16px); max-height: none; overflow: hidden; padding: 0; }
  html.is-touch #ui .set-tabs { position: static; }
  html.is-touch #ui .set-panel { overflow-y: auto; padding: 10px 16px max(12px, env(safe-area-inset-bottom, 0px)); }
}
/* short landscape phones (844x390, 740x360, 915x412): the left rail */
@media (max-height: 500px) {
  html.is-touch #ui .settings.set-tabbed { flex-direction: row; }
  html.is-touch #ui .set-tabs {
    flex-direction: column;
    width: 76px;
    padding: 8px 0 8px 6px;
    gap: 2px;
    border-bottom: 0;
    border-right: 1px solid var(--hairline);
    overflow-y: auto;
    scrollbar-width: none;
  }
  html.is-touch #ui .set-tab { flex: none; min-height: 52px; border-radius: 3px 0 0 3px; font-size: 12px; letter-spacing: .05em; }
  html.is-touch #ui .set-tab[aria-selected='true']::after { left: auto; right: -1px; top: 8px; bottom: 8px; width: 3px; height: auto; }
}
/* the Stage 22a room panel inside the Room tab: no tag chrome of its own */
#ui .set-panel-body > .mp-room { background: transparent; box-shadow: none; border-radius: 0; padding: 0; margin: 0; border: 0; width: auto; }
#ui .set-panel-body > .mp-room::after { display: none; }
