/* 石阶·空间一体化工作台样式
   在 base.css 设计令牌上构建：紧凑空间导轨 + 平滑视口切换 + 节点学习工作舱 + 三栏联动沙箱 + 打卡日历 */

:root {
  --topbar-h: 56px;
  --rail-bg: rgba(247, 246, 240, 0.94);
  --shadow-float: 0 22px 50px -24px rgba(9, 28, 19, 0.32);
  --shadow-card: 0 6px 20px -14px rgba(9, 28, 19, 0.25);
}

body.ws-body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------------- 顶部空间导轨 ---------------- */

.ws-topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  height: var(--topbar-h);
  background: var(--rail-bg);
  backdrop-filter: saturate(1.5) blur(14px);
  border-bottom: 1px solid var(--line);
}

.ws-topbar-inner {
  max-width: 1480px;
  height: 100%;
  margin: 0 auto;
  padding: 0 clamp(14px, 2.5vw, 28px);
  display: flex;
  align-items: center;
  gap: 12px;
}

.ws-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 15.5px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  cursor: pointer;
}

.ws-brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--ink-green);
  color: var(--lime);
}

.ws-brand-mark svg {
  width: 18px;
  height: 18px;
}

.ws-nav {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: 9px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.ws-nav::-webkit-scrollbar { display: none; }

.ws-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.ws-nav-btn:hover { color: var(--ink); background: rgba(255, 255, 255, 0.55); }
.ws-nav-btn.active {
  background: var(--ink-green);
  color: var(--cream);
  box-shadow: 0 3px 10px -6px rgba(9, 28, 19, 0.7);
}
.ws-nav-btn .idx {
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.65;
}
.ws-nav-btn.active .idx { color: var(--lime); opacity: 1; }
.ws-nav-btn.locked { opacity: 0.52; }

.ws-nav-sep {
  width: 1px;
  height: 18px;
  background: var(--line-strong);
  margin: 0 3px;
  flex: none;
}

.ws-top-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.poll-alert-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--lime);
  color: var(--ink-green);
  font-size: 12px;
  font-weight: 800;
  animation: pulseGlow 2.2s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(205, 255, 94, 0.7); }
  50% { box-shadow: 0 0 0 6px rgba(205, 255, 94, 0); }
}

/* ---------------- 主舞台与空间过渡 ---------------- */

.ws-main {
  flex: 1;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
  padding: 16px clamp(14px, 2.5vw, 28px) 36px;
}

.ws-pane {
  animation: wsFadeIn 220ms var(--ease);
}
.ws-pane[hidden] { display: none !important; }

@keyframes wsFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 紧凑空间条：替代原本占 220px 的巨型绿色横幅 */
.ws-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-radius: var(--r-lg);
  background: var(--ink-green);
  color: var(--cream);
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}
.ws-strip::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(700px 200px at 90% -40%, rgba(205, 255, 94, 0.16), transparent 65%);
  pointer-events: none;
}
.ws-strip > * { position: relative; z-index: 1; }
.ws-strip h2 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.ws-strip .sub {
  font-size: 12.5px;
  color: rgba(244, 240, 226, 0.72);
  margin-top: 2px;
}
.ws-strip-kpis {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.ws-kpi {
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.10);
  text-align: right;
}
.ws-kpi b {
  display: block;
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.1;
  color: var(--lime);
}
.ws-kpi span {
  font-size: 10.5px;
  color: rgba(244, 240, 226, 0.68);
}

/* ---------------- 知识图谱舞台与滑出学习工作舱 ---------------- */

.map-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}
.map-stage.with-studio {
  grid-template-columns: minmax(0, 1fr) 470px;
}

.map-canvas-wrap .graph-shell {
  aspect-ratio: auto;
  height: clamp(480px, calc(100vh - 220px), 760px);
  max-height: none;
}

.studio-panel {
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--card);
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  height: clamp(480px, calc(100vh - 220px), 760px);
  overflow: hidden;
  animation: studioSlide 220ms var(--ease);
}
.studio-panel[hidden] { display: none !important; }

@keyframes studioSlide {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: translateX(0); }
}

.studio-head {
  padding: 14px 16px 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.studio-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
}
.studio-tabs button {
  flex: 1;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.studio-tabs button.active {
  background: var(--card);
  color: var(--ink-green);
  box-shadow: 0 2px 6px -4px rgba(9, 28, 19, 0.35);
}

.studio-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.studio-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* 讲义 Markdown 排版 */
.lesson-prose h3 {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink-green);
  margin: 14px 0 6px;
}
.lesson-prose h3:first-child { margin-top: 0; }
.lesson-prose p, .lesson-prose li {
  font-size: 13.5px;
  line-height: 1.72;
  color: var(--ink-2);
}
.lesson-prose ul, .lesson-prose ol {
  margin: 6px 0 10px 18px;
  list-style: disc;
}
.lesson-prose ol { list-style: decimal; }
.lesson-prose code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--raised);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-deep);
}
.lesson-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 12.5px;
}
.lesson-prose th, .lesson-prose td {
  padding: 6px 8px;
  border: 1px solid var(--line);
  text-align: left;
}
.lesson-prose th { background: var(--bg-2); font-weight: 700; }

