/* 接線圖編輯器。畫布永遠是淺色底（像紙），線的顏色在亮暗主題下都一樣；其他介面跟著主題。 */
.wiring-page { display: flex; flex-direction: column; min-height: 100dvh; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 16px; border-bottom: var(--stroke-hair) solid var(--line); background: var(--surface); }
.toolbar button, .side button, .dlg button, .file-btn {
  min-height: 40px; min-width: 40px; padding: 0 12px; background: var(--bg); color: var(--fg);
  border: var(--stroke-hair) solid var(--line); border-radius: var(--radius-sm); font: 600 15px/1 var(--font-head); cursor: pointer;
}
.toolbar button:hover:not(:disabled), .side button:hover, .dlg button:hover, .file-btn:hover { border-color: var(--accent); }
.toolbar button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
button.danger { color: var(--st-fail); }
.toolbar .name { flex: 0 1 220px; min-width: 120px; min-height: 40px; padding: 0 10px; background: var(--bg); color: var(--fg); border: var(--stroke-hair) solid var(--line); border-radius: var(--radius-sm); font: 700 15px/1 var(--font-head); }
.toolbar .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.save-state { margin-left: auto; font: 500 13px/1 var(--font-head); color: var(--muted); }
.toolbar .account { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border: var(--stroke-hair) solid var(--line); border-radius: var(--radius-sm); color: var(--fg); font: 600 14px/1 var(--font-head); text-decoration: none; white-space: nowrap; }
.toolbar .account.on { border-color: var(--st-ok); }
.toolbar .account.on::before { content: "●"; color: var(--st-ok); margin-right: 6px; font-size: 10px; }
.cloud-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 16px; background: var(--surface); border-bottom: 2px solid var(--st-warn); font: 500 14px/1.4 var(--font-head); }
.cloud-bar b { color: var(--st-warn); }
.cloud-bar button, .cloud-bar a { min-height: 36px; padding: 0 12px; display: inline-flex; align-items: center; background: var(--bg); color: var(--fg); border: var(--stroke-hair) solid var(--line); border-radius: var(--radius-sm); font: 600 14px/1 var(--font-head); cursor: pointer; text-decoration: none; }
.cloud-tag { margin-left: 6px; padding: 2px 6px; border: 1px solid var(--st-ok); color: var(--st-ok); font: 600 11px/1 var(--font-head); vertical-align: middle; }
.upload-all { width: calc(100% - 36px); min-height: 44px; margin-top: 12px; background: var(--accent) !important; color: var(--bg) !important; border-color: var(--accent) !important; }
#cloud-list:empty { display: none; }
#cloud-list .sub-head { padding: 0; background: none; border: 0; font: 700 14px/1.2 var(--font-head); color: var(--muted); }

