/* Total Engineering · Robot Lab: estilos compartidos de las celdas (base: Brazo KUKA). */
/* Layout: one-screen app — 3D cell on the left, a teach-pendant style control panel on the right (stacks on phones). The learning article scrolls below it. */
:root {
  color-scheme: dark;
  --bg: #14181c;
  --panel: #1d2329;
  --panel-2: #262e35;
  --line: #34404a;
  --fg: #e6ebef;
  --muted: #93a1ad;
  --accent: #f07a2a;
  --accent-ink: #1a0f06;
  --ok: #4cc38a;
  --warn: #f2c14e;
  --bad: #e5484d;
  --x: #ef5b5b;
  --y: #52c46b;
  --z: #4f8ff0;
  --font-ui: "Barlow", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Consolas", monospace;
}
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 15px; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.home { display: flex; align-items: center; gap: 8px; color: var(--fg); text-decoration: none; font-weight: 700; white-space: nowrap; }
.home img { display: block; }
h1.brand { margin: 0; font-size: 18px; }
h1.brand b { color: var(--accent); }
.labtabs { display: flex; gap: 4px; background: var(--panel-2); border-radius: 999px; padding: 3px; }
.labtabs a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; padding: 5px 12px; border-radius: 999px; white-space: nowrap; }
.labtabs a:hover { color: var(--fg); }
.labtabs a[aria-current] { background: var(--accent); color: var(--accent-ink); }

