/* ═══ Linux 代码练习场（code-lab）· 2026-09-12 ═══

/* ═══ 代码练习场（linux-codelab）· 复用讲义的工作区机制 ═══ */
.learning-dashboard__inner[data-workspace] > #code-lab-root {
  display: none;
  width: 100%;
  min-width: 0;
  margin: 0;
  scroll-margin-top: 5rem;
}
.learning-dashboard__inner[data-codelab-active="true"] > #code-lab-root {
  display: block !important;
  order: 2;
  width: 100%;
  animation: learning-workspace-enter 320ms ease both;
}
.learning-dashboard__inner[data-codelab-active="true"] > #learning-today,
.learning-dashboard__inner[data-codelab-active="true"] > #learning-week,
.learning-dashboard__inner[data-codelab-active="true"] > #learning-budget,
.learning-dashboard__inner[data-codelab-active="true"] > #learning-roadmap,
.learning-dashboard__inner[data-codelab-active="true"] > #learning-library,
.learning-dashboard__inner[data-codelab-active="true"] > #learning-notes,
.learning-dashboard__inner[data-codelab-active="true"] > #learning-memory,
.learning-dashboard__inner[data-codelab-active="true"] > #learning-practice,
.learning-dashboard__inner[data-codelab-active="true"] > #linux-notes-root {
  display: none !important;
}
.learning-dashboard__inner[data-notes-active="true"] > #code-lab-root,
.learning-dashboard__inner[data-practice-active="true"] > #code-lab-root {
  display: none;
}
@media (min-width: 960px) {
  .learning-dashboard__inner[data-workspace] > #code-lab-root {
    grid-column: 2;
    grid-row: 3;
  }
}

