/* seq.powf.net — 製図用紙の白と紺のインク、通電の赤 */
:root {
  --ink: #16324f; --ink2: #4a6278; --line: #c9d4de; --grid: #e8eef3; --paper: #fbfcfd; --bg: #f1f4f7;
  --hot: #e0412e; --hot2: #ff6a4d; --ok: #1d8a4e; --warn: #b7791f; --err: #c53030;
  --panel: #2b3440; --panel2: #39434f;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif; }
button, select, input, textarea { font: inherit; color: inherit; }
a { color: var(--ink); }

/* ヘッダー */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 10px 18px; background: #fff; border-bottom: 2px solid var(--ink); }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo b { display: block; font-size: 17px; letter-spacing: .02em; }
.logo small { display: block; font-size: 10.5px; color: var(--ink2); letter-spacing: .08em; }
.menu { display: flex; flex-wrap: wrap; gap: 6px; }
.mbtn { border: 1.5px solid var(--ink); background: #fff; border-radius: 4px; padding: 5px 12px; cursor: pointer; font-size: 14px; }
.mbtn:hover { background: var(--grid); }
.mbtn.primary { background: var(--ink); color: #fff; }
.mbtn.primary:hover { background: #22476d; }
.mbtn.danger { border-color: var(--err); color: var(--err); }

/* 2つの面 */
.app { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; padding: 14px; max-width: 1500px; margin: 0 auto; }
.pane { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 12px; min-width: 0; }
.pane-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.pane h2 { margin: 0; font-size: 16px; }
.pane h2 small { font-weight: normal; color: var(--ink2); margin-left: 4px; }
.tools, .simctl { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.tool { border: 1px solid var(--line); background: #fff; border-radius: 4px; padding: 4px 8px; cursor: pointer; font-size: 13px; line-height: 1.4; white-space: nowrap; }
.tool:hover { border-color: var(--ink2); }
.tool.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tool:disabled { opacity: .4; cursor: default; }
.ti { display: inline-block; min-width: 1em; text-align: center; margin-right: 3px; font-weight: bold; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.spd { font-size: 13px; display: flex; align-items: center; gap: 4px; }
.spd select { border: 1px solid var(--line); border-radius: 4px; padding: 3px; background: #fff; }

/* シーケンス図 */
.ladder-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); max-height: 70vh; -webkit-overflow-scrolling: touch; }
.ladder { display: block; width: 100%; min-width: 600px; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.cellbg { fill: transparent; stroke: var(--grid); stroke-width: 1; stroke-dasharray: 2 3; }
.cellbg.outcol { fill: rgba(22, 50, 79, .035); }
.rown { font-size: 11px; fill: #9aabbb; text-anchor: middle; }
.rail { stroke: var(--ink); stroke-width: 3.5; }
.rail.hot { stroke: var(--hot); }
.railn { font-size: 11px; fill: var(--ink2); }
.wl { stroke: var(--ink); stroke-width: 2; fill: none; stroke-linecap: round; }
.wl.hot, .blade.hot { stroke: var(--hot); stroke-width: 3; }
.dot { fill: var(--ink); }
.dot.hot { fill: var(--hot); }
.term { fill: #fff; stroke: var(--ink); stroke-width: 1.5; }
.blade { stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
.stop { stroke: var(--ink); stroke-width: 2; }
.act { stroke: var(--ink2); stroke-width: 1.4; stroke-dasharray: 3 2; }
.actk { stroke: var(--ink); stroke-width: 1.8; fill: none; }
.coil { fill: #fff; stroke: var(--ink); stroke-width: 2; }
.coil.en { fill: #ffe3dd; stroke: var(--hot); stroke-width: 2.6; }
.lamp { fill: #fff; stroke: var(--ink); stroke-width: 2; }
.lampx { stroke: var(--ink); stroke-width: 1.4; pointer-events: none; }
.lamp.on.c-green { fill: #5ee08e; } .lamp.on.c-red { fill: #ff6b5a; } .lamp.on.c-yellow { fill: #ffe14d; }
.lamp.on.c-orange { fill: #ffaa3b; } .lamp.on.c-white { fill: #fff6c9; } .lamp.on { stroke: var(--hot); }
.dn { font-size: 12.5px; font-weight: bold; fill: var(--ink); text-anchor: middle; }
.ds { font-size: 10.5px; fill: var(--ink2); text-anchor: middle; }
.osc { font-size: 10px; fill: #fff; text-anchor: middle; paint-order: stroke; stroke: var(--err); stroke-width: 3px; }
.cursor { fill: rgba(224, 65, 46, .08); stroke: var(--hot); stroke-width: 1.5; stroke-dasharray: 4 3; pointer-events: none; }
.cursor-v { stroke: var(--hot); stroke-width: 3; stroke-dasharray: 4 3; pointer-events: none; }
.hint { font-size: 13px; color: var(--ink2); margin: 8px 2px 0; min-height: 2.6em; }
.issues ul { margin: 6px 0 0; padding: 0; list-style: none; font-size: 13px; }
.issues li { padding: 5px 8px 5px 26px; border-radius: 4px; margin-top: 4px; position: relative; }
.issues li::before { position: absolute; left: 8px; font-weight: bold; }
.issues li.err { background: #fdecec; color: #8a1f1f; } .issues li.err::before { content: "✕"; }
.issues li.warn { background: #fdf5e6; color: #7a4f0e; } .issues li.warn::before { content: "!"; left: 11px; }
.issues .ok { font-size: 13px; color: var(--ok); margin: 6px 2px 0; }

/* 制御盤 */
.power { display: flex; align-items: center; gap: 6px; border: 1.5px solid var(--ink); background: #fff; border-radius: 4px; padding: 4px 10px; cursor: pointer; font-weight: bold; font-size: 13px; }
.pw-led { width: 11px; height: 11px; border-radius: 50%; background: #9aa5b1; }
.power.on .pw-led { background: #3fd37a; box-shadow: 0 0 6px #3fd37a; }
.power.trip .pw-led { background: var(--err); box-shadow: 0 0 6px var(--err); }
.breaker { background: #fdecec; border: 2px solid var(--err); border-radius: 6px; padding: 10px 12px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: #7a1c1c; }
.breaker b { font-size: 15px; }
.breaker .mbtn { align-self: flex-start; border-color: var(--err); }
.board { background: linear-gradient(#323c49, var(--panel)); border-radius: 8px; padding: 12px; color: #e9eef3; min-height: 140px; box-shadow: inset 0 0 0 3px #1d242d, inset 0 2px 10px rgba(0, 0, 0, .4); }
.board .empty { color: #b8c4cf; font-size: 14px; margin: 30px 10px; text-align: center; }
.grp { margin-bottom: 10px; }
.grp:last-child { margin-bottom: 0; }
.grp h4 { margin: 0 0 6px; font-size: 11px; letter-spacing: .12em; color: #9fb0c0; font-weight: normal; border-bottom: 1px solid #45505d; padding-bottom: 3px; }
.row { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.dev { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px; }
.dvn { font-size: 12px; font-weight: bold; font-family: Menlo, Consolas, monospace; }
.dvl { font-size: 11px; color: #b8c4cf; max-width: 96px; text-align: center; line-height: 1.3; }

/* 押しボタン */
.pb { width: 50px; height: 50px; border-radius: 50%; border: 5px solid #8d98a5; cursor: pointer; box-shadow: 0 4px 0 #161b21, 0 5px 8px rgba(0, 0, 0, .5), inset 0 -4px 6px rgba(0, 0, 0, .25), inset 0 3px 4px rgba(255, 255, 255, .35); transition: transform .05s, box-shadow .05s; touch-action: none; -webkit-tap-highlight-color: transparent; }
.pb.c-green { background: #28a55a; } .pb.c-red { background: #d93a2b; } .pb.c-yellow { background: #f0c419; }
.pb.c-orange { background: #f08a24; } .pb.c-white { background: #e8ecef; } .pb.c-black { background: #2a2f35; }
.pb.down { transform: translateY(4px); box-shadow: 0 0 0 #161b21, 0 1px 3px rgba(0, 0, 0, .5), inset 0 -2px 4px rgba(0, 0, 0, .3), inset 0 2px 3px rgba(255, 255, 255, .25); filter: brightness(1.15); }
.pb:focus-visible, .ss:focus-visible, .ls:focus-visible { outline: 3px solid #7cc4ff; outline-offset: 3px; }
/* 切換スイッチ */
.ss { width: 50px; height: 50px; border-radius: 50%; background: radial-gradient(#59636f, #2e353e); border: 3px solid #8d98a5; position: relative; cursor: pointer; padding: 0; }
.ss span { position: absolute; left: 50%; top: 6px; width: 8px; height: 34px; margin-left: -4px; background: #e9eef3; border-radius: 4px; transform: rotate(-40deg); transform-origin: 50% 19px; transition: transform .15s; }
.ss.on span { transform: rotate(40deg); background: #ffd25e; }
/* リミットスイッチ */
.ls { width: 56px; height: 42px; border-radius: 6px; background: #4d5763; border: 2px solid #8d98a5; position: relative; cursor: pointer; padding: 0; touch-action: none; }
.ls span { position: absolute; left: 8px; top: 14px; width: 36px; height: 6px; background: #d5dbe1; border-radius: 3px; transform: rotate(-20deg); transform-origin: 3px 3px; transition: transform .08s; }
.ls.down span { transform: rotate(0deg); background: #ffd25e; }
/* サーマル */
.thr { width: 64px; padding: 4px; border-radius: 4px; background: #e2e6ea; color: #26313c; text-align: center; font-size: 11px; line-height: 1.3; border: 2px solid #8d98a5; }
.thr b { display: block; font-size: 12px; }
.thr.tripped { background: #ffd3cc; border-color: var(--err); }
.thr.tripped .st { color: var(--err); font-weight: bold; }
.mini { margin-top: 3px; font-size: 11px; padding: 1px 6px; border-radius: 3px; border: 1px solid #8d98a5; background: #39434f; color: #e9eef3; cursor: pointer; }
.mini:hover { background: #4a5562; }
/* ランプ */
.pl { width: 40px; height: 40px; border-radius: 50%; border: 4px solid #8d98a5; display: block; transition: background .08s, box-shadow .08s; }
.pl.c-green { background: #1f4a31; } .pl.c-red { background: #4e1f1b; } .pl.c-yellow { background: #4d4419; } .pl.c-orange { background: #4f331a; } .pl.c-white { background: #4a4c4e; }
.pl.on.c-green { background: radial-gradient(#d8ffe6, #3ee07f 55%, #1b9b50); box-shadow: 0 0 18px 4px rgba(62, 224, 127, .7); }
.pl.on.c-red { background: radial-gradient(#ffe0da, #ff5a45 55%, #c0281a); box-shadow: 0 0 18px 4px rgba(255, 90, 69, .7); }
.pl.on.c-yellow { background: radial-gradient(#fffbe0, #ffe13e 55%, #c9a412); box-shadow: 0 0 18px 4px rgba(255, 225, 62, .7); }
.pl.on.c-orange { background: radial-gradient(#fff0dc, #ffa23e 55%, #c9701a); box-shadow: 0 0 18px 4px rgba(255, 162, 62, .7); }
.pl.on.c-white { background: radial-gradient(#fff, #fff4c8 60%, #d6cfa8); box-shadow: 0 0 18px 4px rgba(255, 246, 200, .7); }
.bz { width: 40px; height: 40px; border-radius: 50%; background: #1f252c; border: 4px solid #8d98a5; display: flex; align-items: center; justify-content: center; color: #59636f; font-size: 18px; }
.bz.on { color: #ffd25e; animation: buzz .12s linear infinite; box-shadow: 0 0 14px rgba(255, 210, 94, .6); }
@keyframes buzz { 0% { transform: translateX(-1px); } 50% { transform: translateX(1px); } 100% { transform: translateX(-1px); } }
/* モーター */
.motor { width: 82px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.fan { width: 64px; height: 64px; }
.mring { fill: #1f252c; stroke: #8d98a5; stroke-width: 3; }
.blades path { fill: #aab6c2; }
.motor.run .blades path { fill: #ffd25e; }
.hub { fill: #e9eef3; }
.blades { transform-origin: 30px 30px; transform-box: view-box; }
.blades.spin { animation: spin .3s linear infinite; }
.blades.spin.rev { animation-direction: reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
.mdir { font-size: 11px; color: #b8c4cf; }
.motor.run .mdir { color: #ffd25e; font-weight: bold; }
/* リレー */
.relay { width: 72px; padding: 6px 4px 5px; border-radius: 4px; background: #e2e6ea; color: #26313c; text-align: center; position: relative; border: 2px solid #8d98a5; font-size: 12px; }
.relay.mc { background: #d7dde3; border-radius: 2px; }
.relay b { display: block; font-family: Menlo, Consolas, monospace; }
.relay .led { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: #8d98a5; }
.relay.en .led { background: #ff8a3d; box-shadow: 0 0 5px #ff8a3d; }
.relay.on .led { background: #ff3b2a; box-shadow: 0 0 6px #ff3b2a; }
.relay .arm { display: block; height: 5px; width: 40px; margin: 3px auto 0; background: #8d98a5; border-radius: 2px; transform: translateY(-2px) rotate(-6deg); transition: transform .06s; }
.relay.on .arm { transform: none; background: var(--hot); }
.relay.on { border-color: var(--hot); }
.relay.osc { animation: oscw .2s linear infinite; }
@keyframes oscw { 50% { border-color: #ffd25e; } }
.relay .bar { display: block; height: 6px; background: #b6c0ca; border-radius: 3px; overflow: hidden; margin: 4px 2px 2px; }
.relay .bar i { display: block; height: 100%; width: 0; background: var(--hot); }
.relay .tv { font-size: 10.5px; }

/* タイムチャート */
.sub { font-size: 14px; margin: 14px 0 6px; }
.sub small { font-weight: normal; color: var(--ink2); margin-left: 6px; font-size: 12px; }
.chart-wrap { border: 1px solid var(--line); border-radius: 4px; background: var(--paper); }
.chart { display: block; width: 100%; height: auto; }
.cg { stroke: var(--grid); stroke-width: 1; }
.ct { font-size: 10px; fill: var(--ink2); text-anchor: middle; }
.cl { font-size: 11px; fill: var(--ink); font-family: Menlo, Consolas, monospace; }
.cw { fill: none; stroke-width: 2; stroke-linejoin: round; }
.cw.in { stroke: #2b6cb0; } .cw.rel { stroke: var(--hot); } .cw.out { stroke: var(--ok); }

/* 説明 */
.wrap { max-width: 1100px; margin: 0 auto; padding: 10px 18px 40px; }
.explain h2 { font-size: 18px; border-left: 4px solid var(--hot); padding-left: 10px; margin-top: 28px; }
.cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.cols h3 { font-size: 15px; margin: 0 0 4px; }
.cols p { margin: 0; font-size: 14px; color: #33475b; }
.names { width: 100%; border-collapse: collapse; background: #fff; font-size: 14px; }
.names th, .names td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.names th { background: var(--grid); }
.names td:first-child { font-family: Menlo, Consolas, monospace; font-weight: bold; white-space: nowrap; }
.note { font-size: 12.5px; color: var(--ink2); margin-top: 22px; }

/* ダイアログ */
.dlg { border: none; border-radius: 8px; padding: 0; max-width: min(540px, 94vw); width: 100%; box-shadow: 0 10px 40px rgba(0, 0, 0, .35); color: var(--ink); }
.dlg::backdrop { background: rgba(16, 28, 40, .5); }
.dlg form { padding: 18px 20px 16px; }
#dlg-body h3 { margin: 0 0 10px; font-size: 17px; }
#dlg-body h4 { margin: 12px 0 4px; font-size: 14px; }
#dlg-body p, #dlg-body ol { font-size: 14px; }
#dlg-body ol { padding-left: 1.4em; }
#dlg-body ol li { margin: 3px 0; }
#dlg-body label { display: block; font-size: 13px; color: var(--ink2); margin: 8px 0; }
#dlg-body input, #dlg-body select, #dlg-body textarea { display: block; width: 100%; margin-top: 3px; border: 1.5px solid var(--line); border-radius: 4px; padding: 6px 8px; background: #fff; font-size: 15px; }
#dlg-body label.big input { font-size: 20px; font-family: Menlo, Consolas, monospace; text-transform: uppercase; letter-spacing: .05em; }
#dlg-body textarea { font-size: 12px; font-family: Menlo, Consolas, monospace; word-break: break-all; }
.kindp { margin: 4px 0; color: var(--ok); font-weight: bold; font-size: 13.5px; }
.kindp.bad { color: var(--err); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.chip { border: 1.5px solid var(--ink); background: var(--ink); color: #fff; border-radius: 14px; padding: 2px 11px; cursor: pointer; font-size: 13px; font-family: Menlo, Consolas, monospace; }
.chip.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.props { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.dlg-btns { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-top: 14px; }
.samples { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow: auto; }
.sample { width: 100%; text-align: left; border: 1.5px solid var(--line); background: #fff; border-radius: 6px; padding: 8px 12px; cursor: pointer; }
.sample:hover { border-color: var(--ink); background: var(--grid); }
.sample b { display: block; font-size: 15px; }
.sample span { display: block; font-size: 12.5px; color: var(--ink2); line-height: 1.45; margin-top: 2px; }
.srow { display: flex; gap: 6px; align-items: center; }
.srow .mini { background: #fff; color: var(--err); border-color: var(--err); margin: 0; }
.help { padding-left: 1.4em; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 30px); background: var(--ink); color: #fff; padding: 9px 18px; border-radius: 20px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: 92vw; text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; padding: 8px; gap: 10px; }
  .cols { grid-template-columns: 1fr; }
  .ladder-wrap { max-height: 60vh; }
}
@media (max-width: 560px) {
  .top { padding: 8px 10px; }
  .logo small { display: none; }
  .mbtn { padding: 4px 9px; font-size: 13px; }
  .tool { padding: 4px 6px; font-size: 12.5px; }
  .props { grid-template-columns: 1fr; }
  .names td:first-child { white-space: normal; }
  .names th, .names td { padding: 5px 6px; font-size: 13px; }
  .pb { width: 56px; height: 56px; }
}
@media (prefers-reduced-motion: reduce) { .bz.on { animation: none; } }
