#choose-template {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 42px;
  color: var(--brand-navy);
  font-weight: 600;
}
#template-picker {
  width: min(860px, calc(100vw - 32px));
  height: min(750px, calc(100% - 32px));
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  background: white;
  box-shadow: 0 18px 80px #01205438;
}
#template-picker[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
#template-picker::backdrop { background: #01163399; }
.picker-heading, .picker-footer, .picker-results { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.picker-heading, .picker-footer { padding: 16px 22px; }
.picker-heading { border-bottom: 1px solid var(--border); }
.picker-heading h2 { margin: 0; font-size: 22px; }
.picker-heading p, .picker-footer p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.picker-scroll { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 16px 22px 22px; }
.picker-filters { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; }
.picker-filters label { display: grid; gap: 4px; min-width: 0; font-weight: 600; font-size: 12px; }
.picker-filters input, .picker-filters select {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: white;
  color: var(--text);
  font-size: 14px;
  font-weight: normal;
}
.picker-results { min-height: 42px; font-size: 12px; color: var(--muted); }
#picker-clear { padding: 5px; border: 0; color: var(--link); text-decoration: underline; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.picker-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
}
.picker-card:hover { border-color: var(--border-strong); }
.picker-card input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.picker-card:has(:focus-visible) { outline: 3px solid var(--brand-magenta); outline-offset: 2px; }
.picker-card:has(:checked) { border-color: var(--brand-navy); box-shadow: 0 0 0 1px var(--brand-navy); }
.picker-art {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 10;
  padding: 10px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}
.picker-art img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 1px 5px #01205420; }
.picker-blank svg { width: 36px; height: 36px; stroke-width: 1.3; color: var(--muted); }
.picker-name { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex: 1; padding: 9px 10px; font-weight: 600; overflow-wrap: anywhere; }
.picker-card input:checked ~ .picker-name { background: var(--tint-cyan); color: var(--brand-navy); }
.picker-card input:checked ~ .picker-name::after { content: '✓' / ''; }
.picker-footer { border-top: 1px solid var(--border); }
.picker-footer strong { color: var(--brand-navy); overflow-wrap: anywhere; }
.picker-footer p:empty { display: none; }
#picker-apply { flex-shrink: 0; }
@media (max-width: 600px) {
  #template-picker { width: calc(100vw - 12px); height: calc(100% - 12px); height: calc(var(--editor-height, 100dvh) - 12px); }
  .picker-heading, .picker-footer, .picker-scroll { padding: 12px; }
  .picker-heading h2 { font-size: 19px; }
  .picker-filters { grid-template-columns: 1fr 1fr; }
  .picker-filters label:first-child { grid-column: 1 / -1; }
  .picker-filters input, .picker-filters select { font-size: 16px; }
  .picker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .picker-footer { flex-wrap: wrap; gap: 8px; }
  #picker-apply { min-height: 44px; }
}
