:root {
  --bg: #f5f5f7;
  --fg: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.1);
  --seg: rgba(0, 0, 0, 0.05);
  --seg-on: #fff;
  --accent: #1d1d1f;
  --accent-fg: #fff;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161617;
    --fg: #f5f5f7;
    --muted: #98989d;
    --line: rgba(255, 255, 255, 0.12);
    --seg: rgba(255, 255, 255, 0.07);
    --seg-on: rgba(255, 255, 255, 0.16);
    --accent: #f5f5f7;
    --accent-fg: #1d1d1f;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 20px 28px;
}
.mark { font-weight: 600; letter-spacing: -0.01em; color: var(--fg); text-decoration: none; }
.note { color: var(--muted); font-size: 13px; }
.note a { color: var(--fg); text-decoration: none; font-weight: 500; }
.note a:hover { text-decoration: underline; }

main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 28px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.intro { width: 100%; max-width: 760px; margin: 8px 0 18px; }
.intro h1 { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; margin: 0 0 6px; }
.intro p { margin: 0; color: var(--muted); font-size: 14px; }
kbd {
  font: 12px/1 var(--font);
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
}

/* Stage: the one focal object, editable from the first second */
.stage {
  width: 100%;
  display: grid;
  place-items: center;
  border-radius: 20px;
  transition: background-color 0.15s, outline-color 0.15s;
  outline: 1.5px dashed transparent;
  outline-offset: -1.5px;
}
body.dragging .stage {
  outline-color: var(--muted);
  background: var(--seg);
}

.frame { position: relative; line-height: 0; width: min(100%, 760px); }
.frame canvas { position: relative; z-index: 1; }
.bgfx {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  opacity: 0; /* rendered for copying into the canvas, never shown directly */
  pointer-events: none;
  overflow: hidden;
}
.bgfx > div { position: absolute; inset: 0; overflow: hidden; }
.bgfx canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.frame canvas { width: 100%; height: auto; display: block; border-radius: 12px; }
/* None: show transparency in the full-size preview; the export crops to the dock */
.frame.bg-none { border-radius: 12px; background: repeating-conic-gradient(var(--seg) 0 25%, transparent 0 50%) 0 0 / 16px 16px; }

.slots { position: absolute; inset: 0; }
.slot {
  position: absolute;
  border-radius: 22%;
  cursor: grab;
  touch-action: none;
  outline: none;
}
.slot:active { cursor: grabbing; }
.slot:focus-visible { box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.7); }
.remove {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  line-height: 22px;
  font-size: 15px;
  background: rgba(60, 60, 67, 0.82);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.12s, transform 0.12s;
}
.slot:hover .remove,
.slot:focus-visible .remove,
.remove:focus-visible { opacity: 1; transform: none; }

.link {
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--muted);
  cursor: pointer;
}

.origin { margin: 14px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.origin .link { font-size: 13px; margin-left: 6px; color: var(--fg); padding: 0; }
body.touch .only-mac,
body:not(.touch) .only-touch { display: none !important; }

.status {
  min-height: 20px;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  max-width: 680px;
}

/* Controls: one quiet row */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px 22px;
}
.group { display: flex; align-items: center; gap: 8px; }
.label { color: var(--muted); font-size: 13px; }
.seg {
  display: inline-flex;
  padding: 2px;
  border-radius: 9px;
  background: var(--seg);
}
.seg button {
  border: 0;
  background: none;
  padding: 5px 11px;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
}
.seg button[aria-pressed="true"] {
  background: var(--seg-on);
  color: var(--fg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.actions { display: flex; gap: 8px; }
.ghost, .primary {
  border-radius: 9px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}
.ghost:disabled, .primary:disabled { opacity: 0.4; cursor: default; }
.ghost { border: 1px solid var(--line); background: none; }
.primary { border: 0; background: var(--accent); color: var(--accent-fg); font-weight: 500; }
button:focus-visible { outline: 2px solid rgba(10, 132, 255, 0.8); outline-offset: 2px; }

/* Search: add apps from the icon library */
.picker { width: 100%; max-width: 760px; margin-top: 32px; }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--seg);
  color: var(--muted);
  transition: box-shadow 0.12s, background-color 0.12s;
}
.search:focus-within { background: var(--seg-on); box-shadow: 0 0 0 1px var(--line), 0 6px 20px -10px rgba(0, 0, 0, 0.3); }
.search svg { width: 17px; height: 17px; flex: none; }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  color: var(--fg);
  font-size: 16px; /* 16px keeps iOS from zooming on focus */
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { opacity: 0.5; }
.picker-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin: 16px 2px 8px;
  font-variant-numeric: tabular-nums;
}
.search-note { color: var(--muted); font-size: 13px; margin: 0 2px 8px; }
.search-note:empty { display: none; }
.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 4px;
}
.grid-heading {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  margin: 10px 2px 2px;
}
.pick {
  width: 100%;
  border: 0;
  background: none;
  padding: 10px 4px 8px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background-color 0.12s, opacity 0.12s;
}
.pick:hover { background: var(--seg); }
.pick[aria-pressed="true"] { background: var(--seg-on); box-shadow: inset 0 0 0 1.5px var(--fg); }
.pick.loading { opacity: 0.5; }
.pick-icon { width: 56px; height: 56px; display: block; object-fit: contain; }
.credit { color: var(--muted); font-size: 12px; margin: 40px 2px 0; max-width: 760px; width: 100%; }
.credit a { color: var(--fg); }
.pick-name {
  font-size: 11.5px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Publish */
.publish {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 10px;
  margin-top: 16px;
  max-width: 560px;
}
.field {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  background: var(--seg);
}
.field .at { color: var(--muted); }
.field input { border: 0; background: none; outline: none; width: 200px; font-size: 16px; }
.publish .primary { height: 36px; }
.publish-note { flex-basis: 100%; text-align: center; color: var(--muted); font-size: 12px; margin: 0; }

/* The wall */
.wall { width: 100%; max-width: 760px; margin-top: 44px; }
.wall h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.wall-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px 14px;
}
.mini {
  width: 100%;
  aspect-ratio: 19 / 10;
  border: 0;
  border-radius: 12px;
  padding: 0 10px 12px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s;
}
.mini:hover { transform: translateY(-2px); }

