:root {
  --rail-width: 240px;
  --rail-bg: #073667;
  --rail-text: #dfecfb;
  --rail-pad: 16px;
  --shell-bar: 76px;
  --shell-gutter: clamp(24px, 3.25vw, 60px);
  --shell-max: 1856px;
}

.workspace-shell {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  grid-template-rows: var(--shell-bar) 1fr;
  grid-template-areas: "brand toolbar" "rail content";
  min-height: 100vh;
  min-height: 100dvh;
}

.shell-inner {
  box-sizing: border-box;
  width: 100%;
  max-width: var(--shell-max);
  min-width: 0;
  margin-inline: auto;
  padding-inline: var(--shell-gutter);
}

.rail-brand, .workspace-rail, .public-header { background: var(--rail-bg); }
.rail-brand {
  grid-area: brand;
  position: sticky;
  z-index: 5;
  top: 0;
  display: flex;
  align-items: center;
  padding-inline: calc(var(--rail-pad) + 12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 0;
  margin: 0;
  line-height: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.brand .brand-logo {
  display: block;
  width: 100px;
  max-width: 100%;
  height: auto;
  filter: brightness(0) invert(1);
}

.workspace-shell .workspace-rail {
  grid-area: rail;
  position: sticky;
  top: var(--shell-bar);
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  min-width: 0;
  height: calc(100vh - var(--shell-bar));
  height: calc(100dvh - var(--shell-bar));
  padding: 20px var(--rail-pad) 16px;
  overflow-y: auto;
  color: white;
}
.rail-nav { display: grid; gap: 5px; }
.rail-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 43px;
  margin: 0;
  padding: 9px 12px;
  color: var(--rail-text);
  text-decoration: none;
  font-size: .9rem;
  line-height: 1.3;
  font-weight: 500;
  border-radius: 7px;
}
.rail-nav a > svg { flex: none; color: #adc9ea; }
.rail-nav a:hover { background: #12467a; color: white; }
.rail-nav a[aria-current="page"] { background: #20548a; color: white; font-weight: 650; }
.rail-nav a[aria-current="page"] > svg { color: white; }

.rail-account {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: auto;
  padding: 16px 0 0;
  border-top: 1px solid #39618a;
}
.rail-account .account-link {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  gap: 9px;
  padding: 3px;
  border-radius: 6px;
  color: white;
  text-decoration: none;
}
.rail-account .account-link:hover { background: #12467a; }
.rail-account-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 31px;
  height: 34px;
  color: #cee1f4;
}
.rail-account-text { display: grid; gap: 2px; min-width: 0; }
.rail-account-text strong, .rail-account-text small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 1.35;
}
.rail-account-text strong { font-size: .83rem; }
.rail-account-text small { color: #bdd2e9; font-size: .74rem; }
.rail-account form { margin: 0; flex-shrink: 0; }
.rail-account .rail-logout, .rail-toggle, .notification-link {
  display: inline-grid;
  place-items: center;
  width: 38px;
  min-height: 38px;
  border: 0;
  padding: 0;
  margin: 0;
  border-radius: 6px;
  background: transparent;
  text-decoration: none;
  cursor: pointer;
}
.rail-account .rail-logout { color: #ccdff5; }
.rail-account .rail-logout:hover { color: white; background: #12467a; }

.workspace-shell .top {
  grid-area: toolbar;
  position: sticky;
  top: 0;
  z-index: 4;
  display: block;
  height: var(--shell-bar);
  min-width: 0;
  padding: 0;
  background: white;
  border-bottom: 1px solid var(--line);
}
.top-inner, .public-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  height: 100%;
}
.workspace-location, .top-actions { display: flex; align-items: center; min-width: 0; }
.workspace-location {
  gap: 9px;
  color: var(--muted);
  font-size: .825rem;
  line-height: 1.35;
}
.workspace-location span, .workspace-location strong { min-width: 0; }
.workspace-location > span[aria-hidden] { display: inline-flex; color: #7f91a3; }
.workspace-location strong {
  color: var(--ink);
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-actions { flex: none; gap: 12px; }
.notification-link { color: #405a76; }
.notification-link:hover { background: #eaf1f8; color: var(--brand); }
.rail-toggle { display: none; }

.workspace-shell .content {
  grid-area: content;
  align-self: start;
  padding-top: clamp(25px, 3vw, 44px);
  padding-bottom: 72px;
}
.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 0 0 25px;
}
.page-heading > h1 {
  min-width: 0;
  max-width: 100%;
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.7rem, 2.35vw, 2.45rem);
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
}
:lang(zh) .page-heading > h1 { letter-spacing: -.02em; }

.public-header { height: var(--shell-bar); color: white; border: 0; padding: 0; }
.public-inner { max-width: var(--shell-max); }
.public-header .lang-control form {
  border-color: #51779b;
  background: #104679;
}
.public-header .lang-control button { color: #dce9f7; }
.public-header .lang-control button:hover { background: #20578b; color: white; }
.public-header .lang-control button.selected:disabled { background: white; color: #073667; }

/* Navigation remains expanded and usable when scripting is unavailable. */
@media (max-width: 840px) {
  :root { --shell-gutter: clamp(16px, 4vw, 28px); --shell-bar: 66px; }
  .workspace-shell {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: var(--shell-bar) auto minmax(0, 1fr);
    grid-template-areas: "brand toolbar" "rail rail" "content content";
  }
  .rail-brand { align-self: stretch; padding-inline: var(--shell-gutter) 0; }
  .brand .brand-logo { width: 78px; }
  .workspace-shell .top { background: var(--rail-bg); border: 0; }
  .workspace-shell .top-inner { justify-content: flex-end; padding-left: 6px; }
  .workspace-location { display: none; }
  .top-actions { gap: 6px; }
  .top .notification-link, .top .rail-toggle { color: white; }
  .top .notification-link:hover, .top .rail-toggle:hover, .top .rail-toggle[aria-expanded="true"] { background: #20548a; }
  .nav-ready .rail-toggle { display: inline-grid; }
  .workspace-shell .workspace-rail {
    position: static;
    display: flex;
    gap: 10px;
    height: auto;
    min-height: 0;
    max-height: calc(100dvh - var(--shell-bar));
    padding: 5px var(--shell-gutter) 12px;
    border-bottom: 1px solid #285784;
  }
  .workspace-shell.nav-ready .workspace-rail { display: none; }
  .workspace-shell.nav-ready .workspace-rail.rail-open {
    display: flex;
    position: fixed;
    z-index: 3;
    inset: var(--shell-bar) 0 auto;
    max-height: calc(100vh - var(--shell-bar));
    max-height: calc(100dvh - var(--shell-bar));
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 0 8px 18px #152e4926;
  }
  .rail-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; }
  .rail-nav a { font-size: .85rem; min-height: 42px; padding: 8px 10px; gap: 8px; }
  .rail-account { margin: 0; padding-top: 8px; }
  .workspace-shell .content { padding-top: 23px; padding-bottom: 42px; }
  .page-heading { margin-bottom: 20px; gap: 12px; }
  .workspace-shell .top { overflow: visible; }
  .workspace-shell .top .lang-control form { border-color: #51779b; background: #104679; }
  .workspace-shell .top .lang-control button { color: #dce9f7; }
  .workspace-shell .top .lang-control button:hover { background: #20578b; color: white; }
  .workspace-shell .top .lang-control button.selected:disabled { color: #073667; background: white; }
}

@media (max-width: 350px) {
  .top-actions { gap: 2px; }
  .top .rail-toggle, .top .notification-link { width: 32px; }
  .rail-nav { grid-template-columns: 1fr; }
}

@media print {
  .workspace-shell { display: block; }
  .workspace-shell .rail-brand, .workspace-shell .workspace-rail, .workspace-shell .top { display: none; }
  .workspace-shell .content { padding: 0; }
}
