/* AK Campus 在线实验室 */

.akc-lab {
	--lab-line: 22.4px;
	--lab-pad-y: 12px;
	--lab-pad-x: 14px;
	--lab-mono: 14px/1.6 ui-monospace, SFMono-Regular, "Cascadia Code", Consolas,
		"Liberation Mono", "Courier New", monospace;
	max-width: 1180px;
	margin: 26px auto 40px;
	padding: 0 4px;
	font-family: "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	color: #1e293b;
}

.akc-lab * {
	box-sizing: border-box;
}

/* 主题正文容器只有 ~620px，代码编辑器和终端都太挤。
   桌面端突破到全宽（最多 1180px），窄屏保持主题宽度不动。 */
@media (min-width: 900px) {
	#akcLab {
		width: min(1180px, calc(100vw - 56px)) !important;
		max-width: none !important;
		margin-left: 50% !important;
		margin-right: 0 !important;
		transform: translateX(-50%);
	}
}

/* ---------- 头部 ---------- */
.lab-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 14px;
}

.lab-title {
	font-size: 19px;
	font-weight: 700;
	letter-spacing: 0.2px;
	display: flex;
	align-items: center;
	gap: 8px;
}

/* 窄屏 */

.lab-badge {
	font-size: 11.5px;
	font-weight: 600;
	color: #047857;
	background: #ecfdf5;
	border: 1px solid #a7f3d0;
	border-radius: 999px;
	padding: 4px 11px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.lab-status {
	font-size: 12.5px;
	font-weight: 600;
	padding: 5px 12px;
	border-radius: 999px;
	background: #f1f5f9;
	color: #64748b;
	white-space: nowrap;
}

.lab-status.ok {
	background: #ecfdf5;
	color: #047857;
}
.lab-status.wait {
	background: #fffbeb;
	color: #b45309;
}
.lab-status.bad {
	background: #fef2f2;
	color: #b91c1c;
}

/* ---------- 工具栏 ---------- */
.lab-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-bottom: 12px;
	padding: 10px 12px;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.lab-toolbar select,
.lab-toolbar button,
.lab-taskbar select,
.lab-taskbar button {
	font-family: inherit;
	font-size: 13px;
	border-radius: 8px;
	border: 1px solid #d7dee8;
	background: #fff;
	color: #334155;
	padding: 7px 12px;
	cursor: pointer;
	transition: all 0.14s ease;
}

.lab-toolbar select:hover,
.lab-toolbar button:hover,
.lab-taskbar select:hover,
.lab-taskbar button:hover {
	border-color: #94a3b8;
	background: #f8fafc;
}

.lab-toolbar select {
	padding-right: 8px;
	max-width: 190px;
}

#labRun {
	background: #16a34a;
	border-color: #16a34a;
	color: #fff;
	font-weight: 700;
	padding: 7px 18px;
}

#labRun:hover:not(:disabled) {
	background: #15803d;
	border-color: #15803d;
}

#labRun:disabled,
.lab-toolbar button:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

#labStop {
	color: #b91c1c;
	border-color: #fecaca;
	background: #fef2f2;
	font-weight: 600;
}

#labStop:hover:not(:disabled) {
	background: #fee2e2;
	border-color: #fca5a5;
}

.lab-sep {
	width: 1px;
	height: 20px;
	background: #e2e8f0;
	margin: 0 2px;
}

.lab-check {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-size: 12.5px;
	color: #64748b;
	cursor: pointer;
	user-select: none;
}

.lab-check input {
	margin: 0;
	accent-color: #16a34a;
}

.lab-spacer {
	flex: 1;
}

/* ---------- 主体两栏 ---------- */
.lab-main {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
}

.lab-pane {
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	overflow: hidden;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.pane-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 8px 14px;
	font-size: 12.5px;
	font-weight: 700;
	color: #475569;
	background: #f8fafc;
	border-bottom: 1px solid #e2e8f0;
}