/* 微课播放器 */
.video-stage {
  border-radius: var(--r-md);
  background: var(--ink-green);
  color: var(--cream);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.video-chapter-card {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.video-chapter-card + .video-chapter-card { margin-top: 8px; }
.video-chapter-card:hover { border-color: var(--accent); background: var(--accent-wash); }
.video-chapter-card.active { border-color: var(--ink-green); background: var(--accent-soft); }

/* ---------------- 课中三栏联动沙箱 ---------------- */

.lab-grid {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 356px;
  gap: 14px;
  align-items: start;
}

.lab-rail {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--card);
  padding: 12px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

.lab-center .term-mount {
  height: clamp(360px, calc(100vh - 300px), 520px);
}

.lab-side {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 140px);
}

.lab-side-body {
  padding: 14px;
  overflow-y: auto;
  flex: 1;
}

/* 沙箱嵌入式 AI 4 级递进阶梯 */
.hint-stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 10px;
}
.hint-step-btn {
  padding: 6px 4px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  text-align: center;
  transition: all var(--fast) var(--ease);
}
.hint-step-btn.active {
  background: var(--ink-green);
  color: var(--lime);
  border-color: var(--ink-green);
}
.hint-step-btn.done {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-color: var(--accent);
}

.sb-chat-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 180px;
  max-height: 300px;
  overflow-y: auto;
  padding: 8px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.sb-msg {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.sb-msg.me { background: var(--ink-green); color: var(--cream); align-self: flex-end; max-width: 88%; }
.sb-msg.ai { background: var(--card); border: 1px solid var(--line); color: var(--ink); }

.err-hint-card {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(169, 59, 50, 0.28);
  background: var(--st-fail-bg);
  font-size: 12.5px;
  line-height: 1.55;
}
.err-hint-card + .err-hint-card { margin-top: 8px; }

/* ---------------- 课后艾宾浩斯打卡日历 ---------------- */

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.cal-wd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  text-align: center;
  padding-bottom: 4px;
}
.cal-cell {
  aspect-ratio: 1;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 5px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: transform var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.cal-cell:hover { transform: translateY(-1px); border-color: var(--accent); }
.cal-cell.lv1 { background: #e3ede4; border-color: rgba(44, 106, 76, 0.3); }
.cal-cell.lv2 { background: #b8dac1; border-color: rgba(31, 122, 77, 0.45); }
.cal-cell.lv3 { background: var(--ink-green); color: var(--cream); border-color: var(--ink-green); }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell .dnum { font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; }
.cal-cell .dcnt { font-family: var(--font-mono); font-size: 10px; opacity: 0.8; text-align: right; }

/* ---------------- 抢答弹窗 ---------------- */

.poll-modal {
  position: fixed;
  top: 68px;
  right: 20px;
  width: min(380px, calc(100vw - 24px));
  z-index: 150;
  border: 2px solid var(--ink-green);
  border-radius: var(--r-lg);
  background: var(--card);
  box-shadow: var(--shadow-float);
  padding: 16px;
  animation: studioSlide 220ms var(--ease);
}
.poll-modal[hidden] { display: none !important; }

/* ---------------- 浮窗学习抽屉（不打断终端连接时打开讲义） ---------------- */
.ws-drawer-studio {
  position: fixed;
  top: calc(var(--topbar-h) + 10px);
  right: 14px;
  bottom: 14px;
  width: min(490px, calc(100vw - 28px));
  z-index: 220;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--card);
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: studioSlide 220ms var(--ease);
}
.ws-drawer-studio[hidden] { display: none !important; }

/* ---------------- 响应式 ---------------- */

@media (max-width: 1220px) {
  .lab-grid { grid-template-columns: 220px minmax(0, 1fr); }
  .lab-side { grid-column: 1 / -1; max-height: none; }
  .map-stage.with-studio { grid-template-columns: minmax(0, 1fr) 400px; }
}

@media (max-width: 960px) {
  .map-stage.with-studio { grid-template-columns: minmax(0, 1fr); }
  .studio-panel { height: auto; max-height: 620px; }
  .lab-grid { grid-template-columns: minmax(0, 1fr); }
  .lab-rail { max-height: 260px; }
}
