/* Icon rail — wider for readable labels. --rail-width in design-tokens.css */

.app-layout {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.global-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--shell-sidebar-bg, #ffffff);
  border-right: 1px solid var(--shell-sidebar-border, var(--learn-border));
  box-shadow: none;
  padding: 1rem 0.5rem 1.15rem;
  z-index: 40;
}

.global-sidebar::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--glow, #22d3ee), var(--accent, #0891b2), transparent 75%);
}

.icon-rail-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  margin-bottom: 1rem;
  border-radius: 14px;
  background: linear-gradient(145deg, #22d3ee, #0891b2);
  color: #0f172a;
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 800;
  text-decoration: none;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.icon-rail-brand:hover {
  text-decoration: none;
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.45);
}

.icon-rail-brand.active {
  box-shadow: 0 0 0 2px var(--accent), 0 0 16px rgba(8, 145, 178, 0.35);
}

#global-sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 0.2rem 0;
}

.icon-rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  width: 100%;
  max-width: 6.5rem;
  padding: 0.65rem 0.35rem;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.icon-rail-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.icon-rail-item.active {
  color: var(--accent-hover);
  background: var(--accent-soft);
  border-color: rgba(8, 145, 178, 0.25);
  box-shadow: inset 3px 0 0 var(--accent);
}

.icon-rail-item.nav-locked {
  color: #fcd34d;
}

.icon-rail-icon {
  font-size: 1.55rem;
  line-height: 1;
}

.icon-rail-label {
  max-width: 100%;
  white-space: normal;
  line-height: 1.15;
  word-break: break-word;
}

.sidebar-progress-wrap {
  flex-shrink: 0;
  width: 100%;
  padding-top: 0.75rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--shell-sidebar-border, var(--learn-border));
  position: relative;
  z-index: 1;
  display: none;
}

body.mode-learn-lms.sidebar-has-progress .sidebar-progress-wrap {
  display: block;
}

.sidebar-progress-wrap .progress-bar {
  height: 6px;
  width: 100%;
  background: var(--surface2);
  border-radius: 999px;
  margin-bottom: 0.35rem;
}

.sidebar-progress-wrap .progress-fill {
  background: linear-gradient(90deg, var(--accent-hover), var(--accent));
}

.sidebar-progress-label {
  margin: 0;
  font-family: var(--font);
  font-size: 0.84rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.35;
}

.app-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-main .portfolio-topbar {
  margin: 0.75rem 1rem 0;
}

.app-main .main {
  flex: 1;
}

body.mode-intro .app-main .main {
  max-width: none;
  margin: 0;
  padding: 0;
}

body.mode-learn-lms .app-main .main {
  max-width: none;
  margin: 0;
  padding: 0.35rem 0.5rem 1.25rem;
}

body.mode-intro .portfolio-topbar {
  display: none;
}

@media (max-width: 768px) {
  :root {
    --rail-width: 100%;
  }

  .app-layout {
    grid-template-columns: 1fr;
  }

  .global-sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0.65rem;
    gap: 0.35rem;
  }

  #global-sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    flex: none;
  }

  .icon-rail-item {
    max-width: 5.5rem;
    padding: 0.5rem 0.4rem;
  }

  .icon-rail-label {
    font-size: 0.8125rem;
  }

  .sidebar-progress-wrap {
    display: none;
  }

  body.mode-intro .app-main .portfolio-topbar {
    left: 0;
  }
}
