/* CLAUDE 10-16 (Templates): the gallery's search and favorites, the shape / clips / length filters, loading and empty
   states, a saved template's menu, and the "Use template" dialog (cliptemplates.js). The cards, chips and previews are the
   older .ct-* rules (dashboard.css). Graphite: hairlines and text, the accent only for focus and a state. */
.ct-search {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.ct-search input[type='search'] {
  flex: 1;
  min-width: 0;
  min-height: var(--h-md);
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-sm);
  box-shadow: none;
  background: var(--field-line) no-repeat left bottom / 100% 1px;
  color: var(--c-fg);
  font-size: var(--t-body);
}
.ct-search input[type='search']:is(:hover, :focus) {
  background: var(--c-raised);
}
.ct-search input[type='search']::placeholder {
  color: var(--c-fg-3);
}
.ct-search input:focus-visible,
.ct-fav:focus-visible,
.ct-more:focus-visible,
.ct-menuitem:focus-visible,
.ct-link:focus-visible,
.ct-empty button:focus-visible {
  outline: 2px solid var(--c-focus);
  outline-offset: 2px;
}
.ct-fav {
  flex: none;
  display: grid;
  place-items: center;
  min-width: var(--h-md);
  min-height: var(--h-md);
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-fg-3);
  cursor: pointer;
}
.ct-fav:hover {
  color: var(--c-fg);
  background: var(--c-raised);
}
.ct-fav[aria-pressed='true'] {
  color: var(--c-warn);
}
.ct-fav[aria-pressed='true'] path {
  fill: currentColor;
}
.ct-gallery .ct-chips {
  margin: 0 0 6px;
}
.ct-selects {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 8px;
}
.ct-status {
  margin: 0 0 10px;
  color: var(--c-fg-3);
  font-size: var(--t-meta);
}

/* the star sits top right (the sound control and the Premium pill are top left) */
.ct-cell > .fav-star {
  left: auto;
  right: 6px;
}

/* loading: cards of the grid's shape that pulse until the list is there */
.ct-skel {
  aspect-ratio: 9 / 16;
  border-radius: var(--r-md);
  background: var(--c-raised);
  animation: ct-pulse 1.4s ease-in-out infinite;
}
@keyframes ct-pulse {
  50% {
    opacity: 0.55;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ct-skel {
    animation: none;
  }
}
.ct-empty {
  grid-column: 1 / -1;
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 12px 0;
  color: var(--c-fg-2);
}
.ct-empty p {
  margin: 0;
}

/* the editor's Templates > Browse (a narrow panel, a half-height sheet on the phone): the categories and the filters are one
   row each that scrolls sideways, so the cards get the room */
.ct-compact .ct-chips,
.ct-compact .ct-selects {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.ct-compact .ct-chips::-webkit-scrollbar,
.ct-compact .ct-selects::-webkit-scrollbar {
  display: none;
}
.ct-compact .ct-chip,
.ct-compact .ct-selects .ct-select {
  flex: none;
  white-space: nowrap;
}
.ct-compact .ct-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-4) 10px;
}
.ct-compact .ct-card b {
  font-size: var(--t-label);
}
.ct-compact .ct-selects .ct-select {
  padding-left: 0;
}

