/* HKDSE ICT Network Simulator — styles */
:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-2: #dbeafe;
  --ok: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;
  --grid: #e5e9f0;
  --canvas: #fbfcfe;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(15, 23, 42, .18);
  --font: system-ui, -apple-system, "Segoe UI", "Microsoft JhengHei", "PingFang HK", "Noto Sans TC", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); overflow: hidden; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: 12px; background: var(--panel-2); padding: 1px 4px; border-radius: 4px; word-break: break-all; }
h3 { margin: 4px 0 8px; font-size: 16px; }
h4 { margin: 16px 0 6px; font-size: 13px; text-transform: none; color: #334155; }
h5 { margin: 10px 0 4px; font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.warn { color: var(--warn); }
.nowrap { white-space: nowrap; }

/* ---------- top bar ---------- */
.topbar { height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: linear-gradient(90deg, #0f172a, #1e3a8a); color: #fff; position: relative; z-index: 50; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: 8px; min-width: 0; }
.logo { background: #fff; border-radius: 9px; padding: 3px; display: flex; }
.brand-t { font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand-s { font-size: 11px; opacity: .75; white-space: nowrap; }
.tb-group { display: flex; align-items: center; gap: 2px; padding-left: 8px; border-left: 1px solid rgba(255,255,255,.15); }
.tb-right { margin-left: auto; gap: 8px; border-left: 0; }
.tb-btn { display: flex; align-items: center; gap: 5px; background: transparent; color: #e2e8f0; border: 0; padding: 7px 9px; border-radius: 8px; white-space: nowrap; }
.tb-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.tb-btn.active { background: #f59e0b; color: #111827; }
.tb-ic { font-size: 15px; }
.tb-check { display: flex; align-items: center; gap: 5px; font-size: 12px; color: #e2e8f0; cursor: pointer; white-space: nowrap; }
.lang-btn { background: #fff; color: #1e3a8a; border: 0; border-radius: 999px; padding: 5px 12px; font-weight: 700; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 216px 1fr 360px; height: calc(100vh - 56px); }
.palette { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 8px 10px 20px; }
.stage { display: flex; flex-direction: column; min-width: 0; position: relative; }
.side { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }

/* ---------- palette ---------- */
.pal-cat { font-size: 11px; font-weight: 700; color: var(--muted); margin: 12px 2px 6px; letter-spacing: .02em; }
.pal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pal-item { border: 1px solid var(--line); border-radius: 9px; padding: 6px 4px 5px; text-align: center; cursor: grab; background: var(--panel-2); user-select: none; transition: .12s; }
.pal-item:hover { border-color: var(--primary); background: var(--primary-2); }
.pal-item.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary) inset; background: var(--primary-2); }
.pal-ic { display: flex; justify-content: center; }
.pal-lb { font-size: 11px; line-height: 1.2; margin-top: 2px; }
.cable-list { display: flex; flex-direction: column; gap: 3px; }
.cable-item { display: flex; align-items: center; gap: 8px; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 7px; padding: 4px 6px; font-size: 12px; }
.cable-item:hover { background: var(--panel-2); border-color: var(--line); }
.cable-item.active { background: var(--primary-2); border-color: var(--primary); }
.cable-sw { flex: none; display: flex; }
.pal-hint { margin-top: 12px; font-size: 11px; color: var(--muted); background: var(--panel-2); border-radius: 8px; padding: 8px; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 44px; }
.tools { display: flex; gap: 4px; }
.tool { display: flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 5px 9px; font-size: 13px; }
.tool:hover { border-color: var(--primary); }
.tool.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tool:disabled { opacity: .4; cursor: default; border-color: var(--line); }
#btn-undo, #btn-redo { font-size: 16px; padding: 3px 9px; }
.hint { flex: 1; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.view-opts { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.tg { display: flex; align-items: center; gap: 3px; cursor: pointer; white-space: nowrap; }
.icon-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 7px; min-width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; color: inherit; }
.icon-btn:hover { border-color: var(--primary); }

/* ---------- canvas ---------- */
.canvas { flex: 1; width: 100%; background: var(--canvas); display: block; touch-action: none; cursor: default; user-select: none; }
.canvas[data-tool="cable"], .canvas[data-tool="pdu"], .canvas[data-placing="1"] { cursor: crosshair; }
.canvas[data-tool="delete"] { cursor: not-allowed; }
.canvas[data-tool="delete"] .dev:hover .dev-hit { stroke: var(--bad); }
.canvas .bg { cursor: grab; }
.dev { cursor: pointer; }
.dev-hit { fill: transparent; stroke: transparent; stroke-width: 2; }
.dev:hover .dev-hit { fill: rgba(37,99,235,.06); stroke: #93c5fd; }
.dev.selected .dev-hit { fill: rgba(37,99,235,.10); stroke: var(--primary); stroke-dasharray: 5 3; }
.dev.pending .dev-hit { fill: rgba(245,158,11,.15); stroke: #f59e0b; }
.dev-name { font-size: 12px; font-weight: 600; text-anchor: middle; fill: #0f172a; paint-order: stroke; stroke: var(--canvas); stroke-width: 4px; stroke-linejoin: round; }
.dev-ip { font-size: 10.5px; text-anchor: middle; fill: #1d4ed8; font-family: var(--mono); paint-order: stroke; stroke: var(--canvas); stroke-width: 3px; }
.dev-ip.apipa { fill: var(--bad); }
.badge-warn { font-size: 15px; }
.badge-info { font-size: 10px; font-weight: 700; fill: #7c3aed; }
.link { cursor: pointer; }
.link-hit { stroke: transparent; stroke-width: 16; fill: none; }
.link-sel { stroke: #93c5fd; stroke-width: 9; fill: none; opacity: .7; stroke-linecap: round; }
.link-line { fill: none; stroke-linecap: round; }
.link.down .link-line { opacity: .55; }
.link:hover .link-line { filter: drop-shadow(0 0 3px rgba(37,99,235,.6)); }
.port-dot.up { fill: #22c55e; stroke: #fff; stroke-width: 1.5; }
.port-dot.down { fill: #ef4444; stroke: #fff; stroke-width: 1.5; }
.port-label { font-size: 10px; text-anchor: middle; fill: #475569; paint-order: stroke; stroke: var(--canvas); stroke-width: 3px; }
.sat-glyph { font-size: 18px; text-anchor: middle; }
.wl-line { stroke-width: 2; stroke-dasharray: 3 5; stroke-linecap: round; }
.wl-line.wifi { stroke: #0d9488; }
.wl-line.cell { stroke: #ea580c; }
.wl-line.interf { stroke: #dc2626; }
.sig .on { fill: #0d9488; }
.sig .off { fill: #cbd5e1; }
.range { fill: rgba(20,184,166,.06); stroke: rgba(13,148,136,.45); stroke-width: 1.5; stroke-dasharray: 6 6; pointer-events: none; }
.range.cell { fill: rgba(234,88,12,.04); stroke: rgba(234,88,12,.4); }
.range.interf { fill: rgba(220,38,38,.07); stroke: rgba(220,38,38,.55); }
.range-label { font-size: 11px; text-anchor: middle; fill: #0f766e; pointer-events: none; }
.range-label.interf { fill: #b91c1c; font-weight: 600; }
.ov-link { stroke-width: 16; opacity: .28; fill: none; stroke-linecap: round; pointer-events: none; }
.ov-label { pointer-events: none; }
.ov-label text { fill: #fff; font-size: 11px; font-weight: 700; text-anchor: middle; }
.pkt { pointer-events: none; }
.pkt rect { stroke: #fff; stroke-width: 1.5; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
.pkt-flap { fill: none; stroke: rgba(255,255,255,.85); stroke-width: 1.4; }
.pkt-label { font-size: 9.5px; font-weight: 700; text-anchor: middle; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.pkt-lock { font-size: 10px; }
.drop-mark { font-size: 22px; font-weight: 900; fill: #dc2626; pointer-events: none; }
.temp-line { stroke-width: 2.5; pointer-events: none; }

/* ---------- sim bar ---------- */
.simbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: #0f172a; color: #e2e8f0; font-size: 12px; flex-wrap: wrap; }
.sim-mode { font-weight: 700; min-width: 78px; }
.sim-btn { background: #1e293b; color: #e2e8f0; border: 1px solid #334155; border-radius: 7px; padding: 4px 10px; }
.sim-btn:hover { background: #334155; }
.sim-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; min-width: 38px; }
.sim-speed { display: flex; gap: 5px; align-items: center; }
.sim-speed select { background: #1e293b; color: #e2e8f0; border: 1px solid #334155; border-radius: 6px; padding: 2px 4px; }
.sim-clock { margin-left: auto; font-family: var(--mono); color: #94a3b8; }

/* ---------- side panel ---------- */
.side-tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.side-tab { flex: 1; border: 0; background: transparent; padding: 10px 6px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.side-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--panel); }
.side-body { flex: 1; overflow-y: auto; padding: 12px 14px 24px; min-height: 0; display: flex; flex-direction: column; }
.side-body > * { flex: none; }
.btn { border: 1px solid var(--line-2); background: var(--panel); border-radius: 8px; padding: 6px 12px; color: var(--text); }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #1d4ed8; color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); background: #fef2f2; }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats > div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px; text-align: center; font-size: 12px; color: var(--muted); }
.stats b { display: block; font-size: 22px; color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; font-size: 12px; color: var(--muted); }
.chip { background: var(--primary-2); color: #1e40af; border-radius: 999px; padding: 1px 8px; font-size: 11px; }
.empty { text-align: center; padding: 18px 8px; background: var(--panel-2); border-radius: 10px; margin: 10px 0; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 8px; font-size: 12px; }
.legend > div { display: flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }
.dot.up { background: #22c55e; }
.dot.down { background: #ef4444; }
.dot.off { background: #cbd5e1; }
.tasks { padding-left: 20px; }
.tasks li { margin: 8px 0; }
.tasks li label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.tasks li input { margin-top: 3px; }
.tasks li.done span { color: var(--muted); text-decoration: line-through; }
.prop-head { display: flex; gap: 10px; align-items: center; }
.name-input { font-size: 16px; font-weight: 700; border: 1px solid transparent; border-radius: 6px; padding: 2px 6px; width: 100%; background: transparent; }
.name-input:hover, .name-input:focus { border-color: var(--line-2); background: #fff; }
.desc { font-size: 13px; color: #334155; background: #f0f9ff; border-left: 3px solid #38bdf8; padding: 8px 10px; border-radius: 0 8px 8px 0; margin: 10px 0; }
.ptable, .dtable { width: 100%; border-collapse: collapse; font-size: 12px; }
.ptable th, .ptable td, .dtable th, .dtable td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ptable th, .dtable th { color: var(--muted); font-weight: 600; background: var(--panel-2); }
.dtable input, .dtable select { width: 100%; min-width: 60px; padding: 3px 5px; border: 1px solid var(--line-2); border-radius: 5px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12.5px; margin: 8px 0; align-items: baseline; }
.kv > span { color: var(--muted); }
.kv code { white-space: pre-wrap; }
.alert { border-radius: 8px; padding: 8px 10px; font-size: 13px; margin: 8px 0; }
.alert.ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert.bad { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.link-ends { font-family: var(--mono); font-size: 12px; color: #334155; }
.len-input { width: 110px; padding: 3px 6px; border: 1px solid var(--line-2); border-radius: 6px; }
.side select { max-width: 100%; padding: 4px; border: 1px solid var(--line-2); border-radius: 6px; }
.dom-card { border: 1px solid var(--line); border-left: 4px solid #3b82f6; border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-size: 12px; }
.dom-card.wan { border-left-color: #dc2626; }
.dom-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }

/* simulation list */
.proto-filter { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.pchip { border: 0; border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 700; color: #fff; background: var(--c); }
.pchip.off { background: #e2e8f0; color: #94a3b8; text-decoration: line-through; }
.pdu-list { margin-bottom: 6px; }
.pdu { font-size: 12px; padding: 3px 6px; border-radius: 6px; margin: 2px 0; font-family: var(--mono); }
.pdu.ok { background: #f0fdf4; color: #166534; }
.pdu.bad { background: #fef2f2; color: #991b1b; }
.ev-wrap { flex: 1 1 auto !important; min-height: 200px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.events { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.events th { position: sticky; top: 0; background: var(--panel-2); text-align: left; padding: 5px; font-weight: 600; color: var(--muted); z-index: 1; }
.events td { padding: 4px 5px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.events td:nth-child(3) { white-space: normal; min-width: 90px; }
.events td.ev-info { white-space: normal; color: #334155; min-width: 120px; }
.events tr.ev { cursor: pointer; }
.events tr.ev:hover { background: #eff6ff; }
.events tr.drop { background: #fef2f2; }
.events tr.drop td.ev-info { color: #b91c1c; }
.events tr.ignored td { color: #94a3b8; }
.ptag { color: #fff; border-radius: 4px; padding: 0 5px; font-weight: 700; font-size: 10.5px; }

/* inspector */
.inspector .notes { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }
.inspector .notes.drop { background: #fef2f2; border-color: #fecaca; }
.inspector .notes ul { margin: 4px 0 0; padding-left: 20px; }
.layer { border: 1px solid var(--line); border-radius: 9px; margin: 8px 0; overflow: hidden; }
.layer-head { display: flex; justify-content: space-between; padding: 6px 10px; color: #fff; font-size: 13px; }
.layer .kv { padding: 4px 12px 8px; margin: 0; }
.layer.l-app .layer-head { background: #7c3aed; }
.layer.l-tr .layer-head { background: #2563eb; }
.layer.l-net .layer-head { background: #0d9488; }
.layer.l-link .layer-head { background: #d97706; }
.inspector pre { background: #0f172a; color: #e2e8f0; padding: 10px; border-radius: 8px; font-size: 11px; overflow: auto; max-height: 300px; }

/* ---------- modal / menus / toast ---------- */
.modal-ov { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal.wide { width: min(980px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 14px 18px 18px; overflow-y: auto; }
.ctx-menu { position: fixed; z-index: 2000; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; min-width: 180px; }
.ctx-menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 6px 10px; border-radius: 6px; }
.ctx-menu button:hover { background: var(--primary-2); }
.ctx-menu button.danger { color: var(--bad); }
.ctx-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.port-menu { position: fixed; z-index: 2000; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; min-width: 240px; max-height: 60vh; overflow-y: auto; }
.pm-title { font-size: 12px; font-weight: 700; padding: 6px 8px; color: var(--muted); }
.pm-item { display: grid; grid-template-columns: 70px 1fr auto; gap: 6px; width: 100%; text-align: left; border: 0; background: transparent; padding: 5px 8px; border-radius: 6px; font-size: 12px; }
.pm-item:hover:not(:disabled) { background: var(--primary-2); }
.pm-item:disabled { color: #94a3b8; cursor: default; }
.pm-item em { font-style: normal; font-size: 11px; }
.pm-empty { padding: 8px; font-size: 12px; color: var(--warn); }
.toast-root { position: fixed; bottom: 54px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 3000; pointer-events: none; }
.toast { background: #0f172a; color: #fff; padding: 8px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; transition: opacity .4s, transform .4s; max-width: 80vw; }
.toast.ok { background: #166534; }
.toast.warn { background: #92400e; }
.toast.bad { background: #991b1b; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* welcome / scenarios */
.welcome-intro { background: var(--panel-2); border-radius: 10px; padding: 4px 16px; }
.sc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.sc-card { text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 12px; transition: .15s; color: inherit; }
.sc-card:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(37,99,235,.15); transform: translateY(-1px); }
.sc-ic { font-size: 26px; }
.sc-t { font-weight: 700; margin: 4px 0; }
.sc-d { font-size: 12.5px; color: #334155; }
.sc-tags { font-size: 11px; color: var(--primary); margin-top: 6px; }

/* ---------- floating windows ---------- */
.win { position: fixed; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: calc(100vh - 70px); max-width: calc(100vw - 20px); min-width: 320px; resize: both; overflow: hidden; }
.win-head { display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 12px; background: linear-gradient(#f8fafc, #eef2f7); border-bottom: 1px solid var(--line); cursor: move; user-select: none; }
.win-icon { display: flex; }
.win-title { flex: 1; font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-body { flex: 1; overflow: auto; padding: 0 14px 14px; min-height: 0; }
.win-body.no-pad { padding: 0; display: flex; flex-direction: column; }
.tabs { display: flex; gap: 2px; position: sticky; top: 0; background: var(--panel); padding-top: 8px; border-bottom: 1px solid var(--line); z-index: 2; margin: 0 -14px 10px; padding-left: 10px; }
.tab { border: 1px solid transparent; border-bottom: 0; background: transparent; padding: 6px 12px; border-radius: 8px 8px 0 0; color: var(--muted); font-weight: 600; font-size: 13px; }
.tab.active { background: var(--panel); border-color: var(--line); color: var(--primary); margin-bottom: -1px; }
.section { margin-bottom: 12px; }
.section > h4 { margin-top: 6px; }
.field { display: flex; flex-direction: column; gap: 2px; margin: 4px 0; min-width: 0; }
.f-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.f-hint { font-size: 11px; color: var(--muted); }
.field input, .field select, textarea { border: 1px solid var(--line-2); border-radius: 6px; padding: 5px 7px; background: #fff; width: 100%; }
input.ip, input.cidr { font-family: var(--mono); font-size: 12.5px; }
.invalid { border-color: var(--bad) !important; background: #fef2f2 !important; }
textarea { font-family: var(--mono); font-size: 12px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 10px; }
.row { display: flex; gap: 8px; align-items: flex-end; }
.row .field { flex: 1; }
.port-card { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 8px 0; background: var(--panel-2); }
.port-card.unlinked { opacity: .78; }
.pc-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 2px; }
.pstatus { font-size: 12px; margin-left: auto; }
.pstatus.down { color: var(--muted); }
.mode-row { display: flex; gap: 14px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.radio, .check { display: inline-flex; gap: 5px; align-items: center; cursor: pointer; font-size: 13px; }
.chip-btn { border: 1px solid #99f6e4; background: #f0fdfa; color: #0f766e; border-radius: 999px; padding: 1px 8px; margin: 2px; font-size: 11.5px; }
.page-card { border: 1px dashed var(--line-2); border-radius: 8px; padding: 6px 8px; margin: 6px 0; }
.desktop { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; padding: 14px 0; }
.app-icon { border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 14px 6px; font-size: 12.5px; }
.app-icon:hover { border-color: var(--primary); background: var(--primary-2); }
.ai { font-size: 32px; }

/* terminal */
.term { flex: 1; background: #0b1220; color: #d1d5db; font-family: var(--mono); font-size: 12.5px; padding: 10px 12px; overflow-y: auto; min-height: 260px; cursor: text; }
.term-out { margin: 0; white-space: pre-wrap; word-break: break-word; font: inherit; }
.term-out .cmd { color: #fde68a; }
.term-out .ok { color: #86efac; }
.term-out .err { color: #fca5a5; }
.term-out .muted { color: #94a3b8; font-style: italic; }
.term-line { display: flex; gap: 4px; }
.term-prompt { color: #fde68a; }
.term-in { flex: 1; background: transparent; border: 0; outline: 0; color: #fff; font: inherit; padding: 0; }

/* browser */
.browser-bar { display: flex; gap: 6px; align-items: center; padding: 8px 10px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.url-in { flex: 1; border: 1px solid var(--line-2); border-radius: 999px; padding: 5px 12px; font-family: var(--mono); font-size: 12.5px; background: #fff; }
.lock { font-size: 15px; min-width: 18px; }
.url-anatomy { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: #fff; }
.url-anatomy.big { padding: 10px 0; border: 0; }
.ua { display: flex; flex-direction: column; align-items: center; border-radius: 6px; padding: 2px 6px; }
.ua b { font-family: var(--mono); font-size: 12.5px; font-weight: 600; }
.ua small { font-size: 10px; color: var(--muted); }
.ua.scheme { background: #ede9fe; } .ua.host { background: #dbeafe; } .ua.port { background: #fef3c7; } .ua.path { background: #dcfce7; } .ua.query { background: #fce7f3; } .ua.frag { background: #f1f5f9; }
.steps { margin: 0; padding: 6px 12px 6px 30px; font-size: 12px; background: #fff; border-bottom: 1px solid var(--line); max-height: 120px; overflow-y: auto; }
.steps:empty { display: none; }
.steps li { list-style: none; position: relative; }
.steps .si { position: absolute; left: -18px; }
.steps li.done .si { color: var(--ok); }
.steps li.fail { color: var(--bad); }
.steps li.run { color: var(--primary); }
iframe.page { flex: 1; border: 0; width: 100%; min-height: 240px; background: #fff; }

/* ftp */
.ftp-log { background: #0b1220; color: #d1d5db; font-family: var(--mono); font-size: 12px; padding: 8px 10px; border-radius: 8px; min-height: 120px; max-height: 200px; overflow-y: auto; white-space: pre-wrap; margin: 0; }
.ftp-log .cmd { color: #fde68a; } .ftp-log .ok { color: #86efac; } .ftp-log .err { color: #fca5a5; } .ftp-log .muted { color: #93c5fd; }
.ftp-files { margin: 8px 0; }
.small-in { width: 140px; border: 1px solid var(--line-2); border-radius: 6px; padding: 3px 6px; }

/* ---------- learning centre ---------- */
.learn-modal .modal-body { padding: 0; overflow: hidden; display: flex; }
.learn { display: grid; grid-template-columns: 220px 1fr; flex: 1; min-height: 0; height: min(76vh, 760px); }
.learn-nav { border-right: 1px solid var(--line); padding: 10px; overflow-y: auto; background: var(--panel-2); }
.learn-nav button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; margin: 2px 0; }
.learn-nav button:hover { background: #fff; }
.learn-nav button.active { background: var(--primary); color: #fff; }
.learn-content { padding: 6px 22px 22px; overflow-y: auto; line-height: 1.65; }
.learn-content h2 { margin: 12px 0; }
.ltable { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; }
.ltable th, .ltable td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.ltable th { background: var(--panel-2); }
.ltip { background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 8px 12px; margin: 12px 0; font-size: 13px; }
.tool-in { width: 100%; font-family: var(--mono); padding: 7px 10px; border: 1px solid var(--line-2); border-radius: 8px; }
.tool-out { margin-top: 6px; }
.try { margin-top: 18px; }
.q { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
.q.right { border-color: #86efac; background: #f0fdf4; }
.q.wrong { border-color: #fca5a5; background: #fef2f2; }
.q p { margin: 2px 0 6px; }
.qa { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 5px 10px; margin: 3px 0; }
.qa:hover:not(:disabled) { border-color: var(--primary); }
.qa:disabled { cursor: default; color: inherit; }
.qa.correct { border-color: var(--ok); background: #dcfce7; font-weight: 600; }
.qa.chosen { border-color: var(--bad); background: #fee2e2; }
.quiz-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .app { grid-template-columns: 190px 1fr 310px; }
  .tb-lb { display: none; }
  .view-opts .tg { display: none; }
}
@media (max-width: 860px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; grid-template-rows: auto 70vh auto; height: auto; }
  .palette { border-right: 0; border-bottom: 1px solid var(--line); max-height: 220px; }
  .pal-grid { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
  .side { border-left: 0; min-height: 420px; }
  .brand-s, .hint { display: none; }
  .learn { grid-template-columns: 1fr; height: 80vh; }
  .learn-nav { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .learn-nav button { white-space: nowrap; width: auto; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
}

/* optional (out-of-syllabus) palette items */
.pal-item { position: relative; }
.pal-opt { position: absolute; top: 2px; right: 3px; font-size: 9px; line-height: 1; padding: 2px 4px; border-radius: 6px; background: var(--line); color: var(--muted, #64748b); }

/* settings dialog */
.settings { min-width: min(520px, 80vw); }
.settings h4 { margin: 14px 0 6px; }
.settings h4:first-child { margin-top: 0; }
.set-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.set-row:hover { border-color: var(--primary); background: var(--primary-2); }
.set-row input { margin-top: 3px; width: 16px; height: 16px; flex: none; }

/* lesson plan panel */
.lab-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }
.chip.lesson { background: var(--primary); color: #fff; font-weight: 700; }
.lab-progress { display: flex; align-items: center; gap: 8px; margin: 8px 0 10px; font-size: 12px; color: var(--muted); }
.lab-bar { flex: 1; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.lab-bar > div { height: 100%; background: linear-gradient(90deg, #22c55e, #16a34a); transition: width .3s; }
.lab-sec { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; margin: 8px 0; background: var(--panel-2); }
.lab-sec > summary { cursor: pointer; font-weight: 700; padding: 2px 0; }
.lab-sec ul { padding-left: 18px; margin: 6px 0; }
.lab-sec li { margin: 4px 0; }
.lab-sec p { margin: 6px 0; line-height: 1.55; }
.lab-steps li { position: relative; padding-right: 34px; }
.lab-steps li span code, .lab-sec code { background: var(--primary-2); padding: 0 4px; border-radius: 4px; font-size: .92em; }
.auto-badge { position: absolute; right: 0; top: 2px; font-size: 9px; padding: 1px 5px; border-radius: 6px; background: var(--primary-2); color: var(--primary); }
.lab-steps li.done .auto-badge { background: #dcfce7; color: #15803d; }
.hint-box { margin: 4px 0 0 24px; font-size: 12px; color: var(--muted); }
.hint-box summary { cursor: pointer; }
.qa { margin: 6px 0; }
.qa summary { cursor: pointer; font-weight: 600; }
.qa p { margin: 4px 0 4px 14px; color: var(--muted); }
.lab-btns { flex-wrap: wrap; margin-top: 12px; }
.sc-top { display: flex; align-items: center; gap: 8px; }
.sc-comp { font-size: 12px; font-weight: 600; color: var(--muted); }
.sc-extra { opacity: .85; border-style: dashed; }

/* box (marquee) selection */
.marquee { fill: rgba(37, 99, 235, .08); stroke: var(--primary); stroke-width: 1.5; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
/* lesson lock */
.lab-lock { margin-left: auto; font-size: 15px; }
.lab-lock.on { background: var(--primary-2); border-color: var(--primary); }

/* clickable "needs ipconfig /renew" hint under a red (APIPA / out-of-date) IP */
.renew-hint { font-size: 9.5px; text-anchor: middle; fill: var(--bad); font-weight: 700; cursor: pointer; paint-order: stroke; stroke: var(--canvas); stroke-width: 3px; text-decoration: underline; }
.renew-hint:hover { fill: #b91c1c; }
