/* Community tools page.  Plain CSS, no imports, no remote fonts.
 *
 * Bright, flat surfaces: one page background tone, white panels, 1 px
 * borders, one accent colour taken from the logo.  Text is anthracite;
 * secondary text is mid grey.  No gradients, no rounded illusions.
 */

:root {
  --bg: #f2f0ef;
  --panel: #ffffff;
  --panel-2: #f6f5f4;
  --line: #d9d7d5;
  --text: #2b2d2f;
  --dim: #6e7073;
  --accent: #20ccf9;
  --accent-ink: #046fa8;
  --bar: #2b2d2f;
  --bar-text: #eceae8;
  --ok: #1d8a4e;
  --bad: #c4323f;
  --warn: #7a5b00;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[hidden] { display: none !important; }
.hidden { display: none !important; }

body { padding-bottom: 2rem; }

h1, h2, h3 { margin: 0 0 .35rem; line-height: 1.2; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; margin-top: 1rem; }
p { margin: .4rem 0; }

code, pre, .mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}
pre { white-space: pre-wrap; word-break: break-word; }
.small { font-size: .82rem; }

a { color: var(--accent-ink); }
a:hover { text-decoration: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

header.top {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1rem 1.2rem .8rem;
  border-bottom: 1px solid var(--line);
}

.brand-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.brand-row img.logo {
  display: block;
  height: 64px;
  width: auto;
  margin: .2rem 0;
}

.brand { max-width: 46rem; }
.sub { color: var(--dim); }

.transport {
  min-width: min(30rem, 100%);
  padding: .7rem .8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: .7rem 1.2rem;
  background: var(--bar);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem .8rem;
  border: 1px solid #4a4c4e;
  border-radius: 6px;
  background: transparent;
  color: var(--bar-text);
  cursor: pointer;
  font: inherit;
}
.tab:hover { border-color: var(--dim); }
.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}

main {
  display: grid;
  gap: .9rem;
  padding: 1rem 1.2rem;
  max-width: 78rem;
}
main > * { min-width: 0; }   /* lets long hashes shrink instead of pushing */

/* long hex strings and hashes must wrap at any character on a phone */
p, .hint, .sub, td, .status, .result, .file-info, code {
  overflow-wrap: anywhere;
}

.panel {
  padding: .9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .5rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  align-items: center;
}
.row.wrap { align-items: flex-start; }
.grid2 {
  display: grid;
  grid-template-columns: minmax(18rem, 1fr) minmax(18rem, 1.2fr);
  gap: .9rem;
}
@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
}

.field {
  display: inline-flex;
  flex-direction: column;
  gap: .18rem;
  font-size: .8rem;
  color: var(--dim);
}
.field > span { white-space: nowrap; }

input, select, button {
  font: inherit;
  color: var(--text);
}
input[type="text"], input[type="number"], select {
  padding: .38rem .5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  min-width: 4rem;
}
input[type="color"] {
  width: 2.6rem;
  height: 2.1rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}
input[type="file"] { color: var(--dim); max-width: 16rem; }

button {
  padding: .45rem .8rem;
  border: 1px solid var(--text);
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent-ink); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--text);
  font-weight: 600;
}
button.danger {
  border-color: var(--bad);
  background: var(--panel);
  color: var(--bad);
}

a.button {
  display: inline-block;
  padding: .45rem .8rem;
  border: 1px solid var(--text);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}
a.button:hover { border-color: var(--accent-ink); color: var(--accent-ink); }

.install { padding: 16px; border: 1px solid var(--line); border-radius: 8px; }
esp-web-install-button { --esp-tools-button-color: #2b2d2f;
                         --esp-tools-button-text-color: #fff;
                         --esp-tools-button-border-radius: 6px; }

