:root {
  --bg: #fbf8f3;
  --card: #ffffff;
  --ink: #1d1a24;
  --muted: #6d6678;
  --line: #ebe4d9;
  --soft: #f3eee6;
  --c1: #ff5c8a;
  --c2: #ffb020;
  --c3: #19b5a5;
  --c4: #6c5cff;
  --focus: #6c5cff;
  --radius: 16px;
  --shadow: 0 1px 0 rgba(29, 26, 36, 0.04), 0 6px 20px -12px rgba(29, 26, 36, 0.18);
  --l: 52%;
  --s: 85%;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15131b;
    --card: #1e1b26;
    --ink: #f3eff9;
    --muted: #a49db0;
    --line: #2e2a38;
    --soft: #262230;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 8px 24px -14px rgba(0, 0, 0, 0.6);
    --l: 66%;
    --s: 80%;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font:
    15px/1.5 system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

code,
.mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.86em;
}

h1,
h2,
h3,
.logo {
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
}

/* header */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.logo svg {
  width: 34px;
  height: 34px;
  transition: transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.logo:hover svg {
  transform: rotate(-10deg) scale(1.08);
}

.logo b {
  color: var(--c1);
  font-weight: 800;
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.make .short {
  display: none;
}

#account {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  vertical-align: middle;
}

/* buttons */

.btn,
.ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.ghost:hover {
  color: var(--ink);
  background: var(--soft);
}

.btn:hover {
  border-color: var(--muted);
}

.btn.primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.btn.primary:hover {
  background: hsl(var(--h, 340) var(--s) 45%);
  border-color: transparent;
  color: #fff;
}

.btn.small {
  min-height: 30px;
  padding: 4px 11px;
  font-size: 13px;
}

.btn.danger {
  color: #d23b3b;
}

/* hero */

main {
  min-width: 0;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.hero {
  padding: 28px 0 18px;
}

.hero h1 {
  margin: 0;
  max-width: 820px;
  font-size: clamp(28px, 5vw, 48px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 800;
}

.hl {
  padding: 0 0.12em;
  border-radius: 0.2em;
  white-space: nowrap;
}

.hl.a {
  background: color-mix(in srgb, var(--c1) 26%, transparent);
}

.hl.b {
  background: color-mix(in srgb, var(--c3) 26%, transparent);
}

.sub {
  margin: 10px 0 0;
  color: var(--muted);
}

/* controls */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 10px 0;
  background: var(--bg);
}

.search {
  flex: 1 1 260px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
}

.search:focus-within {
  border-color: var(--focus);
}

.search svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  flex: none;
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  outline: none;
}

.seg {
  display: inline-flex;
  max-width: 100%;
  padding: 3px;
  border-radius: 999px;
  background: var(--soft);
}

.seg button {
  min-height: 34px;
  padding: 0 13px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.seg button[aria-pressed='true'] {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
}

select {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

.tags {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 8px;
  scrollbar-width: none;
}

.tags::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.chip:hover {
  color: var(--ink);
}

.chip[aria-pressed='true'] {
  --h: 340;
  background: hsl(var(--h) var(--s) var(--l));
  border-color: transparent;
  color: #fff;
}

/* filter links sit above the card's own link */
.card .flink {
  position: relative;
  z-index: 1;
}

.by .flink {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}

.by .flink:hover {
  color: var(--ink);
}

a.badge.dev {
  text-decoration: none;
}

a.badge.dev:hover {
  outline: 1px solid hsl(var(--h) var(--s) var(--l));
}

.chip.on {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 9px;
  background: var(--soft);
  border-color: var(--line);
  color: var(--ink);
  text-decoration: none;
}

.chip.on:hover {
  border-color: var(--muted);
}

.filter-actions {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.tagadd {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.tagadd input {
  flex: 1;
  min-width: 0;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

a.badge.tag {
  background: hsl(var(--h) var(--s) var(--l) / 0.22);
  text-decoration: none;
}

a.badge.tag:hover {
  outline: 1px solid hsl(var(--h) var(--s) var(--l));
}

.count {
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 2;
}

.count b {
  color: var(--ink);
}

/* cards */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr));
  gap: 14px;
  padding-bottom: 40px;
}

.card {
  --h: 340;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 16px 14px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition:
    transform 0.15s ease,
    border-color 0.15s ease;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg, hsl(var(--h) var(--s) var(--l)), hsl(calc(var(--h) + 50) var(--s) var(--l)));
}

.card:hover {
  transform: translateY(-2px);
  border-color: hsl(var(--h) var(--s) var(--l) / 0.6);
}

.card .pic {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  margin: -16px -16px 4px;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
  background: hsl(var(--h) 30% 12%);
}

.card .pic,
.card .pic:hover {
  text-decoration: none;
}

/* the whole picture (no cropping), over a blurred copy of itself */
.card .pic img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card .pic img.bg {
  object-fit: cover;
  filter: blur(18px) saturate(1.3) brightness(0.7);
  transform: scale(1.15);
}

/* the device's own 240x240 screen: whole, sharp pixels, on the panel colour */
.card .pic.screen {
  background: #0b0a0e;
}

.card .pic.screen img,
.shot.screen {
  object-fit: contain;
  image-rendering: pixelated;
}

.card .pic.none {
  background: linear-gradient(135deg, hsl(var(--h) var(--s) var(--l) / 0.35), hsl(calc(var(--h) + 50) var(--s) var(--l) / 0.35));
}

.card .pic.none span {
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  font-weight: 800;
  font-size: 64px;
  color: hsl(var(--h) var(--s) var(--l));
  opacity: 0.8;
}

.card h3 {
  margin: 0;
  font-size: 19px;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.card h3 a {
  text-decoration: none;
}

.card h3 a::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}

.card .head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.by {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.desc {
  margin: 0;
  color: var(--ink);
  opacity: 0.86;
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.badge {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 600;
  font-size: 12px;
}

.badge.dev {
  background: hsl(var(--h) var(--s) var(--l) / 0.18);
}

.badge.new {
  flex: none;
  background: var(--c3);
  color: #fff;
}

.warnline {
  margin: -2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.note.muted {
  font-size: 13px;
  color: var(--muted);
}

.dates {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: -2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.badge.warn {
  background: color-mix(in srgb, var(--c2) 25%, transparent);
}

.actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.empty {
  grid-column: 1 / -1;
  padding: 40px 0;
  text-align: center;
  color: var(--muted);
}

/* dialog */

dialog {
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.45);
}

dialog::backdrop {
  background: rgba(21, 19, 27, 0.5);
  backdrop-filter: blur(3px);
}

.sheet {
  --h: 340;
  position: relative;
  padding: 24px;
}

.sheet::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 8px;
  background: linear-gradient(90deg, hsl(var(--h) var(--s) var(--l)), hsl(calc(var(--h) + 50) var(--s) var(--l)));
}

.sheet h2 {
  margin: 4px 40px 2px 0;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--soft);
  color: var(--ink);
  font-size: 20px;
  cursor: pointer;
}

.picprev {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.picprev[hidden] {
  display: none;
}

.picprev img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--soft);
}

.picprev.bad img {
  display: none;
}

.picprev.bad small {
  color: var(--c1);
}

.shots {
  display: flex;
  gap: 10px;
  margin: 14px 0 4px;
}

.shots .shot.screen {
  flex: 0 0 auto;
  width: auto;
  height: 300px;
  max-width: 100%;
  aspect-ratio: 1;
  background: #0b0a0e;
}

.sheet .shot {
  display: block;
  width: 100%;
  max-height: 300px;
  min-width: 0;
  flex: 1 1 auto;
  object-fit: cover;
  border-radius: 12px;
  background: var(--soft);
}

.sheet p.lead {
  font-size: 16px;
}

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  margin: 14px 0;
  font-size: 14px;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.files {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.files li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.files li a {
  overflow-wrap: anywhere;
}

.note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--soft);
  font-size: 13px;
  color: var(--muted);
}

details.versions {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--soft);
}

