:root {
  color-scheme: dark;
  --bg: #0e1116;
  --panel: #171b23;
  --panel-2: #202631;
  --text: #edf2f7;
  --muted: #9aa7b6;
  --line: #303846;
  --accent: #3dd6a3;
  --accent-2: #ffca5c;
  --danger: #ff6b6b;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 44px) 18px;
  border-bottom: 1px solid var(--line);
  background: #11161d;
  box-shadow: 0 10px 28px rgb(0 0 0 / .28);
}

.topActions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
}

.status {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  white-space: nowrap;
}

#aboutBtn {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
  color: var(--text);
  cursor: pointer;
}

main {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 28px) 48px;
}

.siteFooter {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 22px clamp(18px, 4vw, 44px) 30px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #0b0f14;
}

.siteFooter p {
  margin: 0;
}

.siteFooter a {
  color: var(--accent);
  text-decoration: none;
}

.notice {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #574328;
  border-radius: var(--radius);
  background: #211a10;
  color: #ffe2aa;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 210px 210px 180px;
  gap: 12px;
  margin-bottom: 18px;
}

label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

input, select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 0 11px;
  font: inherit;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.card {
  display: flex;
  flex-direction: column;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.cardHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 10px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}

.categoryIcon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #3b4656;
  border-radius: var(--radius);
  background: #101721;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 900;
}

.category {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
}

h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.badge {
  flex: 0 0 auto;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}

.badge.ok {
  color: #b9ffe8;
  border-color: #267657;
  background: #10291f;
}

.badge.warn {
  color: #ffe0a2;
  border-color: #745626;
  background: #291f10;
}

.description {
  margin: 0;
  padding: 14px 16px 8px;
  color: #d9e2ea;
}

.creator {
  margin: 0;
  padding: 0 16px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .055em;
  text-transform: uppercase;
}

.tagList,
.hardwareList {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 16px 8px;
}

.tagList span,
.hardwareList span {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #101720;
  color: #cbd7e2;
  font-size: 12px;
}

.hardwareList span {
  border-color: #614924;
  background: #21190f;
  color: #ffd891;
}

.controls {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 1px;
  margin: 8px 16px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--line);
}

.controls div {
  padding: 7px 9px;
  background: #121720;
}

.controls div:nth-child(odd) {
  color: var(--accent-2);
  font-weight: 700;
}

.actions {
  display: flex;
  gap: 8px;
  margin: auto 16px 12px;
  flex-wrap: wrap;
}

button, a {
  border-radius: var(--radius);
  font: inherit;
}

.actions button, .actions a, dialog a, dialog button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--text);
  background: #111720;
  cursor: pointer;
}

.flashBtn {
  background: var(--accent) !important;
  color: #052016 !important;
  border-color: var(--accent) !important;
  font-weight: 800;
}

.dangerBtn {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: #260707 !important;
  font-weight: 800;
}

.disabled {
  opacity: .45;
  pointer-events: none;
  color: var(--muted) !important;
}

.notes {
  min-height: 22px;
  margin: 0;
  padding: 0 16px 15px;
  color: var(--muted);
  font-size: 13px;
}

dialog {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}

.readmeDialog {
  width: min(900px, calc(100vw - 28px));
  max-height: min(840px, calc(100vh - 28px));
}

.readmeDialog form {
  max-height: calc(100vh - 58px);
  display: flex;
  flex-direction: column;
}

.readmeHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.readmeHeader h2 {
  margin: 0;
}

.readmeContent {
  overflow: auto;
  padding-top: 16px;
  color: #dce6ee;
}

.readmeContent h2,
.readmeContent h3,
.readmeContent h4 {
  margin: 22px 0 8px;
}

.readmeContent p,
.readmeContent ul {
  margin: 0 0 12px;
}

.readmeContent code {
  padding: 1px 5px;
  border-radius: 4px;
  background: #0e131a;
  color: #ffe0a2;
}

.readmeContent pre {
  overflow: auto;
  margin: 12px 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1118;
  color: #dce6ee;
  line-height: 1.45;
}

.readmeContent pre code {
  display: block;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  white-space: pre;
}

.readmeContent table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 18px;
  font-size: 14px;
}

.readmeContent th,
.readmeContent td {
  border: 1px solid var(--line);
  padding: 7px 9px;
  vertical-align: top;
}

.readmeContent th {
  background: var(--panel-2);
  color: var(--accent-2);
  text-align: left;
}

dialog::backdrop {
  background: rgb(0 0 0 / .65);
}

dialog h2 { margin-top: 0; }

dialog menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
  margin: 18px 0 0;
}

.webusbBox {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
}

.webusbBox p {
  flex-basis: 100%;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.webusbBox progress {
  flex-basis: 100%;
  width: 100%;
  height: 12px;
  accent-color: var(--accent);
}

@media (max-width: 760px) {
  .topbar {
    display: block;
  }

  .status {
    display: inline-block;
    margin-top: 14px;
    white-space: normal;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }
}