.linux-codelab {
  position: relative;
  width: 100%;
  margin-top: clamp(1rem, 3vw, 2rem);
  overflow: hidden;
  border: 1px solid rgb(87 101 75 / 20%);
  border-radius: 1.35rem;
  color: #4d5148;
  background:
    linear-gradient(90deg, rgb(113 137 99 / 4%) 1px, transparent 1px),
    linear-gradient(rgb(113 137 99 / 4%) 1px, transparent 1px),
    radial-gradient(circle at 82% 4%, rgb(176 207 218 / 30%), transparent 25rem),
    rgb(255 253 246 / 72%);
  background-size: 2rem 2rem, 2rem 2rem, auto, auto;
  box-shadow: 0 .9rem 2.1rem rgb(78 65 48 / 10%);
}
.linux-codelab::before {
  position: absolute; inset: 0 0 auto; height: 2px; content: "";
  background: linear-gradient(90deg, #829b75, #a8bea0 58%, transparent);
}
.linux-codelab button, .linux-codelab input, .linux-codelab textarea { font: inherit; }
.linux-codelab button:focus-visible, .linux-codelab input:focus-visible,
.linux-codelab textarea:focus-visible { outline: 3px solid #a8bea0; outline-offset: 3px; }

.linux-codelab__heading {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2rem;
  align-items: end; padding: clamp(1.2rem, 3vw, 2rem);
  border-bottom: 1px solid rgb(87 101 75 / 14%);
  background: linear-gradient(135deg, rgb(236 244 229 / 82%), rgb(255 253 246 / 34%));
}
.linux-codelab__eyebrow {
  margin: 0; color: #718969; font-family: var(--font-mono); font-size: .72rem;
  font-weight: 700; letter-spacing: .18em;
}
.linux-codelab__heading h2 {
  margin: .4rem 0 0; color: #403a33; font-family: var(--font-serif);
  font-size: clamp(1.65rem, 3vw, 2.35rem); font-weight: 600;
}
.linux-codelab__intro { max-width: 44rem; margin: .7rem 0 0; color: #697064; font-size: .96rem; line-height: 1.75; }
.linux-codelab__stats { display: grid; grid-template-columns: repeat(3, minmax(4.4rem, 1fr)); gap: .45rem; }
.linux-codelab__stats > div { min-width: 4.6rem; padding: .65rem .7rem; border-left: 1px solid rgb(103 126 91 / 18%); }
.linux-codelab__stats strong, .linux-codelab__stats span { display: block; }
.linux-codelab__stats strong { color: #4c5e47; font-family: var(--font-mono); font-size: 1.18rem; }
.linux-codelab__stats span { margin-top: .18rem; color: #7b8676; font-size: .72rem; }

.linux-codelab__workspace {
  display: grid; height: clamp(30rem, calc(100vh - 12.5rem), 66rem);
  grid-template-columns: minmax(13rem, .3fr) minmax(0, 1fr);
}
.linux-codelab__rail {
  display: flex; flex-direction: column; min-height: 0;
  padding: 1.1rem;
  border-right: 1px solid rgb(87 101 75 / 14%);
  background: rgb(246 242 231 / 74%);
  overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: rgb(113 137 99 / 45%) transparent;
}
.linux-codelab__rail-label {
  display: block; margin: 0 0 .5rem; color: #63745c;
  font-family: var(--font-mono); font-size: .7rem; font-weight: 700; letter-spacing: .12em;
}
.linux-codelab__chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.linux-codelab__chip {
  padding: .3rem .6rem; border: 1px solid rgb(113 137 99 / 26%); border-radius: 2rem;
  color: #6f776a; font-size: .78rem; cursor: pointer; background: rgb(255 253 246 / 70%);
}
.linux-codelab__chip:hover { color: #455140; background: rgb(220 235 212 / 66%); }
.linux-codelab__chip[aria-pressed="true"] {
  border-color: #718969; color: #fffdf6; font-weight: 600; background: #718969;
}
.linux-codelab__group {
  margin: .8rem 0 .3rem; color: #848b7e;
  font-family: var(--font-mono); font-size: .68rem; font-weight: 700; letter-spacing: .1em;
}
.linux-codelab__list { display: grid; gap: .25rem; }
.linux-codelab__item {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  min-height: 2.3rem; padding: .4rem .6rem;
  border: 1px solid transparent; border-radius: .55rem;
  color: #5d665a; font-size: .84rem; text-align: left; cursor: pointer; background: transparent;
}
.linux-codelab__item:hover { color: #455140; background: rgb(220 235 212 / 66%); }
.linux-codelab__item.is-active {
  border-color: rgb(113 137 99 / 30%); color: #41503c; font-weight: 600;
  background: linear-gradient(90deg, rgb(211 229 201 / 90%), rgb(239 246 232 / 54%));
}
.linux-codelab__item-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linux-codelab__done-mark { color: #5f8a4f; font-weight: 700; margin-right: .25rem; }
.linux-codelab__stars { flex: none; font-size: .7rem; letter-spacing: -.08em; color: rgb(113 137 99 / 30%); }
.linux-codelab__stars .is-on { color: #c98f3f; }

.linux-codelab__stage { min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.linux-codelab__scroll {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: clamp(1rem, 2.4vw, 1.8rem);
  scrollbar-width: thin; scrollbar-color: rgb(113 137 99 / 45%) transparent;
}
.linux-codelab__cardhead {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-bottom: .7rem;
}
.linux-codelab__file {
  display: inline-block; margin-right: .5rem; padding: .2rem .55rem;
  border: 1px solid rgb(113 137 99 / 30%); border-radius: .45rem;
  color: #4c5e47; font-family: var(--font-mono); font-size: .78rem;
  background: rgb(211 229 201 / 38%);
}
.linux-codelab__sec { margin-left: .5rem; color: #848b7e; font-size: .76rem; }
.linux-codelab__done { display: inline-flex; align-items: center; gap: .35rem; color: #5f8a4f; font-size: .84rem; cursor: pointer; }
.linux-codelab__done input { width: 1rem; height: 1rem; accent-color: #718969; }
.linux-codelab__title { margin: .2rem 0 .5rem; color: #403a33; font-family: var(--font-serif); font-size: 1.35rem; }
.linux-codelab__desc { margin: 0 0 1rem; color: #5a6353; line-height: 1.8; }
.linux-codelab__know { margin-bottom: 1.1rem; }
.linux-codelab__tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.linux-codelab__tag {
  padding: .22rem .6rem; border: 1px solid rgb(113 137 99 / 30%); border-radius: 2rem;
  color: #5c6a52; font-size: .78rem; background: rgb(226 239 216 / 45%);
  text-decoration: none;
}
.linux-codelab__tag--link { color: #4c5e47; font-weight: 600; cursor: pointer; }
.linux-codelab__tag--link:hover { background: rgb(211 229 201 / 80%); }

.linux-codelab__editor {
  width: 100%; min-height: 15rem; padding: .85rem 1rem;
  border: 1px solid rgb(97 119 85 / 30%); border-radius: .8rem;
  color: #37402f; font-family: var(--font-mono); font-size: .82rem; line-height: 1.65;
  background: rgb(253 252 246 / 95%);
  resize: vertical; tab-size: 4; white-space: pre; overflow-wrap: normal; overflow-x: auto;
}
.linux-codelab__editor:focus { outline: 2px solid #829b75; outline-offset: 1px; }
.linux-codelab__actions {
  display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0 1.2rem;
}
.linux-codelab__actions button, .linux-codelab__ai-actions button {
  padding: .42rem .85rem; border: 1px solid #718969; border-radius: .6rem;
  color: #44523f; cursor: pointer; background: rgb(255 253 246 / 82%); font-size: .86rem;
}
.linux-codelab__actions button:hover, .linux-codelab__ai-actions button:hover { background: rgb(226 239 216 / 90%); }
.linux-codelab__actions button.is-primary, .linux-codelab__ai-actions button.is-primary {
  border-color: #334f46; color: #fffdf6; background: #334f46;
}
.linux-codelab__actions button.is-primary:hover, .linux-codelab__ai-actions button.is-primary:hover { background: #3f6053; }
.linux-codelab__ref { margin-bottom: 1.2rem; }
.linux-codelab__ref-title { margin: 0 0 .4rem; color: #718969; font-family: var(--font-mono); font-size: .72rem; font-weight: 700; letter-spacing: .1em; }
.linux-codelab__code {
  margin: 0 0 .9rem; padding: .85rem 1rem; overflow-x: auto;
  border: 1px solid rgb(113 137 99 / 22%); border-radius: .8rem;
  background: rgb(252 251 244 / 92%);
  font-family: var(--font-mono); font-size: .78rem; line-height: 1.65;
  scrollbar-width: thin;
}
.linux-codelab__ai {
  margin-top: .4rem; padding: 1rem 1.1rem;
  border-left: 3px solid #829b75; border-radius: .8rem;
  background: rgb(226 239 216 / 40%);
}
.linux-codelab__ai-quick { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.linux-codelab__ai-quick button {
  padding: .32rem .7rem; border: 1px solid rgb(113 137 99 / 35%); border-radius: 2rem;
  color: #5c6a52; font-size: .8rem; cursor: pointer; background: rgb(255 253 246 / 80%);
}
.linux-codelab__ai-quick button:hover { color: #3f4b3a; background: rgb(220 235 212 / 80%); }
.linux-codelab__ai-input {
  width: 100%; min-height: 2.6rem; margin-bottom: .5rem; padding: .5rem .75rem;
  border: 1px solid rgb(97 119 85 / 30%); border-radius: .6rem;
  color: #464b42; background: rgb(255 254 249 / 90%); font-size: .86rem;
  resize: vertical;
}
.linux-codelab__ai-hint { margin: .4rem 0; color: #7b8676; font-size: .86rem; line-height: 1.7; }
.linux-codelab__ai-hint code { padding: .05rem .3rem; border-radius: .3rem; background: rgb(211 229 201 / 45%); }
.linux-codelab__ai-hint--warn { color: #a05c3f; }
.linux-codelab__ai-out { font-size: .88rem; line-height: 1.75; color: #4d5148; }
.linux-codelab__ai-out p { margin: .5rem 0; }
.linux-codelab__ai-out strong { color: #3f4b3a; }
.linux-codelab__ai-out code { padding: .05rem .3rem; border-radius: .3rem; background: rgb(211 229 201 / 45%); font-family: var(--font-mono); font-size: .85em; }
.linux-codelab__ai-out ul { margin: .4rem 0; padding-left: 1.3rem; }
.linux-codelab__ai-out li { margin: .25rem 0; }
.linux-codelab__ai-code {
  margin: .5rem 0; padding: .75rem .9rem; overflow-x: auto;
  border: 1px solid rgb(113 137 99 / 25%); border-radius: .6rem;
  background: #0e1f1a; color: #d7ecd9;
  font-family: var(--font-mono); font-size: .78rem; line-height: 1.6;
}
.linux-codelab__footer {
  padding: .8rem clamp(1.2rem, 3vw, 2rem);
  border-top: 1px solid rgb(87 101 75 / 14%);
  color: #848b7e; font-size: .78rem;
}

@media (max-width: 900px) {
  .linux-codelab__heading { grid-template-columns: 1fr; }
  .linux-codelab__workspace {
    grid-template-columns: 1fr;
    height: auto; max-height: none;
  }
  .linux-codelab__rail {
    border-right: 0; border-bottom: 1px solid rgb(87 101 75 / 14%);
    max-height: 18rem;
  }
  .linux-codelab__stage { min-height: 0; }
}

/* ── AI 学长对话流 ── */
.linux-codelab__ai-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.linux-codelab__ai-head .linux-codelab__rail-label { margin-bottom: 0; }
.linux-codelab__ai-head button {
  padding: .25rem .6rem; border: 1px solid rgb(113 137 99 / 35%); border-radius: .5rem;
  color: #6f776a; font-size: .76rem; cursor: pointer; background: rgb(255 253 246 / 80%);
}
.linux-codelab__ai-head button:hover { color: #3f4b3a; background: rgb(220 235 212 / 80%); }
.linux-codelab__ai-body {
  max-height: 26rem; overflow-y: auto; margin-top: .55rem;
  padding-right: .2rem;
  scrollbar-width: thin; scrollbar-color: rgb(113 137 99 / 45%) transparent;
}
.linux-codelab__msg { margin: .55rem 0; padding: .55rem .8rem; border-radius: .75rem; font-size: .87rem; line-height: 1.75; }
.linux-codelab__msg--user {
  margin-left: 2.2rem; border-bottom-right-radius: .2rem;
  background: #334f46; color: #edf6f0;
  white-space: pre-wrap; word-break: break-word;
}
.linux-codelab__msg--ai {
  margin-right: .6rem; border: 1px solid rgb(113 137 99 / 22%);
  background: rgb(255 253 246 / 92%);
}
.linux-codelab__msg--ai p { margin: .4rem 0; }
.linux-codelab__msg--ai strong { color: #3f4b3a; }
.linux-codelab__msg--ai code {
  padding: .05rem .3rem; border-radius: .3rem; background: rgb(211 229 201 / 50%);
  font-family: var(--font-mono); font-size: .84em;
}
.linux-codelab__ai-hr { border: 0; border-top: 1px dashed rgb(113 137 99 / 30%); margin: .6rem 0; }

/* ── 本地工作区联动 ── */
.linux-codelab__ws {
  margin-bottom: 1.1rem; padding: .9rem 1rem;
  border: 1px dashed rgb(113 137 99 / 40%); border-radius: .8rem;
  background: rgb(240 246 233 / 60%);
}
.linux-codelab__ws-hint { margin: .4rem 0; color: #697064; font-size: .84rem; line-height: 1.7; }
.linux-codelab__ws-hint--warn { color: #a05c3f; }
.linux-codelab__ws-hint--ok { color: #5f8a4f; }
.linux-codelab__ws-hint code { padding: .05rem .3rem; border-radius: .3rem; background: rgb(211 229 201 / 45%); }
.linux-codelab__ws-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .6rem 0; }
.linux-codelab__ws-actions button {
  padding: .4rem .8rem; border: 1px solid #718969; border-radius: .6rem;
  color: #44523f; cursor: pointer; background: rgb(255 253 246 / 85%); font-size: .84rem;
}
.linux-codelab__ws-actions button:hover { background: rgb(226 239 216 / 90%); }
.linux-codelab__ws-actions button.is-primary { border-color: #334f46; color: #fffdf6; background: #334f46; }
.linux-codelab__ws-actions button.is-primary:hover { background: #3f6053; }
.linux-codelab__ws-vscode { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.linux-codelab__ws-path {
  flex: 1; min-width: 14rem; padding: .4rem .7rem;
  border: 1px solid rgb(97 119 85 / 30%); border-radius: .5rem;
  color: #464b42; background: rgb(255 254 249 / 92%); font-size: .82rem;
}
.linux-codelab__ws-vscode button {
  padding: .4rem .75rem; border: 1px solid rgb(113 137 99 / 40%); border-radius: .5rem;
  color: #44523f; cursor: pointer; background: rgb(255 253 246 / 85%); font-size: .82rem;
}
.linux-codelab__ws-vscode button:hover { background: rgb(226 239 216 / 90%); }
.linux-codelab__ws-link { border: 0; background: none; color: #4c5e47; font-weight: 600; cursor: pointer; text-decoration: underline; padding: 0; font-size: inherit; }
.linux-codelab__draft { margin-bottom: 1rem; }
.linux-codelab__draft > summary {
  cursor: pointer; color: #718969; font-family: var(--font-mono);
  font-size: .72rem; font-weight: 700; letter-spacing: .1em; margin-bottom: .5rem;
}
.linux-codelab__draft-actions { margin-top: .5rem; }
.linux-codelab__draft-actions button {
  padding: .3rem .7rem; border: 1px solid rgb(113 137 99 / 35%); border-radius: .5rem;
  color: #6f776a; cursor: pointer; background: rgb(255 253 246 / 80%); font-size: .8rem;
}

/* ── 练习工程下载卡片 ── */
.linux-codelab__dl {
  display: block;
  padding: .8rem 1rem;
  border: 1px solid #334f46;
  border-radius: .8rem;
  color: #fffdf6;
  font-family: var(--font-mono);
  font-size: .92rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  background: linear-gradient(135deg, #334f46, #3f6053);
  box-shadow: 0 .5rem 1.2rem rgb(51 79 70 / 24%);
  transition: transform .15s ease, box-shadow .15s ease;
}
.linux-codelab__dl:hover { transform: translateY(-1px); box-shadow: 0 .7rem 1.6rem rgb(51 79 70 / 30%); }
.linux-codelab__dl span {
  display: block; margin-top: .3rem;
  color: rgb(255 253 246 / 75%);
  font-size: .7rem; font-weight: 400; letter-spacing: .04em;
}
.linux-codelab__stats { max-width: 17rem; justify-self: end; }
.linux-codelab__stats { grid-template-columns: 1fr; }