.pane-tip {
	font-size: 11.5px;
	font-weight: 500;
	color: #94a3b8;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ---------- 代码编辑区 ---------- */
.code-wrap {
	display: flex;
	height: 430px;
	background: #fcfdfe;
	overflow: hidden;
}

.code-gutter {
	flex: 0 0 auto;
	min-width: 42px;
	padding: var(--lab-pad-y) 8px var(--lab-pad-y) 10px;
	font: var(--lab-mono);
	color: #b6c2d1;
	text-align: right;
	user-select: none;
	overflow: hidden;
	background: #f6f8fa;
	border-right: 1px solid #eaedf1;
	white-space: pre;
	line-height: var(--lab-line);
}

.code-area {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
}

.code-hl,
.code-area textarea {
	position: absolute;
	inset: 0;
	margin: 0;
	border: 0;
	padding: var(--lab-pad-y) var(--lab-pad-x);
	font: var(--lab-mono);
	line-height: var(--lab-line);
	tab-size: 4;
	-moz-tab-size: 4;
	letter-spacing: normal;
	white-space: pre;
	word-wrap: normal;
	overflow: auto;
}

.code-hl {
	color: #1e293b;
	pointer-events: none;
	overflow: hidden;
	background: transparent;
	z-index: 1;
}

.code-area textarea {
	color: transparent;
	background: transparent;
	caret-color: #0f172a;
	resize: none;
	outline: none;
	z-index: 2;
	overflow: auto;
	-webkit-text-fill-color: transparent;
}

.code-area textarea::selection {
	background: #bfdbfe;
	-webkit-text-fill-color: transparent;
}

/* 高亮配色 */
.code-hl .k-k {
	color: #7c3aed;
	font-weight: 600;
}
.code-hl .k-s {
	color: #059669;
}
.code-hl .k-c {
	color: #94a3b8;
	font-style: italic;
}
.code-hl .k-n {
	color: #ea580c;
}
.code-hl .k-b {
	color: #2563eb;
}

/* ---------- 输出区 ---------- */
.lab-out {
	margin: 0;
	height: 430px;
	padding: var(--lab-pad-y) var(--lab-pad-x);
	background: #0f172a;
	color: #e2e8f0;
	font: var(--lab-mono);
	line-height: var(--lab-line);
	white-space: pre-wrap;
	word-break: break-word;
	overflow: auto;
	tab-size: 4;
}

.lab-out .lab-err {
	color: #fca5a5;
}

.lab-out .lab-hint {
	color: #fde68a;
}

.lab-out .lab-sys {
	color: #7c8ca4;
	font-style: italic;
}

/* ---------- 程序输入 ---------- */
.lab-stdin {
	margin-top: 12px;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	overflow: hidden;
}

.lab-stdin summary {
	padding: 10px 14px;
	font-size: 13px;
	font-weight: 600;
	color: #475569;
	cursor: pointer;
	user-select: none;
	list-style: none;
	background: #f8fafc;
}

.lab-stdin summary::-webkit-details-marker {
	display: none;
}

.lab-stdin summary:hover {
	background: #f1f5f9;
}

.lab-stdin .lab-stdin-body {
	padding: 10px 14px 14px;
}

.lab-stdin textarea {
	width: 100%;
	height: 84px;
	padding: 10px 12px;
	border: 1px solid #d7dee8;
	border-radius: 9px;
	font: 13px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace;
	color: #1e293b;
	background: #fcfdfe;
	resize: vertical;
	outline: none;
}

.lab-stdin textarea:focus {
	border-color: #16a34a;
	box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}

.lab-stdin p {
	margin: 0 0 8px;
	font-size: 12px;
	line-height: 1.7;
	color: #8595a8;
}

/* ---------- 页脚说明 ---------- */
.lab-foot {
	margin-top: 14px;
	padding: 12px 14px;
	background: #f8fafc;
	border: 1px dashed #dde4ec;
	border-radius: 10px;
	font-size: 12px;
	line-height: 1.9;
	color: #7b8a9c;
}

.lab-foot b {
	color: #475569;
}

/* ---------- 窄屏 ---------- */
@media (max-width: 900px) {
	.akc-lab {
		margin: 16px auto 28px;
	}
	.lab-main {
		grid-template-columns: 1fr;
	}
	.code-wrap,
	.lab-out {
		height: 300px;
	}
	.lab-title {
		font-size: 16px;
	}
	.lab-badge {
		font-size: 10.5px;
		padding: 3px 8px;
		max-width: 100%;
	}
	.lab-badge-more,
	.lab-opt,
	.lab-spacer,
	.lab-sep {
		display: none;
	}
	.lab-toolbar {
		padding: 8px 10px;
		gap: 6px;
	}
	.lab-toolbar select,
	.lab-toolbar button {
		padding: 6px 10px;
		font-size: 12.5px;
	}
	#labRun {
		padding: 6px 14px;
	}
	.lab-spacer,
	.lab-sep {
		display: none;
	}
}

