/* The KiCad editor pages: our header (and, in the guided modes, a help panel) on top; KiCad owns the rest of the
   window below them (editor.js sets --ed-top; wx sizes its frame from #main-window's offsetTop). Light and dark from
   the site's theme (html[data-theme], theme.js) or the system. */
:root {
  --ed-top: 44px;
  --ed-bg: #f6f4ef;
  --ed-panel: #ffffff;
  --ed-fg: #13171d;
  --ed-muted: #5b6573;
  --ed-line: #ddd6c9;
  --ed-btn: #f0ece4;
  --ed-btn-hover: #e6e0d4;
  --ed-accent: #c2672b;
  --ed-accent-ink: #ffffff;
  --ed-ok: #1d8a5f;
  --ed-err: #c43c3c;
  --ed-kbd: #f0ece4;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ed-bg: #0f131a;
    --ed-panel: #141922;
    --ed-fg: #e8edf4;
    --ed-muted: #a5b0be;
    --ed-line: #2e3847;
    --ed-btn: #1a202b;
    --ed-btn-hover: #232b38;
    --ed-accent: #e8894a;
    --ed-accent-ink: #1b0f06;
    --ed-ok: #35c48d;
    --ed-err: #f06d6d;
    --ed-kbd: #222a36;
  }
}
:root[data-theme="dark"] {
  --ed-bg: #0f131a;
  --ed-panel: #141922;
  --ed-fg: #e8edf4;
  --ed-muted: #a5b0be;
  --ed-line: #2e3847;
  --ed-btn: #1a202b;
  --ed-btn-hover: #232b38;
  --ed-accent: #e8894a;
  --ed-accent-ink: #1b0f06;
  --ed-ok: #35c48d;
  --ed-err: #f06d6d;
  --ed-kbd: #222a36;
}
/* nothing on html / body that KiCad's HTML widgets would inherit (text colour, font, color-scheme): wx styles them */
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ed-bg);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
#ed-top,
#ed-help,
.ed-note {
  font: 14px/1.35 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ed-fg);
  box-sizing: border-box;
}
#ed-top *,
#ed-help *,
.ed-note * {
  box-sizing: border-box;
}
#ed-top [hidden],
#ed-help [hidden] {
  display: none !important;
}
#ed-top svg,
#ed-help svg,
.ed-note svg {
  width: 16px;
  height: 16px;
  flex: none;
}
#ed-top {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 5px 10px;
  background: var(--ed-panel);
  border-bottom: 1px solid var(--ed-line);
  flex-wrap: wrap;
}
#ed-top a {
  color: inherit;
}
.ed-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 28vw;
  text-decoration: none;
  font-weight: 560;
}
.ed-back span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ed-back:hover span,
.ed-back:focus-visible span {
  text-decoration: underline;
}
.ed-mode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--ed-btn);
  white-space: nowrap;
}
.ed-mode svg {
  color: var(--ed-accent);
}
.ed-edited {
  color: var(--ed-muted);
  font-size: 12px;
}
#ed-status {
  flex: 1 1 200px;
  min-width: 0;
  color: var(--ed-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#ed-status[data-kind="ok"] {
  color: var(--ed-ok);
}
#ed-status[data-kind="error"] {
  color: var(--ed-err);
}
.ed-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ed-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  color: var(--ed-fg);
  background: var(--ed-btn);
  border: 1px solid var(--ed-line);
  border-radius: 8px;
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.ed-btn:hover:not(:disabled) {
  background: var(--ed-btn-hover);
}
.ed-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.ed-primary {
  background: var(--ed-accent);
  border-color: var(--ed-accent);
  color: var(--ed-accent-ink);
  font-weight: 600;
}
.ed-primary:hover:not(:disabled) {
  background: var(--ed-accent);
  filter: brightness(1.08);
}
.ed-btn:focus-visible,
#ed-top a:focus-visible {
  outline: 2px solid var(--ed-accent);
  outline-offset: 2px;
}
.ed-credits {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ed-muted);
  white-space: nowrap;
}
.gpl-link a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.gpl-more {
  text-decoration: none !important;
}
/* the guided modes' five lines, above KiCad */
#ed-help {
  position: relative;
  z-index: 5;
  background: var(--ed-panel);
  border-bottom: 1px solid var(--ed-line);
  padding: 6px 12px 5px;
}
#ed-help ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 4px 18px;
}
#ed-help li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  min-width: 0;
}
#ed-help kbd {
  flex: none;
  font: 600 11.5px/1.6 "JetBrains Mono", ui-monospace, monospace;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--ed-kbd);
  border: 1px solid var(--ed-line);
  color: var(--ed-fg);
  white-space: nowrap;
}
#ed-help li:last-child span {
  color: var(--ed-accent);
  font-weight: 560;
}
html[data-mode="view"] #ed-help li:last-child span {
  color: var(--ed-muted);
}
.ed-tm {
  margin: 3px 0 0;
  font-size: 11px;
  color: var(--ed-muted);
}
/* KiCad sizes its frame from the window less #main-window's offsetTop and writes the frame's rect into the element's
   own style (left/top 0, width/height): the top keeps our header and help panel above it */
#main-window {
  position: absolute;
  top: var(--ed-top) !important;
  left: 0;
}
/* no JSPI (phones, Safari, Firefox): a note instead of a broken page */
.ed-note {
  position: absolute;
  inset: var(--ed-top) 0 0 0;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--ed-bg);
}
.ed-note[hidden] {
  display: none;
}
.ed-note > div {
  max-width: 520px;
  background: var(--ed-panel);
  border: 1px solid var(--ed-line);
  border-radius: 14px;
  padding: 22px 22px 16px;
}
.ed-note h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  font-size: 19px;
}
.ed-note h1 svg {
  width: 22px;
  height: 22px;
  color: var(--ed-accent);
}
.ed-note p {
  margin: 0 0 12px;
  color: var(--ed-muted);
}
@media (max-width: 900px) {
  .gpl-more,
  .ed-edited {
    display: none;
  }
}
@media (max-width: 640px) {
  .ed-back {
    max-width: 40vw;
  }
  #ed-status {
    order: 5;
    flex-basis: 100%;
  }
  .ed-mode b {
    display: none;
  }
}
