@font-face{font-family:Montserrat;src:url(assets/Montserrat-Medium.ttf) format("truetype");font-weight:500;font-display:swap}
:root{color-scheme:dark;--bg:#101113;--surface:#1b1c1f;--line:#2c2d31;--button:#2d2e33;--text:#f0f0ee;--muted:#a5a5a8;--amber:#f3b000;--go:#2ea043;--danger:#d1242f;font:500 16px/1.24 Montserrat,system-ui,sans-serif;color:var(--text);background:#090a0b}
*{box-sizing:border-box}body{margin:0}button,input,select{font:inherit;color:inherit}button{cursor:pointer;border:0;background:var(--button);border-radius:7px;padding:9px 15px;touch-action:manipulation;-webkit-tap-highlight-color:transparent}button:disabled{cursor:default;opacity:.43}button:focus-visible,a:focus-visible,input:focus-visible,summary:focus-visible{outline:2px solid var(--amber);outline-offset:2px}button:active:enabled{filter:brightness(1.2)}img{display:block;max-width:100%;pointer-events:none;user-select:none}[hidden]{display:none!important}h1,h2,h3,h4,p{margin:0}button.go,.dialog-actions button[type=submit],#config-close{background:var(--go);color:#fff}button.danger{background:var(--danger);color:#fff}
main{width:min(100%,1280px,calc((100svh - 62px)*1.66667));margin:0 auto}
.frame{position:relative;width:100%;aspect-ratio:5/3;overflow:hidden}
.panel{position:absolute;inset:0 auto auto 0;width:800px;height:480px;transform:scale(var(--scale,1));transform-origin:top left;overflow:hidden;background:var(--bg)}
.panel-head{position:relative;height:52px;background:#101113 url(assets/panel-header.png) center/800px 52px no-repeat;touch-action:none}
.brand,.loco-id strong.original,#power span{color:transparent}
.brand{position:absolute;left:18px;top:16px;pointer-events:none}
#head-status{position:absolute;top:18px;left:306px;max-width:149px;font-size:14px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#head-status.running{background:var(--amber);border-radius:20px;color:#151515;padding:3px 9px;top:15px}
#power{position:absolute;left:464px;top:8px;width:97px;height:43px;padding:0;background:transparent}
#power img{position:absolute;left:39px;top:14px;width:50px}
.loco-id{position:absolute;left:590px;right:4px;top:18px;display:flex;align-items:baseline;gap:5px;white-space:nowrap}
.loco-id strong{font:600 21px/1.2 system-ui,sans-serif;max-width:146px;overflow:hidden;text-overflow:ellipsis;background:#101113}
.loco-id strong.original{width:103px;background:transparent}
#address{color:#99999c;font-size:15px}
#loco-view{height:428px;position:relative;background:#121315 url(assets/panel-cab.webp) center/800px 428px}
.scene{width:800px;height:349px;position:relative;touch-action:pan-y}
.scene .control{position:absolute;left:var(--x);top:var(--y);transform:translate(-50%,-50%);width:var(--w);background:none;padding:0;border-radius:3px}
.scene .control::after{content:"";position:absolute;inset:-5px}
.control .name{display:none}.control img{width:100%}
.drive{position:relative;height:79px}
.arrows{position:absolute;left:14px;top:7px;display:flex;gap:10px}
.arrows button,.stop{background:transparent;padding:0}.arrows img{width:62px;height:40px}
.throttle{position:absolute;left:155px;top:5px;width:243px;height:44px;display:grid;align-items:center}
#speed{--knob:42px;appearance:none;width:100%;height:42px;background:transparent;margin:0;padding:0;touch-action:none;cursor:grab}
#speed::-webkit-slider-runnable-track{height:14px;border-radius:12px;background:linear-gradient(to right,var(--amber) var(--pct,0%),#58575a var(--pct,0%))}
#speed::-webkit-slider-thumb{appearance:none;width:var(--knob);height:var(--knob);border-radius:50%;background:#e4e4e2;margin-top:-14px}
#speed::-moz-range-track{height:14px;border-radius:12px;background:#58575a}
#speed::-moz-range-progress{height:14px;border-radius:12px;background:var(--amber)}
#speed::-moz-range-thumb{width:var(--knob);height:var(--knob);border:0;border-radius:50%;background:#e4e4e2}
#speed:disabled{opacity:.5}
#reading{position:absolute;top:3px;left:400px;width:66px;text-align:center;font-size:40px;line-height:48px}
.brakes{position:absolute;left:466px;top:-3px;width:238px}
.brakes button{width:100%;height:30px;padding:0;display:flex;align-items:center;justify-content:flex-end;gap:6px;background:transparent;font-size:16px}
.brakes img{width:50px}.brakes button:active,.cell:active{color:var(--amber)}
.stop{width:72px;height:72px;z-index:2;touch-action:none}.stop img{width:100%}.drive .stop{position:absolute;right:12px;top:-17px}
#tech-view{position:relative;height:428px}
#functions{position:absolute;inset:4px 4px auto;display:grid;grid-template-rows:repeat(8,50px);grid-template-columns:repeat(4,196px);grid-auto-flow:column;gap:2px}
.cell{display:grid;grid-template-columns:30px 50px 1fr;gap:5px;align-items:center;text-align:left;background:transparent;padding:0;font-size:16px}
.cell small{font-size:16px;text-align:right;color:#8c8c8f}.cell-control{display:grid;place-items:center}.cell-control img{max-width:50px}.cell-name{line-height:1.12;overflow-wrap:anywhere}
.tech-stop,.program-stop{position:absolute;right:12px;bottom:3px}
#program-view{position:relative;height:428px}.program-workspace,#program-content{height:100%}
.panel.editing[data-page="3"] .panel-head,.panel[data-page="4"] .panel-head{display:none}
.panel.editing #program-view{height:480px}
.program-heading,.screen-title{height:57px;display:flex;align-items:center;justify-content:space-between;padding:4px 16px;gap:12px}
.program-heading h3,.screen-title h2{font-size:20px;font-weight:500}
.program-heading button,.screen-title button,.program-actions button{height:44px}
.program-list{margin:0 104px 0 14px;height:calc(100% - 80px);overflow:auto;scrollbar-width:thin}
.program-list:has(.program-empty){display:grid;align-items:center;text-align:center}
.program-empty{color:var(--muted);white-space:pre-line;font-size:20px;line-height:1.4;text-align:center}
.program-row,.step-row{border:1px solid var(--line);background:var(--surface);border-radius:8px}
.program-row{min-height:62px;margin:4px 5px 7px 0;display:flex;align-items:center;gap:8px;padding:5px 8px 5px 14px}
.program-row.current{border:2px solid var(--amber)}.program-name{flex:1;min-width:0;overflow-wrap:anywhere;font-size:18px}.program-name small{display:block;margin-top:3px;font-size:14px;color:var(--muted)}.current .program-name small,.step-info small{color:var(--amber)}
.program-actions,.dialog-actions{display:flex;gap:8px;align-items:center}.program-actions button{font-size:15px;padding:6px 12px}
.program-actions .go,.program-actions .danger{width:148px;font-size:18px}
.program-footer{position:absolute;left:18px;bottom:5px;max-width:675px;color:var(--muted);font-size:14px}.program-footer:has(button:not([hidden])){background:var(--surface)}
.editing .program-heading,.screen-title{padding:5px 10px;border-bottom:2px solid var(--line)}
.editing .program-heading .go,.screen-title .go{min-width:150px;font-size:20px}
.edit-name{flex:1;min-width:0;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;background:transparent;font-size:20px}
.editor-columns{height:calc(100% - 57px);display:grid;grid-template-columns:minmax(0,536fr) minmax(0,264fr)}
.step-list,.palette{overflow:auto;scrollbar-width:thin;overscroll-behavior:contain}
.step-list{padding:8px 16px 36px 10px}.step-list:has(.program-empty){display:grid;place-items:center}
.step-row{min-height:50px;margin-bottom:6px;display:grid;grid-template-columns:45px 35px 1fr 38px;align-items:center;gap:3px}
.step-row button{background:transparent;padding:4px}.step-row .drag-step{font-size:22px;color:var(--muted);touch-action:none;cursor:grab}.step-row small,.move-hint{color:#98989b}
.step-row .step-info{display:flex;align-items:center;justify-content:space-between;gap:4px;text-align:left;min-height:44px;font-size:15px}
.step-row .step-info small{color:var(--amber);text-align:right}.delete-step{font-size:23px}.step-row.unreachable .step-info,.step-row.unreachable .step-info small{color:#aa6060}
.step-row.current,.step-row.drop-target{border-color:var(--amber)}.move-hint{position:absolute;bottom:0;left:10px;font-size:14px;padding:4px;background:var(--bg)}
.editing .program-footer{left:0;bottom:0;max-width:524px;background:var(--bg)}.editing .program-footer:has(#stop-active-program[hidden]){display:none}
.palette{border-left:2px solid var(--line);padding:4px 10px 85px 5px}
.palette h4{font-weight:500;color:var(--muted);margin:8px 0 6px}.palette>button,.choices button,#talk-options button{display:block;text-align:left;width:100%;min-height:42px;margin-bottom:5px;padding:7px 10px}
.function-pair{display:grid;align-items:center;grid-template-columns:1fr auto auto;gap:4px;font-size:14px;margin-bottom:5px}.function-pair button{padding:7px}
#config-view{height:480px}.config-columns{display:grid;grid-template-columns:200px 1fr;gap:16px;padding:8px 12px;height:calc(100% - 57px)}
#config-menu{display:flex;flex-direction:column;gap:8px}#config-menu button{min-height:55px;font-size:18px}
#config-menu button[aria-pressed=true],.current-loco,.choices button[aria-pressed=true]{background:var(--amber);color:#161310}
.config-body{overflow:auto;padding:3px 8px 15px 0}.config-body h3{font-weight:500;font-size:19px;margin-bottom:12px}.config-body p{margin-bottom:16px;color:#c4c4c6}.config-body button{margin:5px 0 15px}
.config-body .current-loco{padding:12px;color:#181818;border-radius:6px}.config-body form{margin:22px 0 10px}
#decoder-address{width:130px}.ui-link{display:inline-block;background:var(--button);padding:10px;border-radius:6px}
footer{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 4px;border-top:1px solid #343538;background:#111214;min-height:51px}
footer nav{display:flex;gap:3px}footer button{font:500 13px/1.2 system-ui,sans-serif;background:transparent;color:#b2b2b5;padding:8px 12px;min-height:33px}
footer button[aria-pressed=true]{color:var(--amber);background:#252421}.led{display:inline-block;background:var(--amber);width:7px;height:7px;border-radius:50%;margin-right:7px}
body[data-link=online] .led{background:#63ba7b}body[data-link=offline] .led{background:#e78370}
#warning{position:fixed;bottom:10px;left:50%;transform:translateX(-50%);background:#3d2c16;padding:12px;border-radius:6px;z-index:8;color:#ffe2a8;max-width:95vw}
dialog{background:var(--surface);color:var(--text);border:2px solid var(--line);border-radius:12px;padding:22px;width:min(520px,94vw);max-height:90dvh;overflow:auto}
dialog::backdrop{background:#000b}dialog h2{font-size:20px;font-weight:500}
dialog p,dialog details{margin:13px 0;line-height:1.45}
.dialog-head,.dialog-actions{display:flex;align-items:center;justify-content:space-between;gap:8px}.dialog-head>button{background:transparent;font-size:22px}.dialog-actions{justify-content:flex-end;margin-top:16px}
input:not([type=range]),select{background:#101113;border:1px solid #47484c;padding:9px;color:var(--text);border-radius:6px;font:inherit}
#key,#program-fields label input{display:block;width:100%;margin-top:5px}
#program-fields{display:grid;gap:12px;margin:14px 0}.parameter{display:grid;grid-template-columns:48px 90px 48px 1fr;gap:8px;align-items:center}
.parameter>span{grid-column:1/-1;color:var(--muted)}.parameter input[type=number]{width:100%;text-align:center;font-size:22px;appearance:textfield}.parameter input::-webkit-inner-spin-button{appearance:none}.parameter input[type=range]{width:100%;accent-color:var(--amber)}
#talk-options{margin-top:16px}.choices>span{display:block;color:var(--muted);margin-bottom:8px}
#login-error{color:#ffc377}a{color:var(--amber)}
@media(max-width:650px) and (orientation:portrait){
  main{width:100%}.frame{aspect-ratio:auto;overflow:visible}.panel{position:relative;inset:auto;width:100%;height:auto;transform:none;overflow:visible}
  .panel-head{height:52px;background:#131416;display:flex;padding:6px 10px;gap:9px;align-items:center;border-bottom:1px solid var(--line)}
  .brand{position:static;color:var(--amber);font:bold 19px/1.15 system-ui,sans-serif}.brand span{display:none}
  .loco-id{position:static;display:block;margin-left:auto}.loco-id strong,.loco-id strong.original{display:inline;color:var(--text);font-size:16px;background:transparent}#address{font-size:12px}
  #head-status{display:none}#head-status.running{display:block;left:auto;right:5px;top:52px;z-index:3;max-width:140px}
  #power{position:static;display:flex;gap:4px;align-items:center;justify-content:center;width:auto;min-height:40px;padding:4px;background:transparent}
  #power span{color:var(--text);font-size:13px}#power img{position:static;width:42px}
  #loco-view{height:auto;background:var(--bg);display:flex;flex-direction:column}
  .scene{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%;height:auto;gap:0 8px;padding:0 10px;order:2}
  .scene::before{content:"";grid-column:1/-1;margin:0 -10px 5px;aspect-ratio:691/349;background:#111 url(assets/panel-photo.webp) center/cover}
  .scene .control{position:static;transform:none;display:flex;align-items:center;justify-content:space-between;gap:5px;width:100%;padding:4px 0;min-height:48px;border-bottom:1px solid var(--line)}
  .scene .control::after{display:none}.control .name{display:block;text-align:left;font-size:13px}.control img{width:auto;max-width:44px;max-height:34px}
  .drive{height:auto;order:1;display:grid;grid-template-columns:auto 1fr 44px 48px;align-items:center;gap:7px;padding:7px 10px;background:#18191b;border-bottom:1px solid var(--line)}
  .drive>*{position:static}.arrows{gap:3px}.arrows img{width:36px;height:auto}.arrows button{min-height:42px}.throttle{width:100%;height:auto}#speed{--knob:30px}#speed::-webkit-slider-thumb{margin-top:-8px}
  #reading{position:static;width:auto;font-size:24px;line-height:1}.drive .stop{position:static;grid-column:4;grid-row:1/3;width:48px;height:48px}.brakes{width:100%;grid-column:1/4;grid-row:2;display:flex;gap:8px}.brakes button{min-height:40px;height:auto;font-size:12px;text-align:left;justify-content:space-between}.brakes img{width:31px}
  #tech-view{height:auto}#functions{position:static;grid-auto-flow:row;grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:none;gap:0 4px;padding:2px 5px}
  .cell{grid-template-columns:25px 37px 1fr;gap:3px;font-size:13px;min-height:50px;border-bottom:1px solid var(--line);border-radius:0}.cell small{font-size:12px}.cell-control img{max-width:35px}
  .tech-stop,.program-stop{position:sticky;display:block;bottom:54px;margin:3px 8px 4px auto;width:52px;height:52px}
  #program-view,.panel.editing #program-view,#config-view{height:auto;min-height:58svh}.program-workspace,#program-content{height:auto}
  .program-heading{height:auto;min-height:53px;padding:6px 8px}.program-heading button{height:auto;min-height:42px;font-size:14px}.program-heading h3{font-size:18px}
  .program-list{margin:0 8px;max-height:60svh;height:auto;min-height:35svh}.program-empty{font-size:16px}.program-row{display:block;margin:6px 0;padding:8px}.program-name{font-size:16px}.program-actions{gap:6px;margin-top:8px}.program-actions button,.program-actions .go,.program-actions .danger{font-size:13px;width:auto;flex:1}
  .program-footer,.editing .program-footer{position:static;padding:4px 9px}
  .editing .program-heading{display:grid;grid-template-columns:auto 1fr auto;gap:3px}.editing .program-heading .go{min-width:0;font-size:14px}.editing .program-heading button{padding:5px 7px}.edit-name{font-size:15px}
  .editor-columns{display:flex;flex-direction:column;height:auto}.step-list{max-height:42svh;padding:7px}.step-list:has(.program-empty){min-height:90px}
  .palette{display:grid;grid-template-columns:1fr 1fr;gap:4px;max-height:42svh;border:0;border-top:1px solid var(--line);padding:7px}.palette h4,.function-pair{grid-column:1/-1}.palette>button{font-size:13px;margin:0}.step-row{grid-template-columns:35px 21px 1fr 34px}.step-row .step-info{font-size:13px}.move-hint{position:static;display:block;font-size:12px}
  .screen-title .go{min-width:0;font-size:16px}.config-columns{display:block;height:auto;padding:8px}#config-menu{display:flex;flex-direction:row;flex-wrap:wrap;gap:4px}#config-menu button{min-height:40px;padding:6px 9px;font-size:13px}.config-body{padding:16px 4px}
  footer{position:sticky;bottom:0;z-index:4;flex-wrap:wrap;justify-content:center;gap:2px;padding:3px}footer button{font-size:12px;padding:5px 9px}#connect{font-size:12px;min-height:26px}footer nav{width:100%;justify-content:space-around}
  .parameter{grid-template-columns:40px 65px 40px minmax(40px,1fr);gap:4px}dialog{padding:15px}
}
@media(orientation:landscape) and (max-height:550px){main{width:min(100%,calc((100svh - 31px)*1.66667))}footer{min-height:30px;padding:0}footer button{min-height:28px;font-size:11px;padding:4px 8px}}
.throttle:before{content:"";position:absolute;left:21px;right:21px;top:50%;transform:translateY(-50%);height:14px;border-radius:12px;background:linear-gradient(to right,var(--amber) var(--pct,0%),#58575a var(--pct,0%));pointer-events:none}
#speed{position:relative}#speed::-webkit-slider-runnable-track{background:transparent}#speed::-moz-range-track,#speed::-moz-range-progress{background:transparent}
dialog{zoom:clamp(.6,var(--ui-scale,1),1.6);max-height:min(470px,85dvh)}
#program-dialog[data-kind=keyboard]{width:800px;height:480px;max-width:100vw;max-height:100dvh;padding:14px 20px;border:0;border-radius:0;background:var(--bg)}
#program-dialog[data-kind=keyboard] .dialog-head>button{display:none}
#program-dialog[data-kind=keyboard] #program-fields label{font-size:0;width:65%}
#program-dialog[data-kind=keyboard] #program-fields input{font-size:20px;height:54px}
#program-dialog[data-kind=keyboard] .dialog-actions{position:absolute;right:20px;top:44px;margin:0;height:54px}
#program-dialog[data-kind=keyboard] .dialog-actions button{height:100%;min-width:98px}
.name-keys{position:absolute;inset:124px 5px 4px;display:flex;flex-direction:column;gap:5px}
.name-keys>div{display:flex;flex:1;gap:4px}.name-keys button{flex:1;padding:4px;font-size:19px}.name-keys .space-key{flex:5}
@media(max-width:650px) and (orientation:portrait){
  .throttle{position:relative}.throttle:before{left:15px;right:15px}
  dialog{zoom:1}
  #program-dialog[data-kind=keyboard]{width:min(94vw,520px);height:auto;padding:15px;border:2px solid var(--line);border-radius:10px}
  #program-dialog[data-kind=keyboard] #program-fields label{width:100%}
  #program-dialog[data-kind=keyboard] .dialog-actions{position:static;height:auto}
  #program-dialog[data-kind=keyboard] .dialog-actions button{height:44px}
  .name-keys{display:none}
}