/* ---------- turtle 画出来的图（插在终端文字上方） ---------- */
.lab-out .lab-figure {
	display: block;
	margin: 0 auto 10px;
	max-width: 100%;
	background: #fff;
	border-radius: 8px;
}

/* ================================================================
 * 练习任务模块
 * ================================================================ */

/* ---------- 选项卡 ---------- */
.lab-tabs {
	display: flex;
	gap: 6px;
	margin-bottom: 12px;
}

.lab-tab {
	font-family: inherit;
	font-size: 13.5px;
	font-weight: 600;
	color: #64748b;
	background: #f1f5f9;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	padding: 9px 16px;
	cursor: pointer;
	transition: all 0.14s ease;
}

.lab-tab:hover {
	color: #334155;
	background: #e8eef6;
}

.lab-tab.on {
	color: #fff;
	background: #0f172a;
	border-color: #0f172a;
	box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
}

.lab-tab-n {
	display: inline-block;
	margin-left: 5px;
	padding: 1px 7px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 700;
	background: #e2e8f0;
	color: #64748b;
}

.lab-tab.on .lab-tab-n {
	background: rgba(255, 255, 255, 0.22);
	color: #fff;
}

/* 练习任务模式下，工具栏里「载入课堂例题」没意义，收起来 */
.akc-lab[data-mode="task"] .lab-toolbar #labSample {
	display: none;
}

/* ---------- 任务条 ---------- */
.lab-taskwrap {
	margin-bottom: 12px;
}

.lab-taskbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	padding: 9px 12px;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.lab-taskbar select {
	max-width: 360px;
	font-weight: 600;
}

#labTaskPrev,
#labTaskNext {
	padding: 7px 11px;
	font-weight: 700;
	color: #475569;
}

.lab-task-done.is-done {
	color: #047857;
	background: #ecfdf5;
	border-color: #a7f3d0;
}

.lab-task-prog {
	margin-left: auto;
	font-size: 12.5px;
	font-weight: 600;
	color: #94a3b8;
	white-space: nowrap;
}

/* ---------- 任务总览网格 ---------- */
.lab-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
	gap: 6px;
	margin-top: 8px;
	padding: 10px;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
}

.lab-grid[hidden] {
	display: none;
}

.lab-grid .tg {
	font-family: inherit;
	font-size: 12.5px;
	font-weight: 700;
	color: #64748b;
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	padding: 7px 0;
	cursor: pointer;
	transition: all 0.12s ease;
}

.lab-grid .tg:hover {
	border-color: #94a3b8;
	color: #334155;
}

.lab-grid .tg.is-done {
	color: #047857;
	background: #ecfdf5;
	border-color: #a7f3d0;
}

.lab-grid .tg.is-cur {
	color: #fff;
	background: #0f172a;
	border-color: #0f172a;
}

