#rail {
  position: sticky;
  top: 0;
  align-self: start;
  width: 232px;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  background: var(--rail);
  border-inline-end: 1px solid var(--line);
}

.ed-rail-inner {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 34px 18px 20px;
}

.ed-rail-brand,
.ed-mobile-brand {
  display: inline-flex;
  align-items: center;
  width: max-content;
  gap: 10px;
  color: var(--text-strong);
  text-decoration: none;
}

.ed-rail-brand {
  margin: 0 0 44px 12px;
}

.ed-brand-emblem {
  position: relative;
  display: inline-block;
  flex: 0 0 23px;
  width: 23px;
  height: 18px;
  color: var(--wine-text);
}

.ed-brand-emblem::before,
.ed-brand-emblem::after {
  position: absolute;
  top: 1px;
  width: 12px;
  height: 16px;
  border: 1px solid currentColor;
  border-radius: 50%;
  content: "";
  transform: rotate(-26deg);
}

.ed-brand-emblem::before { left: 2px; }
.ed-brand-emblem::after { right: 2px; }

.ed-brand-wordmark {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: .95;
  letter-spacing: -.025em;
  white-space: nowrap;
}

.ed-rail-links {
  display: grid;
  align-content: start;
  gap: 5px;
}

.ed-nav-link,
.ed-rail-settings {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-muted);
  background: transparent;
  font: 500 14px/1 var(--font-body);
  text-decoration: none;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.ed-nav-glyph {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  line-height: 0;
}

.ed-nav-link:hover,
.ed-rail-settings:hover,
.ed-rail-logout:hover,
.ed-mobile-tool:hover {
  color: var(--text-strong);
  background-color: var(--surface-hi);
}

.ed-nav-link[aria-current="page"] {
  border-color: color-mix(in srgb, var(--wine) 32%, var(--line));
  color: var(--text-strong);
  background-color: var(--wine-soft);
}

.ed-nav-link[aria-current="page"] > .ed-nav-glyph {
  color: var(--wine-text);
}

.ed-nav-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  min-height: 22px;
  margin-inline-start: auto;
  padding: 1px 5px;
  border-radius: 100px;
  color: var(--wine-text);
  background-color: var(--wine-soft);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.ed-nav-link[aria-current="page"] .ed-nav-count {
  color: var(--text-strong);
  background-color: var(--wine);
}

.ed-rail-footer {
  display: grid;
  gap: 15px;
  margin-top: auto;
  padding-top: 35px;
}

.ed-rail-settings {
  width: 100%;
  cursor: pointer;
  text-align: start;
}

.ed-rail-profile {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 15px 10px 0;
  border-top: 1px solid var(--line);
}

.ed-profile-avatar {
  display: grid;
  flex: 0 0 35px;
  width: 35px;
  height: 35px;
  place-items: center;
  border: 1px solid var(--wine);
  border-radius: 50%;
  color: var(--wine-text);
  background-color: var(--wine-soft);
  font: 400 23px/1 var(--font-display);
}

.ed-profile-name {
  overflow: hidden;
  color: var(--text-strong);
  font: 500 14px/1.3 var(--font-body);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ed-rail-logout {
  display: inline-grid;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  margin-inline-start: auto;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
}

#topbar {
  position: relative;
  z-index: 3;
  border-bottom: 1px solid var(--line);
}

.ed-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  min-height: 71px;
  padding: 0 var(--shell-gutter, clamp(24px, 4vw, 44px));
}

.ed-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ed-room-switch {
  position: relative;
  min-width: 0;
}

.ed-room-toggle,
.ed-room-static,
.ed-mobile-tool {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  max-width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  font: 500 13px/1.1 var(--font-body);
  white-space: nowrap;
}

.ed-room-static {
  padding-inline-end: 12px;
}

