/* ============================================================
   חשמל ובקרים — עיצוב
   ============================================================ */

:root {
  --bg: #f3f6fa;
  --bg2: #e9eef6;
  --surface: #ffffff;
  --ink: #0d1726;
  --ink2: #24344a;
  --muted: #64748b;
  --faint: #93a1b5;
  --line: #e2e8f0;
  --line2: #cfd8e3;
  --brand: #0b5fff;
  --brand-dk: #0a3fb0;
  --brand-lt: #e8f0ff;
  --green: #0f9d6e;
  --green-lt: #e6f7f1;
  --amber: #e08a00;
  --amber-lt: #fff6e5;
  --red: #d92d20;
  --red-lt: #fdecea;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(13, 23, 38, .05), 0 8px 24px -12px rgba(13, 23, 38, .18);
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Assistant", "Arial Hebrew", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
button { font: inherit; color: inherit; }
svg { display: block; }

/* ---------------- shell ---------------- */
.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-inline-start: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.brand-mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--brand), #0746c4);
  display: grid; place-items: center;
  color: #fff;
  flex: none;
  box-shadow: 0 4px 12px -4px rgba(11, 95, 255, .6);
}

.brand-txt strong { display: block; font-size: 15px; }
.brand-txt span { font-size: 11.5px; color: var(--muted); letter-spacing: .02em; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink2);
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  border: 0;
  background: none;
  width: 100%;
  text-align: start;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--bg); }
.nav-link.active { background: var(--brand-lt); color: var(--brand-dk); font-weight: 600; }
.nav-link .ic { width: 18px; height: 18px; opacity: .75; flex: none; }
.nav-link.active .ic { opacity: 1; }

.side-foot {
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--faint);
  line-height: 1.5;
}

.main { min-width: 0; padding: 26px 30px 90px; }
.wrap { max-width: 940px; margin: 0 auto; }

/* ---------------- generic ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: 11px;
  border: 1px solid var(--line2);
  background: var(--surface);
  color: var(--ink2);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .08s, box-shadow .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 6px 16px -8px rgba(11, 95, 255, .8);
}
.btn-primary:hover { background: var(--brand-dk); border-color: var(--brand-dk); }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { background: #0b855c; }
.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.btn-red:hover { background: #b81f14; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg2);
  color: var(--ink2);
  white-space: nowrap;
}
.pill-blue { background: var(--brand-lt); color: var(--brand-dk); }
.pill-green { background: var(--green-lt); color: #0a6b4b; }
.pill-amber { background: var(--amber-lt); color: #8a5300; }
.pill-red { background: var(--red-lt); color: #a11d12; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.hide { display: none !important; }

/* ---------------- header ---------------- */
.page-head { margin-bottom: 20px; }
.crumb {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
}
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--brand); }
.page-head h1 { font-size: 27px; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); font-size: 14.5px; margin-top: 6px; }