/* ---------- 题目卡 ---------- */
.lab-taskcard {
	padding: 13px 15px;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.tc-top {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 8px;
	margin-bottom: 6px;
}

.tc-no {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.3px;
	color: #4338ca;
	background: #eef2ff;
	border-radius: 6px;
	padding: 2px 8px;
	white-space: nowrap;
}

.tc-title {
	font-size: 15px;
	font-weight: 700;
	color: #0f172a;
}

.tc-star {
	font-size: 11px;
	letter-spacing: 1px;
	color: #f59e0b;
}

.tc-goal {
	margin: 0 0 8px;
	font-size: 13px;
	line-height: 1.7;
	color: #475569;
}

/* 投稿题的完整题干 */
.tc-brief {
	margin: 0 0 9px;
	padding: 10px 12px;
	background: #f8fafc;
	border: 1px solid #eef2f7;
	border-radius: 8px;
	font-size: 13px;
	line-height: 1.75;
	color: #334155;
	white-space: pre-wrap;
	word-break: break-word;
}

/* 同学投稿题：出题人署名 */
/* 投稿题配图（最多两张并排） */
.tc-imgs {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 6px;
	margin: 0 0 9px;
}

.tc-imgs a {
	display: block;
	border: 1px solid #e8eef5;
	border-radius: 8px;
	overflow: hidden;
	background: #f8fafc;
}

.tc-imgs img {
	display: block;
	width: 100%;
	height: 96px;
	object-fit: cover;
}

.tc-imgs a:only-child {
	grid-column: 1 / -1;
}

.tc-imgs a:only-child img {
	height: auto;
	max-height: 220px;
	object-fit: contain;
}

/* 投稿题：输入 / 输出格式 */
.tc-fmt {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	margin: 0 0 9px;
}

.tc-fmt > div {
	padding: 8px 10px;
	border: 1px solid #eef2f7;
	border-radius: 8px;
	background: #fff;
}

.tc-fmt span {
	display: block;
	margin-bottom: 3px;
	font-size: 11px;
	font-weight: 700;
	color: #0f766e;
	letter-spacing: 0.02em;
}

.tc-fmt p {
	margin: 0;
	font-size: 12.5px;
	line-height: 1.7;
	color: #475569;
	white-space: pre-wrap;
	word-break: break-word;
}

/* 参考流程图 */
.tc-flow {
	display: block;
	padding: 8px;
}

.tc-flow img {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 6px;
}

@media (max-width: 640px) {
	.tc-fmt,
	.tc-imgs {
		grid-template-columns: 1fr;
	}

	.tc-imgs img {
		height: auto;
		max-height: 240px;
		object-fit: contain;
	}
}

.tc-author {
	margin: -2px 0 9px;
	padding: 6px 11px;
	font-size: 12.5px;
	line-height: 1.6;
	color: #0f766e;
	background: #f0fdfa;
	border: 1px solid #ccfbf1;
	border-radius: 7px;
}

.tc-author b {
	font-weight: 700;
}

.tc-author a {
	color: #0d9488;
	font-weight: 600;
	text-decoration: none;
}

.tc-author a:hover {
	text-decoration: underline;
}

.tc-need {
	margin: 0 0 9px;
	padding-left: 20px;
	font-size: 13px;
	line-height: 1.85;
	color: #334155;
}

.tc-need li {
	margin-bottom: 1px;
}

.tc-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
	margin-bottom: 9px;
}

.tc-tags i {
	font-style: normal;
	font-size: 11px;
	font-weight: 600;
	color: #64748b;
	background: #f1f5f9;
	border-radius: 999px;
	padding: 2px 9px;
}

.tc-fold {
	margin-bottom: 6px;
	border: 1px solid #e8eef5;
	border-radius: 9px;
	background: #fbfdff;
}

.tc-fold > summary {
	padding: 7px 11px;
	font-size: 12.5px;
	font-weight: 600;
	color: #475569;
	cursor: pointer;
	list-style: none;
	user-select: none;
}

.tc-fold > summary::-webkit-details-marker {
	display: none;
}

.tc-fold[open] > summary {
	border-bottom: 1px solid #eef3f9;
	color: #0f172a;
}

.tc-body {
	padding: 9px 12px;
	font-size: 12.5px;
	line-height: 1.85;
	color: #475569;
}

.tc-code {
	margin: 0;
	padding: 10px 12px;
	background: #0f172a;
	color: #e2e8f0;
	font: 12.5px/1.65 ui-monospace, SFMono-Regular, "Cascadia Code", Consolas,
		"Liberation Mono", "Courier New", monospace;
	white-space: pre;
	overflow-x: auto;
	border-radius: 0 0 9px 9px;
}

.tc-ref .tc-code {
	max-height: 260px;
	overflow-y: auto;
}

.tc-load {
	margin: 8px 12px 10px;
	font-family: inherit;
	font-size: 12.5px;
	font-weight: 600;
	color: #1d4ed8;
	background: #eff6ff;
	border: 1px solid #bfdbfe;
	border-radius: 8px;
	padding: 6px 12px;
	cursor: pointer;
}

.tc-load:hover {
	background: #dbeafe;
}

.tc-note {
	margin: 8px 0 0;
	padding: 8px 11px;
	font-size: 12px;
	line-height: 1.8;
	color: #92400e;
	background: #fffbeb;
	border: 1px solid #fde68a;
	border-radius: 8px;
}

@media (max-width: 900px) {
	.lab-tab {
		font-size: 12.5px;
		padding: 8px 12px;
	}
	.lab-taskbar select {
		max-width: 100%;
		flex: 1 1 100%;
	}
	.lab-task-prog {
		margin-left: 0;
		width: 100%;
	}
	.lab-taskcard {
		max-height: none;
		padding: 11px 12px;
	}
	.tc-title {
		font-size: 14px;
	}
}