.ed-room-toggle,
.ed-mobile-tool {
  cursor: pointer;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.ed-room-toggle:hover,
.ed-room-toggle[aria-expanded="true"] {
  border-color: var(--line-strong);
  color: var(--text-strong);
  background-color: var(--surface-hi);
}

.ed-room-toggle > .ed-nav-glyph:first-child,
.ed-room-static > .ed-nav-glyph:first-child {
  color: var(--wine-text);
}

.ed-room-toggle > .ed-nav-glyph:last-child {
  color: var(--text-muted);
  transition: transform 140ms ease;
}

.ed-room-toggle[aria-expanded="true"] > .ed-nav-glyph:last-child {
  transform: rotate(180deg);
}

.ed-room-name {
  max-width: 24ch;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ed-room-options {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 4;
  box-sizing: border-box;
  width: max-content;
  min-width: 195px;
  max-width: min(285px, calc(100vw - 32px));
  max-height: min(45vh, 320px);
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface-hi);
  box-shadow: var(--shadow);
  list-style: none;
}

.ed-room-options[hidden] { display: none; }

.ed-room-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 8px 9px;
  border: 0;
  border-radius: 6px;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font: 500 13px/1.35 var(--font-body);
  text-align: start;
}

.ed-room-option:hover,
.ed-room-option[aria-current="true"] {
  color: var(--text-strong);
  background-color: var(--wine-soft);
}

.ed-room-option-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.ed-room-option > .ed-nav-glyph { color: var(--wine-text); }

.ed-room-action-start {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.ed-room-action { justify-content: flex-start; }

.ed-rail-brand:focus-visible,
.ed-mobile-brand:focus-visible,
.ed-nav-link:focus-visible,
.ed-rail-settings:focus-visible,
.ed-rail-logout:focus-visible,
.ed-mobile-tool:focus-visible,
.ed-room-toggle:focus-visible,
.ed-room-option:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

#mobile-nav,
.ed-mobile-brand,
.ed-mobile-tool { display: none; }

@media (max-width: 760px) {
  #rail { display: none; }

  .ed-mobile-brand,
  .ed-mobile-tool { display: inline-flex; }

  .ed-topbar-inner {
    justify-content: space-between;
    gap: 12px;
    min-height: 64px;
    padding-inline: 16px;
  }

  .ed-mobile-brand {
    flex: 0 0 auto;
    gap: 6px;
  }

  .ed-mobile-brand .ed-brand-wordmark {
    font-size: 29px;
  }

  .ed-topbar-actions {
    position: relative;
    gap: 4px;
  }

  .ed-room-switch { position: static; }

  .ed-room-toggle,
  .ed-room-static,
  .ed-mobile-tool { min-height: 44px; }

  .ed-room-toggle,
  .ed-room-static {
    gap: 5px;
    padding-inline: 8px;
  }

  .ed-mobile-tool {
    flex: 0 0 44px;
    justify-content: center;
    width: 44px;
    padding: 0;
    border-color: transparent;
    color: var(--text-muted);
    background: transparent;
  }

  #mobile-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
    display: block;
    padding: 3px 8px calc(3px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--rail) 94%, transparent);
    backdrop-filter: blur(14px);
  }

  .ed-mobile-links {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
  }

  .ed-mobile-links .ed-nav-link {
    position: relative;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 6px;
    min-height: 56px;
    padding: 4px 2px;
    border: 0;
    font-size: 11px;
  }

  .ed-mobile-links .ed-nav-link[aria-current="page"] {
    color: var(--wine-text);
    background-color: var(--wine-soft);
  }

  .ed-mobile-links .ed-nav-count {
    position: absolute;
    top: 2px;
    left: calc(50% + 5px);
    min-width: 17px;
    min-height: 17px;
    margin: 0;
    padding: 0 4px;
    border: 1px solid var(--rail);
    color: var(--text-strong);
    background-color: var(--wine);
    font-size: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ed-nav-link,
  .ed-room-toggle,
  .ed-room-toggle > .ed-nav-glyph,
  .ed-rail-settings,
  .ed-mobile-tool { transition: none; }
}
