/* Gatewright app layout — built on the LATCH design system (../styles.css). */
html, body { height: 100%; }
body { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s2) var(--s4); background: var(--surface); border-bottom: var(--bw) solid var(--line-2); flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: var(--s3); }
.brand b { font: 700 var(--fs-lg)/1 var(--font-ui); letter-spacing: .02em; }
.logo { width: 14px; height: 14px; background: var(--ink); box-shadow: 4px 4px 0 var(--high); margin-right: 4px; }
.toolbar { flex-wrap: wrap; }
.select--sm { height: 28px; width: auto; font-size: var(--fs-xs); }

main { flex: 1; display: flex; min-height: 0; }

/* Sidebar */
#side { width: 208px; flex: none; overflow-y: auto; padding: var(--s3); background: var(--paper-2); border-right: var(--bw) solid var(--line-2); }
#palette section + section { margin-top: var(--s4); }
#palette h3 { margin: 0 0 var(--s2); font: 500 var(--fs-xs)/1 var(--font-mono); text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); }
.items { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.item {
  display: flex; flex-direction: column; align-items: center; gap: var(--s1); padding: var(--s2) var(--s1);
  background: var(--surface); border: var(--bw) solid var(--line-2); box-shadow: var(--shadow-1);
  cursor: grab; user-select: none; touch-action: none;
  transition: box-shadow .15s var(--ease), border-color .15s var(--ease), transform .15s var(--ease);
}
.item:hover { border-color: var(--accent); box-shadow: var(--shadow-2); transform: translate(-1px, -1px); }
.item:active { cursor: grabbing; }
.item span { font: 500 var(--fs-xs)/1.2 var(--font-mono); color: var(--ink-2); text-align: center; }
.pv { width: 100%; height: 44px; pointer-events: none; }
.ghost { position: fixed; z-index: 10; pointer-events: none; transform: translate(-50%, -50%); opacity: .85; height: auto; }

/* Shared SVG theme: the part/wire classes read these variables. */
#ws, .pv, .ghost {
  --body: var(--surface); --off: var(--low); --on: var(--high); --dim: var(--ink-3);
  --bulbOff: var(--low-soft); --bulbOn: var(--high); --shd: var(--line);
}

/* Canvas */
.stage { position: relative; flex: 1; min-width: 0; background: var(--surface-2); }
#ws { position: relative; z-index: 1; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#ws:active { cursor: grabbing; }
.gline { fill: none; stroke: var(--line); stroke-width: 1; }
#hint[hidden] { display: none; }
#hint { position: absolute; inset: 0; z-index: 0; display: grid; place-items: center; pointer-events: none; color: var(--ink-3); font-size: var(--fs-md); }
.stage footer {
  position: absolute; z-index: 2; left: var(--s3); bottom: var(--s3); right: var(--s3); padding: var(--s2) var(--s3);
  background: var(--surface); border: var(--bw) solid var(--line-2); pointer-events: none; line-height: 1.6;
}
.stage footer .kbd { height: 18px; min-width: 18px; vertical-align: middle; }

/* Inspector */
#inspector { margin-bottom: var(--s4); padding: var(--s3); background: var(--surface); border: var(--bw) solid var(--accent); box-shadow: 3px 3px 0 var(--accent-soft); }
#inspector h3 { margin: 0 0 var(--s2); color: var(--accent); }
#inspector label { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-top: var(--s2); }
#inspector .input, #inspector .select { width: 84px; height: 28px; font-size: var(--fs-xs); padding: 0 var(--s2); }

/* Circuit export dialog */
.dlg {
  width: min(1200px, 94vw); height: 88vh; padding: 0; color: var(--ink);
  background: var(--surface); border: var(--bw) solid var(--line-2); box-shadow: var(--shadow-2);
}
.dlg[open] { display: flex; flex-direction: column; }
.dlg::backdrop { background: rgba(30, 33, 36, .45); }
.dlg--notice { width: min(560px, 92vw); height: auto; }
.dlg-body { padding: var(--s4); font-size: var(--fs-md); line-height: 1.5; }
.chk-agree { display: flex; align-items: center; gap: var(--s2); cursor: pointer; font-size: var(--fs-sm); }
#disclaimer-ok:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.dlg-body p { margin: 0 0 var(--s3); }
.dlg-body p:last-child { margin-bottom: 0; }
.dlg-body a { color: var(--accent); }
.dlg-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: var(--bw) solid var(--line); }
.dlg-head b { font: 600 var(--fs-lg)/1 var(--font-ui); }
.dlg-head .label { flex: 1; }
.dlg-bar { display: flex; align-items: center; gap: var(--s4); padding: var(--s2) var(--s4); border-bottom: var(--bw) solid var(--line); flex-wrap: wrap; background: var(--surface-2); }
.dlg-bar label { display: flex; align-items: center; gap: var(--s2); }
.dlg-bar .grow { flex: 1; }
.dlg-preview { flex: 1; overflow: auto; background: #fff; padding: var(--s2); }
#c-preview svg, #e-preview svg { display: block; background: #fff; }
#c-preview.fit svg, #e-preview.fit svg { width: 100%; height: auto; }
.dlg-preview .empty { color: var(--ink-3); padding: var(--s7); text-align: center; font-size: var(--fs-md); }

@media (max-width: 640px) {
  .tagline { display: none; }
  #side { width: 140px; }
  .items { grid-template-columns: 1fr; }
}

.dlg-bar .chk { align-items: flex-start; }
.dlg-bar .chk > span { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-sm); }

/* Copyright box: flush in the very bottom-right corner, no margin */
.stage footer { right: 190px; }
.credit {
  position: absolute; z-index: 3; right: 0; bottom: 0; margin: 0; padding: var(--s2) var(--s3);
  font: 500 var(--fs-xs)/1 var(--font-mono); letter-spacing: .04em; white-space: nowrap; color: var(--ink-2);
  background: var(--surface); border-top: var(--bw) solid var(--line-2); border-left: var(--bw) solid var(--line-2);
}
.credit a { color: var(--accent); }
.credit .disclaimer { color: var(--ink-3); }
@media (max-width: 700px) { .credit .disclaimer { display: none; } }
@media (max-width: 900px) { .stage footer { display: none; } }
