/* Superadmin's circuit editor (js/ui/pages/trackEditor.js): full screen, outside the app shell.
   PC: list | centre | properties, checks along the bottom. Phone: everything stacked. */
.te { position: fixed; inset: 0; z-index: 40; display: grid; background: var(--bg); color: var(--text); font-size: 13px;
  grid-template-columns: 230px minmax(0, 1fr) 370px; grid-template-rows: auto minmax(0, 1fr) minmax(170px, 34vh);
  grid-template-areas: 'head head head' 'list center props' 'list checks props'; outline: none; }
.te-head { grid-area: head; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.te-title { display: flex; gap: 10px; align-items: baseline; min-width: 0; }
.te-title b { font-family: var(--display); letter-spacing: .5px; font-size: 15px; }
.te-title span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.te-title code { color: var(--accent); }
.te-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.te .btn.small { height: 32px; padding: 0 11px; font-size: 11px; }
.te-list { grid-area: list; overflow: auto; padding: 10px; border-right: 1px solid var(--line); background: var(--panel); }
.te-list h4 { margin: 14px 0 6px; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.te-filter { display: flex; gap: 4px; }
.te-filter button, .te-tabs button, .te-chips button { flex: 1; padding: 6px 8px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); font-size: 12px; cursor: pointer; }
.te-filter button.on, .te-tabs button.on, .te-chips button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.te-new { margin-top: 8px; }
.te-new .btn { width: 100%; }
.te-item { display: grid; grid-template-columns: 1fr auto; width: 100%; text-align: left; gap: 0 6px; padding: 6px 8px; margin: 2px 0; border-radius: 7px; border: 1px solid transparent; background: none; color: var(--text); cursor: pointer; }
.te-item:hover { background: var(--panel2); }
.te-item.on { border-color: var(--accent); background: var(--panel2); }
.te-item span { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.te-item small { grid-column: 1; color: var(--muted); font-size: 11px; }
.te-item i { grid-row: 1 / 3; grid-column: 2; align-self: center; font-style: normal; font-size: 10px; padding: 2px 6px; border-radius: 99px; background: var(--panel3); }
.te-item i.k-real { color: var(--accent); }
.te-item i.k-event { color: var(--gold); }
.te-center { grid-area: center; display: flex; flex-direction: column; min-height: 0; padding: 10px; gap: 8px; overflow: hidden; }
.te-tabs, .te-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.te-tabs button { flex: 0 0 auto; min-width: 90px; }
.te-chips button { flex: 0 0 auto; }
.te-view { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; overflow: auto; }
.te-empty { flex: 1; display: grid; place-items: center; color: var(--muted); padding: 20px; text-align: center; }
.te-plan { width: 100%; flex: 1; min-height: 260px; max-height: 70vh; background: var(--panel); border-radius: 10px; }
.te-seg { fill: none; stroke: #5d5246; stroke-linecap: butt; cursor: pointer; }
.te-seg.turn { stroke: #7d7f86; }
.te-seg:hover { stroke: #9a8a74; }
.te-seg.sel { stroke: var(--accent); }
.te-feat { fill: none; stroke-linecap: butt; cursor: pointer; opacity: .92; }
.te-feat.jump { stroke: #ff8a3d; } .te-feat.manual { stroke: #4db3ff; } .te-feat.rhythm { stroke: #c77dff; }
.te-feat.sel { stroke: #fff; opacity: 1; }
.te-lbl { fill: var(--text); font-size: 15px; font-weight: 700; text-anchor: middle; pointer-events: none; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; }
.te-lbl.turn { fill: var(--muted); font-size: 13px; }
.te-gate { stroke: #fff; stroke-width: 3; }
.te-finish { stroke: #fff; stroke-width: 3; stroke-dasharray: 4 3; }
.te-legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.te-legend span::before { content: ''; display: inline-block; width: 14px; height: 5px; border-radius: 2px; margin-right: 6px; vertical-align: middle; background: var(--muted); }
.te-legend .l-jump::before { background: #ff8a3d; } .te-legend .l-manual::before { background: #4db3ff; } .te-legend .l-rhythm::before { background: #c77dff; }
.te-legend span:last-child::before { display: none; }
.te-scroll { overflow-x: auto; max-width: 100%; }
.te-profile { display: block; background: var(--panel); border-radius: 10px; touch-action: none; }
.te-ground { fill: #6b5236; stroke: #c9a274; stroke-width: 1.5; }
.te-tick { stroke: var(--line); stroke-width: 1; }
.te-tick-l { fill: var(--muted); font-size: 10px; }
.te-flat { fill: rgba(255, 77, 94, .13); }
.te-gap { fill: var(--muted); font-size: 11px; font-weight: 600; }
.te-gap.warn { fill: #ffc94d; } .te-gap.bad { fill: #ff4d5e; }
.te-pj { cursor: ew-resize; }
.te-pj rect { fill: rgba(77, 179, 255, .12); stroke: rgba(77, 179, 255, .5); }
.te-pj.sel rect { fill: rgba(var(--accent-rgb), .2); stroke: var(--accent); }
.te-pj text { fill: var(--text); font-size: 11px; font-weight: 600; pointer-events: none; }
.te-pj text.te-pj-at { fill: var(--muted); font-weight: 400; font-size: 10px; }
.te-sel { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 8px 10px; background: var(--panel2); border-radius: 10px; }
.te-sel p { margin: 2px 0 0; color: var(--muted); }
.te-row { display: flex; gap: 6px; align-items: center; }
.te-row.wrap { flex-wrap: wrap; }
.te-muted { color: var(--muted); font-size: 12px; margin: 4px 0; }
.te-err { color: #ff4d5e; font-size: 12px; margin: 4px 0; }
.te-ro { margin: 0 0 8px; padding: 8px 10px; border-radius: 8px; background: var(--panel2); color: var(--gold); font-size: 12px; }
.te-props { grid-area: props; overflow: auto; padding: 10px; border-left: 1px solid var(--line); background: var(--panel); }
.te-fs { border: 0; margin: 0; padding: 0; min-width: 0; }
.te-fs[disabled] input, .te-fs[disabled] select, .te-fs[disabled] textarea, .te-fs[disabled] button { opacity: .55; }
.te-props details { border-bottom: 1px solid var(--line); padding: 4px 0; }
.te-props summary { cursor: pointer; padding: 8px 2px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; font-size: 12px; }
.te-sec { display: flex; flex-direction: column; gap: 8px; padding: 2px 0 10px; }
.te-f { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.te-f > span { font-size: 11px; color: var(--muted); font-weight: 600; }
.te-f > small { font-size: 11px; color: var(--muted); }
.te-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.te-in { width: 100%; min-width: 0; height: 32px; padding: 0 8px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 7px; font: inherit; }
textarea.te-in { height: auto; padding: 6px 8px; resize: vertical; }
.te-json { font-family: ui-monospace, Consolas, monospace; font-size: 11px; }
.te-in:focus { outline: none; border-color: var(--accent); }
.te-color { width: 100%; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel2); }
.te-chk { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.te-rangebox { display: flex; gap: 8px; align-items: center; }
.te-range { flex: 1; accent-color: var(--accent); }
.te-rangebox b { width: 34px; text-align: right; font-size: 12px; }
.te-x, .te-ib { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); cursor: pointer; padding: 0; }
.te-ib:disabled { opacity: .35; cursor: default; }
.te-layout { display: flex; flex-direction: column; gap: 4px; }
.te-lrow { display: flex; gap: 5px; align-items: center; padding: 4px; border-radius: 8px; border: 1px solid transparent; }
.te-lrow.turn { padding-left: 18px; background: var(--panel2); }
.te-lrow.sel { border-color: var(--accent); }
.te-lrow select.te-in { flex: 1; }
.te-lname { flex: 0 0 auto; min-width: 66px; text-align: left; background: none; border: 0; color: var(--text); font-weight: 600; cursor: pointer; padding: 0; }
.te-pal h5 { margin: 6px 0 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.te-pal-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 5px; }
.te-obs { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 5px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); cursor: pointer; text-align: left; min-width: 0; }
.te-obs:hover { border-color: var(--accent); }
.te-obs span { font-size: 11px; font-weight: 600; line-height: 1.15; }
.te-obs small { font-size: 10px; color: var(--muted); }
.te-obs-svg svg { display: block; max-width: 100%; height: auto; }
.te-obs-svg path { fill: #8a6a46; stroke: #d4ad7c; stroke-width: 1; }
.te-checks { grid-area: checks; overflow: auto; padding: 8px 12px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; align-items: start; }
.te-ck.wide { grid-column: span 2; }
.te-ck h4 { margin: 4px 0 6px; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.te-ck h4 em { font-style: normal; text-transform: none; letter-spacing: 0; margin-left: 4px; }
.te-ok { color: var(--green); } .te-bad { color: #ff4d5e; } .te-run { color: var(--accent); } .te-stale { color: var(--gold); }
.te-msgs { margin: 0; padding-left: 16px; font-size: 12px; }
.te-msgs li.bad { color: #ff4d5e; } .te-msgs li.warn { color: #ffc94d; }
.te-par { font-size: 22px; font-family: var(--display); }
.te-tab { border-collapse: collapse; font-size: 11.5px; width: 100%; }
.te-tab th, .te-tab td { padding: 3px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.te-tab th { color: var(--muted); font-weight: 600; }
.te-tab td.crash { color: #ff4d5e; font-weight: 700; }
.te-rh td.te-c { text-align: center; font-weight: 700; color: #111; min-width: 40px; }
.te-c.ok { background: #3ddc84; } .te-c.short { background: #ffc94d; } .te-c.crash { background: #ff4d5e; color: #fff !important; }
.te-3dbar { position: fixed; top: calc(8px + var(--safe-t, 0px)); left: 50%; transform: translateX(-50%); z-index: 60; display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 12px; background: #0b0c0fe8; color: #fff; box-shadow: 0 4px 18px #000a; }
.te-3dbar .btn.small { height: 32px; padding: 0 11px; font-size: 11px; }

@media (max-width: 1100px) {
  .te { grid-template-columns: 200px minmax(0, 1fr) 320px; }
  .te-ck.wide { grid-column: auto; }
}
/* Phone and narrow screens: one column, the page scrolls. */
@media (max-width: 820px) {
  .te { display: block; overflow: auto; }
  .te-head { position: sticky; top: 0; z-index: 2; }
  .te-list { max-height: 34vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .te-center { overflow: visible; }
  .te-plan { min-height: 220px; }
  .te-props { border-left: 0; border-top: 1px solid var(--line); }
  .te-checks { display: flex; flex-direction: column; }
  .te-3dbar { flex-wrap: wrap; justify-content: center; width: calc(100% - 16px); }
}

/* "Reintentar" next to a list that failed to load. */
.te-link { background: none; border: 0; padding: 0; color: var(--accent, #39ff14); text-decoration: underline; cursor: pointer; font: inherit; }
