/* Undo buttons in the caption, and the app galleries (/discover, /my-apps). */
#caption .undo-delete, #caption .undo-layout, .layouts-card .sub .undo-layout {
  margin-left: 8px;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
#caption .undo-delete:hover, #caption .undo-layout:hover, .layouts-card .sub .undo-layout:hover { border-color: var(--accent); }
.actions .del-all { padding: 8px 14px; border: 1px solid var(--border); border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.actions .del-all:hover { color: var(--danger); border-color: var(--danger); }
.actions .del-all.armed { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ---------- /discover: the public apps window ---------- */
#card.discover { width: min(1400px, 100%); height: calc(100vh - 32px); gap: 16px; overflow: hidden; }
#card.discover .dhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
#card.discover .dclose { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
#card.discover .dclose:hover { color: var(--fg, inherit); background: var(--surface-2); }
#card.discover .dbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
#card.discover .dbar .filter { flex: 1; min-width: 220px; }
#card.discover .dby { display: inline-flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border: 1px solid var(--accent); border-radius: 999px; color: var(--accent); white-space: nowrap; }
#card.discover .dby[hidden] { display: none; }
#card.discover .dby button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 6px; border-radius: 999px; font-size: 12px; line-height: 1.6; }
#card.discover .dby button:hover { background: var(--surface-2); }
#card.discover .dhide { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap; }
#card.discover .dview { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
#card.discover .dview button { width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
#card.discover .dview button[aria-pressed="true"] { background: var(--surface-2); color: var(--accent); }
#card.discover .dview svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dlist { list-style: none; margin: 0; padding: 2px; overflow: auto; flex: 1; min-height: 0; align-content: start; }
.dlist.dlist[hidden] { display: none; } /* the grid/flex view rules would otherwise override [hidden] and leave the list beside the reviews panel */
.dlist li { cursor: pointer; border-radius: 14px; outline: none; transition: background 0.12s, transform 0.12s; }
.dlist li:hover, .dlist li:focus-visible { background: var(--surface-2); }
.dlist li:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.dlist .tile { display: grid; place-items: center; color: #fff; font-weight: 600; text-shadow: 0 1px 2px rgb(0 0 0 / 0.25); }
.dlist .tile.pic { border: 1px solid var(--border); }
.share-thumb { display: block; width: 240px; max-width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); margin-top: 14px; }
/* The make-public card: the gallery tile as others will see it, beside the category list. */
#card.share-public { width: min(760px, 100%); gap: 20px; padding: 26px; }
.share-head { display: flex; gap: 14px; align-items: flex-start; }
.share-badge { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.share-badge svg { width: 22px; height: 22px; }
.share-public svg path { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.share-body { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 22px; align-items: start; }
.share-preview { margin: 0; padding: 12px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-2); }
.share-pic { aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; box-shadow: 0 6px 22px rgb(0 0 0 / 0.12); }
.share-pic img { display: block; width: 100%; height: 100%; object-fit: cover; }
.share-pic.tile { display: grid; place-items: center; color: #fff; font-size: 64px; font-weight: 600; text-shadow: 0 1px 2px rgb(0 0 0 / 0.25); }
.share-preview figcaption { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.share-title { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share-chip { flex: none; padding: 3px 10px; border-radius: 999px; font-size: 12px; color: var(--muted); border: 1px dashed var(--border); }
.share-chip.set { color: var(--accent); border: 1px solid transparent; background: color-mix(in srgb, var(--accent) 14%, transparent); }
.share-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.share-side h3 { margin: 0 0 0 4px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.share-cats .list { display: flex; flex-direction: column; gap: 2px; max-height: none; outline: none; border-radius: 12px; }
.share-cats .list:focus-visible { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent); }
.share-cats .list li { align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border: 1px solid transparent; transition: background 0.12s, border-color 0.12s; }
.share-cats .list li:hover { background: var(--surface-2); }
.share-cats .list li.sel { background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.share-cats .cat-ico { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); color: var(--muted); transition: background 0.12s, color 0.12s; }
.share-cats .cat-ico svg { width: 16px; height: 16px; }
.share-cats li.sel .cat-ico { background: var(--accent); color: var(--accent-fg); }
.share-cats .radio { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--border); transition: border-color 0.12s, box-shadow 0.12s; }
.share-cats li.sel .radio { border-color: var(--accent); box-shadow: inset 0 0 0 3.5px var(--surface), inset 0 0 0 8px var(--accent); }
#card .share-desc { margin: 6px 0 0; }
#card .share-desc span { margin-left: 4px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
#card .share-desc textarea { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--fg); font: inherit; font-size: 14px; line-height: 1.4; resize: vertical; outline: 0; }
#card .share-desc textarea:focus { border-color: var(--accent); }
#card .share-prompts { flex-direction: row; align-items: center; gap: 10px; margin: 6px 0 0 4px; text-align: left; cursor: pointer; } /* beat the stacked #card label */
#card .share-prompts .switch { margin: 0; }
@media (max-width: 640px) { .share-body { grid-template-columns: minmax(0, 1fr); } }
.dlist .body { display: flex; flex-direction: column; min-width: 0; }
.dlist .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlist .by, .dlist .p { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlist li.mine .by { color: var(--accent); }
.dlist.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; padding: 4px; }
.dlist.gallery li { padding: 10px 10px 12px; border: 1px solid var(--border); }
.dlist.gallery li:hover { transform: translateY(-2px); }
.dlist.gallery .tile { aspect-ratio: 16 / 10; border-radius: 10px; font-size: 44px; margin-bottom: 10px; }
.dlist.gallery .p { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin-top: 4px; }
.dlist.list { display: flex; flex-direction: column; gap: 2px; max-height: none; } /* beat the generic .list { max-height: 50vh } */
.dlist.list li { display: flex; align-items: center; gap: 14px; padding: 8px 12px; }
.dlist.list .tile { width: 40px; height: 40px; border-radius: 10px; font-size: 18px; flex: none; }
.dlist.list .body { flex: 1; display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 3fr); gap: 4px 16px; align-items: center; }

/* ---------- /my-apps: sections of the same tiles ---------- */
.dsections { overflow: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.dsections .dlist { overflow: visible; flex: none; }
.dsec { margin: 10px 4px 2px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.dlist li { position: relative; }
.dlist li .del { position: absolute; bottom: 8px; right: 8px; border: 0; border-radius: 6px; padding: 0 5px; line-height: 16px; font-size: 10px; background: var(--surface-2); color: var(--muted); cursor: pointer; opacity: 0.75; }
.dlist li:hover .del, .dlist li:focus-within .del { opacity: 1; }
.dlist li .foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
/* The themed selects of the other cards (see /settings), in two sizes. */
#card.discover select {
  appearance: none;
  flex: none;
  border: 1px solid var(--border);
  background-color: var(--bg);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-repeat: no-repeat;
  outline: 0;
  cursor: pointer;
}
#card.discover select:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
#card.discover select:focus { border-color: var(--accent); }
#card.discover .dbar .designfilter[hidden] { display: none; }
#card.discover .dbar .catfilter, #card.discover .dbar .designfilter, #card.discover .dbar .sort, #card.discover .dbar .kind { min-width: 170px; padding: 10px 34px 10px 12px; border-radius: 10px; background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; }
.dlist .catchip { display: inline-block; margin-left: 8px; vertical-align: 1px; padding: 0 8px; border-radius: 999px; font-size: 11px; line-height: 18px; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.dlist li .foot .cat { margin-right: auto; max-width: 150px; padding: 3px 24px 3px 9px; font-size: 12px; border-radius: 8px; background-color: var(--surface-2); color: var(--muted); background-position: calc(100% - 13px) 52%, calc(100% - 9px) 52%; background-size: 4px 4px; }
.dlist li .foot .del { position: static; padding: 3px 8px; font-size: 11px; line-height: 16px; }
.dlist.list li .foot { margin-top: 0; flex: none; }
.dlist.list li .foot .cat { margin-right: 0; }
.dlist li .del:hover { color: #fff; background: #c0392b; }
.dlist.list li .del { position: static; flex: none; }
.dlist li.gone { opacity: 0; transition: opacity 0.18s; }
.pubmark { display: inline-flex; vertical-align: -2px; margin-left: 6px; color: var(--accent); }
.pubmark svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#card.discover { position: relative; }
.dconfirm { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgb(0 0 0 / 0.45); border-radius: inherit; }
.dconfirm .box { background: var(--surface, #fff); border: 1px solid var(--border); border-radius: 14px; padding: 20px 22px; width: min(420px, 90%); display: flex; flex-direction: column; gap: 10px; box-shadow: 0 10px 40px rgb(0 0 0 / 0.35); }
.dconfirm h3 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.dconfirm .sub { margin: 0; }
.dconfirm .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.dconfirm .danger { background: #c0392b; border-color: #c0392b; color: #fff; }
