/* SWD Programmer: app-specific styles (shared styles: /assets/css/site.css) */

:root {
  --accent: #0b5f7a;           /* teal */
  --accent-dark: #084a5f;
  --ok: #2ea043;
  --busy: #e0a800;
  --danger: #b3261e;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1rem 1.5rem;
  align-items: start;
}
.app-head, .banner { grid-column: 1 / -1; }
.app-head { max-width: 76ch; }
.app-head h1 { margin: 0 0 0.35rem; font-size: 2rem; color: var(--brand); }
.app-head p { margin: 0; color: var(--ink-soft); }
.banner { margin: 0; padding: 0.75rem 1rem; background: #fdecea; border-left: 4px solid var(--danger); border-radius: 4px; color: #7a1c1c; font-weight: 700; }

.work, .side { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem 1.1rem; min-width: 0; }
.panel h2 { margin: 0 0 0.75rem; font-size: 1.0625rem; color: var(--brand); }

/* ---------- Controls ---------- */

.btn {
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #c5c8d4;
  border-radius: 5px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); background: #e8f3f6; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-big { font-size: 1rem; padding: 0.65rem 1.3rem; }
.btn-wide { width: 100%; }
.stack { display: flex; flex-direction: column; gap: 0.5rem; }
.hint { margin: 0.75rem 0 0; font-size: 0.875rem; color: var(--ink-soft); }
.small { font-size: 0.875rem; color: var(--ink-soft); margin: 0.6rem 0; }

/* ---------- Firmware ---------- */

.drop {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1.1rem;
  border: 2px dashed #b9bccb;
  border-radius: var(--radius);
  cursor: pointer;
}
.drop:hover, .drop.dragging, body.dragging .drop { border-color: var(--accent); background: #e8f3f6; }
.drop:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.drop strong { overflow-wrap: anywhere; }
.drop span { font-size: 0.9375rem; color: var(--ink-soft); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop.loaded { border-style: solid; border-color: var(--line); }

.fit { margin-top: 0.85rem; }
.fit-bar { height: 12px; border-radius: 6px; background: #eceef3; overflow: hidden; }
.fit-bar div { height: 100%; width: 0; background: var(--brand); }
.fit.over .fit-bar div { background: var(--danger); }
.fit-text { margin: 0.35rem 0 0; font-size: 0.875rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.messages { list-style: none; margin: 0.85rem 0 0; padding: 0; }
.messages:empty { display: none; }
.messages li { padding: 0.5rem 0.75rem; border-left: 4px solid; border-radius: 4px; margin-bottom: 0.4rem; font-size: 0.9375rem; }
.messages .error { border-color: var(--danger); background: #fdecea; color: #7a1c1c; }
.messages .warning { border-color: #d89b00; background: #fff6e0; color: #5d4300; }

.flash-row { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }
.progress { flex: 1; height: 14px; border-radius: 7px; background: #eceef3; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--ok); transition: width 0.1s linear; }

/* ---------- Chip actions ---------- */

.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0.75rem 1rem; }
.action { display: flex; flex-direction: column; gap: 0.35rem; }
.action .btn { align-self: flex-start; }
.action p { margin: 0; font-size: 0.875rem; color: var(--ink-soft); }
.more { margin-top: 1rem; }
.more summary { cursor: pointer; font-weight: 700; color: var(--brand); font-size: 0.9375rem; }
.more[open] summary { margin-bottom: 0.75rem; }

/* ---------- Side ---------- */

.conn { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.4rem; font-weight: 700; }
.dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: #b9bccb; flex: none; }
.conn.connected .dot { background: var(--ok); }
.conn.busy .dot { background: var(--busy); }
.conn.arm .dot { background: #2f6fe0; }
.link-note { margin: 0 0 0.85rem; font-size: 0.875rem; color: var(--ink-soft); min-height: 1.2em; }
.link-note.warn { color: #8a5a00; font-weight: 700; }
.code { margin: 0.4rem 0 0.75rem; padding: 0.6rem; background: #f4f4f9; border: 1px solid var(--line); border-radius: 4px; font-size: 0.6875rem; white-space: pre-wrap; overflow-wrap: anywhere; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; margin: 0; font-size: 0.9375rem; }
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.log { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; font-size: 0.8125rem; }
.log li { padding: 0.2rem 0; border-bottom: 1px solid var(--line); color: var(--ink-soft); }
.log li:last-child { border-bottom: 0; }
.log time { color: var(--ink); font-variant-numeric: tabular-nums; margin-right: 0.4rem; }
.log li.error { color: var(--danger); }
.log li.ok { color: #1d6b2a; }
.log:empty::before { content: "Nothing yet."; color: var(--ink-soft); }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .app-head h1 { font-size: 1.6rem; }
  .side { display: contents; }
  .app-head, .banner { order: -2; }
  .side .panel { order: -1; }
  .side .panel.log-panel { order: 1; }
}

/* ---------- Additions (as the PUYA ISP Programmer) ---------- */

.progress-wrap { flex: 1; display: flex; align-items: center; gap: 0.75rem; }
.progress-label { font-size: 0.875rem; color: var(--ink-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ways { margin: 0.4rem 0 0.6rem; padding-left: 1.1rem; font-size: 0.9375rem; }
.ways li { margin-bottom: 0.35rem; }
.progress div.verify { background: #2f6fe0; }
.after { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin-top: 0.9rem; font-size: 0.9375rem; }
.after label { display: inline-flex; align-items: center; gap: 0.4rem; }
.field { display: flex; flex-direction: column; gap: 0.25rem; margin: 0 0 0.75rem; font-size: 0.9375rem; }
.field span { font-weight: 700; }
.field small { color: var(--ink-soft); }
select { font: inherit; font-size: 0.9375rem; padding: 0.35rem 0.5rem; border: 1px solid #c5c8d4; border-radius: 5px; background: var(--surface); color: var(--ink); }
.wiring { margin: 0.4rem 0 0.75rem; padding: 0.6rem 0.75rem; background: #f4f4f9; border: 1px solid var(--line); border-radius: 4px; font-size: 0.8125rem; line-height: 1.5; white-space: pre; overflow-x: auto; }

/* ---------- Chip list (as the STM32 ISP Programmer) ---------- */

.btn-danger:hover:not(:disabled) { border-color: var(--danger); background: #fdecea; }
.chips-wrap { overflow-x: auto; margin-top: 0.4rem; }
.chips { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.chips th, .chips td { text-align: left; padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.chips th { color: var(--ink-soft); font-weight: 700; white-space: nowrap; }
.chips td:nth-child(2), .chips td:nth-child(3) { white-space: nowrap; font-variant-numeric: tabular-nums; }
.chips tr.found td { background: #e8f3f6; font-weight: 700; }
.tag { display: inline-block; margin-left: 0.35rem; padding: 0 0.35rem; border-radius: 3px; background: #eceef3; font-size: 0.75rem; font-weight: 400; color: var(--ink-soft); }

/* ---------- SWD Programmer additions ---------- */

.chips-wrap { max-height: 26rem; overflow-y: auto; border: 1px solid var(--line); border-radius: 4px; }
.chips thead th { position: sticky; top: 0; background: var(--surface); box-shadow: 0 1px 0 var(--line); }
.chips td:nth-child(4), .chips td:nth-child(5) { white-space: nowrap; }
.filter { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin: 0.4rem 0 0.6rem; font-size: 0.9375rem; }
.filter input { font: inherit; font-size: 0.9375rem; padding: 0.35rem 0.5rem; border: 1px solid #c5c8d4; border-radius: 5px; min-width: 0; flex: 1 1 12rem; }
.check { display: flex; align-items: flex-start; gap: 0.4rem; margin: 0 0 0.75rem; font-size: 0.9375rem; }
.check input { margin-top: 0.25rem; }
.btn-link { margin-top: 0.5rem; }
.probes { margin: 0.4rem 0 0.6rem; padding-left: 1.1rem; font-size: 0.9375rem; }
.probes li { margin-bottom: 0.3rem; }