.mini-dock {
  display: flex;
  gap: 2px;
  max-width: 100%;
  padding: 4px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.24);
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.6), 0 6px 16px -6px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.mini.tone-dark .mini-dock { background: rgba(30, 30, 34, 0.55); box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.18); }
.mini.bg-light .mini-dock { background: rgba(255, 255, 255, 0.8); }
.mini-dock img { width: 28px; height: 28px; min-width: 0; flex: 0 1 28px; display: block; object-fit: contain; }
.card-meta { margin: 8px 2px 0; font-size: 12.5px; color: var(--muted); }
.card-meta a { color: var(--fg); text-decoration: none; font-weight: 500; }
.card-meta a:hover { text-decoration: underline; }
.mini { position: relative; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.mini-dock { touch-action: pan-y; }
.mini-tip {
  position: absolute;
  left: 0;
  bottom: 0;
  max-width: calc(100% - 8px);
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(30, 30, 34, 0.86);
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.16), 0 4px 12px -4px rgba(0, 0, 0, 0.4);
  color: #f5f5f7;
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 2px);
  transition: opacity 0.1s, transform 0.1s;
}
.mini-tip.on { opacity: 1; transform: translate(-50%, 0); }
.mini.bg-light .mini-tip { background: rgba(250, 250, 252, 0.92); color: #1d1d1f; box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 4px 12px -4px rgba(0, 0, 0, 0.25); }
.wall-empty { color: var(--muted); font-size: 13px; }
.upload-hint { color: var(--muted); font-size: 13px; margin: 14px 2px 0; }
.upload-hint .link { font-size: 13px; color: var(--fg); padding: 0; }

/* Background picker: swatches */
.bg-picker { display: flex; flex-direction: column; align-items: center; gap: 8px; flex-basis: 100%; }
.bg-name { color: var(--fg); margin-left: 4px; }
.swatches { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 640px; }
.swatches button {
  width: 44px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: none;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--line);
  transition: box-shadow 0.12s, transform 0.12s;
}
.swatches button:hover { transform: translateY(-1px); }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--fg); }
.sw { display: block; width: 100%; height: 100%; border-radius: 9px; }

/* Swatch + wall card looks (CSS stand-ins for the animated backgrounds) */
.sw-desktop, .mini.bg-desktop {
  background:
    radial-gradient(55% 45% at 78% 18%, rgba(120, 205, 255, 0.85) 0%, transparent 70%),
    radial-gradient(60% 55% at 12% 30%, rgba(38, 104, 230, 0.75) 0%, transparent 70%),
    radial-gradient(80% 60% at 60% 105%, rgba(16, 64, 170, 0.9) 0%, transparent 70%),
    radial-gradient(40% 30% at 40% 62%, rgba(150, 120, 255, 0.35) 0%, transparent 70%),
    linear-gradient(170deg, #0d3a8a 0%, #0a2563 45%, #061538 100%);
}
.sw-silk, .mini.bg-silk { background: linear-gradient(135deg, #1a2150 0%, #4b5fd1 45%, #8f9cf0 55%, #1a2150 100%); }
.sw-aurora, .mini.bg-aurora { background: radial-gradient(90% 70% at 50% 0%, #5ec8ff 0%, #1d4ed8 35%, #8b5cf6 55%, #050816 85%); }
.sw-veil, .mini.bg-veil { background: radial-gradient(80% 80% at 50% 40%, #6b12ff 0%, #2a0866 45%, #05040a 85%); }
.sw-light, .mini.bg-light { background: linear-gradient(#f4f4f6, #e3e3e8); }
.sw-dark, .mini.bg-dark { background: linear-gradient(#232326, #141416); }
.sw-none, .mini.bg-none {
  background: repeating-conic-gradient(var(--seg) 0 25%, transparent 0 50%) 0 0 / 10px 10px;
}
#wallMore { margin-top: 16px; }

@media (max-width: 640px) {
  .top, main { padding-left: 16px; padding-right: 16px; }
  .top { padding-top: 14px; padding-bottom: 14px; }
  .intro h1 { font-size: 22px; }
  .actions { flex-wrap: wrap; justify-content: center; }
  .wall-grid { grid-template-columns: 1fr 1fr; gap: 14px 10px; }
  .mini-dock img { width: 20px; height: 20px; flex-basis: 20px; }
  .controls { gap: 12px 16px; }
  .seg button { padding: 6px 10px; }
}

/* Touch: no hover, so the remove button is always visible */
body.touch .remove { opacity: 1; transform: none; }