/* Welding: PPE button stays above the arc-flash overlay so it can always be found */
.ppe { position: relative; z-index: 1001; padding: 6px 12px; border-radius: 999px; border: 2px solid var(--warn); background: transparent; color: var(--warn); font-weight: 700; white-space: nowrap; }
.ppe[aria-pressed="true"] { border-color: var(--ok); background: rgba(76,195,138,.16); color: var(--ok); }
.ppe.alert { background: var(--warn); color: #1a1300; animation: ppePulse .5s infinite alternate; }
@keyframes ppePulse { to { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(242,193,78,.45); } }
.blind { position: fixed; inset: 0; z-index: 1000; background: #fff; pointer-events: none; animation: flash .09s infinite alternate; }
@keyframes flash { from { opacity: .97; background: #fff; } to { opacity: 1; background: #f4f8ff; } }
.shade { position: absolute; inset: 0; background: rgba(6, 30, 14, .88); pointer-events: none; }
.arcglow { position: absolute; width: 150px; height: 150px; margin: -75px 0 0 -75px; border-radius: 50%; pointer-events: none; background: radial-gradient(circle, #fff 0 8%, #e9ffe9 14%, rgba(150,255,170,.45) 32%, rgba(60,160,90,.12) 55%, transparent 70%); }
.equip { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sw { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 600; font-size: 13.5px; text-align: left; }
.sw::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); flex: none; }
.sw[aria-pressed="true"] { border-color: var(--ok); }
.sw[aria-pressed="true"]::before { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.wparams { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; font-size: 13.5px; }
.wparams input[type="range"] { grid-column: 1 / -1; accent-color: var(--accent); }
.meter { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.meter div { background: #11161a; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-family: var(--font-mono); font-size: 15px; font-variant-numeric: tabular-nums; }
.meter small { display: block; font-family: var(--font-ui); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.qline { font-size: 13.5px; padding: 8px 10px; border-radius: 6px; background: var(--panel-2); border-left: 4px solid var(--ok); }
.qline[data-kind="warn"] { border-left-color: var(--warn); }
.qline[data-kind="bad"] { border-left-color: var(--bad); }
.report { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; line-height: 1.5; background: #11161a; }
.report b { color: var(--fg); }
.report ul { margin: 4px 0 0; padding-left: 18px; color: #cfd8df; }
.prog .ln .t-ARC { color: #ffd34d; font-weight: 600; }
.learn { max-width: 1100px; margin: 0 auto; padding: 36px 16px 56px; }
.learn h2 { font-size: 24px; margin: 0 0 16px; }
.learn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.learn section { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.learn h3 { margin: 0 0 6px; font-size: 16px; color: var(--accent); }
.learn p { margin: 0; font-size: 14.5px; line-height: 1.55; color: #cfd8df; }
.learn .links { margin-top: 20px; color: var(--muted); }
.learn a { color: var(--accent); }
.bar { display: flex; align-items: center; gap: 12px; padding-block: 8px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.brand small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.pill { font-family: var(--font-mono); font-size: 12px; padding: 3px 8px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.mode { color: var(--accent); border-color: var(--accent); }
.msg { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 4px 10px; border-radius: 4px; background: var(--panel-2); min-height: 32px; }
.msg .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }
.msg[data-kind="warn"] .dot { background: var(--warn); }
.msg[data-kind="error"] .dot { background: var(--bad); }
.msg span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ack { margin-left: auto; padding: 3px 10px; border-radius: 4px; border: 1px solid var(--warn); background: transparent; color: var(--warn); font-weight: 600; }
.estop { width: 56px; height: 56px; border-radius: 50%; border: 5px solid var(--warn); background: radial-gradient(circle at 40% 35%, #ff6b6b, #b3141b); color: #fff; font-weight: 700; font-size: 11px; line-height: 1.05; flex: none; box-shadow: 0 2px 0 #000; }
.estop[aria-pressed="true"] { transform: translateY(2px); box-shadow: none; filter: saturate(1.3); outline: 3px solid var(--bad); }

.layout { flex: 1; min-height: 0; display: flex; }
.view { position: relative; flex: 1; min-width: 0; }
.view canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.readout { position: absolute; top: 10px; left: 10px; background: rgba(20,24,28,.82); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-family: var(--font-mono); font-size: 12px; display: grid; grid-template-columns: auto auto auto auto; gap: 2px 10px; font-variant-numeric: tabular-nums; pointer-events: none; }
.readout .h { grid-column: 1 / -1; color: var(--muted); font-family: var(--font-ui); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin-top: 2px; }
.readout b { color: var(--muted); font-weight: 400; }
.speed { position: absolute; left: 10px; bottom: 10px; font-family: var(--font-mono); font-size: 12px; background: rgba(20,24,28,.82); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.speed .lim { color: var(--warn); }
.views { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; }
.views button, .btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 6px 10px; font-weight: 600; }
.views button:hover, .btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.pad { width: 400px; flex: none; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; padding: 10px 4px; background: transparent; border: 0; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600; }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.tabpane { flex: 1; overflow-y: auto; padding: 14px 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.group { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { background: var(--panel-2); border: 0; border-right: 1px solid var(--line); padding: 8px 4px; font-weight: 600; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.seg button:disabled { opacity: .4; cursor: not-allowed; }
.row { display: flex; align-items: center; gap: 10px; }
.row input[type="range"] { flex: 1; accent-color: var(--accent); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.enable { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.enable-btn { padding: 12px; border-radius: 6px; border: 2px solid var(--line); background: var(--panel-2); font-weight: 700; user-select: none; -webkit-user-select: none; touch-action: none; }
.enable-btn[data-state="1"] { border-color: var(--ok); background: rgba(76,195,138,.18); color: var(--ok); }
.enable-btn[data-state="2"] { border-color: var(--bad); background: rgba(229,72,77,.18); color: var(--bad); }
.panic { padding: 12px 10px; border-radius: 6px; border: 1px solid var(--bad); background: transparent; color: var(--bad); font-weight: 600; font-size: 13px; touch-action: none; user-select: none; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.check input { accent-color: var(--accent); }

.jog { display: grid; grid-template-columns: 44px 1fr 92px 1fr; gap: 6px; align-items: center; }
.jog .ax { font-weight: 700; font-family: var(--font-mono); }
.jog .val { text-align: center; font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); }
.jog button { padding: 11px 0; border-radius: 6px; border: 1px solid var(--line); background: var(--panel-2); font-size: 18px; font-weight: 700; touch-action: none; user-select: none; -webkit-user-select: none; }
.jog button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.prog { border: 1px solid var(--line); border-radius: 6px; background: #11161a; font-family: var(--font-mono); font-size: 12.5px; max-height: 230px; overflow-y: auto; }
.prog .ln { display: grid; grid-template-columns: 18px 26px 1fr; gap: 4px; padding: 5px 8px; border-bottom: 1px solid #1f262c; cursor: pointer; }
.prog .ln:hover { background: #182027; }
.prog .ln.sel { background: #23303a; }
.prog .ln .ptr { color: var(--accent); }
.prog .ln .n { color: var(--muted); }
.prog .ln .t-PTP { color: #ff9a55; } .prog .ln .t-LIN { color: #49cbe3; } .prog .ln .t-CIRC { color: #7be287; }
.prog .empty { padding: 14px; color: var(--muted); font-family: var(--font-ui); }
.add { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field select, .field input { background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 7px 8px; color: var(--fg); width: 100%; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.hint { font-size: 13px; color: var(--muted); line-height: 1.4; }
pre.krl { margin: 0; background: #11161a; border: 1px solid var(--line); border-radius: 6px; padding: 10px; font-family: var(--font-mono); font-size: 12px; overflow-x: auto; white-space: pre; color: #cfd8df; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 4px; }

.ch { border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: grid; grid-template-columns: 30px 1fr; gap: 4px 10px; background: var(--panel-2); }
.ch .st { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--muted); grid-row: span 2; }
.ch.done .st { background: var(--ok); border-color: var(--ok); color: #06210f; }
.ch h3 { margin: 0; font-size: 15px; }
.ch p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.4; grid-column: 2; }
.score { font-family: var(--font-mono); font-size: 13px; }
kbd { font-family: var(--font-mono); font-size: 12px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--panel-2); }
.help p, .help li { font-size: 14px; line-height: 1.5; color: #cfd8df; }
.help ul { padding-left: 18px; margin: 4px 0; }
.help h3 { margin: 6px 0 0; font-size: 15px; }

@media (max-width: 860px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .layout { flex-direction: column; }
  .view { height: 52vh; min-height: 300px; flex: none; }
  .pad { width: 100%; border-left: 0; border-top: 1px solid var(--line); }
  .tabpane { overflow: visible; }
  .readout { font-size: 10px; padding: 5px 7px; gap: 1px 7px; top: 6px; left: 6px; }
  .brand small, #pillTool, #pillCoord { display: none; }
  h1.brand { font-size: 16px; }
  .msg { flex-basis: 100%; min-width: 0; order: 5; }
  .views { right: 10px; bottom: 44px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Robot Lab · celdas compartidas (SCARA, cartesiano, delta, colaborativo) */
.labtabs { overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.labtabs::-webkit-scrollbar { display: none; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-size: 13.5px; }
.kv span:nth-child(odd) { color: var(--muted); }
.kv b { font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.kv .ok { color: var(--ok); } .kv .warn { color: var(--warn); } .kv .bad { color: var(--bad); }
textarea.code { width: 100%; min-height: 220px; resize: vertical; background: #11161a; color: #cfd8df; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; tab-size: 2; }
.codeview { border: 1px solid var(--line); border-radius: 6px; background: #11161a; font-family: var(--font-mono); font-size: 12.5px; max-height: 260px; overflow-y: auto; }
.codeview div { padding: 2px 8px; white-space: pre; color: #cfd8df; }
.codeview div.cur { background: #23303a; color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.codeview div.err { background: rgba(229,72,77,.18); }
.codeview i { color: var(--muted); font-style: normal; }
canvas.chart { width: 100%; height: 110px; display: block; background: #11161a; border: 1px solid var(--line); border-radius: 6px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tiles div { background: #11161a; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-family: var(--font-mono); font-size: 16px; font-variant-numeric: tabular-nums; }
.tiles small { display: block; font-family: var(--font-ui); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.lamp { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.lamp::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #3a454e; }
.lamp.on::before { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.lamp.warn::before { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.lamp.bad::before { background: var(--bad); box-shadow: 0 0 6px var(--bad); }
.lamps { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.tag { position: absolute; transform: translate(-50%, -100%); font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 4px; background: rgba(20,24,28,.85); border: 1px solid var(--line); pointer-events: none; white-space: nowrap; }
table.ref { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.ref th, table.ref td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
table.ref th:first-child, table.ref td:first-child { text-align: left; }
table.ref th { color: var(--muted); font-weight: 600; font-size: 11.5px; }
table.ref .bad { color: var(--bad); } table.ref .ok { color: var(--ok); }
@media (max-width: 860px) { .labtabs { order: 4; flex-basis: 100%; } }.speed { max-width: calc(100% - 200px); }
