:root {
    --bg: #eef3f6;
    --panel: #ffffff;
    --ink: #173042;
    --muted: #647783;
    --line: #d4e0e7;
    --accent: #216a91;
    --accent-soft: #e7f2f8;
    --good: #287a52;
    --warn: #b57919;
    --bad: #b94747;
    --dark: #263f50;
    --sidebar: #f8fbfc;
    --shadow: 0 12px 32px rgba(28, 59, 78, .10);
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-header {
    min-height: 64px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 22px;
    align-items: center;
    padding: 10px 22px;
    background: #173042;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 4px 18px rgba(0,0,0,.18);
}
.brand { color: #fff; text-decoration: none; font-size: 20px; font-weight: 900; letter-spacing: .03em; }
.brand span { color: #8fd0ef; }
.course-title { font-weight: 700; text-align: center; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.user-chip {
    padding: 8px 11px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 999px;
    color: #e9f4f9;
    font-size: 13px;
    white-space: nowrap;
}
.user-chip.teacher { background: rgba(255,255,255,.12); }
.sem-shell { display: grid; grid-template-columns: 285px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sem-sidebar {
    background: var(--sidebar);
    border-right: 1px solid var(--line);
    padding: 22px 18px;
    position: sticky;
    top: 64px;
    height: calc(100vh - 64px);
    overflow: auto;
}
.side-course span { display: block; color: var(--accent); font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.side-course strong { display: block; margin-top: 6px; font-size: 18px; line-height: 1.2; }
.side-note { margin: 14px 0 18px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.module-list { display: grid; gap: 8px; }
.module-btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 12px;
    padding: 10px 10px;
    display: grid;
    grid-template-columns: 30px 1fr;
    grid-template-rows: auto auto;
    gap: 1px 8px;
    text-align: left;
    transition: .15s ease;
}
.module-btn:hover { border-color: #9dbccc; transform: translateY(-1px); }
.module-btn.is-active { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.module-btn > span { grid-row: 1 / 3; align-self: center; width: 27px; height: 27px; display: grid; place-items: center; background: #dbe7ed; border-radius: 8px; font-weight: 800; font-size: 12px; }
.module-btn.is-active > span { background: var(--accent); color: #fff; }
.module-btn b { font-size: 14px; }
.module-btn small { color: var(--muted); font-size: 11px; }
.module-btn.is-complete b::after { content: " ✓"; color: var(--good); }
.side-stats { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side-stats div { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px; }
.side-stats span { display: block; color: var(--muted); font-size: 11px; }
.side-stats strong { font-size: 17px; }
.overall-progress { height: 7px; background: #dce7ec; border-radius: 99px; overflow: hidden; margin: 9px 0 15px; }
.overall-progress i { display: block; width: 0; height: 100%; background: var(--accent); transition: width .2s ease; }
.teacher-toggle, .reset-button {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    margin-top: 8px;
    font-weight: 700;
    background: #fff;
    color: var(--ink);
}
.teacher-toggle[aria-pressed="true"] { background: #fff4dd; border-color: #e4bd6b; }
.reset-button { color: var(--bad); }
.safety-note { margin-top: 18px; padding: 12px; border-radius: 12px; background: #fff8e9; border: 1px solid #ecd39b; font-size: 12px; line-height: 1.4; }
.safety-note strong { display: block; color: #8c651c; margin-bottom: 3px; }
.sem-main { padding: 28px; min-width: 0; }
.sem-hero {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
    gap: 20px;
    align-items: start;
    background: linear-gradient(135deg, #fff, #f5fafc);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: 18px;
    padding: 24px;
    margin-bottom: 18px;
}
.eyebrow { margin: 0 0 6px; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; font-size: 12px; font-weight: 900; }
.sem-hero h1 { margin: 0; font-size: clamp(26px, 3vw, 40px); }
.sem-hero p:not(.eyebrow) { margin: 8px 0 0; max-width: 850px; color: var(--muted); line-height: 1.55; }
.result-box { min-width: 180px; border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 14px; }
.result-box span, .result-box small { display: block; color: var(--muted); }
.result-box strong { display: block; margin: 4px 0; font-size: 18px; }
.result-box.is-good { border-color: #9bcbb2; background: #f1fbf6; }
.teacher-panel { background: #fff9e9; border: 1px solid #ead19a; border-radius: 16px; padding: 18px; margin-bottom: 18px; }
.teacher-kicker { color: #8e671a; text-transform: uppercase; font-size: 12px; font-weight: 900; letter-spacing: .06em; }
.teacher-grid { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 18px; }
.teacher-grid h3 { margin: 12px 0 6px; font-size: 15px; }
.teacher-grid p, .teacher-grid li { font-size: 13px; line-height: 1.45; }
.module-panel { background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 18px; padding: 22px; }
.panel-head { display: flex; align-items: start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.panel-number { color: var(--accent); font-weight: 900; font-size: 12px; }
.panel-head h2 { margin: 3px 0 5px; font-size: 23px; }
.panel-head p { margin: 0; color: var(--muted); line-height: 1.45; }
.formula-chip { background: var(--accent-soft); color: #155374; border: 1px solid #bad6e5; border-radius: 999px; padding: 9px 12px; font-weight: 800; white-space: nowrap; }
.lab-grid { display: grid; grid-template-columns: minmax(270px, 360px) minmax(0, 1fr); gap: 18px; }
.control-card, .graph-card { border: 1px solid var(--line); border-radius: 14px; background: #fbfdfe; padding: 16px; min-width: 0; }
.control-card label { display: block; margin-bottom: 16px; font-size: 13px; font-weight: 700; }
.control-card input[type="range"] { width: 100%; margin: 8px 0 4px; accent-color: var(--accent); }
.control-card select { width: 100%; margin-top: 7px; border: 1px solid #bdcdd6; border-radius: 9px; padding: 9px; background: #fff; color: var(--ink); }
.control-card label > strong { display: block; color: var(--accent); margin-top: 2px; }
.meters { display: grid; gap: 8px; margin-top: 8px; }
.meters.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.meters div { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px; min-width: 0; }
.meters span { color: var(--muted); font-size: 11px; display: block; }
.meters strong { display: block; margin-top: 3px; font-size: 14px; overflow-wrap: anywhere; }
.observation { margin-top: 12px; padding: 11px 12px; border-left: 4px solid var(--accent); background: #eef7fb; border-radius: 8px; font-size: 13px; line-height: 1.45; min-height: 58px; }
.observation.warn { border-left-color: var(--warn); background: #fff8e8; }
.action-btn { width: 100%; border: 0; border-radius: 10px; padding: 11px; background: var(--accent); color: #fff; font-weight: 800; margin: 2px 0 8px; }
.action-btn.secondary { background: #e8eef2; color: var(--ink); border: 1px solid var(--line); }
.graph-card { display: flex; flex-direction: column; min-height: 430px; }
.graph-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.graph-head span { color: var(--muted); font-size: 12px; }
.graph-card canvas { width: 100%; height: 360px; display: block; border-radius: 10px; background: #fff; border: 1px solid #d9e3e8; }
.control-question { margin-top: 18px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 20px; display: grid; grid-template-columns: minmax(220px,.8fr) 1.3fr; gap: 18px; align-items: start; }
.control-question h2 { margin: 0 0 6px; font-size: 20px; }
.control-question p { margin: 0; color: var(--muted); line-height: 1.45; }
.question-options { display: grid; gap: 8px; }
.question-options button { text-align: left; border: 1px solid var(--line); border-radius: 10px; background: #fbfdfe; color: var(--ink); padding: 10px 12px; }
.question-options button:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.question-options button.is-correct { border-color: #6caf8a; background: #ebf8f1; }
.question-options button.is-wrong { border-color: #d99a9a; background: #fff0f0; }
.question-options button:disabled { cursor: default; opacity: .82; }
.question-feedback { grid-column: 2; min-height: 22px; font-size: 13px; font-weight: 700; }
.question-feedback.good { color: var(--good); }
.question-feedback.bad { color: var(--bad); }
.model-note { margin-top: 18px; padding: 16px 18px; border-radius: 14px; border: 1px dashed #b6c8d2; color: var(--muted); font-size: 13px; line-height: 1.5; }
.model-note strong { color: var(--ink); }
.model-note p { margin: 5px 0 0; }
@media (max-width: 1100px) {
    .sem-shell { grid-template-columns: 230px minmax(0,1fr); }
    .lab-grid { grid-template-columns: 1fr; }
    .teacher-grid { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
    .app-header { grid-template-columns: 1fr auto; }
    .course-title { grid-column: 1 / -1; grid-row: 2; text-align: left; font-size: 12px; }
    .user-chip { display: none; }
    .sem-shell { display: block; }
    .sem-sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .module-list { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .sem-main { padding: 16px; }
    .sem-hero { grid-template-columns: 1fr; }
    .result-box { min-width: 0; }
    .panel-head { display: block; }
    .formula-chip { display: inline-block; margin-top: 10px; }
    .control-question { grid-template-columns: 1fr; }
    .question-feedback { grid-column: 1; }
}
@media (max-width: 520px) {
    .module-list { grid-template-columns: 1fr; }
    .meters.three { grid-template-columns: 1fr; }
    .graph-card canvas { height: 300px; }
}


.detailed-diode-lab-link {
    display: block;
    margin: 12px 0 16px;
    padding: 11px 12px;
    border: 1px solid #9acfe8;
    border-radius: 10px;
    background: #eef9ff;
    color: #155e75;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.4;
    text-decoration: none;
}

.detailed-diode-lab-link:hover {
    border-color: #38bdf8;
    background: #e0f7ff;
    color: #0e7490;
}