/* a saved template's menu: a small button under the card, the list opens over the cards */
.ct-menubox {
  position: absolute;
  right: 0;
  bottom: 0;
}
.ct-more {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-fg-3);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.ct-more:hover,
.ct-more[aria-expanded='true'] {
  color: var(--c-fg);
  background: var(--c-raised);
}
@media (hover: none) {
  .ct-more {
    width: 44px;
    height: 44px;
  }
}
.ct-menu {
  position: absolute;
  right: 0;
  bottom: 100%;
  z-index: 5;
  display: grid;
  min-width: 170px;
  padding: 4px;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-md);
  background: var(--c-surface);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.45);
}
.ct-menuitem {
  min-height: var(--h-md);
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-fg);
  font-size: var(--t-label);
  text-align: left;
  cursor: pointer;
}
.ct-menuitem:hover {
  background: var(--c-raised);
}
.ct-menuitem.danger {
  color: var(--c-danger, #ff8a80);
}

/* "Use template" */
.ct-use {
  width: min(560px, calc(100vw - 32px));
}
.ct-dhead {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.ct-dhead .ct-thumb {
  margin: 0;
}
.ct-dinfo h2 {
  margin: 0 0 4px;
}
.ct-dinfo .ct-sub {
  margin: 0 0 4px;
}
.ct-carries {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  color: var(--c-fg-2);
  font-size: var(--t-meta);
}
.ct-premium {
  margin: 8px 0 0;
  color: var(--c-fg-2);
  font-size: var(--t-meta);
}
.ct-quick {
  display: grid;
  justify-items: start;
  gap: 6px;
  margin-top: 12px;
}
.ct-cut {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
}
.ct-cut .ct-select {
  padding-left: 0;
}
.ct-link {
  min-height: var(--h-sm);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--c-fg-2);
  font-size: var(--t-label);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.ct-link:hover {
  color: var(--c-fg);
  background: transparent;
}
.ct-link:disabled {
  opacity: 0.5;
  cursor: wait;
}
.ct-use .ct-slots li {
  grid-template-columns: 22px 44px minmax(0, 1fr);
}
.ct-slot-n {
  color: var(--c-fg-3);
  font-size: var(--t-meta);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.ct-slot-pic {
  width: 44px;
  height: 56px;
  border-radius: var(--r-sm);
  background: var(--c-raised);
  object-fit: cover;
}
.ct-slot-col {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.ct-slot-col b {
  font-size: var(--t-label);
  font-weight: 500;
}
.ct-slot-col .ct-select {
  width: 100%;
  padding-left: 0;
}
.ct-err {
  margin: 8px 0 0;
  min-height: 1.2em;
  color: var(--c-danger, #ff8a80);
  font-size: var(--t-label);
}
/* slot rules (the Save panel's folded section, the card menu's dialog), a slot's rule and why a clip does not fit it */
.ct-rules {
  display: grid;
  gap: 8px;
  margin: 8px 0;
}
.ct-rule-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 4px 8px;
  align-items: center;
}
.ct-rule-row > b {
  grid-column: 1 / -1;
  font-size: var(--t-label);
  font-weight: 500;
}
.ct-rule-row .ct-select {
  width: 100%;
  padding-left: 0;
}
.ct-rule-min {
  width: 100%;
  min-height: var(--h-sm);
}
.ct-rules-box > summary {
  cursor: pointer;
  min-height: var(--h-md);
  display: flex;
  align-items: center;
  color: var(--c-fg-2);
  font-size: var(--t-label);
}
.ct-slot-rule {
  color: var(--c-fg-3);
  font-size: var(--t-meta);
}
.ct-slot-why {
  color: var(--c-danger);
  font-size: var(--t-meta);
}
.ct-slot-why:empty {
  display: none;
}
.ct-use .ct-actions {
  flex-wrap: wrap;
  align-items: center;
}
.ct-actions .ct-look-link {
  margin-right: auto;
}
@media (max-width: 520px) {
  .ct-actions .ct-look-link {
    flex: 1 0 100%; /* on a phone the link has a line of its own, the buttons keep theirs */
    text-align: left;
    margin-bottom: 4px;
  }
}
.ct-look-parts {
  display: grid;
  gap: 4px;
  margin: 10px 0;
}
.ct-look-part {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: var(--h-md);
}
.ct-look-part small {
  color: var(--c-fg-3);
  font-size: var(--t-meta);
}
.ct-edit {
  width: min(420px, calc(100vw - 32px));
}
.ct-edit form {
  display: grid;
  gap: 10px;
}
.ct-use form[aria-busy='true'] {
  opacity: 0.75;
  pointer-events: none;
}
@media (max-width: 520px) {
  .ct-dhead {
    grid-template-columns: 72px minmax(0, 1fr);
  }
  .ct-use .ct-slots li {
    grid-template-columns: 22px 44px minmax(0, 1fr);
  }
}