/* ---------------- home ---------------- */
.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #0b1a33 0%, #0e2c5c 55%, #0b4bb8 100%);
  border-radius: 20px;
  color: #fff;
  padding: 28px 26px;
  margin-bottom: 18px;
}
.hero::after {
  content: "";
  position: absolute;
  inset-inline-end: -70px;
  top: -80px;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(90, 170, 255, .35), transparent 68%);
  pointer-events: none;
}
.hero h2 { font-size: 25px; margin-bottom: 8px; }
.hero p { color: #c5d7f2; font-size: 14.5px; max-width: 52ch; }
.hero-art {
  position: absolute;
  inset-inline-end: 26px;
  top: 50%;
  transform: translateY(-50%);
  width: 260px;
  height: 260px;
  color: #cfe2ff;
  opacity: .38;
  pointer-events: none;
}
.hero-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero .btn { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .25); color: #fff; }
.hero .btn:hover { background: rgba(255, 255, 255, .18); }
.hero .btn-primary { background: #fff; color: #0b2a5e; border-color: #fff; }
.hero .btn-primary:hover { background: #eaf1ff; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 22px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.stat .v small { font-size: 13px; font-weight: 600; color: var(--faint); }

.sec-title {
  display: flex; align-items: baseline; gap: 10px;
  margin: 26px 0 12px;
}
.sec-title h3 { font-size: 17px; }
.sec-title span { font-size: 12.5px; color: var(--muted); }

.mod-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.mod-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.lesson-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lesson-card {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  cursor: pointer;
  text-align: start;
  transition: border-color .15s, transform .1s, box-shadow .15s;
  align-items: flex-start;
}
.lesson-card:hover { border-color: var(--line2); box-shadow: var(--shadow); transform: translateY(-1px); }
.lesson-card .num {
  width: 30px; height: 30px; flex: none;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  background: var(--bg2); color: var(--muted);
}
.lesson-card.done .num { background: var(--green-lt); color: var(--green); }
.lesson-card .t { font-size: 14.5px; font-weight: 600; line-height: 1.35; }
.lesson-card .m { font-size: 12px; color: var(--muted); margin-top: 3px; }
.lesson-card .go { margin-inline-start: auto; color: var(--faint); flex: none; }

/* ---------------- lesson ---------------- */
.lesson-body { padding: 26px 30px 30px; }
.lesson-body h2 {
  font-size: 20px;
  margin: 26px 0 10px;
  padding-inline-start: 12px;
  border-inline-start: 3px solid var(--brand);
  line-height: 1.35;
}
.lesson-body h2:first-child { margin-top: 0; }
.lesson-body p { margin: 0 0 12px; color: var(--ink2); font-size: 16px; line-height: 1.75; }
.lesson-body ul, .lesson-body ol { margin: 0 0 14px; padding-inline-start: 22px; color: var(--ink2); }
.lesson-body li { margin-bottom: 7px; line-height: 1.7; }

.formula {
  background: #0e1b2f;
  color: #e8f0ff;
  border-radius: 12px;
  padding: 16px 18px;
  margin: 0 0 16px;
  direction: ltr;
  text-align: left;
  font-family: var(--mono);
  font-size: 15.5px;
  line-height: 2;
  overflow-x: auto;
}
.formula .f-line { white-space: pre; }
.formula .f-note {
  direction: inherit;
  text-align: start;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 12.5px;
  color: #9db4d4;
  margin-top: 8px;
  line-height: 1.6;
  white-space: normal;
}

.note {
  display: flex;
  gap: 11px;
  padding: 13px 15px;
  border-radius: 12px;
  margin: 0 0 16px;
  font-size: 14.5px;
  line-height: 1.65;
  border: 1px solid transparent;
}
.note .ni { flex: none; font-size: 15px; line-height: 1.5; }
.note-tip { background: var(--green-lt); border-color: #bde9d8; color: #0a5c41; }
.note-warn { background: var(--amber-lt); border-color: #f7dfb0; color: #7a4a00; }
.note-info { background: var(--brand-lt); border-color: #c9dcff; color: #103a80; }

.tbl-wrap { overflow-x: auto; margin: 0 0 16px; border: 1px solid var(--line); border-radius: 12px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 480px; }
table.tbl th {
  background: #f7f9fc;
  text-align: start;
  padding: 10px 13px;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.tbl td { padding: 10px 13px; border-bottom: 1px solid #eef2f7; color: var(--ink2); vertical-align: top; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tr:hover td { background: #fbfcfe; }

.lesson-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 30px;
  border-top: 1px solid var(--line);
  background: #fbfcfe;
  border-radius: 0 0 var(--radius) var(--radius);
  flex-wrap: wrap;
}

/* ---------------- widget shell ---------------- */
.widget {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfe;
  margin: 0 0 18px;
  overflow: hidden;
}
.widget-head {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 15px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink2);
}
.widget-head .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-lt); }
.widget-body { padding: 16px; }

/* ---------------- controls ---------------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field .val { float: left; font-family: var(--mono); font-size: 13px; color: var(--brand-dk); font-weight: 700; direction: ltr; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  cursor: pointer;
  direction: ltr;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand) var(--p, 50%), #dde5ef var(--p, 50%), #dde5ef 100%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand);
  box-shadow: 0 2px 6px rgba(11, 95, 255, .35);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: #dde5ef; }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--brand); }
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 3px solid var(--brand);
}

input[type="number"], input[type="text"], select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line2);
  border-radius: 10px;
  background: var(--surface);
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input[type="number"]:focus, input[type="text"]:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(11, 95, 255, .13);
}
input[type="number"] { font-family: var(--mono); }

.seg {
  display: inline-flex;
  background: var(--bg2);
  border-radius: 11px;
  padding: 3px;
  gap: 2px;
  flex-wrap: wrap;
}
.seg button {
  border: 0;
  background: none;
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.seg button.on { background: var(--surface); color: var(--brand-dk); box-shadow: 0 1px 3px rgba(13, 23, 38, .12); }

/* ---------------- results ---------------- */
.res-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.res {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 13px;
}
.res .k { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.res .v { font-family: var(--mono); font-size: 19px; font-weight: 700; color: var(--ink); margin-top: 1px; direction: ltr; text-align: right; }
.res .v u { text-decoration: none; font-size: 12px; color: var(--faint); font-weight: 600; margin-inline-start: 2px; }

/* ---------------- circuit svg ---------------- */
.schem { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px; margin-bottom: 14px; display: flex; justify-content: center; }
.schem svg { width: 100%; max-width: 470px; height: auto; }

/* ---------------- ladder ---------------- */
.ladder { display: flex; flex-direction: column; gap: 10px; }
.rung {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}
.rung-top {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 11px;
  border-bottom: 1px solid #eef2f7;
  background: #fafcff;
  font-size: 12.5px;
  color: var(--muted);
}
.rung-top .idx { font-weight: 700; color: var(--ink2); }
.rung-diagram { padding: 10px 8px 4px; background: #fff; overflow-x: auto; display: flex; justify-content: center; }
.rung-diagram svg { min-width: 320px; }
.rung-edit { padding: 9px 11px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: #fbfcfe; direction: ltr; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line2);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.chip:hover { border-color: var(--brand); }
.chip.nc { background: #fff6f5; border-color: #f6c9c5; }
.chip .x { color: var(--faint); font-family: sans-serif; font-size: 13px; }
.chip .x:hover { color: var(--red); }
.chip-add {
  padding: 4px 9px; border-radius: 8px; border: 1px dashed var(--line2);
  background: none; font-size: 12px; color: var(--muted); cursor: pointer;
}
.chip-add:hover { border-color: var(--brand); color: var(--brand); }

.io-panel { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.io-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 11px;
  border-radius: 9px;
  border: 1px solid var(--line2);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 12.5px;
  cursor: pointer;
  transition: all .12s;
}
.io-btn .led {
  width: 9px; height: 9px; border-radius: 50%;
  background: #cbd5e1;
  transition: background .1s, box-shadow .1s;
}
.io-btn.on { border-color: #9ee0c6; background: var(--green-lt); }
.io-btn.on .led { background: var(--green); box-shadow: 0 0 0 3px rgba(15, 157, 110, .18); }
.io-btn.q.on { border-color: #a8c8ff; background: var(--brand-lt); }
.io-btn.q.on .led { background: var(--brand); box-shadow: 0 0 0 3px rgba(11, 95, 255, .18); }

/* ---------------- star-delta ---------------- */
.sd-lamps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.lamp-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px;
  text-align: center;
  background: var(--surface);
  transition: all .2s;
}
.lamp-card .nm { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--ink2); }
.lamp-card .st { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.lamp-card .bulb {
  width: 34px; height: 34px; margin: 0 auto 7px;
  border-radius: 50%;
  background: #e8eef6;
  border: 2px solid #d5dfeb;
  transition: all .2s;
}
.lamp-card.on { border-color: #9ee0c6; background: var(--green-lt); }
.lamp-card.on .bulb { background: var(--green); border-color: #0b855c; box-shadow: 0 0 14px rgba(15, 157, 110, .55); }
.lamp-card.on .st { color: #0a6b4b; font-weight: 600; }

.motor-bar {
  height: 10px; border-radius: 6px; background: #e8eef6; overflow: hidden; margin: 6px 0 4px;
}
.motor-bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #0f9d6e, #0b5fff); transition: width .3s; }

.log {
  font-family: var(--mono);
  font-size: 12px;
  background: #0e1b2f;
  color: #b9cde8;
  border-radius: 11px;
  padding: 11px 13px;
  height: 118px;
  overflow-y: auto;
  direction: rtl;
  text-align: right;
  line-height: 1.8;
}
.log div { animation: fadein .25s; }
.log .t { color: #6b8bb5; }
@keyframes fadein { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

/* ---------------- drills ---------------- */
.drill-card { padding: 22px; }
.drill-q {
  font-size: 17px;
  line-height: 1.7;
  margin-bottom: 6px;
  color: var(--ink);
}
.drill-q b { font-family: var(--mono); color: var(--brand-dk); }
.drill-hint { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.answer-row { display: flex; gap: 9px; align-items: stretch; flex-wrap: wrap; }
.answer-row input { flex: 1 1 140px; font-size: 17px; padding: 12px 14px; }
.unit { display: grid; place-items: center; padding: 0 4px; color: var(--muted); font-family: var(--mono); font-size: 14px; }
.verdict { margin-top: 14px; padding: 13px 15px; border-radius: 11px; font-size: 14.5px; line-height: 1.7; }
.verdict.ok { background: var(--green-lt); color: #0a5c41; border: 1px solid #bde9d8; }
.verdict.no { background: var(--red-lt); color: #8f1b11; border: 1px solid #f5c6c2; }
.verdict .steps {
  margin-top: 8px; font-family: var(--mono); font-size: 13px;
  direction: ltr; text-align: left; color: #0b3f7a;
  background: rgba(255, 255, 255, .65); border-radius: 8px; padding: 9px 11px;
  line-height: 1.9; overflow-x: auto;
}

/* ---------------- quiz ---------------- */
.quiz-wrap { max-width: 720px; margin: 0 auto; }
.q-progress { height: 6px; background: var(--bg2); border-radius: 4px; overflow: hidden; margin-bottom: 20px; }
.q-progress i { display: block; height: 100%; background: var(--brand); transition: width .3s; }
.q-card { padding: 24px; }
.q-text { font-size: 19px; line-height: 1.6; font-weight: 600; margin-bottom: 20px; }
.q-opt {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 9px;
  border: 1px solid var(--line2);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  text-align: start;
  font-size: 15.5px;
  transition: border-color .12s, background .12s, transform .08s;
}
.q-opt:hover:not(:disabled) { border-color: var(--brand); background: #f7faff; }
.q-opt:active:not(:disabled) { transform: scale(.995); }
.q-opt .key {
  width: 26px; height: 26px; flex: none;
  border-radius: 7px; display: grid; place-items: center;
  background: var(--bg2); font-size: 12.5px; font-weight: 700; color: var(--muted);
}
.q-opt.correct { border-color: var(--green); background: var(--green-lt); }
.q-opt.correct .key { background: var(--green); color: #fff; }
.q-opt.wrong { border-color: var(--red); background: var(--red-lt); }
.q-opt.wrong .key { background: var(--red); color: #fff; }
.q-opt:disabled { cursor: default; }
.q-why { margin-top: 14px; padding: 13px 15px; border-radius: 11px; background: var(--brand-lt); color: #103a80; font-size: 14.5px; line-height: 1.7; }

.result-hero { text-align: center; padding: 36px 24px; }
.result-hero .big { font-size: 56px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.result-hero .lbl { color: var(--muted); margin-top: 6px; }

/* ---------------- glossary ---------------- */
.gloss-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gloss {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.gloss .he { font-weight: 700; font-size: 15px; }
.gloss .en { font-family: var(--mono); font-size: 12px; color: var(--brand-dk); margin-top: 1px; }
.gloss .df { font-size: 13.5px; color: var(--muted); line-height: 1.6; margin-top: 6px; }

/* ---------------- drawings ---------------- */
.drawings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.draw-card {
  display: flex; flex-direction: column; align-items: stretch; text-align: start;
  padding: 0; overflow: hidden; font-family: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.draw-card:hover { border-color: var(--brand); box-shadow: 0 8px 22px rgba(13, 23, 38, .09); transform: translateY(-1px); }
.draw-thumb { display: block; height: 136px; padding: 8px; background: #fbfcfe; border-bottom: 1px solid var(--line); }
.draw-thumb svg { width: 100%; height: 100%; pointer-events: none; }
.draw-meta { display: flex; flex-direction: column; gap: 5px; padding: 12px 14px 14px; }
.draw-meta .pill { align-self: flex-start; }
.draw-t { font-size: 14.5px; font-weight: 700; color: var(--ink); }

.draw-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 12px; align-items: start; }
.draw-layout.solo { grid-template-columns: minmax(0, 1fr); }
.draw-layout > * { min-width: 0; }
.draw-stage-wrap { padding: 10px; }
.drawing-stage { background: #fff; border-radius: 10px; }
.drawing-stage svg { display: block; width: 100%; height: auto; }
.drawing-stage svg text { unicode-bidi: plaintext; }
.drawing-stage .part { cursor: pointer; }
.drawing-stage .part:hover > * { filter: drop-shadow(0 0 3px rgba(11, 95, 255, .55)); }
.drawing-stage.focusing .part { opacity: .25; transition: opacity .15s; }
.drawing-stage.focusing .part.hl { opacity: 1; }
.drawing-stage .part.hl > * { filter: drop-shadow(0 0 4px rgba(11, 95, 255, .7)); }
.draw-hint { display: none; }
.part-info {
  display: flex; flex-direction: column; gap: 4px; margin-top: 10px; min-height: 66px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; font-size: 13.5px; line-height: 1.65;
}
.part-info b { color: var(--brand-dk); font-size: 14px; }
.part-list { display: flex; flex-direction: column; gap: 5px; }
.part-list button {
  display: flex; align-items: center; gap: 8px; text-align: start; font-family: inherit;
  border: 1px solid transparent; background: var(--bg2); border-radius: 8px;
  padding: 7px 10px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.part-list button:hover { border-color: var(--brand); color: var(--brand-dk); }
.part-list button.on { background: var(--brand-lt); border-color: var(--brand); color: var(--brand-dk); }
.part-list .dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .55; }
.check-card { padding: 16px 18px; margin-bottom: 10px; }
.chk-q { font-size: 15.5px; font-weight: 600; line-height: 1.55; }
.chk-opts { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.chk-opts .q-opt { width: 100%; }
.chk-why { margin-top: 11px; background: var(--bg2); border-radius: 9px; padding: 10px 12px; font-size: 13.5px; line-height: 1.65; color: var(--muted); }

/* ---------------- ladder tasks ---------------- */
.ladder-tasks { margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--line); }
.tasks-head { display: flex; align-items: baseline; gap: 10px; }
.tasks-head h3 { font-size: 15.5px; margin: 0; }
.task { margin-top: 9px; padding: 11px 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
.task-top { display: flex; align-items: flex-start; gap: 9px; }
.task-n {
  flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-lt); color: var(--brand-dk); font-size: 12px; font-weight: 700;
}
.task-txt { min-width: 0; font-size: 13.5px; line-height: 1.5; }
.task-txt b { font-size: 14px; }
.task-res { margin-top: 9px; border-radius: 9px; padding: 9px 11px; font-size: 13px; line-height: 1.55; }
.task-res.ok { background: var(--green-lt); border: 1px solid #bde9d8; color: #0a5c41; }
.task-res.no { background: var(--red-lt); border: 1px solid #f5c6c2; color: #8f1b11; }
.task-sol { margin-top: 9px; background: var(--bg2); border-radius: 9px; padding: 10px 12px; }
.task-rung { padding: 2px 0; font-size: 12.5px; }

.topic-select {
  width: auto; max-width: 100%; padding: 7px 12px; border-radius: 9px;
  font-size: 13.5px; font-weight: 600;
}

/* ---------------- dark theme ---------------- */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --bg2: #121c2c;
  --surface: #16202f;
  --ink: #e8eef8;
  --ink2: #cbd7e6;
  --muted: #9aabc2;
  --faint: #8fa1b8;
  --line: #243247;
  --line2: #2f4058;
  --brand: #5b8cff;
  --brand-dk: #a8c2ff;
  --brand-lt: #1b2b4a;
  --green: #2fbf8d;
  --green-lt: #123527;
  --amber: #f0a83c;
  --amber-lt: #3a2b12;
  --red: #ff6b5e;
  --red-lt: #3a1a19;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px -14px rgba(0, 0, 0, .7);
}

html[data-theme="dark"] .btn:hover { background: var(--bg2); }
html[data-theme="dark"] table.tbl tr:hover td { background: var(--bg2); }
html[data-theme="dark"] .tabbar { background: rgba(16, 24, 38, .96); }
html[data-theme="dark"] .formula { background: var(--bg2); }
html[data-theme="dark"] .note-tip { background: #0f2f26; border-color: #1c4a3b; color: #9fe6cb; }
html[data-theme="dark"] .note-warn { background: #33260f; border-color: #5a441c; color: #f3c987; }
html[data-theme="dark"] .note-info { background: #14243d; border-color: #24405f; color: #a9c8ef; }
html[data-theme="dark"] .pill-blue { background: #1b2b4a; color: #a9c4ff; }
html[data-theme="dark"] .pill-green { background: #123527; color: #7fe0bb; }
html[data-theme="dark"] .pill-amber { background: #3a2b12; color: #f3c987; }
html[data-theme="dark"] .pill-red { background: #3a1a19; color: #ffa49b; }
html[data-theme="dark"] .verdict.ok { background: #0f2f26; color: #9fe6cb; border-color: #1c4a3b; }
html[data-theme="dark"] .verdict.no { background: #3a1a19; color: #ffb0a8; border-color: #5a2a26; }
html[data-theme="dark"] .chip.nc { background: #2a1a1a; border-color: #5a2a26; }
html[data-theme="dark"] .task-res.ok { background: #0f2f26; border-color: #1c4a3b; color: #9fe6cb; }
html[data-theme="dark"] .task-res.no { background: #3a1a19; border-color: #5a2a26; color: #ffb0a8; }
html[data-theme="dark"] .q-opt.correct { background: #0f2f26; }
html[data-theme="dark"] .q-opt.wrong { background: #3a1a19; }
html[data-theme="dark"] .drawing-stage,
html[data-theme="dark"] .draw-thumb,
html[data-theme="dark"] .rung-diagram,
html[data-theme="dark"] .rung-edit { color-scheme: light; }

/* ---------------- shell additions ---------------- */
.side-sep { height: 1px; background: var(--line); margin: 10px 8px; }
.side-btn { background: none; border: 0; font: inherit; cursor: pointer; text-align: start; width: 100%; }

.lang-row { display: flex; align-items: center; gap: 8px; }
.lang-row .lang-select { width: auto; margin-inline-start: auto; padding: 3px 6px; font-size: 11.5px; }
.lang-item { display: flex; align-items: center; gap: 9px; }
.lang-item .lang-select { width: auto; margin-inline-start: auto; padding: 4px 6px; font-size: 12px; }
.lang-select { width: auto; padding: 6px 9px; font-size: 13px; }

.content-note {
  background: var(--amber-lt); border: 1px solid #f0d9a8; color: #7a4a00;
  border-radius: 10px; padding: 9px 13px; font-size: 13px; margin: 0 0 16px;
}
html[data-theme="dark"] .content-note { border-color: #5a441c; color: #f3c987; }

.app-foot {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 6px; margin: 26px 0 8px; padding-top: 14px;
  border-top: 1px solid var(--line); color: var(--faint);
  font-size: 12.5px; text-align: center;
}
.app-foot b { color: var(--muted); font-weight: 700; }
.app-foot a { color: var(--muted); font-weight: 600; text-decoration: none; }
.app-foot a:hover { color: var(--brand-dk); text-decoration: underline; }
.app-foot .sep { opacity: .5; }

.page-actions { display: flex; gap: 6px; margin: 8px 0 2px; }
.icon-btn {
  display: inline-flex; align-items: center; gap: 5px; font: inherit; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--line2); background: var(--surface); color: var(--muted);
  border-radius: 9px; padding: 5px 9px; cursor: pointer;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand-dk); }
.icon-btn.on { border-color: var(--brand); background: var(--brand-lt); color: var(--brand-dk); }

.stats { grid-template-columns: repeat(4, 1fr); }

.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 14px 0 24px; }
.quick {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: 13px;
  padding: 13px 14px; cursor: pointer; font: inherit; color: var(--ink);
  transition: border-color .15s, transform .15s;
}
.quick:hover { border-color: var(--brand); transform: translateY(-1px); }
.quick .q-ic {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: var(--brand-lt); color: var(--brand-dk); margin-bottom: 4px;
}
.quick .q-t { font-weight: 700; font-size: 14px; }
.quick .q-s { font-size: 11.5px; color: var(--muted); }

.home-search { display: flex; gap: 8px; margin-top: 16px; max-width: 540px; }
.home-search input { flex: 1; }

.why-link {
  display: inline-block; margin-top: 8px; font-size: 13px; font-weight: 600;
  color: var(--brand-dk); text-decoration: none;
}
.why-link:hover { text-decoration: underline; }

/* ---------------- diagnostic cases ---------------- */
.cases-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.case-card {
  display: flex; flex-direction: column; gap: 6px; text-align: start; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 15px 16px;
  cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.case-card:hover { border-color: var(--brand); box-shadow: 0 8px 22px rgba(13, 23, 38, .09); transform: translateY(-1px); }
.case-card.done { border-color: #bde9d8; }
html[data-theme="dark"] .case-card.done { border-color: #1c4a3b; }
.case-top { display: flex; align-items: center; gap: 8px; }
.case-t { font-weight: 700; font-size: 16px; }
.case-s { font-size: 13.5px; color: var(--muted); }
.case-f { margin-top: 3px; font-size: 12px; color: var(--faint); }

.case-body { padding: 22px; }
.case-brief { background: var(--bg2); border-radius: 10px; padding: 12px 14px; font-size: 14px; color: var(--ink2); margin-bottom: 18px; }
.case-node { font-size: 16px; line-height: 1.7; }
.case-q { margin: 16px 0 10px; font-weight: 700; }
.case-opts { display: flex; flex-direction: column; gap: 8px; }
.case-opt {
  display: flex; gap: 10px; align-items: flex-start; text-align: start; width: 100%;
  background: var(--surface); border: 1px solid var(--line2); border-radius: 10px;
  padding: 11px 13px; font: inherit; font-size: 14.5px; line-height: 1.5; cursor: pointer; color: var(--ink);
}
.case-opt:hover:not(:disabled) { border-color: var(--brand); background: var(--bg2); }
.case-opt.tried { opacity: .45; cursor: default; }
.case-opt .case-mark { flex: none; width: 8px; height: 8px; margin-top: 8px; border-radius: 50%; background: var(--line2); }
.case-fb { margin-top: 14px; border-radius: 10px; padding: 11px 13px; font-size: 14px; line-height: 1.6; }
.case-fb.ok { background: var(--green-lt); border: 1px solid #bde9d8; color: #0a5c41; }
.case-fb.bad { background: var(--red-lt); border: 1px solid #f5c6c2; color: #8f1b11; }
html[data-theme="dark"] .case-fb.ok { border-color: #1c4a3b; color: #8fe6c6; }
html[data-theme="dark"] .case-fb.bad { border-color: #5a2a26; color: #ffb0a8; }
.case-take { background: var(--green-lt); border: 1px solid #bde9d8; border-radius: 12px; padding: 14px 16px; font-size: 15px; line-height: 1.7; color: #0a5c41; }
html[data-theme="dark"] .case-take { border-color: #1c4a3b; color: #a6ecd3; }
.case-h { font-size: 17px; margin: 20px 0 8px; }

/* ---------------- calculators ---------------- */
.calcs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.calc { padding: 16px; }
.calc-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.calc-head b { font-size: 15px; }
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 10px; }
.calc-field { display: flex; flex-direction: column; gap: 3px; }
.calc-label { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.calc-control { display: flex; align-items: center; gap: 6px; }
.calc-control input, .calc-control select { padding: 7px 9px; font-size: 14px; }
.calc-unit { font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.calc-formula { font-size: 11.5px; color: var(--muted); direction: ltr; text-align: right; margin-bottom: 8px; }
.calc-out { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.calc-res { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 13px; }
.calc-res .k { color: var(--muted); }
.calc-res .v { font-family: var(--mono); font-weight: 700; font-size: 15px; direction: ltr; }
.calc-res .v u { text-decoration: none; font-size: 11.5px; color: var(--faint); margin-inline-start: 3px; font-weight: 600; }
.calc-verdict { margin-top: 6px; font-size: 12.5px; font-weight: 600; border-radius: 8px; padding: 7px 10px; }
.calc-verdict.ok { background: var(--green-lt); color: #0a5c41; }
.calc-verdict.warn { background: var(--amber-lt); color: #7a4a00; }
.calc-verdict.bad { background: var(--red-lt); color: #8f1b11; }
html[data-theme="dark"] .calc-verdict.ok { color: #8fe6c6; }
html[data-theme="dark"] .calc-verdict.warn { color: #f3c987; }
html[data-theme="dark"] .calc-verdict.bad { color: #ffb0a8; }
.conv-list { display: flex; flex-direction: column; gap: 10px; }
.conv-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: end; }
.conv-eq { color: var(--faint); padding-bottom: 8px; font-size: 14px; }

/* ---------------- reference & checklists ---------------- */
.seg-wrap { display: flex; width: 100%; }
.ref-card { padding: 20px 22px; }
.checklist { padding: 16px 18px; margin-bottom: 10px; }
.check-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.checklist.done { border-color: #bde9d8; }
html[data-theme="dark"] .checklist.done { border-color: #1c4a3b; }
.check-items { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.check-item { display: flex; gap: 9px; align-items: flex-start; padding: 7px 9px; border-radius: 8px; cursor: pointer; font-size: 14px; line-height: 1.5; }
.check-item:hover { background: var(--bg2); }
.check-item input { margin: 4px 0 0; width: 16px; height: 16px; accent-color: var(--green); flex: none; }
.check-item.on span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }

/* ---------------- guided path ---------------- */
.place-card { padding: 18px; margin-bottom: 14px; border-color: var(--brand); }
.place-card .btn { white-space: normal; text-align: start; max-width: 100%; line-height: 1.35; }
.place-ic { font-size: 24px; line-height: 1.2; }
.path-list { display: flex; flex-direction: column; gap: 10px; }
.path-card { padding: 16px 18px; }
.path-head { display: flex; align-items: center; gap: 8px; }
.path-head .mod-dot { width: 9px; height: 9px; border-radius: 50%; }
.path-lessons { display: flex; flex-direction: column; gap: 3px; }
.path-lesson { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 8px; text-decoration: none; color: var(--ink2); font-size: 13.5px; }
.path-lesson:hover { background: var(--bg2); }
.path-lesson.done { color: var(--muted); }
.pl-n { flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--bg2); color: var(--muted); display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.path-lesson.done .pl-n { background: var(--green-lt); color: var(--green); }
.path-lesson .small { margin-inline-start: auto; }

/* ---------------- search ---------------- */
.search-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.search-hit { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-decoration: none; color: var(--ink); }
.search-hit:hover { border-color: var(--brand); }
.hit-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--brand-lt); color: var(--brand-dk); flex: none; }
.hit-txt { display: flex; flex-direction: column; min-width: 0; }
.hit-txt b { font-size: 14px; }
.hit-txt .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hit-go { margin-inline-start: auto; color: var(--faint); }

/* ---------------- fault finder ---------------- */
.fault-bar { display: flex; gap: 11px; align-items: flex-start; padding: 13px 15px; margin-bottom: 12px; border-radius: 12px; background: var(--amber-lt); border: 1px solid #f0d9a8; color: #7a4a00; }
.fault-bar.done { background: var(--green-lt); border-color: #bde9d8; color: #0a5c41; }
html[data-theme="dark"] .fault-bar { border-color: #5a441c; color: #f3c987; }
html[data-theme="dark"] .fault-bar.done { border-color: #1c4a3b; color: #8fe6c6; }
.fault-ic { font-size: 20px; line-height: 1.2; }
.fault-try { margin-top: 6px; font-size: 12.5px; font-weight: 600; }
.shake { animation: shake .4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ---------------- mobile sheet ---------------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(6, 12, 22, .45); opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 70; }
.sheet {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 71; background: var(--surface);
  border-radius: 18px 18px 0 0; padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .22s ease;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .25); max-height: 82vh; overflow-y: auto;
}
body.sheet-open .sheet { transform: translateY(0); }
body.sheet-open .sheet-backdrop { opacity: 1; pointer-events: auto; }
.sheet-handle { width: 42px; height: 4px; border-radius: 3px; background: var(--line2); margin: 0 auto 12px; }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-item {
  display: flex; align-items: center; gap: 9px; padding: 11px 12px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--ink);
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; text-align: start;
}
.sheet-item:hover { border-color: var(--brand); }
.sheet-close { margin: 12px auto 0; display: block; }

.toast {
  position: fixed; bottom: 92px; left: 50%; transform: translate(-50%, 12px); z-index: 90;
  background: #101b2c; color: #fff; padding: 9px 16px; border-radius: 999px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.settings-card { padding: 16px 18px; margin-bottom: 10px; }

input[type="search"] {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line2); border-radius: 10px;
  background: var(--surface); font: inherit; font-size: 15px; color: var(--ink); outline: none;
}
input[type="search"]:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11, 95, 255, .13); }

/* ---------------- cabinet builder ---------------- */
.cab-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.cab-enc { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.cab-enc select { width: auto; padding: 7px 10px; font-size: 13.5px; }

.cab-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
.cab-layout > * { min-width: 0; }
.cab-main { min-width: 0; }

.cab-rail-block { margin-bottom: 10px; }
.cab-rail-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.cab-over { color: var(--red); font-weight: 700; }

.cab-rail {
  --cab-mod: 26px;
  display: flex;
  gap: 4px;
  min-height: 74px;
  padding: 7px;
  overflow-x: auto;
  background:
    repeating-linear-gradient(90deg, #e6ebf2 0 10px, #dde4ed 10px 20px),
    var(--bg2);
  border: 1px solid var(--line2);
  border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
.cab-rail.on { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11, 95, 255, .12); }
.cab-rail.over { border-color: var(--red); }
.cab-rail.drop { border-color: var(--green); box-shadow: 0 0 0 3px rgba(15, 157, 110, .18); }
.cab-empty { font-size: 12px; color: var(--faint); align-self: center; padding: 0 8px; }

.cab-comp {
  flex: none;
  width: calc(var(--cab-mod) * var(--w));
  height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid #8fa3b8;
  border-radius: 4px;
  background: #fff;
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: outline-color .12s, transform .12s;
}
.cab-comp.kind-power { background: #eef4ff; }
.cab-comp.kind-control { background: #f6f8fc; }
.cab-comp.kind-protect { background: #fff8ec; }
.cab-comp.kind-misc { background: #f1f5f9; }
.cab-comp:hover { transform: translateY(-1px); }
.cab-comp.sel { outline: 2px solid var(--brand); outline-offset: 1px; }
.cab-comp .cc-tag { font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: #0f172a; white-space: nowrap; }
.cab-comp .cc-name { font-size: 8.5px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.cab-selbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  background: var(--brand-lt); border: 1px solid var(--brand);
  border-radius: 10px; padding: 9px 12px; margin: 10px 0; font-size: 13px;
}

.cab-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

.cab-palette, .cab-bom { padding: 14px; margin-bottom: 10px; }
.cab-cat { font-size: 11.5px; font-weight: 700; color: var(--faint); margin: 10px 0 5px; }
.cab-cat:first-of-type { margin-top: 0; }
.cab-pal { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.cab-pal-item {
  display: flex; align-items: center; gap: 7px; text-align: start;
  padding: 6px 7px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit; cursor: grab;
}
.cab-pal-item:hover { border-color: var(--brand); background: var(--bg2); }
.cab-pal-item:active { cursor: grabbing; }
.cab-pal-item .pal-w {
  flex: none; width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center;
  background: var(--brand-lt); color: var(--brand-dk); font-family: var(--mono); font-size: 10.5px; font-weight: 700;
}
.cab-pal-item .pal-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.cab-pal-item .pal-txt b { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cab-pal-item .pal-txt .small { font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-var { flex: none; font-size: 9px; font-weight: 700; color: var(--brand-dk); background: var(--brand-lt); border-radius: 4px; padding: 1px 4px; }

.cab-pick-backdrop { position: fixed; inset: 0; background: rgba(6, 12, 22, .45); z-index: 96; }
.cab-pick {
  position: fixed; z-index: 97; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 28px)); max-height: 80vh; overflow-y: auto;
  background: var(--surface); border-radius: 14px; padding: 14px 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.cab-pick-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cab-pick-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cab-var {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 9px 11px; border: 1px solid var(--line2); border-radius: 9px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 13px;
  cursor: pointer; text-align: start;
}
.cab-var:hover { border-color: var(--brand); background: var(--bg2); }

.cab-bom b { font-size: 14px; }
.bom-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.bom-row { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.bom-tags { flex: 1; min-width: 0; font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bom-n { color: var(--muted); }
.bom-w { font-size: 11px; color: var(--faint); }
.bom-total { display: flex; justify-content: space-between; margin-top: 9px; font-size: 13px; }

.cab-checks { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.cab-score {
  display: flex; align-items: baseline; gap: 9px; border-radius: 10px; padding: 10px 13px;
  font-size: 14px; font-weight: 600;
}
.cab-score b { font-size: 20px; }
.cab-score.ok { background: var(--green-lt); color: #0a5c41; }
.cab-score.warn { background: var(--amber-lt); color: #7a4a00; }
.cab-score.bad { background: var(--red-lt); color: #8f1b11; }
html[data-theme="dark"] .cab-score.ok { color: #9fe6cb; }
html[data-theme="dark"] .cab-score.warn { color: #f3c987; }
html[data-theme="dark"] .cab-score.bad { color: #ffb0a8; }
.cab-check { display: flex; gap: 9px; align-items: flex-start; padding: 8px 11px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; }
.cab-check.ok { border-color: #bde9d8; }
.cab-check.no { border-color: #f5c6c2; }
html[data-theme="dark"] .cab-check.ok { border-color: #1c4a3b; }
html[data-theme="dark"] .cab-check.no { border-color: #5a2a26; }
.cab-check .cc-ic { flex: none; font-weight: 700; }
.cab-check.ok .cc-ic { color: var(--green); }
.cab-check.no .cc-ic { color: var(--red); }
.cab-check .cc-txt { display: flex; flex-direction: column; gap: 1px; }
.cab-check .cc-txt .small { color: var(--muted); }

.cab-view { padding: 12px; }
.cab-view-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.cab-svg { background: #eef2f8; border-radius: 10px; overflow: hidden; }
.cab-svg svg { display: block; width: 100%; height: auto; }

.cab3d-wrap { position: relative; background: #eef2f8; border-radius: 10px; overflow: hidden; }
.cab3d { display: block; width: 100%; height: 460px; touch-action: none; cursor: grab; }
.cab3d:active { cursor: grabbing; }
.cab3d-hint { position: absolute; inset-inline-start: 12px; bottom: 8px; background: rgba(255,255,255,.7); border-radius: 6px; padding: 2px 8px; }

.cab-shop { margin-top: 12px; padding: 16px 18px; }
.cab-shop-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.shop-sec { margin-top: 12px; }
.shop-sec h4 { margin: 0 0 6px; font-size: 14px; color: var(--brand-dk); }
.shop-table { display: flex; flex-direction: column; gap: 2px; }
.shop-row { display: grid; grid-template-columns: 1fr 70px 1.1fr; gap: 10px; align-items: baseline; padding: 5px 4px; border-bottom: 1px dashed var(--line); font-size: 13px; }
.shop-row:last-child { border-bottom: 0; }
.shop-name { font-weight: 600; }
.shop-qty { font-weight: 700; text-align: start; }
.shop-note { font-size: 11.5px; }
.cab-view-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }

/* ---------------- exam mode ---------------- */
.exam-facts { display: flex; flex-wrap: wrap; gap: 6px; }
.resume-card {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: var(--brand-lt); border: 1px solid var(--brand);
  border-radius: 12px; padding: 11px 14px; margin-bottom: 14px; font-size: 13.5px;
}
.resume-card b { font-size: 14.5px; color: var(--brand-dk); }
.resume-card.expired { background: var(--amber-lt); border-color: #f0d9a8; }
.resume-card.expired b { color: #7a4a00; }
html[data-theme="dark"] .resume-card.expired { border-color: #5a441c; }
.exam-timer { font-family: var(--mono); font-size: 14px; font-weight: 700; color: var(--ink2); background: var(--bg2); border-radius: 8px; padding: 3px 9px; }
.exam-timer.low { background: var(--red-lt); color: var(--red); }
.q-opt.sel { border-color: var(--brand); background: var(--brand-lt); box-shadow: 0 0 0 2px rgba(11, 95, 255, .12); }
html[data-theme="dark"] .q-opt.sel { background: #1b2b4a; }
.exam-topic { display: grid; grid-template-columns: 110px 1fr 44px; gap: 10px; align-items: center; margin: 8px 0; font-size: 13px; }
.exam-topic-name { color: var(--ink2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exam-bar { height: 7px; background: var(--bg2); border-radius: 4px; overflow: hidden; }
.exam-bar i { display: block; height: 100%; border-radius: 4px; }

/* ---------------- hours log ---------------- */
.hour-form { padding: 16px 18px; margin-bottom: 12px; }
.hour-summary { padding: 16px 18px; margin-bottom: 12px; }
.hour-cats { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12.5px; }
.hour-cat { display: flex; gap: 6px; color: var(--muted); }
.hour-cat .mono { color: var(--ink2); font-weight: 700; }
.hour-list { padding: 6px 10px; }
.hour-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px dashed var(--line); font-size: 13px; }
.hour-row:last-child { border-bottom: 0; }
.hour-date { color: var(--muted); font-size: 12px; flex: none; }
.hour-cat-name { font-weight: 600; white-space: nowrap; }
.hour-note { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hour-dur { font-weight: 700; }
.hour-del { padding: 2px 7px; font-size: 12px; }

/* ---------------- badges ---------------- */
.home-badges { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: -8px 0 24px; }
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px;
  background: var(--bg2); color: var(--faint); font-size: 11.5px; font-weight: 600;
  border: 1px solid transparent;
}
.badge.on { background: var(--amber-lt); color: #7a4a00; border-color: #f0d9a8; }
html[data-theme="dark"] .badge.on { color: #f3c987; border-color: #5a441c; }
.badge .b-ic { font-size: 13px; }

/* ---------------- about / legal ---------------- */
.about-card { padding: 22px 24px; font-size: 15px; line-height: 1.75; }
.about-card h2 { font-size: 17px; margin: 20px 0 8px; }
.about-card h2:first-child { margin-top: 0; }
.about-card p { margin: 0 0 10px; color: var(--ink2); }
.about-card ul { margin: 0 0 12px; padding-inline-start: 20px; color: var(--ink2); }
.about-card li { margin-bottom: 5px; }
.about-card a { color: var(--brand-dk); font-weight: 600; }

/* ---------------- update bar & a11y ---------------- */
.update-bar {
  position: fixed; inset-inline: 16px; bottom: 88px; z-index: 95;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--brand-dk); color: #fff; padding: 11px 14px;
  border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  font-size: 13.5px;
}
.update-bar .btn { background: #fff; color: #0a3fb0; border-color: #fff; }
@media (min-width: 901px) {
  .update-bar { inset-inline: auto; right: 50%; transform: translateX(50%); bottom: 20px; }
}

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------------- mobile ---------------- */
.tabbar { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 16px 14px 92px; }
  .page-head h1 { font-size: 22px; }
  .hero { padding: 22px 18px; border-radius: 16px; }
  .hero h2 { font-size: 20px; }
  .hero-art { display: none; }
  .stats { gap: 8px; }
  .stat { padding: 10px 11px; border-radius: 11px; }
  .stat .v { font-size: 19px; }
  .lesson-grid { grid-template-columns: 1fr; }
  .lesson-body { padding: 18px 16px 22px; }
  .lesson-body h2 { font-size: 17.5px; margin: 22px 0 9px; }
  .lesson-body p { font-size: 15.5px; }
  .lesson-foot { padding: 14px 16px; }
  .res-grid { grid-template-columns: 1fr 1fr; }
  .gloss-grid { grid-template-columns: 1fr; }
  .drawings-grid { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .quick-grid { grid-template-columns: 1fr 1fr; }
  .cases-grid { grid-template-columns: 1fr; }
  .calcs { grid-template-columns: 1fr; }
  .cab-layout { display: flex; flex-direction: column; align-items: stretch; }
  .cab-side { order: -1; }
  .cab-bom { display: none; }
  .cab-palette { padding: 10px 12px; margin-bottom: 10px; }
  .cab-pal { display: flex; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .cab-pal-item { flex: 0 0 auto; min-width: 120px; }
  .cab-cat { display: none; }
  .cab-pick-list { grid-template-columns: 1fr; }
  .cab-rail { --cab-mod: 22px; }
  .cab-pal { grid-template-columns: 1fr 1fr; }
  .cab-view { padding: 8px; }
  .cab-view-head .btn { flex: 1; }
  .cab-svg { overflow-x: auto; direction: ltr; }
  .cab-svg svg { min-width: 560px; }
  .cab3d { height: 330px; }
  .shop-row { grid-template-columns: 1fr 52px; }
  .shop-note { grid-column: 1 / -1; padding-inline-start: 0; }
  .case-body { padding: 16px; }
  .ref-card { padding: 16px; }
  .draw-layout { grid-template-columns: 1fr; }
  .drawing-stage { overflow-x: auto; direction: ltr; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .drawing-stage svg { min-width: 560px; }
  .draw-hint { display: block; margin-top: 7px; font-size: 12px; }
  .draw-thumb { height: 104px; padding: 5px; }
  .draw-meta { padding: 10px 11px 12px; gap: 4px; }
  .draw-t { font-size: 13px; }
  .draw-meta .small { font-size: 11.5px; line-height: 1.4; }
  .check-card { padding: 14px; }
  .task-top { flex-wrap: wrap; }
  .task-top .spacer { display: none; }
  .task-top .btn { flex: 1; }
  .sec-title {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 8px;
    row-gap: 3px;
    align-items: center;
  }
  .sec-title h3 { grid-column: 2; font-size: 16px; }
  .sec-title > span:not(.mod-dot) { grid-column: 2; font-size: 12px; line-height: 1.45; }
  .sec-title .mod-dot { grid-row: 1 / span 2; align-self: start; margin-top: 7px; }
  .formula { font-size: 13.5px; padding: 13px 14px; }
  .q-card { padding: 18px 15px; }
  .q-text { font-size: 17px; }
  .q-opt { font-size: 14.5px; padding: 12px 13px; }
  .sd-lamps { gap: 6px; }
  .lamp-card { padding: 8px 6px; }
  .lamp-card .bulb { width: 26px; height: 26px; }
  .tabbar {
    display: flex;
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 50;
  }
  .tabbar button {
    flex: 1;
    border: 0;
    background: none;
    padding: 6px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--faint);
    cursor: pointer;
    border-radius: 9px;
  }
  .tabbar button.active { color: var(--brand); background: var(--brand-lt); }
  .tabbar svg { width: 20px; height: 20px; }
  .widget-body { padding: 12px; }
}

@media (max-width: 380px) {
  .tabbar button { font-size: 9.5px; }
  .tabbar svg { width: 18px; height: 18px; }
  .drawings-grid { grid-template-columns: 1fr; }
  .draw-thumb { height: 132px; }
}

@media print {
  .side, .tabbar, .hero-actions, .btn { display: none !important; }
  .no-print, .page-actions, .lesson-foot, .draw-side, .part-info, .home-search,
  .case-opts, .case-fb, .sheet, .sheet-backdrop, .toast { display: none !important; }
  .cab-shop-head .btn, .cab3d-hint, .cab-view-foot { display: none !important; }
  .cab3d { height: 420px; }
  .draw-layout { grid-template-columns: 1fr; }
  .drawing-stage { overflow: visible !important; }
  .drawing-stage svg { min-width: 0 !important; width: 100% !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ddd; }
}

/* ---------------- certificates ---------------- */
.cert-cta {
  background: linear-gradient(135deg, var(--brand-lt), var(--surface) 68%);
  border: 1px solid var(--brand);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 18px;
}
.cert-cta b { color: var(--brand-dk); font-size: 15.5px; }
html[data-theme="dark"] .cert-cta { background: linear-gradient(135deg, #10284d, #0f1a2c 68%); }
html[data-theme="dark"] .cert-cta b { color: #bcd3ff; }

.cert-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }

.certificate {
  max-width: 760px;
  margin: 0 auto 28px;
  padding: 0;
  background: transparent;
  color: #172033;
}
.cert-paper {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 1020px;
  background: #fff;
  border: 7px solid #0d2a4a;
  border-radius: 4px;
  box-shadow: 0 30px 70px -38px rgba(13, 42, 74, .55);
}

/* top colour band */
.cert-band-top {
  position: relative;
  flex: 0 0 auto;
  height: 92px;
  overflow: hidden;
  background: linear-gradient(100deg, #0b5fff, #0a3fb0);
}
.cert-band-top::before {
  content: "";
  position: absolute;
  left: -6%;
  right: -6%;
  bottom: 0;
  height: 27px;
  background: linear-gradient(90deg, #1f9d63, #43c187);
  clip-path: polygon(0 65%, 100% 8%, 100% 100%, 0 100%);
}
.cert-band-top::after {
  content: "";
  position: absolute;
  left: -6%;
  right: -6%;
  bottom: 23px;
  height: 4px;
  background: rgba(255, 255, 255, .6);
  transform: rotate(-1.2deg);
}
.cert-logo {
  position: absolute;
  top: 52px;
  left: 50%;
  z-index: 3;
  width: 92px;
  height: 92px;
  padding: 0;
  border: 4px solid #0b5fff;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 8px 20px -8px rgba(13, 42, 74, .45);
  transform: translateX(-50%);
}
.cert-logo svg { width: 100%; height: 100%; display: block; }

.cert-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 56px 46px 0;
}

.cert-head { text-align: center; }
.cert-brand {
  padding-left: .3em;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: .3em;
  color: #0b5fff;
}
.cert-inst {
  margin-top: 2px;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #0d2a4a;
}

.cert-kicker {
  margin-top: 22px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: #1f9d63;
}
.certificate h2 {
  margin: 3px 0 0;
  text-align: center;
  font-family: "Times New Roman", David, "FrankRuhl Libre", serif;
  font-size: clamp(38px, 5.2vw, 54px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: .02em;
  color: #0b5fff;
}
.cert-sub {
  margin-top: 2px;
  text-align: center;
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #0d2a4a;
}

.cert-awarded {
  margin-top: 22px;
  text-align: center;
  font-size: 12px;
  color: #64748b;
}
.cert-name {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 2px auto 0;
  padding: 0 24px 6px;
  text-align: center;
  font-family: "Times New Roman", David, "FrankRuhl Libre", serif;
  font-size: clamp(32px, 4.4vw, 46px);
  font-weight: 700;
  line-height: 1.15;
  color: #0d2a4a;
  border-bottom: 2px solid #0b5fff;
}
.cert-id-line {
  margin-top: 8px;
  text-align: center;
  font-size: 11px;
  color: #64748b;
}
.cert-id-line b { color: #0d2a4a; }

.cert-body {
  margin-top: 14px;
  text-align: center;
  font-size: 13.5px;
  color: #334155;
}
.cert-program {
  margin-top: 6px;
  text-align: center;
  font-size: 13px;
  color: #0d2a4a;
}
.cert-program b { padding-bottom: 1px; color: #0b5fff; border-bottom: 1px solid #0b5fff; }

.cert-score-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  margin: 10px auto 0;
  padding: 5px 18px;
  border: 1px solid #cfe0ff;
  border-radius: 999px;
  background: #eef5ff;
}
.cert-score-label { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: #0a3fb0; }
.cert-score {
  font-family: "Times New Roman", serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  color: #0b5fff;
}
.cert-score small { font-size: 13px; }
.cert-honor {
  padding-inline-start: 8px;
  border-inline-start: 1px solid #bfd4ff;
  font-size: 9.5px;
  font-weight: 700;
  color: #1f9d63;
}

.cert-topics { width: min(560px, 100%); margin: 16px auto 0; }
.cert-topics-title {
  margin-bottom: 6px;
  text-align: center;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: #1f9d63;
}
.cert-topics ul {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 26px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.cert-topics li {
  position: relative;
  padding-inline-start: 14px;
  font-size: 11.5px;
  color: #334155;
}
.cert-topics li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: .58em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #1f9d63;
}

.cert-date-line {
  margin-top: 14px;
  text-align: center;
  font-size: 10.5px;
  color: #64748b;
}

.cert-signatures {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: auto;
  padding-top: 34px;
  direction: ltr;
}
.cert-sign { width: 210px; flex: 0 1 auto; text-align: center; }
.cert-sign-script {
  margin-bottom: -2px;
  font-family: "Segoe Script", "Snell Roundhand", "Bradley Hand", "Brush Script MT", cursive;
  font-size: 29px;
  font-style: italic;
  font-weight: 600;
  line-height: 1;
  color: #0b5fff;
  white-space: nowrap;
  transform: rotate(-4deg);
}
.cert-sign-script-alt { color: #1f9d63; }
.cert-line { width: 190px; max-width: 100%; margin: 0 auto 4px; border-top: 1px solid #9fb3c8; }
.cert-sign-name { font-size: 12.5px; font-weight: 700; line-height: 1.3; color: #0d2a4a; }
.cert-sign-role { margin-top: 1px; font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: #64748b; }

.cert-brand-row { display: flex; flex-direction: column; align-items: center; margin-top: 18px; }
.cert-seal { width: 104px; flex: 0 0 auto; }
.cert-seal-svg { display: block; width: 100%; height: auto; overflow: visible; }
.seal-arc-text { fill: #ffffff; font-family: "Segoe UI", Arial, sans-serif; font-size: 7.6px; font-weight: 700; letter-spacing: .55px; }
.seal-cert { fill: #ffffff; font-family: "Times New Roman", serif; font-size: 10.5px; font-weight: 700; letter-spacing: 1.2px; }
.seal-prof { fill: #bfe8d2; font-family: "Segoe UI", Arial, sans-serif; font-size: 6.6px; letter-spacing: 1.1px; }
.seal-est { fill: #7fd3a8; font-family: "Segoe UI", Arial, sans-serif; font-size: 5.6px; letter-spacing: .8px; }

.cert-note {
  max-width: 560px;
  margin: 8px auto 10px;
  text-align: center;
  font-size: 9px;
  line-height: 1.4;
  color: #8393a7;
}

.cert-band-bottom {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  overflow: hidden;
  background: #0d2a4a;
  color: #fff;
  font-size: 9.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.cert-band-bottom::before {
  content: "";
  position: absolute;
  left: -6%;
  right: -6%;
  top: -16px;
  height: 22px;
  background: linear-gradient(90deg, #1f9d63, #43c187);
  clip-path: polygon(0 100%, 100% 0, 100% 100%, 0 100%);
}
.cert-bottom-bolt { position: relative; z-index: 1; color: #8be0b0; }
.cert-bottom-bolt svg { display: block; width: 13px; height: 13px; }
.cert-band-bottom span:last-child { position: relative; z-index: 1; }

.cert-history { display: grid; gap: 8px; }
.cert-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font-size: 13.5px;
}
.cert-row:hover { border-color: var(--brand); background: var(--brand-lt); }
html[data-theme="dark"] .cert-row:hover { background: #10284d; }

@media (max-width: 640px) {
  .cert-paper { min-height: 0; border-width: 5px; }
  .cert-band-top { height: 76px; }
  .cert-band-top::before { height: 23px; }
  .cert-band-top::after { bottom: 19px; }
  .cert-logo { top: 42px; width: 76px; height: 76px; border-width: 3px; }
  .cert-main { padding: 46px 16px 0; }
  .cert-brand { font-size: 24px; }
  .cert-inst { font-size: 8.5px; }
  .cert-kicker { margin-top: 16px; font-size: 9px; }
  .certificate h2 { font-size: 34px; }
  .cert-sub { font-size: 9.5px; }
  .cert-awarded { margin-top: 16px; }
  .cert-name { padding: 0 8px 5px; }
  .cert-topics ul { grid-template-columns: 1fr; gap: 3px; }
  .cert-date-line { margin-top: 12px; }
  .cert-signatures { flex-direction: column; align-items: center; gap: 18px; padding-top: 24px; }
  .cert-sign { width: 220px; }
  .cert-brand-row { margin-top: 14px; }
  .cert-seal { width: 94px; }
  .cert-band-bottom { height: 48px; font-size: 8.5px; }
  .cert-row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; }
  .cert-row .mono { grid-column: 1 / -1; font-size: 11px; }
}

@media print {
  @page { size: A4 portrait; margin: 6mm; }
  body.printing-cert { background: #fff !important; }
  body.printing-cert .side,
  body.printing-cert .tabbar,
  body.printing-cert .app-foot,
  body.printing-cert .toast { display: none !important; }
  body.printing-cert .shell { display: block !important; min-height: 0; }
  body.printing-cert .main { padding: 0 !important; margin: 0 !important; }
  body.printing-cert #view { padding: 0 !important; }
  body.printing-cert .wrap { max-width: none !important; padding: 0 !important; margin: 0 !important; }
  body.printing-cert .page-head,
  body.printing-cert .cert-actions { display: none !important; }
  body.printing-cert .certificate {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    break-inside: avoid;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body.printing-cert .cert-paper {
    min-height: 283mm;
    border-width: 2.6mm;
    border-radius: 0;
    box-shadow: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body.printing-cert .cert-band-top { height: 22mm; }
  body.printing-cert .cert-logo { top: 11mm; width: 21mm; height: 21mm; border-width: 1mm; }
  body.printing-cert .cert-main { padding: 13mm 14mm 0; }
  body.printing-cert .cert-brand { font-size: 7.5mm; }
  body.printing-cert .cert-inst { font-size: 2.6mm; }
  body.printing-cert .cert-kicker { margin-top: 5mm; font-size: 2.2mm; }
  body.printing-cert .certificate h2 { font-size: 13mm; }
  body.printing-cert .cert-sub { font-size: 2.5mm; }
  body.printing-cert .cert-awarded { margin-top: 5mm; font-size: 2.8mm; }
  body.printing-cert .cert-name { font-size: 11mm; padding: 0 6mm 1.4mm; }
  body.printing-cert .cert-id-line { margin-top: 2mm; font-size: 2.4mm; }
  body.printing-cert .cert-body { margin-top: 3.5mm; font-size: 3.1mm; }
  body.printing-cert .cert-program { margin-top: 1.5mm; font-size: 3mm; }
  body.printing-cert .cert-score-wrap { margin-top: 2.5mm; padding: 1mm 4mm; }
  body.printing-cert .cert-score-label { font-size: 2.1mm; }
  body.printing-cert .cert-score { font-size: 5.5mm; }
  body.printing-cert .cert-topics { margin-top: 4mm; }
  body.printing-cert .cert-topics-title { margin-bottom: 1.5mm; font-size: 2.1mm; }
  body.printing-cert .cert-topics li { padding-inline-start: 3mm; font-size: 2.6mm; }
  body.printing-cert .cert-date-line { margin-top: 3mm; font-size: 2.4mm; }
  body.printing-cert .cert-signatures { gap: 14mm; padding-top: 8mm; }
  body.printing-cert .cert-sign { width: 48mm; }
  body.printing-cert .cert-sign-script { font-size: 7mm; }
  body.printing-cert .cert-line { width: 44mm; }
  body.printing-cert .cert-sign-name { font-size: 2.9mm; }
  body.printing-cert .cert-sign-role { font-size: 2.1mm; }
  body.printing-cert .cert-brand-row { margin-top: 4mm; }
  body.printing-cert .cert-seal { width: 24mm; }
  body.printing-cert .cert-note { margin-top: 2mm; font-size: 2mm; }
  body.printing-cert .cert-band-bottom { height: 12mm; font-size: 2.2mm; }
}

/* ---------------- study hub ---------------- */
.study-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.study-daily { grid-column: 1 / -1; }
.study-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.study-kicker { font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--brand); }
.study-big { margin-top: 6px; font-size: 44px; font-weight: 800; line-height: 1; color: var(--brand); }
.study-daily .daily-q { margin-top: 12px; font-size: 18px; font-weight: 700; line-height: 1.45; }
.daily-opts { display: grid; gap: 8px; margin-top: 12px; }
.daily-opts .q-opt { width: 100%; }
.daily-result {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px;
  padding: 8px 14px; border-radius: 10px; font-size: 14px; font-weight: 700;
}
.daily-result.ok { background: var(--green-lt); color: #0a6b4b; }
.daily-result.bad { background: var(--red-lt); color: var(--red); }
.weak-list { display: grid; gap: 6px; margin-top: 10px; }
.weak-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); font-size: 13px;
}
.weak-row:hover { border-color: var(--brand); background: var(--brand-lt); }
.weak-row > span:first-child { flex: 1; }
.weak-row .go { color: var(--faint); }
.study-empty {
  margin-top: 10px; padding: 14px; border: 1px dashed var(--line2);
  border-radius: 10px; color: var(--muted); font-size: 13px;
}
.study-stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.study-stat-grid > div {
  padding: 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); text-align: center;
}
.study-stat-grid b { display: block; font-size: 22px; line-height: 1.2; color: var(--ink); }
.study-stat-grid span { display: block; font-size: 11px; color: var(--muted); }

/* ---------------- flashcards ---------------- */
.flash-top { display: flex; align-items: center; margin-bottom: 8px; }
.flash-stage { perspective: 1200px; cursor: pointer; outline: none; }
.flash-stage:focus-visible .flash-inner { box-shadow: 0 0 0 3px var(--brand-lt); border-radius: 16px; }
.flash-inner {
  position: relative; min-height: 300px;
  transform-style: preserve-3d; transition: transform .45s ease;
}
.flash-stage.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: 26px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.flash-back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, var(--brand-lt), var(--surface) 70%);
}
.flash-tag { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.flash-term { margin: 10px 0; font-size: clamp(30px, 5vw, 46px); font-weight: 800; line-height: 1.15; color: var(--brand-dk); }
.flash-en { font-size: 18px; font-weight: 700; color: var(--brand); }
.flash-def { max-width: 560px; margin-top: 10px; font-size: 15px; line-height: 1.6; color: var(--ink2); }
.flash-hint { margin-top: 16px; font-size: 11px; color: var(--faint); }
.flash-foot { display: flex; justify-content: center; gap: 10px; margin-top: 12px; }
.flash-summary { padding: 30px 20px; text-align: center; }
.flash-done {
  display: grid; place-items: center; width: 52px; height: 52px;
  margin: 0 auto 8px; border-radius: 50%; background: var(--green-lt);
  color: var(--green); font-size: 26px; font-weight: 800;
}

@media (max-width: 720px) {
  .study-grid { grid-template-columns: 1fr; }
  .study-daily { grid-column: auto; }
  .study-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flash-inner { min-height: 260px; }
  .flash-face { padding: 18px 14px; }
  .flash-def { font-size: 14px; }
}

/* ---------------- lesson notes & bookmarks ---------------- */
.lesson-notes {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.lesson-notes-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.lesson-notes textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  line-height: 1.55;
  color: var(--ink);
  background: var(--surface);
}
.lesson-notes textarea:focus { outline: 2px solid var(--brand-lt); border-color: var(--brand); }

.book-list { display: grid; gap: 8px; }
.book-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.book-row-main { flex: 1; min-width: 0; }
.book-title { font-weight: 700; color: var(--ink); }
.book-title:hover { color: var(--brand); }
.book-note { margin-top: 4px; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.book-row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

@media (max-width: 640px) {
  .book-row { flex-direction: column; align-items: stretch; }
  .book-row-actions { justify-content: flex-start; }
}

/* ---------------- certificate QR & verification ---------------- */
.cert-verify {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  margin: 8px auto 0;
  padding: 8px 12px;
  border: 1px solid #d8e2ef;
  border-radius: 10px;
  background: #fff;
}
.cert-qr { width: 82px; flex: 0 0 auto; }
.cert-qr svg { display: block; width: 100%; height: auto; }
.cert-verify-text { display: flex; flex-direction: column; gap: 2px; font-size: 9.5px; line-height: 1.35; color: #64748b; }
.cert-verify-text b { font-size: 11px; color: #0d2a4a; }
.cert-verify-text .mono { font-size: 9px; }

.verify-card { max-width: 620px; margin: 0 auto; padding: 26px; text-align: center; }
.verify-ok {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 15px; border-radius: 999px;
  background: var(--green-lt); color: #0a6b4b;
  font-size: 13px; font-weight: 700;
}
.verify-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.verify-grid > div { padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.verify-grid span { display: block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.verify-grid b { display: block; font-size: 14px; color: var(--ink); }

@media (max-width: 640px) {
  .verify-grid { grid-template-columns: 1fr; }
  .cert-verify { flex-direction: column; text-align: center; }
}

body.printing-cert .cert-verify {
  max-width: none;
  margin: 3mm auto 0;
  padding: 0;
  border: 0;
  gap: 4mm;
  background: transparent;
}
body.printing-cert .cert-qr { width: 20mm; }
body.printing-cert .cert-verify-text { font-size: 2.1mm; }
body.printing-cert .cert-verify-text b { font-size: 2.4mm; }
body.printing-cert .cert-verify-text .mono { font-size: 2mm; }

/* ---------------- exam configuration ---------------- */
.exam-config { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.exam-config .field { margin: 0; }
.exam-config select { width: 100%; }
@media (max-width: 640px) {
  .exam-config { grid-template-columns: 1fr; }
}

/* ---------------- panel schedule ---------------- */
.panel-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.panel-kpi { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.panel-kpi span { display: block; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.panel-kpi b { display: block; margin-top: 2px; font-size: 16px; color: var(--ink); }
.panel-kpi b.ok { color: var(--green); }
.panel-kpi b.warn { color: var(--amber); }
.panel-kpi b.bad { color: var(--red); }
.panel-table-card { padding: 0; overflow: hidden; }
.panel-print-head { padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.panel-table-wrap { overflow-x: auto; }
.panel-table { width: 100%; min-width: 760px; border-collapse: collapse; }
.panel-table th {
  padding: 8px 8px; background: var(--bg); border-bottom: 1px solid var(--line);
  text-align: start; font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
}
.panel-table td { padding: 6px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.panel-num { font-size: 11px; color: var(--muted); }
.panel-in {
  width: 100%; padding: 6px 7px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 12.5px;
}
.panel-in:focus { outline: 2px solid var(--brand-lt); border-color: var(--brand); }
.panel-del { color: var(--red); border-color: transparent; }
.panel-warn-card { margin-top: 12px; }

@media (max-width: 900px) {
  .panel-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media print {
  .panel-head-card, .panel-warn-card { display: none !important; }
  .panel-table-card { border: 0 !important; }
  .panel-table { min-width: 0 !important; }
  .panel-in { border: 0 !important; padding: 0 !important; background: transparent !important; }
  .panel-del { display: none !important; }
  .panel-summary { grid-template-columns: repeat(5, 1fr) !important; gap: 4px !important; }
  .panel-kpi { border: 1px solid #ddd !important; background: #fff !important; }
}

/* ---------------- inspection report ---------------- */
.report-card { padding: 0; overflow: hidden; }
.report-print-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.report-print-head b { color: var(--ink); }
.report-print-head span { color: var(--muted); font-size: 12px; }
.report-table td { vertical-align: top; }
.report-notes { padding: 14px; border-top: 1px solid var(--line); }
.report-notes textarea {
  width: 100%; min-height: 90px; resize: vertical; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font: inherit; color: var(--ink); background: var(--surface);
}
.report-sign { max-width: 260px; margin: 20px auto 8px; text-align: center; font-size: 11px; color: var(--muted); }
@media print {
  .report-card { border: 0 !important; }
  .report-table .panel-in, .report-table select { border: 0 !important; padding: 0 !important; background: transparent !important; }
  .report-notes { border-top: 1px solid #ddd; }
}

/* ---------------- audio pronunciation ---------------- */
.speak-btn {
  border: 0; background: transparent; color: var(--brand); cursor: pointer;
  padding: 2px 4px; font-size: 14px; line-height: 1; border-radius: 6px;
}
.speak-btn:hover { background: var(--brand-lt); }
.flash-back .speak-btn { margin-top: 12px; font-size: 12.5px; font-weight: 600; }

/* ---------------- profiles ---------------- */
.profile-list { display: grid; gap: 6px; }
.profile-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; }
.profile-row > span:first-child { flex: 1; font-weight: 600; }

@media (max-width: 640px) {
  .calc-grid { grid-template-columns: 1fr !important; }
  .formula { overflow-x: auto; }
}

@media (max-width: 640px) {
  .calc-grid { grid-template-columns: 1fr !important; }
  .formula { overflow-x: auto; }
  table.tbl { min-width: 0; font-size: 12px; }
  table.tbl th, table.tbl td { padding: 7px 6px; }
}

@media (max-width: 640px) {
  .lesson-foot { flex-wrap: wrap; }
  .lesson-foot .btn { max-width: 100%; white-space: normal; text-align: center; }
}

/* ---------------- RCD test log ---------------- */
.rcd-card { padding: 0; overflow: hidden; }
@media print {
  .rcd-card { border: 0 !important; }
}

/* ---------------- HMI Builder ---------------- */
.hmi-wrap { max-width: 1180px; }
.hmi-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 14px;
}
.hmi-mode-hint { font-size: 12px; color: var(--muted); max-width: 320px; line-height: 1.4; }
.hmi-scenario { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.hmi-scenario select { padding: 7px 9px; font-size: 13px; }
.hmi-layout {
  display: grid;
  grid-template-columns: 158px minmax(0, 1fr) 272px;
  gap: 12px;
  align-items: start;
}
.hmi-main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.hmi-palette { padding: 12px; position: sticky; top: 16px; }
.hmi-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.hmi-side-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; }
.hmi-side-head b { font-size: 13.5px; }
.hmi-pal-btn {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 9px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink2);
  cursor: pointer; font-size: 13px; font-weight: 600; text-align: start;
  transition: border-color .15s, background .15s;
}
.hmi-pal-btn:hover { border-color: var(--brand); background: var(--brand-lt); }
.hmi-pal-ic { width: 22px; height: 22px; border-radius: 6px; flex: none; background: var(--bg2); border: 1px solid var(--line2); position: relative; overflow: hidden; }
.hmi-pal-label { background: repeating-linear-gradient(180deg, var(--muted) 0 2px, transparent 2px 5px); }
.hmi-pal-button { border-radius: 50%; background: var(--green); border-color: var(--green); box-shadow: inset 0 -2px 0 rgba(0,0,0,.18); }
.hmi-pal-lamp { border-radius: 50%; background: radial-gradient(circle at 35% 30%, #c8ffe8, #20c98a 60%, #0a7d57); border-color: #0a7d57; }
.hmi-pal-switch { background: var(--bg2); }
.hmi-pal-switch::after { content: ""; position: absolute; top: 7px; left: 4px; width: 14px; height: 8px; border-radius: 999px; background: var(--green); }
.hmi-pal-display { background: #07111f; border-color: #26374d; }
.hmi-pal-display::after { content: "88"; position: absolute; inset: 0; display: grid; place-items: center; color: #5ef2c0; font: 700 9px var(--mono); }
.hmi-pal-bar { background: #07111f; border-color: #26374d; }
.hmi-pal-bar::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: 3px; height: 11px; border-radius: 2px; background: linear-gradient(0deg, #0f9d6e, #5ef2c0); }
.hmi-tip { margin-top: 10px; line-height: 1.45; }

.hmi-canvas-shell { padding: 0; overflow: hidden; }
.hmi-canvas-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--bg);
  font-size: 13px;
}
.hmi-runtime-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.hmi-runtime-dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(15,157,110,.18); animation: hmiPulse 1.5s infinite; }
@keyframes hmiPulse { 50% { box-shadow: 0 0 0 6px rgba(15,157,110,.06); } }
.hmi-canvas-scen { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hmi-stage-scroll {
  padding: 14px; overflow-x: auto; overflow-y: hidden;
  background: var(--bg2);
  background-image: radial-gradient(var(--line2) 0.6px, transparent 0.6px);
  background-size: 14px 14px;
}
.hmi-stage {
  position: relative; width: 100%; min-width: 560px; aspect-ratio: 760 / 430;
  border-radius: 12px; overflow: hidden;
  background:
    radial-gradient(circle at 50% -20%, #1c3352 0%, transparent 55%),
    linear-gradient(160deg, #0d1a2b 0%, #07111d 100%);
  border: 1px solid #26374d;
  box-shadow: inset 0 0 40px rgba(0,0,0,.45);
  touch-action: none;
  direction: ltr;
}
.hmi-stage-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #5f7690; font-size: 13px; text-align: center; padding: 20px;
}
.hmi-w {
  position: absolute; border-radius: 8px;
  border: 1px dashed transparent;
  display: flex; align-items: stretch; justify-content: stretch;
  user-select: none; -webkit-user-select: none;
}
.hmi-w.sel { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59,130,246,.25); }
.hmi-w.dragging { opacity: .86; }
.hmi-w.hmi-interactive { cursor: pointer; }
.hmi-w:focus-visible { outline: 2px solid #93c5fd; outline-offset: 3px; }
.hmi-handle {
  position: absolute; top: -10px; left: -10px; z-index: 4;
  width: 19px; height: 19px; border-radius: 5px;
  background: #2563eb; color: #fff; font-size: 11px; line-height: 1;
  display: grid; place-items: center; cursor: grab;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.hmi-resize {
  position: absolute; right: -5px; bottom: -5px; z-index: 4;
  width: 12px; height: 12px; border-radius: 3px;
  background: #2563eb; cursor: nwse-resize;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.hmi-w .hmi-handle, .hmi-w .hmi-resize { opacity: 0; pointer-events: none; transition: opacity .12s; }
.hmi-w:hover .hmi-handle, .hmi-w:hover .hmi-resize,
.hmi-w.sel .hmi-handle, .hmi-w.sel .hmi-resize { opacity: 1; pointer-events: auto; }
.hmi-canvas-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 11.5px; }

/* stage widgets */
.hmi-label {
  align-self: center; width: 100%; text-align: center;
  color: #e7eef7; font-size: clamp(12px, 1.6vw, 20px); font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  direction: inherit;
}
.hmi-btn {
  width: 100%; height: 100%; border-radius: 9px;
  display: grid; place-items: center; padding: 2px 8px;
  color: #fff; font-weight: 700; font-size: clamp(11px, 1.35vw, 15px);
  letter-spacing: .04em; line-height: 1.15; text-align: center;
  background: var(--hmi-c, #0f9d6e);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.22), 0 4px 12px -4px rgba(0,0,0,.6);
  cursor: pointer;
}
.hmi-btn:active { transform: translateY(1px); box-shadow: inset 0 -2px 0 rgba(0,0,0,.22); }
.hc-green { --hmi-c: #0f9d6e; }
.hc-red { --hmi-c: #d92d20; }
.hc-amber { --hmi-c: #e08a00; }
.hc-blue { --hmi-c: #0b5fff; }

.hmi-lamp {
  --lamp: #20c98a; --lamp-soft: rgba(32,201,138,.4);
  width: 100%; height: 100%; border-radius: 12px;
  background: #0d1a29; border: 1px solid #26374d;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  color: #73889f; padding: 6px;
}
.hmi-lamp.hc-red { --lamp: #ff5a4d; --lamp-soft: rgba(255,90,77,.4); }
.hmi-lamp.hc-amber { --lamp: #ffb020; --lamp-soft: rgba(255,176,32,.4); }
.hmi-lamp.hc-blue { --lamp: #4d8dff; --lamp-soft: rgba(77,141,255,.4); }
.hmi-lamp-core {
  width: 40%; aspect-ratio: 1; max-width: 54px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #44576d, #1b2a3d 70%);
  box-shadow: inset 0 0 10px #000;
  transition: background .18s, box-shadow .18s;
}
.hmi-lamp.on { color: #eaf6ff; border-color: var(--lamp); }
.hmi-lamp.on .hmi-lamp-core {
  background: radial-gradient(circle at 35% 30%, #fff, var(--lamp) 58%, #0a3a2b);
  box-shadow: 0 0 16px var(--lamp-soft), 0 0 40px var(--lamp-soft), inset 0 0 6px rgba(255,255,255,.55);
}
.hmi-lamp-label {
  font-size: clamp(9px, 1vw, 11px); font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hmi-switch {
  width: 100%; height: 100%; border-radius: 9px;
  background: #0d1a29; border: 1px solid #26374d;
  display: flex; align-items: center; gap: 8px; padding: 0 10px;
  color: #aebfd2; font-size: clamp(10px, 1.15vw, 13px); font-weight: 600;
  cursor: pointer; overflow: hidden;
}
.hmi-track {
  width: 40px; height: 21px; border-radius: 999px; background: #2a3a50;
  position: relative; flex: none; transition: background .18s;
}
.hmi-track i {
  position: absolute; top: 3px; left: 3px; width: 15px; height: 15px;
  border-radius: 50%; background: #8fa2b8; transition: left .18s, background .18s;
}
.hmi-switch.on .hmi-track { background: var(--green); }
.hmi-switch.on .hmi-track i { left: 22px; background: #fff; }
.hmi-switch.on { color: #dff7ec; border-color: #1d6b52; }
.hmi-switch-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hmi-display {
  width: 100%; height: 100%; border-radius: 9px; border: 1px solid #26374d;
  background: #050d18; padding: 5px 9px; position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center;
}
.hmi-display-label {
  font-size: 9px; color: #6e8aa6; text-transform: uppercase;
  letter-spacing: .08em; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hmi-display-value {
  font-size: clamp(16px, 2.2vw, 27px); font-weight: 700; color: #5ef2c0;
  line-height: 1.1; text-shadow: 0 0 12px rgba(94,242,192,.5);
}
.hmi-display-unit {
  position: absolute; right: 8px; bottom: 5px;
  font-size: 10px; color: #6e8aa6;
}
.hmi-bar {
  width: 100%; height: 100%; border-radius: 9px; border: 1px solid #26374d;
  background: #0b1626; padding: 7px 9px;
  display: flex; flex-direction: column; gap: 4px; overflow: hidden;
}
.hmi-bar-track { flex: 1; background: #12233a; border-radius: 5px; overflow: hidden; position: relative; }
.hmi-bar-track i {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(0deg, #0f9d6e, #5ef2c0);
  border-radius: 5px; transition: height .25s;
}
.hmi-bar-value { font-size: 10.5px; color: #9fb3c8; line-height: 1.2; }
.hmi-bar-value u { text-decoration: none; color: #6e8aa6; }

/* inspector */
.hmi-inspector, .hmi-tags { padding: 12px; }
.hmi-insp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; }
.hmi-insp-body .field { margin-bottom: 9px; }
.hmi-insp-body .field span { display: block; font-size: 10.5px; font-weight: 700; color: var(--muted); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .03em; }
.hmi-insp-body .field input, .hmi-insp-body .field select { width: 100%; padding: 6px 8px; font-size: 13px; border-radius: 7px; }
.hmi-two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hmi-four { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hmi-insp-sub {
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  margin: 10px 0 6px; text-transform: uppercase; letter-spacing: .04em;
}
.hmi-empty { font-size: 12.5px; color: var(--muted); text-align: center; padding: 16px 6px; line-height: 1.5; }

/* tag table */
.hmi-tag-list { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow: auto; }
.hmi-tag-row {
  display: flex; flex-direction: column; gap: 4px;
  padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.hmi-tag-line { display: flex; align-items: center; gap: 4px; min-width: 0; }
.hmi-tag-row input, .hmi-tag-row select {
  min-width: 0; padding: 4px 6px; font-size: 11.5px; border-radius: 6px;
}
.hmi-tag-name { flex: 1; font-weight: 700; }
.hmi-tag-row .hmi-tag-type { width: 90px; flex: none; }
.hmi-tag-row .hmi-tag-value { flex: 1; }
.hmi-tag-row .hmi-tag-unit { width: 46px; flex: none; }
.hmi-tag-row .icon-btn { width: 24px; height: 24px; padding: 0; border-radius: 6px; flex: none; }
.hmi-tag-bool { flex: 1; display: flex; align-items: center; justify-content: center; gap: 3px; font-size: 10px; color: var(--muted); }
.hmi-tag-bool input { width: 14px; height: 14px; accent-color: var(--green); }

/* live tags */
.hmi-live { padding: 12px; }
.hmi-live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(15,157,110,.15); }
.hmi-live-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.hmi-live-tag {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 9px; font-size: 12px;
}
.hmi-live-name { font-family: var(--mono); color: var(--muted); font-size: 11.5px; }
.hmi-live-num { font-weight: 700; color: var(--ink2); }
.hmi-live-num u { text-decoration: none; font-size: 10px; color: var(--faint); }
.hmi-live-bool {
  border: 1px solid var(--line2); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 1px 8px; font-size: 10.5px; font-weight: 700; cursor: pointer;
}
.hmi-live-bool.on { background: var(--green-lt); border-color: #bde9d8; color: #0a6b4b; }

@media (max-width: 1180px) {
  .hmi-layout { grid-template-columns: minmax(0, 1fr); }
  .hmi-palette {
    grid-column: 1 / -1; position: static;
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  }
  .hmi-palette .hmi-side-head { width: 100%; margin-bottom: 0; }
  .hmi-pal-btn { width: auto; margin: 0; }
  .hmi-tip { width: 100%; margin-top: 4px; }
  .hmi-stage-scroll { padding: 10px; }
  .hmi-side {
    order: 3;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    align-items: start;
  }
}
@media (max-width: 760px) {
  .hmi-layout { grid-template-columns: minmax(0, 1fr); }
  .hmi-side { grid-template-columns: minmax(0, 1fr); }
  .hmi-mode-hint { display: none; }
  .hmi-toolbar .hmi-scenario { width: 100%; }
  .hmi-toolbar .hmi-scenario select { flex: 1; }
  .hmi-stage { min-width: 540px; }
  .hmi-stage-scroll { padding: 10px; }
  .hmi-tag-list { max-height: none; }
}
@media print {
  .hmi-toolbar, .hmi-palette, .hmi-side, .hmi-canvas-foot { display: none !important; }
  .hmi-stage-scroll { overflow: visible; padding: 0; background: none; }
}

/* ---------------- PLC Workbench ---------------- */
.plc-wrap { max-width: 1180px; }
.plc-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 14px;
}
.plc-mode-hint { font-size: 12px; color: var(--muted); max-width: 360px; line-height: 1.4; }
.plc-scenario { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.plc-scenario select { padding: 7px 9px; font-size: 13px; }
.plc-scen-desc { flex-basis: 100%; line-height: 1.45; }

.plc-fault {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; margin-bottom: 14px;
  border-color: #e5c26a; background: var(--amber-lt); color: #6b4300;
}
.plc-fault-ic {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: #e0a000; color: #fff; font-weight: 800;
}
.plc-fault-txt { display: flex; flex-direction: column; gap: 1px; flex: 1; font-size: 12.5px; line-height: 1.45; }
.plc-fault-txt b { font-size: 13px; }
html[data-theme="dark"] .plc-fault { background: #2a210f; border-color: #5a441c; color: #f3c987; }

.plc-io {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px; padding: 14px; margin-bottom: 14px;
}
.plc-io-col { min-width: 0; }
.plc-io-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 13px; }
.plc-io-head b { font-size: 13px; }
.plc-io-head .icon-btn { margin-inline-start: auto; width: 22px; height: 22px; font-size: 13px; }
.plc-bit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.plc-bit {
  display: flex; align-items: center; gap: 5px; min-width: 0;
  padding: 6px 8px; border: 1px solid var(--line2); border-radius: 8px;
  background: var(--surface); color: var(--ink2); font-size: 11.5px;
  text-align: start; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.plc-bit:hover { border-color: var(--brand); }
.plc-bit.out { cursor: default; }
.plc-bit.out:hover { border-color: var(--line2); }
.plc-bit-tag { font-size: 10.5px; color: var(--muted); flex: none; }
.plc-bit-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plc-bit.on { border-color: #7fd6b8; background: var(--green-lt); }
.plc-bit.stuck { border-color: #f0aaa2; background: var(--red-lt); }
.plc-bit.logic { border-color: #e6b95c; background: var(--amber-lt); }
.plc-led {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: #c3cedd; box-shadow: inset 0 0 2px rgba(0,0,0,.25);
}
.plc-led.on { background: #16b981; box-shadow: 0 0 6px rgba(22,185,129,.85); }
.plc-bit.stuck .plc-led { background: #e04a3a; box-shadow: 0 0 6px rgba(224,74,58,.7); }
.plc-bit.logic .plc-led { background: #e0a000; box-shadow: 0 0 6px rgba(224,160,0,.75); }
html[data-theme="dark"] .plc-bit.on { background: #123527; border-color: #1c4a3b; }
html[data-theme="dark"] .plc-bit.stuck { background: #3a1a19; border-color: #5a2a26; }
html[data-theme="dark"] .plc-bit.logic { background: #2a210f; border-color: #5a441c; }

.plc-res-list { display: flex; flex-direction: column; gap: 5px; }
.plc-res {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 7px; background: var(--bg); border: 1px solid var(--line); border-radius: 7px;
  font-size: 11.5px;
}
.plc-res-name { font-weight: 700; }
.plc-res-val { flex: 1; min-width: 0; color: var(--muted); font-size: 11px; white-space: nowrap; }
.plc-nores { line-height: 1.45; }

.plc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 282px; gap: 12px; align-items: start; }
.plc-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.plc-program {
  padding: 0; overflow: hidden;
  background: #0b1626; border-color: #22344c; color: #c9d7e8;
  box-shadow: 0 10px 30px -18px rgba(0,0,0,.7);
}
.plc-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid #1d2c42; background: #0e1b2c;
  font-size: 13px;
}
.plc-head .pill { background: #17283e; color: #9fb4cb; }
.plc-run-dot { width: 8px; height: 8px; border-radius: 50%; background: #4a5d75; flex: none; }
.plc-run-dot.on { background: #3ddc97; box-shadow: 0 0 0 3px rgba(61,220,151,.18); animation: plcPulse 1.5s infinite; }
@keyframes plcPulse { 50% { box-shadow: 0 0 0 6px rgba(61,220,151,.05); } }

.plc-rungs { position: relative; padding: 10px 20px 8px 34px; }
.plc-rungs::before, .plc-rungs::after {
  content: ""; position: absolute; top: 10px; bottom: 10px; width: 2px;
  background: #2b3f59; border-radius: 1px;
}
.plc-rungs::before { left: 28px; }
.plc-rungs::after { right: 14px; }
.plc-rung {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 7px 6px 7px 20px; border-radius: 6px; min-height: 40px;
}
.plc-rung::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  height: 2px; background: #2e4560; z-index: 0; border-radius: 1px;
  transition: background .18s, box-shadow .18s;
}
.plc-rung > * { position: relative; z-index: 1; }
.plc-rung.powered::before { background: #3ddc97; box-shadow: 0 0 8px rgba(61,220,151,.65); }
.plc-rung.scanning { background: rgba(59,130,246,.13); }
.plc-rung.editable:hover { background: rgba(59,130,246,.06); }
.plc-rung-num {
  width: 20px; margin-left: -22px; flex: none;
  font-size: 10px; color: #5f7894; text-align: right;
}
.plc-rung-line {
  display: flex; align-items: center; gap: 6px;
  width: 100%; min-width: 0; overflow-x: auto; overflow-y: hidden;
  padding: 1px 0;
  scrollbar-width: thin;
}
.plc-wire { flex: 1; min-width: 12px; height: 2px; background: #2e4560; border-radius: 1px; }

.plc-contact {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  padding: 3px 7px; border: 1px solid #2f4762; border-radius: 6px;
  background: #102033; color: #c6d8ef;
  font: 600 11.5px var(--mono); white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
}
.plc-contact.editable { cursor: pointer; border-style: dashed; }
.plc-contact.editable:hover { border-color: #5b8fd6; }
.plc-contact.sel { outline: 2px solid #3b82f6; outline-offset: 1px; }
.plc-contact.on { color: #8ef0c8; border-color: #2c9d75; background: rgba(61,220,151,.14); }
.plc-contact.flow { box-shadow: 0 0 8px rgba(61,220,151,.18); }
.plc-csym {
  position: relative; display: inline-block; width: 18px; height: 12px; flex: none;
  border-left: 2px solid currentColor; border-right: 2px solid currentColor;
}
.plc-contact.nc .plc-csym::after {
  content: ""; position: absolute; left: -2px; right: -2px; top: 50%;
  border-top: 2px solid currentColor; transform: rotate(-32deg);
}
.plc-addc, .plc-addout {
  flex: none; border: 1px dashed #3d5a7c; background: transparent; color: #7b97b5;
  border-radius: 6px; cursor: pointer; font: 600 11px var(--mono);
}
.plc-addc { width: 22px; height: 22px; font-size: 14px; line-height: 1; }
.plc-addout { padding: 3px 7px; }
.plc-addc:hover, .plc-addout:hover { border-color: #5b8fd6; color: #cfe4ff; }

.plc-output {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  padding: 3px 8px; border: 1px solid #2f4762; border-radius: 999px;
  background: #102033; color: #c6d8ef;
  font: 600 11.5px var(--mono); white-space: nowrap; cursor: default;
  transition: border-color .15s, background .15s, color .15s;
}
.plc-output.editable { cursor: pointer; border-style: dashed; }
.plc-output.editable:hover { border-color: #5b8fd6; }
.plc-output.sel { outline: 2px solid #3b82f6; outline-offset: 1px; }
.plc-output.active { color: #8ef0c8; border-color: #2c9d75; background: rgba(61,220,151,.14); box-shadow: 0 0 10px rgba(61,220,151,.15); }
.plc-output.energized:not(.active) { border-color: #3b82f6; box-shadow: 0 0 8px rgba(59,130,246,.25); }
.plc-osub { font-size: 9.5px; color: #8199b3; font-weight: 400; }
.plc-rung-del {
  position: absolute; right: 0; top: 0; width: 18px; height: 18px;
  border: 1px solid transparent; border-radius: 4px; background: transparent;
  color: #6b86a3; cursor: pointer; opacity: 0; padding: 0;
  display: grid; place-items: center; transition: opacity .15s, color .15s;
}
.plc-rung.editable:hover .plc-rung-del { opacity: 1; }
.plc-rung-del:hover { color: #ff9c92; border-color: #5a2a26; }
.plc-program-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-top: 1px solid #1d2c42; background: #0e1b2c;
}
.plc-program-foot .small { color: #7e96b0; }
.plc-program .plc-empty { color: #7e96b0; }

.plc-inspector, .plc-monitor, .plc-notes { padding: 13px; }
.plc-insp-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; }
.plc-insp-head b { font-size: 13.5px; }
.plc-inspector .field { margin-bottom: 9px; }
.plc-inspector .field span {
  display: block; font-size: 10.5px; font-weight: 700; color: var(--muted);
  margin-bottom: 3px; text-transform: uppercase; letter-spacing: .03em;
}
.plc-inspector .field input, .plc-inspector .field select {
  width: 100%; padding: 6px 8px; font-size: 13px; border-radius: 7px;
}
.plc-empty { font-size: 12.5px; color: var(--muted); text-align: center; padding: 14px 4px; line-height: 1.5; }
.plc-tips { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.plc-tips b { display: block; color: var(--ink2); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }

.plc-side-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; }
.plc-live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(15,157,110,.15); }
.plc-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.plc-stat-grid > div { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; min-width: 0; }
.plc-stat-grid span { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.plc-stat-grid b { font-family: var(--mono); font-size: 13px; }
.plc-watch { display: flex; flex-direction: column; gap: 1px; max-height: 310px; overflow: auto; }
.plc-watch-row {
  display: grid; grid-template-columns: 44px minmax(0,1fr) 40px; gap: 6px;
  align-items: center; font-size: 11px; padding: 3px 4px;
  border-bottom: 1px dashed var(--line);
}
.plc-watch-tag { color: var(--muted); }
.plc-watch-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plc-watch-row b { font-size: 10px; text-align: end; color: var(--faint); }
.plc-watch-row b.on { color: var(--green); }
.plc-legend-row { display: flex; align-items: center; gap: 7px; font-size: 11.5px; margin-bottom: 5px; }
.plc-notes p { margin-top: 8px; line-height: 1.45; }

@media (max-width: 1180px) {
  .plc-io { grid-template-columns: 1fr 1fr; }
  .plc-layout { grid-template-columns: minmax(0, 1fr); }
  .plc-side {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    align-items: start;
  }
}
@media (max-width: 760px) {
  .plc-io { grid-template-columns: minmax(0, 1fr); }
  .plc-side { grid-template-columns: minmax(0, 1fr); }
  .plc-mode-hint { display: none; }
  .plc-toolbar .plc-scenario { width: 100%; }
  .plc-toolbar .plc-scenario select { flex: 1; }
  .plc-rungs { padding-left: 28px; padding-right: 12px; }
  .plc-rung { padding-left: 18px; }
  .plc-rung-num { width: 16px; margin-left: -18px; }
  .plc-contact, .plc-output { padding: 3px 5px; font-size: 10.5px; }
  .plc-bit-grid { grid-template-columns: 1fr 1fr; }
}

/* keep ladder flow left-to-right in every UI language */
.plc-program .plc-rungs, .plc-program .plc-rung, .plc-program .plc-rung-line { direction: ltr; }
.plc-contact, .plc-output, .plc-bit-tag, .plc-res, .plc-watch-tag, .plc-stat-grid b, .plc-csym, .plc-osym { direction: ltr; }
html[dir="rtl"] .plc-head, html[dir="rtl"] .plc-program-foot { direction: rtl; }
html[dir="rtl"] .plc-program-foot .small { text-align: right; }

/* ---------------- HMI ↔ PLC link ---------------- */
.hmi-plc-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin-bottom: 12px;
  border-color: #b7d3ff; background: var(--brand-lt); color: var(--brand-dk);
}
.hmi-plc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.hmi-plc-dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(15,157,110,.18); }
.hmi-plc-txt { flex: 1; display: flex; flex-direction: column; gap: 1px; font-size: 12px; line-height: 1.45; }
.hmi-plc-txt b { font-size: 12.5px; }
html[data-theme="dark"] .hmi-plc-link { background: #10233f; border-color: #244a7a; color: #b9d4ff; }
html[data-theme="dark"] .hmi-plc-txt b { color: #dbeaff; }

.hmi-tag-row .hmi-tag-src {
  width: 58px; flex: none; padding: 4px 5px; font-size: 10.5px; border-radius: 6px;
}
.hmi-tag-live {
  flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center;
  padding: 3px 5px; border: 1px dashed var(--line2); border-radius: 6px;
  font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hmi-tag-live.on { color: #0a6b4b; border-color: #bde9d8; background: var(--green-lt); }
html[data-theme="dark"] .hmi-tag-live.on { color: #8fe6c6; border-color: #1c4a3b; background: #123527; }

.hmi-live-bool:disabled { opacity: .65; cursor: not-allowed; }

/* ---------------- PLC branches, analog and compare ---------------- */
.plc-rung::before { display: none; }
.plc-branches { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.plc-branch {
  position: relative; display: flex; align-items: center; gap: 6px;
  padding: 3px 0; min-height: 34px;
}
.plc-branch::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  height: 2px; background: #2e4560; z-index: 0; border-radius: 1px;
  transition: background .18s, box-shadow .18s;
}
.plc-branch > * { position: relative; z-index: 1; }
.plc-branch.powered::before { background: #3ddc97; box-shadow: 0 0 8px rgba(61,220,151,.65); }
.plc-addbranch {
  flex: none; border: 1px dashed #3d5a7c; background: transparent; color: #7b97b5;
  border-radius: 6px; cursor: pointer; padding: 3px 5px;
  font: 600 10px var(--mono); white-space: nowrap;
}
.plc-addbranch:hover { border-color: #5b8fd6; color: #cfe4ff; }
.plc-branch-del {
  position: absolute; right: 0; top: -7px; z-index: 4;
  width: 15px; height: 15px; padding: 0; border-radius: 4px;
  border: 1px solid #3d5a7c; background: #0b1626; color: #7b97b5;
  display: grid; place-items: center; cursor: pointer; opacity: 0;
  transition: opacity .12s, color .12s;
}
.plc-branch:hover .plc-branch-del { opacity: 1; }
.plc-branch-del:hover { color: #ff9c92; border-color: #5a2a26; }
.plc-two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.plc-analog { padding: 12px 14px; margin-bottom: 14px; }
.plc-analog .plc-io-head { margin-bottom: 10px; }
.plc-analog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; }
.plc-ai { display: flex; align-items: center; gap: 9px; font-size: 12px; min-width: 0; }
.plc-ai-name { flex: none; min-width: 160px; color: var(--muted); }
.plc-ai-name b { color: var(--ink2); }
.plc-ai input[type="range"] { flex: 1; min-width: 0; }
.plc-ai-val { min-width: 42px; text-align: end; font-size: 12px; }

@media (max-width: 760px) {
  .plc-analog-grid { grid-template-columns: minmax(0, 1fr); }
  .plc-ai-name { min-width: 120px; }
}

.plc-branches.multi { padding-left: 9px; }
.plc-branches.multi::before {
  content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 2px;
  background: #2e4560; border-radius: 1px; transition: background .18s;
}
.plc-rung.powered .plc-branches.multi::before { background: #3ddc97; box-shadow: 0 0 8px rgba(61,220,151,.55); }
/* ---------------- Math learning path ---------------- */
.math-wrap { max-width: 1080px; }
.math-tabs, .nb-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.math-tab {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 15px; border-radius: 999px;
  border: 1px solid var(--line2); background: var(--surface);
  color: var(--ink2); font-size: 13px; font-weight: 600; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.math-tab:hover { border-color: var(--brand); color: var(--brand-dk); }
.math-tab.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.math-overview {
  display: flex; align-items: flex-start; gap: 18px; flex-wrap: wrap;
  padding: 22px; margin-bottom: 12px;
  background: linear-gradient(135deg, var(--brand-lt), var(--surface) 65%);
}
html[data-theme="dark"] .math-overview { background: linear-gradient(135deg, #10233f, var(--surface) 65%); }
.math-overview-main { flex: 1; min-width: 240px; }
.math-kicker { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-dk); }
html[data-theme="dark"] .math-kicker { color: #8fc0ff; }
.math-overview h2 { font-size: 23px; margin: 4px 0 6px; }
.math-overview p { color: var(--muted); font-size: 14px; line-height: 1.55; max-width: 680px; }
.math-overview-side { display: flex; flex-direction: column; gap: 7px; }
.math-stats { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.math-diag {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 13px 15px; margin-bottom: 14px;
}
.math-diag.done { border-color: #bde9d8; }
html[data-theme="dark"] .math-diag.done { border-color: #1c4a3b; }
.math-diag-main { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 220px; }
.math-diag-icon {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; background: var(--brand-lt); color: var(--brand-dk);
  font-weight: 800;
}
.math-diag.done .math-diag-icon { background: var(--green-lt); color: #0a6b4b; }
.math-rec { font-size: 12.5px; margin-top: 4px; }
.math-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.math-unit { padding: 16px; display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.math-unit.learned { border-color: #bde9d8; }
html[data-theme="dark"] .math-unit.learned { border-color: #1c4a3b; }
.math-unit-head { display: flex; align-items: flex-start; gap: 10px; }
.math-num {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center; background: var(--brand-lt); color: var(--brand-dk);
  font: 700 13px var(--mono);
}
.math-unit-titles { flex: 1; min-width: 0; }
.math-unit-titles h3 { font-size: 15.5px; line-height: 1.3; }
.math-summary { font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.math-chips { display: flex; flex-direction: column; gap: 5px; }
.math-chip {
  font-size: 11px; color: var(--ink2); background: var(--bg);
  border: 1px solid var(--line); border-radius: 7px; padding: 4px 7px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.math-unit-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }

.math-detail-head { margin-bottom: 16px; }
.math-detail-head h1 { font-size: 26px; margin-top: 6px; }
.math-detail-head .sub { color: var(--muted); font-size: 14.5px; margin-top: 6px; max-width: 780px; }
.math-lesson { padding: 22px; }
.math-meta { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.math-lesson h2 { font-size: 17px; margin: 20px 0 9px; }
.math-points { margin: 0; padding-inline-start: 21px; line-height: 1.65; font-size: 14px; }
.math-points li { margin-bottom: 4px; }
.math-formula-list { display: flex; flex-direction: column; gap: 7px; }
.math-formula {
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); min-width: 0;
}
.math-formula.mini { padding: 8px 11px; }
.math-formula-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.math-formula-head b { font-size: 13.5px; }
.math-formula .expr { font-size: 14px; font-weight: 700; color: var(--brand-dk); margin: 3px 0 5px; overflow-wrap: anywhere; }
html[data-theme="dark"] .math-formula .expr { color: #8fc0ff; }
.math-example {
  border: 1px solid var(--line); background: var(--bg2);
  border-radius: 12px; padding: 14px 16px;
}
.math-problem { font-size: 14px; font-weight: 600; margin-bottom: 7px; }
.math-example ol { margin: 0; padding-inline-start: 20px; line-height: 1.65; font-size: 13.5px; }
.math-example ol li { margin-bottom: 3px; }
.math-answer { margin-top: 9px; font-size: 14px; color: #0a6b4b; }
html[data-theme="dark"] .math-answer { color: #8fe6c6; }
.math-lesson-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.math-method-note { margin-top: 12px; text-align: center; }

.math-formulas-card { padding: 15px; }
.math-formula-search { margin-bottom: 11px; }
.math-formula-search input { width: 100%; }
.math-empty { padding: 22px; text-align: center; color: var(--muted); font-size: 13.5px; }

.math-practice-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 12px; align-items: start; }
.math-practice-card, .math-stats-card { padding: 18px; }
.math-practice-card h2, .math-stats-card h2 { font-size: 17px; margin-bottom: 5px; }
.math-practice-card .field { margin-top: 12px; }
.math-practice-card .btn-primary { margin-top: 6px; }
.math-practice-note { margin-top: 12px; line-height: 1.5; }
.math-stat-line { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.math-stat-line b { font-family: var(--mono); font-size: 13px; }
.math-stats-card .btn { margin-top: 12px; }

.math-session { padding: 20px; max-width: 680px; margin: 0 auto; }
.math-session-head { display: flex; align-items: center; gap: 8px; }
.math-progress { height: 5px; border-radius: 999px; background: var(--bg2); margin: 11px 0 16px; overflow: hidden; }
.math-progress i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.math-q-text { font-size: 17px; line-height: 1.6; font-weight: 600; margin-bottom: 14px; }
.math-answer-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.math-answer-row input { width: 150px; font-family: var(--mono); font-size: 16px; }
.math-unit-badge { font-size: 13px; color: var(--muted); min-width: 32px; }
.math-hint-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 9px; }
.math-feedback { margin-top: 14px; padding: 12px 14px; border-radius: 10px; font-size: 13.5px; line-height: 1.55; }
.math-feedback.ok { background: var(--green-lt); border: 1px solid #bde9d8; color: #0a5c41; }
.math-feedback.bad { background: var(--red-lt); border: 1px solid #f5c6c2; color: #8f1b11; }
html[data-theme="dark"] .math-feedback.ok { background: #123527; border-color: #1c4a3b; color: #8fe6c6; }
html[data-theme="dark"] .math-feedback.bad { background: #3a1a19; border-color: #5a2a26; color: #ffb0a8; }
.math-feedback .math-steps { margin: 6px 0 8px; font-family: var(--mono); font-size: 12px; line-height: 1.6; }
.math-session-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.math-result-icon { font-size: 30px; color: var(--green); }
.math-big { font-size: 36px; font-weight: 800; letter-spacing: -.03em; margin: 6px 0 0; }
.math-rec-card { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; margin-top: 14px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 13px; }
.math-rec-card b { font-size: 14.5px; }

.math-method { padding: 22px; max-width: 860px; }
.math-method h1 { font-size: 25px; }
.math-method-intro { color: var(--muted); font-size: 14.5px; line-height: 1.65; margin-top: 8px; }
.math-principles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.math-principle { border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; background: var(--bg); font-size: 13px; line-height: 1.55; }
.math-principle b { display: block; margin-bottom: 3px; color: var(--ink2); }
.math-routine { padding-inline-start: 20px; line-height: 1.7; font-size: 13.5px; }
.math-sources { padding-inline-start: 20px; line-height: 1.7; font-size: 13px; }
.math-disclaimer { margin-top: 16px; line-height: 1.5; }

/* ---------------- Notebook ---------------- */
.nb-wrap { max-width: 1100px; }
.nb-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.nb-stat { padding: 12px 14px; }
.nb-stat span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.nb-stat b { font-size: 21px; font-family: var(--mono); }
.nb-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 12px; align-items: start; }
.nb-list { padding: 12px; }
.nb-list-head { display: flex; gap: 7px; align-items: center; margin-bottom: 10px; }
.nb-list-head input { flex: 1; min-width: 0; }
.nb-list-head .btn { flex: none; }
.nb-notes { display: flex; flex-direction: column; gap: 4px; max-height: 620px; overflow: auto; }
.nb-note {
  display: block; width: 100%; text-align: start;
  padding: 9px 10px; border: 1px solid transparent; border-radius: 9px;
  background: transparent; cursor: pointer; color: var(--ink);
}
.nb-note:hover { background: var(--bg); }
.nb-note.active { background: var(--brand-lt); border-color: #b7d3ff; }
html[data-theme="dark"] .nb-note.active { background: #10233f; border-color: #244a7a; }
.nb-note-title { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-pin { color: var(--amber); margin-inline-end: 4px; }
.nb-note-meta { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.nb-note-snippet { font-size: 11.5px; color: var(--faint); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-editor { padding: 16px; }
.nb-editor-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 11px; }
.nb-editor-head h2 { font-size: 18px; }
.nb-editor .field { margin-bottom: 10px; }
.nb-editor .field span { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 3px; }
.nb-editor input, .nb-editor select, .nb-editor textarea { width: 100%; }
.nb-editor textarea {
  padding: 9px 12px; border: 1px solid var(--line2); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; line-height: 1.55;
  outline: none; resize: vertical; transition: border-color .15s, box-shadow .15s;
}
.nb-editor textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11,95,255,.13); }
.nb-two { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.nb-check { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); margin: 4px 0 12px; }
.nb-check input { width: 16px; height: 16px; accent-color: var(--green); }
.nb-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 10px; line-height: 1.5; }

.nb-practice-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 12px; align-items: start; }
.nb-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.nb-practice-row { display: flex; align-items: flex-start; gap: 8px; padding: 9px 7px; border-bottom: 1px dashed var(--line); }
.nb-practice-main { flex: 1; min-width: 0; }
.nb-practice-title { font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nb-practice-meta { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.nb-practice-problem { font-size: 11.5px; color: var(--faint); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-practice-actions { display: flex; gap: 3px; flex: none; }
.nb-result { font-size: 9.5px; font-weight: 700; border-radius: 999px; padding: 2px 7px; }
.nb-result.correct { background: var(--green-lt); color: #0a6b4b; }
.nb-result.partial { background: var(--amber-lt); color: #7a4a00; }
.nb-result.wrong { background: var(--red-lt); color: #8f1b11; }
html[data-theme="dark"] .nb-result.correct { background: #123527; color: #8fe6c6; }
html[data-theme="dark"] .nb-result.partial { background: #2a210f; color: #f3c987; }
html[data-theme="dark"] .nb-result.wrong { background: #3a1a19; color: #ffb0a8; }

@media (max-width: 900px) {
  .math-grid { grid-template-columns: minmax(0, 1fr); }
  .math-practice-grid, .nb-layout, .nb-practice-layout { grid-template-columns: minmax(0, 1fr); }
  .nb-notes { max-height: 360px; }
}
@media (max-width: 620px) {
  .math-principles, .nb-two, .nb-form-grid { grid-template-columns: minmax(0, 1fr); }
  .nb-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .math-overview { padding: 17px; }
  .math-overview-side { flex-direction: row; flex-wrap: wrap; }
  .math-session { padding: 15px; }
  .nb-list-head { flex-wrap: wrap; }
  .nb-list-head input { flex-basis: 100%; }
}
@media print {
  .math-tabs, .nb-tabs, .no-print, .nb-list-head, .nb-practice-actions, .math-unit-actions, .math-lesson-actions { display: none !important; }
  .nb-layout, .nb-practice-layout { display: block; }
  .nb-list, .nb-editor, .nb-stat, .math-unit, .math-lesson { box-shadow: none; border-color: #ddd; }
}

/* ---------------- Cognition learning cycle ---------------- */
.math-cognition {
  display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  padding: 18px 20px; margin-bottom: 14px;
  border-color: #b7d3ff;
  background: linear-gradient(135deg, var(--brand-lt), var(--surface) 70%);
}
html[data-theme="dark"] .math-cognition { background: linear-gradient(135deg, #10233f, var(--surface) 70%); border-color: #244a7a; }
.math-cognition-main { flex: 1; min-width: 240px; }
.math-cognition-main h2 { font-size: 20px; margin: 3px 0 5px; }
.math-cognition-main p { color: var(--muted); font-size: 13px; line-height: 1.55; max-width: 680px; }
.math-cognition-side { display: flex; flex-direction: column; gap: 7px; align-items: flex-start; }
.math-cognition-focus { flex-basis: 100%; border-top: 1px dashed var(--line); padding-top: 8px; }
.math-cognition-head {
  display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  padding: 20px; margin-bottom: 14px;
  background: linear-gradient(135deg, var(--brand-lt), var(--surface) 70%);
}
html[data-theme="dark"] .math-cognition-head { background: linear-gradient(135deg, #10233f, var(--surface) 70%); }
.math-cognition-head h2 { font-size: 22px; margin: 3px 0 5px; }
.math-cognition-head p { color: var(--muted); font-size: 13.5px; line-height: 1.55; max-width: 700px; }
.math-cog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.math-plan, .math-mastery, .math-due, .math-reflections { padding: 16px; }
.math-plan h3, .math-mastery h3, .math-due h3, .math-reflections h3 { font-size: 15px; margin-bottom: 10px; }
.coach-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.coach-steps li { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; line-height: 1.45; }
.coach-steps li b { display: block; font-size: 13px; }
.coach-steps li span:not(.coach-step-num) { color: var(--muted); }
.coach-steps li.done { opacity: .75; }
.coach-step-num {
  width: 23px; height: 23px; border-radius: 50%; flex: none;
  display: grid; place-items: center; background: var(--brand-lt); color: var(--brand-dk);
  font: 700 11px var(--mono);
}
.coach-steps li.done .coach-step-num { background: var(--green-lt); color: #0a6b4b; }
.coach-focus-box { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); display: flex; flex-direction: column; gap: 4px; align-items: flex-start; font-size: 13px; }
.coach-nodiag { margin-top: 10px; line-height: 1.5; }
.coach-mastery-row { margin-bottom: 10px; }
.coach-mastery-top { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; margin-bottom: 3px; }
.coach-mastery-top b { font-size: 10px; color: var(--muted); font-weight: 700; }
.coach-mastery-bar { height: 6px; border-radius: 999px; background: var(--bg2); overflow: hidden; }
.coach-mastery-bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--green)); }
.coach-due-row { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 12px; }
.coach-due-row b { font-size: 11px; color: var(--muted); }
.coach-reflection { padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 12px; line-height: 1.5; }
.coach-reflection:last-child { border-bottom: 0; }
.coach-reflect { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.coach-reflect h3 { font-size: 15px; margin-bottom: 3px; }
.coach-reflect p { margin-bottom: 7px; line-height: 1.45; }
.coach-reflect textarea { width: 100%; }
.math-research-note { margin: 8px 0 4px; line-height: 1.55; }
@media (max-width: 900px) {
  .math-cog-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) {
  .math-cognition, .math-cognition-head { padding: 16px; }
  .math-cognition-side { flex-direction: row; flex-wrap: wrap; }
}

/* ---------------- Practice reports ---------------- */
.reports-wrap { max-width: 1180px; }
.reports-head .page-actions { margin-top: 10px; }
.reports-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.reports-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 14px; margin-bottom: 14px;
}
.reports-toolbar .small { max-width: 300px; line-height: 1.4; }
.reports-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
.report-paper {
  background: #ffffff; color: #111111;
  border-radius: 4px; padding: 30px 32px;
  box-shadow: 0 10px 40px -18px rgba(0,0,0,.35);
  border: 1px solid #e2e8f0;
  max-width: 820px; margin: 0 auto;
}
.report-head {
  display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  border-bottom: 2px solid #0b5fff; padding-bottom: 14px; margin-bottom: 16px;
}
.report-brand { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.report-logo {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: #0b5fff; color: #fff; font-size: 18px;
}
.report-brand b { display: block; font-size: 15px; color: #0d1726; }
.report-brand span { display: block; font-size: 10px; color: #64748b; }
.report-title { flex: 1; min-width: 200px; }
.report-title h1 { font-size: 22px; margin: 0 0 3px; color: #0d1726; }
.report-title span { font-size: 11px; color: #64748b; }
.report-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11px; }
.report-meta b { display: block; color: #64748b; font-weight: 600; font-size: 9.5px; text-transform: uppercase; letter-spacing: .04em; }
.report-meta span { color: #0d1726; font-weight: 600; }
.report-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.report-kpi { border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px 10px; background: #f8fafc; }
.report-kpi span { display: block; font-size: 9.5px; color: #64748b; text-transform: uppercase; letter-spacing: .03em; }
.report-kpi b { font-size: 15px; color: #0d1726; font-family: var(--mono); }
.report-section { margin-bottom: 18px; }
.report-section h2 { font-size: 13.5px; color: #0b5fff; border-bottom: 1px solid #e2e8f0; padding-bottom: 4px; margin-bottom: 7px; }
.report-section { overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
.report-table th { text-align: start; color: #64748b; font-weight: 700; background: #f8fafc; padding: 5px 7px; border-bottom: 1px solid #e2e8f0; }
.report-table td { padding: 4px 7px; border-bottom: 1px solid #eef2f7; color: #24344a; vertical-align: top; }
.report-items { margin: 0; padding-inline-start: 19px; font-size: 11px; line-height: 1.6; color: #24344a; }
.report-items li { margin-bottom: 3px; }
.report-empty { font-size: 11px; color: #64748b; padding: 6px 0; }
.report-foot {
  margin-top: 20px; padding-top: 10px; border-top: 1px solid #e2e8f0;
  font-size: 9.5px; color: #64748b; line-height: 1.5;
}
.reports-saved { padding: 12px; position: sticky; top: 16px; }
.reports-saved-head { display: flex; align-items: center; gap: 7px; margin-bottom: 9px; font-size: 13px; }
.reports-saved-row { display: flex; align-items: center; gap: 5px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.reports-saved-row a { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--ink2); }
.reports-saved-row a b { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reports-saved-row a span { font-size: 9.5px; color: var(--muted); }
.reports-saved-row .icon-btn { width: 24px; height: 24px; padding: 0; }
.reports-empty { text-align: center; padding: 16px 6px; line-height: 1.5; }

@media (max-width: 900px) {
  .reports-layout { grid-template-columns: minmax(0, 1fr); }
  .reports-saved { position: static; }
}
@media (max-width: 620px) {
  .report-paper { padding: 18px 15px; }
  .report-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-title h1 { font-size: 18px; }
  .report-table { min-width: 520px; }
}
@media print {
  @page { size: A4 portrait; margin: 9mm; }
  .reports-tabs, .reports-toolbar, .reports-saved, .reports-head, .side, .tabbar, .app-foot, .toast, .no-print { display: none !important; }
  .shell { display: block !important; min-height: 0; }
  .main { padding: 0 !important; }
  #view { padding: 0 !important; }
  .reports-wrap { max-width: none !important; margin: 0 !important; }
  .reports-layout { display: block; }
  .report-paper {
    width: 100% !important; max-width: none !important; margin: 0 !important;
    padding: 0 !important; box-shadow: none !important; border: 0 !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .report-section { overflow: visible !important; break-inside: auto; }
  .report-table { min-width: 0 !important; }
  .report-section, .report-summary, .report-head { break-inside: avoid; }
}
