/* The shell stays mounted so the shared rail indicator can glide between routes. */
:root {
  --nav-ease: cubic-bezier(.22, 1, .36, 1);
  --rail-item: 44px;
  --rail-gap: 6px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr);
  align-items: center;
  gap: 24px;
  height: 104px;
  max-width: none;
  margin: 0;
  padding: 0 32px 0 24px;
}

.topbar .brand { width: fit-content; margin: 0; font-size: 28px; }
.topbar .workspace-label { justify-self: end; white-space: nowrap; }
.topnav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: auto;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 32px;
  background: var(--surface);
}
.topnav button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 18px;
  border-radius: 24px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
  transition: color .2s ease, background-color .2s ease, transform .2s var(--nav-ease);
}
.topnav button:hover { color: var(--text); background: var(--surface2); filter: none; }
.topnav button.selected { color: var(--surface); background: var(--text); }
.topnav button:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }

.rail {
  position: fixed;
  left: 22px;
  right: auto;
  top: 142px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 56px;
  height: auto;
  z-index: 10;
}
.rail .rail-group {
  --active-index: 0;
  position: relative;
  isolation: isolate;
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  gap: var(--rail-gap);
  width: 56px;
  padding: 6px;
  border: 0;
  border-radius: 28px;
  background: var(--surface);
}
.rail-indicator {
  position: absolute;
  top: 6px;
  left: 6px;
  width: var(--rail-item);
  height: var(--rail-item);
  border-radius: 50%;
  background: var(--text);
  pointer-events: none;
  transform: translateY(calc(var(--active-index) * (var(--rail-item) + var(--rail-gap))));
  transition: transform .46s var(--nav-ease), background-color .2s ease;
  z-index: -1;
}
.rail .nav-item,
.rail .nav-item:hover,
.rail .nav-item:focus-visible,
.rail .nav-item.selected,
.rail .nav-item.selected:hover,
.rail .nav-item.selected:focus-visible,
.rail .nav-item.future,
.rail .nav-item.future:hover,
.rail .nav-item.future:focus-visible {
  display: flex;
  flex: 0 0 var(--rail-item);
  align-items: center;
  justify-content: center;
  width: var(--rail-item);
  height: var(--rail-item);
  min-width: var(--rail-item);
  padding: 0;
  gap: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  filter: none;
  transition: color .2s ease, background-color .2s ease, transform .2s var(--nav-ease);
}
.rail .nav-item { color: var(--muted); }
.rail .nav-item:hover { color: var(--text); background: var(--surface2); }
.rail .nav-item.selected,
.rail .nav-item.selected:hover,
.rail .nav-item.selected:focus-visible { color: var(--surface); background: transparent; }
.rail .nav-item svg { width: 20px; height: 20px; }
.rail .nav-item > span { display: none; }
.rail .nav-item:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.rail .nav-item.future { opacity: .75; }
.rail .nav-item.future:hover, .rail .nav-item.future:focus-visible { opacity: 1; }
.rail .rail-bottom {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-self: center;
  gap: 6px;
  width: 56px;
  padding: 6px;
  margin-top: auto;
  border: 0;
  border-radius: 28px;
  background: var(--surface);
  box-shadow: none;
}
.rail .rail-bottom .icon-btn { width: 44px; height: 44px; }
.rail .rail-bottom svg { width: 19px; height: 19px; }

/* Use the available workspace on every monitor, with the same right edge as the header. */
main { min-width: 0; max-width: none; margin-left: 100px; margin-right: 32px; padding-bottom: 16px; }
.page-heading { min-width: 0; gap: 16px; }
.page-heading > div { min-width: 0; }
.page-heading > .button { flex-shrink: 0; }
footer { flex-wrap: wrap; }
.table-scroll { position: relative; }

/* Press feedback changes only the control, never the surrounding layout. */
.button, .icon-btn, .segment button, .text-button, .catalog-option, .custom-service,
.full-text-button, .backup-option, .add-card {
  transition: transform .2s var(--nav-ease), background-color .2s ease,
    color .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.button:active:not(:disabled), .icon-btn:active:not(:disabled),
.segment button:active:not(:disabled), .topnav button:active:not(:disabled),
.rail .nav-item:active:not(:disabled), .catalog-option:active:not(:disabled),
.backup-option:active:not(:disabled), .add-card:active:not(:disabled) {
  transform: scale(.96);
  transition-duration: .08s;
}
.text-button:active:not(:disabled), .custom-service:active:not(:disabled),
.full-text-button:active:not(:disabled) { transform: translateY(1px); }

@media (max-width: 1100px) {
  .topbar { grid-template-columns: minmax(135px, 1fr) auto minmax(32px, 1fr); gap: 16px; padding-right: 24px; }
  .topnav button { padding: 0 13px; font-size: 11px; }
  .topbar .workspace-label { font-size: 0; gap: 0; }
  main { margin-right: 24px; }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 42px 52px;
    gap: 16px 12px;
    height: 142px;
    padding: 16px 18px;
  }
  .topbar .brand { font-size: 26px; }
  .topbar .workspace-label { grid-column: 2; grid-row: 1; }
  .topnav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    border-radius: 28px;
    scroll-padding-inline: 6px;
  }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav button { flex: 1 0 auto; min-height: 40px; padding: 0 15px; font-size: 11px; }
  .rail { top: 166px; left: 12px; bottom: 16px; gap: 12px; }
  main { margin-left: 84px; margin-right: 18px; }
  .page-heading { flex-wrap: wrap; align-items: center; padding: 20px 0 24px; }
  .page-heading h1 { font-size: 27px; }
  .page-heading > .button { min-height: 38px; }
}

@media (max-width: 430px) {
  .topbar { padding-inline: 12px; }
  .rail { left: 8px; }
  main { margin-left: 76px; margin-right: 12px; }
  .page-heading h1 { font-size: 25px; }
  footer { gap: 12px; line-height: 1.5; }
}

@media (max-height: 660px) {
  .rail { overflow-y: auto; overflow-x: hidden; scrollbar-width: none; padding-bottom: 4px; }
  .rail::-webkit-scrollbar { display: none; }
  .rail .rail-bottom { margin-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .rail-indicator, .rail .nav-item, .topnav button, .button, .icon-btn,
  .segment button, .text-button, .catalog-option, .custom-service,
  .full-text-button, .backup-option, .add-card { transition: none; }
  .button:active:not(:disabled), .icon-btn:active:not(:disabled),
  .segment button:active:not(:disabled), .topnav button:active:not(:disabled),
  .rail .nav-item:active:not(:disabled), .catalog-option:active:not(:disabled),
  .backup-option:active:not(:disabled), .add-card:active:not(:disabled),
  .text-button:active:not(:disabled), .custom-service:active:not(:disabled),
  .full-text-button:active:not(:disabled) { transform: none; }
}
