/* ===========================================================================
   App Shell — shared global rail + contextual top strip.
   Net-new, isolated surface. ALL selectors use the `app-` prefix exclusively
   (no collision with the legacy nav, the qw- workspace, or pw- page styles).
   Brand tokens are copied verbatim from question_workspace.css :root so every
   shell-backed page shares one visual language.
   This file owns: the shared root tokens, the dark global rail, and the strip.
   Page modules (e.g. progress_workspace.css) layer on top and reuse the tokens.
   =========================================================================== */

.app-shell {
  /* brand tokens (copied from question_workspace.css .qw-app-root) */
  --brand-primary: #4f46e5;
  --brand-secondary: #7c3aed;
  --brand-light: #eef2ff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e3e6ee;
  --bg: #f4f6fb;
  --card: #ffffff;
  --rail: #1b1733;
  --rail-ink: #b9b4d6;
  --ok: #16a34a;
  --ok-bg: #f0fdf4;
  --warn: #ea580c;
  --warn-bg: #fff7ed;
  --bad: #dc2626;
  --bad-bg: #fef2f2;
  --info: #0369a1;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .05), 0 12px 30px rgba(15, 23, 42, .07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* layout tokens */
  --app-rail-w: 66px;
  --app-strip-h: 56px;

  /* z-index layering */
  --app-z-rail: 30;
  --app-z-strip: 20;
  --app-z-rail-overlay: 40;
}

/* The shell fills the viewport and owns its own scroll container so the page
   body never double-scrolls. Applied to the shell root, not the body, so it
   stays isolated from any other page chrome. */
.app-shell {
  display: flex;
  /* Fill the viewport MINUS the shared top navbar (60px) — parity with the question workspace
     (.qw-app-root uses the same). The rail/content scroll, not the body. */
  height: calc(100vh - 60px);
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

.app-shell *,
.app-shell *::before,
.app-shell *::after { box-sizing: border-box; }

.app-shell :where(button) {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}
.app-shell a { text-decoration: none; }

/* ---------- GLOBAL LEFT RAIL ---------- */
.app-rail {
  width: var(--app-rail-w);
  flex: none;
  background: var(--rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 0;
  z-index: var(--app-z-rail);
}
.app-rail__logo {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  margin-bottom: 12px;
  flex: none;
}
.app-rail-item {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: var(--rail-ink);
  font-size: 19px;
  position: relative;
  text-decoration: none;
}
.app-rail-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.app-rail-item.app-active { background: rgba(124, 58, 237, .28); color: #fff; }
.app-rail-item.app-active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 3px;
  background: var(--brand-secondary);
}
/* hover tooltip */
.app-rail-item .app-tip {
  position: absolute;
  left: 56px;
  white-space: nowrap;
  background: #0f172a;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 7px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
  transform: translateX(-4px);
  z-index: 1;
}
.app-rail-item:hover .app-tip { opacity: 1; transform: none; }

.app-rail__bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.app-rail__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22d3ee, #4f46e5);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
}

/* ---------- STAGE (everything right of the rail) ---------- */
.app-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ---------- CONTEXTUAL TOP STRIP ---------- */
.app-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--app-strip-h);
  padding: 0 22px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  flex: none;
  z-index: var(--app-z-strip);
}
.app-crumbs {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 7px;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.app-crumbs a { color: var(--muted); }
.app-crumbs a:hover { color: var(--brand-primary); }
.app-crumbs .app-crumb-sep { color: var(--muted); opacity: .7; }
.app-crumbs .app-here { color: var(--ink); font-weight: 600; }

.app-search {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 11px;
  color: var(--muted);
  font-size: 13px;
  width: 200px;
  flex: none;
}
.app-search .app-search__kbd { margin-left: auto; opacity: .6; }

/* non-interactive status chip (e.g. "Overall 64%") — sits right of the crumbs */
.app-status { display: inline-flex; align-items: baseline; gap: 6px; flex: none; white-space: nowrap; }
.app-status__label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.app-status__value { font-size: 15px; font-weight: 800; color: var(--brand-primary); }

.app-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.app-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 11px;
  font-weight: 600;
  font-size: 13px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
}
.app-action-btn:hover { background: var(--brand-light); color: var(--brand-primary); }
.app-action-btn--primary {
  background: var(--brand-primary);
  color: #fff;
  border-color: transparent;
}
.app-action-btn--primary:hover { background: #4338ca; color: #fff; }

/* ---------- CONTENT REGION (page renders into this) ---------- */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 26px 60px;
  min-width: 0;
}
.app-content__wrap { max-width: 1080px; margin: 0 auto; }

/* ---------- RESPONSIVE: rail collapses to an overlay below 900px ---------- */
@media (max-width: 900px) {
  .app-search { display: none; }
  .app-content { padding: 18px 16px 48px; }
}
@media (prefers-reduced-motion: reduce) {
  .app-rail-item .app-tip { transition: none; }
}