.hint { color: var(--dim); font-size: .86rem; }
.hint.bad, .status.bad { color: var(--bad); }
.warn { color: var(--warn); }
.status {
  margin-top: .35rem;
  padding: .35rem .55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--dim);
  font-size: .86rem;
}
.status.ok { color: var(--ok); border-color: #a7d3bc; }
.status.bad { color: var(--bad); border-color: #e0b6bc; }

.badge {
  display: inline-block;
  padding: .08rem .45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .72rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--panel);
}
.badge.live { color: var(--ok); border-color: #a7d3bc; }
.badge.cli { color: var(--warn); border-color: #d9c77a; }
.badge.soon { color: var(--dim); }

.ack {
  display: flex;
  gap: .45rem;
  align-items: flex-start;
  margin: .55rem 0;
  color: var(--dim);
  font-size: .86rem;
}

.result {
  margin: .5rem 0;
  padding: .45rem .6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: .88rem;
  color: var(--dim);
  background: var(--panel-2);
}
.result.ok { color: var(--ok); border-color: #a7d3bc; }
.result.bad { color: var(--bad); border-color: #e0b6bc; }

.file-info {
  margin: .35rem 0;
  padding: .35rem .5rem;
  border-left: 3px solid var(--dim);
  color: var(--dim);
  font-size: .86rem;
}
.file-info.ok { border-left-color: var(--ok); }
.file-info.bad { border-left-color: var(--bad); }

progress { width: 100%; height: .7rem; margin: .35rem 0;
           color: var(--accent); accent-color: var(--accent); }

table.list {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
table.list th, table.list td {
  padding: .28rem .4rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
table.list th { color: var(--dim); font-weight: 600; }

.downloads {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  align-items: center;
  margin: .5rem 0;
}

.editor-list {
  display: grid;
  gap: .55rem;
  grid-template-columns: repeat(auto-fit, minmax(21rem, 1fr));
}
.edit-card {
  padding: .55rem .6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}
.edit-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .35rem;
}

.neo-keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .4rem;
  margin: .4rem 0 .7rem;
}
.neo-key {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: .3rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: center;
  font-weight: 700;
  overflow: hidden;
  background: var(--panel-2);
}
canvas.neo-bar {
  width: 248px;
  max-width: 100%;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 6px;
  /* the device preview keeps the dark screen of the hardware */
  background: #10161b;
  image-rendering: pixelated;
}

.frames {
  max-height: 16rem;
  overflow: auto;
  margin: .5rem 0 0;
  padding: .55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
}
.frames.bad { color: var(--bad); }

.log {
  max-height: 11rem;
  overflow: auto;
  margin: .35rem 0 0;
  padding: .5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--dim);
}

.cli {
  margin: .35rem 0;
  padding: .55rem .65rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  overflow: auto;
}

.safety {
  margin-top: .6rem;
  padding: .55rem .65rem;
  border: 1px solid #d9c77a;
  border-radius: 6px;
  background: #fbf7ea;
  color: #6b5b00;
  font-size: .88rem;
}
.safety strong { color: #554700; }

.log-panel { margin: 0 1.2rem; }

.youtube-link {
  display: inline-block;
  margin-top: .3rem;
  color: var(--accent-ink);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-ink);
}

footer {
  max-width: 78rem;
  margin: 1rem 1.2rem 0;
  padding-top: .8rem;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: .82rem;
}

/* ------------------------------------------------------------------ MDJ site --
 * Additions only: the reference look (panels, tabs, buttons, badges, hints)
 * stays as it is. New classes below.
 */

/* The tab bar holds links: same box as a reference .tab button. */
a.tab {
  text-decoration: none;
}
a.tab.active { text-decoration: none; }

/* Cards: Home's four doors, equal height, the whole card is the link. */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: .9rem;
}
.card {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: .9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}
.card:hover { border-color: var(--accent-ink); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card h2 { color: var(--accent-ink); }
.card p { color: var(--dim); font-size: .9rem; flex: 1; }
.card .card-go {
  align-self: flex-start;
  padding: .3rem .6rem;
  border: 1px solid var(--text);
  border-radius: 6px;
  font-size: .86rem;
  font-weight: 600;
}
.card:hover .card-go { border-color: var(--accent-ink); color: var(--accent-ink); }

/* Warn box: the .warn wording in a panel that stands out. */
.warn-box {
  border-left: 4px solid #d9c77a;
  background: #fbf7ea;
}

/* Plain lists of facts and numbered steps. */
ul.facts, ol.steps-list {
  margin: .4rem 0 .6rem;
  padding-left: 1.3rem;
}
ul.facts li, ol.steps-list li { margin: .22rem 0; }
ul.facts li::marker { color: var(--accent-ink); }

h3 { color: var(--text); }

/* Tables that may be wider than a phone: scroll the table, not the page. */
.table-wrap { overflow-x: auto; margin-top: .5rem; }
table.list td, table.list th { vertical-align: top; }
table.list td.mono { font-size: .84rem; }

/* Text filter row. */
#filter { min-width: 16rem; }
input[type="text"]:focus-visible { border-color: var(--accent-ink); }

/* ------------------------------- Prepare stick (the importer, restyled) ---- */
.steps-list { counter-reset: step; }

.source-selector {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.source-option {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  cursor: pointer;
}
.source-option input[type="radio"] { margin-top: .3rem; cursor: pointer; }
.source-details {
  margin-left: 1.6rem;
  padding: .4rem .55rem;
  border-left: 3px solid var(--line);
  border-radius: 0 6px 6px 0;
  background: var(--panel-2);
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}

/* The importer's markup keeps the class names main.js / ui.js build rows with;
 * these rules give them the site's look instead of the importer stylesheet. */
.progress-bar {
  position: relative;
  height: 1.4rem;
  margin: .6rem 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .2s ease;
}
.progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  color: var(--text);
}

.results-container { margin-top: .6rem; }
.summary {
  margin-bottom: .5rem;
  padding: .4rem .55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--dim);
}

#tracksTable, #unmatchedTracks table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
}
#tracksTable th, #tracksTable td,
#unmatchedTracks th, #unmatchedTracks td {
  padding: .3rem .4rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
#tracksTable th, #unmatchedTracks th {
  color: var(--dim);
  font-weight: 600;
  background: var(--panel-2);
  position: sticky;
  top: 0;
}
#tracksTable tr:hover td, #unmatchedTracks tr:hover td { background: var(--panel-2); }

.status-icon {
  display: inline-block;
  min-width: 1.2rem;
  padding: .05rem .3rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .78rem;
  text-align: center;
}
.status-matched { color: var(--ok); border-color: #a7d3bc; }
.status-partial { color: var(--warn); border-color: #d9c77a; }
.status-unmatched, .status-error { color: var(--bad); border-color: #e0b6bc; }

.edit-btn, .use-tags { padding: .25rem .55rem; font-size: .82rem; }

.stats-box span { font-weight: 600; color: var(--text); }

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(20, 22, 24, .55);
  z-index: 1000;
}
.modal-content {
  width: min(34rem, 100%);
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.modal-body { margin: .6rem 0; }
.form-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin: .5rem 0;
}
.form-group label { min-width: 7rem; color: var(--dim); }
.form-group input, .form-group select { flex: 1; min-width: 6rem; }
.btn-icon {
  width: 2.2rem;
  height: 2.1rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
}
.modal .btn { border-color: var(--text); }

/* Toast the importer prepends to <body> when the folder API is missing. */
.warning-box {
  margin: .6rem 1.2rem;
  padding: .45rem .6rem;
  border: 1px solid #d9c77a;
  border-left: 3px solid #d9c77a;
  border-radius: 6px;
  background: #fbf7ea;
  color: #6b5b00;
  font-size: .88rem;
}

/* ------------------------------------------------- controls page: diagrams -- */
.diagram-block { margin-bottom: 1.4rem; }
.diagram-block h3 { margin-top: 1rem; }
.diagram-block:first-of-type h3 { margin-top: .2rem; }

.legend li {
  display: grid;
  grid-template-columns: 1.9rem minmax(7rem, 13rem) 1fr;
  gap: .5rem;
  align-items: baseline;
  padding: .3rem 0;
  border-bottom: 1px solid var(--line);
  font-size: .88rem;
}
.legend li:last-child { border-bottom: 0; }
.legend-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--accent);
  color: #10161b;
  font-weight: 700;
  font-size: .78rem;
}
.legend-name { font-weight: 600; }
.legend-what { color: var(--dim); }

/* The callout styles for the SVG layer live here (the SVG markup is built in
   panel.mjs; a CSP without 'unsafe-inline' cannot take <style> in SVG). */
.callout-leader {
  stroke: var(--accent-ink);
  stroke-width: 1.4;
  stroke-dasharray: 3 2;
  stroke-linecap: round;
  opacity: .85;
}
.callout-dot {
  fill: var(--accent);
  stroke: var(--accent-ink);
  stroke-width: 1.5;
}
.callout-num {
  fill: #10161b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  font-weight: 700;
}
.panel-svg {
  display: block;
  width: 100%;
  height: auto;
  margin: .4rem 0;
}

/* The complete table: mode badges and the unverified marker. */
.badge.mode-shift { color: var(--accent-ink); border-color: var(--accent); }
.badge.mode-glo, .badge.mode-hold, .badge.mode-sync-held { color: var(--warn); border-color: #d9c77a; }
.badge.mode-boot { color: var(--bad); border-color: #e0b6bc; }
.badge.unverified { margin-left: .35rem; color: var(--bad); border-color: #e0b6bc; }
.controls-table td { font-size: .86rem; }
.controls-table .col-n { color: var(--dim); width: 2.4rem; }

@media (max-width: 640px) {
  .legend li { grid-template-columns: 1.9rem 1fr; }
  .legend-what { grid-column: 2; }
  main { padding: .8rem; }
}

/* Home: latest videos from the channel (static links with local thumbnails). */
.videos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: .9rem;
}
.video {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  color: var(--text);
  text-decoration: none;
}
.video img { width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); background: #000; }
.video:hover .video-title { color: var(--accent-ink); }
.video:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.video-title { font-size: .9rem; font-weight: 600; }