.workspace { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 0; }
.canvas-wrap { position: relative; min-height: 420px; overflow: hidden; background: #F3F4EF; }
.canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.canvas .part { cursor: move; }
.canvas .pin-hit { cursor: crosshair; }
.canvas .pin-hit:hover { fill: #3E7BD633; }
.canvas .wire-hit { cursor: pointer; }
.canvas .handle { cursor: grab; }
.canvas .flash { animation: flash 1.2s ease-out 2; }
@keyframes flash { 50% { opacity: .1; } }
@media (prefers-reduced-motion: reduce) { .canvas .flash { animation: none; } }

.tip { position: absolute; z-index: 2; max-width: 230px; padding: 8px 10px; background: #1E241C; color: #F3F4EF; border-radius: 6px; font: 500 13px/1.45 var(--font-head); pointer-events: none; box-shadow: 0 4px 14px #0004; }
.tip b, .tip span { display: block; }
.tip span { color: #C9CFC3; }

.empty-hint { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; color: #45503F; pointer-events: none; }
.empty-hint[hidden] { display: none; }
.empty-hint > * { pointer-events: auto; }
.empty-hint p { margin: 0; font: 700 18px/1.3 var(--font-head); }
.empty-hint a { font-size: 14px; color: #626B5F; }

.side { border-left: var(--stroke-hair) solid var(--line); background: var(--surface); overflow-y: auto; max-height: calc(100dvh - 120px); }
.box { padding: 16px; border-bottom: var(--stroke-hair) solid var(--line); }
.box h2 { margin: 0 0 8px; font: 800 17px/1.3 var(--font-head); }
.box-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.box-head h2 { margin: 0; }
.box .lead { margin: 0 0 6px; font: 500 15px/1.5 var(--font-head); }
.box .row, .dlg .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.sub { margin: 16px 0 8px; font: 700 14px/1.2 var(--font-head); color: var(--muted); }
.howto, .notes { margin: 0; padding-left: 20px; font: 500 14px/1.6 var(--font-head); }
.howto li, .notes li { margin-bottom: 4px; }
.side .toggle { min-height: 36px; }
.side .summary { margin: 10px 0; }
.side .check { padding: 10px; gap: 10px; grid-template-columns: 26px minmax(0, 1fr); }
.side .check .light { width: 26px; height: 26px; font-size: 14px; }
.side .check-title { font-size: 15px; }
.side .check-msg { font-size: 14px; }
.side [data-check] { cursor: pointer; }
.side [data-check]:hover { outline: 1px solid var(--line); }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button { min-width: 36px; min-height: 36px; padding: 0; background: var(--sw); border: 2px solid #0003; }
.swatches button.auto { padding: 0 10px; background: var(--bg); }
.swatches button.on { outline: 3px solid var(--accent-text); outline-offset: 1px; }

.dlg { width: min(640px, calc(100vw - 32px)); max-height: min(80dvh, 720px); padding: 0; background: var(--surface); color: var(--fg); border: var(--stroke-hair) solid var(--line); }
.dlg::backdrop { background: #0008; }
.dlg > * { margin-inline: 18px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin: 14px 18px 10px; }
.dlg-head h2 { margin: 0; font: 800 19px/1.2 var(--font-head); }
.dlg .x { min-width: 40px; font-size: 22px; }
.dlg input[type="search"] { width: calc(100% - 36px); min-height: 44px; padding: 0 12px; background: var(--bg); color: var(--fg); border: var(--stroke-hair) solid var(--line); border-radius: var(--radius-sm); font: 500 16px/1 var(--font-head); }
.part-list { padding-bottom: 18px; }
.part-list h3 { margin: 16px 0 8px; font: 700 14px/1.2 var(--font-head); color: var(--muted); }
.part-list .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.part-list button { display: flex; justify-content: space-between; align-items: center; gap: 6px; min-height: 48px; padding: 8px 12px; text-align: left; line-height: 1.3; }
.part-list small { color: var(--st-warn); font-size: 12px; white-space: nowrap; }
.file-btn { display: inline-flex; align-items: center; position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.project-list { list-style: none; padding: 0; margin-top: 14px; margin-bottom: 18px; display: grid; gap: 6px; }
.project-list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; background: var(--bg); border: var(--stroke-hair) solid var(--line); }
.project-list li.current { border-color: var(--accent); }
.project-list li > div:first-child { display: grid; gap: 2px; min-width: 0; }
.project-list .row { margin-top: 0; }
.export-list { display: grid; gap: 8px; padding-bottom: 18px; }
.export-list button { display: grid; gap: 4px; justify-items: start; min-height: 60px; padding: 10px 14px; text-align: left; }
.export-list span { font-weight: 500; font-size: 13px; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10; padding: 10px 16px; background: #1E241C; color: #F3F4EF; border-radius: 8px; font: 600 15px/1.3 var(--font-head); box-shadow: 0 6px 20px #0005; }

@media (max-width: 820px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .canvas-wrap { min-height: 62dvh; }
  .side { border-left: 0; border-top: var(--stroke-hair) solid var(--line); max-height: none; }
  .toolbar { padding: 8px 12px; }
  .toolbar .name { flex: 1 1 100%; }
  .toolbar .sep { display: none; }
  .save-state { flex-basis: 100%; margin-left: 0; }
}