details.versions summary {
  cursor: pointer;
  font-weight: 600;
}

.ver {
  padding: 8px 0 2px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
}

.ver .files li:first-child {
  border-top: 0;
}

pre.code {
  overflow-x: auto;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg);
  font:
    12px/1.5 'JetBrains Mono',
    ui-monospace,
    monospace;
}

.sheet h3 {
  margin: 22px 0 6px;
  font-size: 19px;
}

.num {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--c1);
  color: #fff;
  font-size: 14px;
  vertical-align: 2px;
}

.starters {
  display: grid;
  gap: 8px;
  margin: 10px 0;
  padding: 0;
  list-style: none;
}

.starters li {
  --h: 340;
  padding: 12px 14px;
  border-radius: 12px;
  border-left: 4px solid hsl(var(--h) var(--s) var(--l));
  background: var(--soft);
}

.starters p {
  margin: 4px 0 8px;
  font-size: 14px;
}

.codewrap {
  position: relative;
}

.codewrap .copy {
  position: absolute;
  top: 8px;
  right: 8px;
}

.note.warn {
  margin: 0;
  border: 1px solid color-mix(in srgb, var(--c2) 45%, transparent);
  background: color-mix(in srgb, var(--c2) 10%, var(--card));
  color: var(--ink);
}

.note.warn p {
  margin: 0 0 8px;
}

.confirm {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-weight: 600;
  cursor: pointer;
}

.confirm input {
  margin-top: 3px;
}

.field input[readonly] {
  opacity: 0.6;
  cursor: not-allowed;
}

dialog.wide {
  width: min(1180px, calc(100vw - 24px));
}

.emuframe {
  position: relative;
  margin: 14px 0;
  border-radius: 12px;
  overflow: hidden;
  background: #0b0a0e;
  aspect-ratio: 16 / 9;
  max-height: 72vh;
}

.emuframe.smk {
  aspect-ratio: 2 / 1;
}

.emuframe iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.emu-devs {
  margin-top: 10px;
}

.emu-devs a {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}

.emu-devs a.on {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
}

@media (max-width: 560px) {
  .emuframe,
  .emuframe.smk {
    aspect-ratio: 3 / 4;
  }
}

.idcheck {
  display: flex;
  gap: 6px;
  max-width: 360px;
}

.idcheck input {
  flex: 1;
  min-width: 0;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font:
    13px 'JetBrains Mono',
    ui-monospace,
    monospace;
}

.idresult {
  min-height: 1.5em;
  font-size: 14px;
}

/* forms */

form.edit {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.field {
  display: grid;
  align-content: start;
  gap: 4px;
}

.field > span {
  font-weight: 600;
  font-size: 13px;
}

.field small {
  color: var(--muted);
  font-size: 12px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

.field textarea {
  min-height: 90px;
  resize: vertical;
}

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

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.checks label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.checks label:has(input:checked) {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.checks input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.checks label:has(input:focus-visible) {
  outline: 2px solid var(--focus);
}

.links-ed {
  display: grid;
  gap: 6px;
}

.links-ed .lrow {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 6px;
}

.links-ed input {
  min-height: 36px;
}

.formbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding-top: 6px;
}

.err {
  color: #d23b3b;
  font-weight: 600;
  font-size: 14px;
}

/* my stuff */

.mine {
  display: grid;
  gap: 6px;
  margin: 14px 0;
  padding: 0;
  list-style: none;
}

.mine li {
  --h: 340;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border-left: 4px solid hsl(var(--h) var(--s) var(--l));
  background: var(--soft);
}

.mine li span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* footer */

.foot {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 16px 48px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.foot p {
  margin: 0;
}

.foot a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.foot a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.foot-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
}

.foot .heart {
  color: var(--c1);
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
}

.foot-links .mono {
  font-size: 13px;
}

.foot .fine {
  flex: 1 1 min(100%, 420px);
  max-width: 72ch;
}

.foot .report {
  flex: none;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-weight: 600;
}

.foot .report:hover {
  border-color: var(--c1);
  text-decoration: none;
}

@media (max-width: 560px) {
  .controls {
    position: static;
  }
  .seg {
    flex: 1 1 100%;
  }
  select {
    flex: 1 1 100%;
  }
  .nav .ghost[href='/firmware.json'] {
    display: none;
  }
  .nav {
    gap: 2px;
  }
  .nav .ghost,
  .nav .btn {
    padding: 6px 10px;
  }
  .make .long {
    display: none;
  }
  .make .short {
    display: inline;
  }
  .logo {
    font-size: 19px;
  }
  .hl {
    white-space: normal;
  }
  .seg button {
    flex: 1;
  }
  .links-ed .lrow {
    grid-template-columns: 1fr auto;
  }
  .links-ed .lrow input:first-child {
    grid-column: 1 / -1;
  }
  .sheet {
    padding: 20px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
