.creative-tools {
  --tools-line: color-mix(in srgb, var(--text) 13%, var(--surface));
  --tools-motion: 200ms cubic-bezier(.2, .7, .2, 1);
  width: min(100%, 1380px);
  margin-inline: auto;
  padding: clamp(12px, 2vw, 32px);
  color: var(--text);
}

.creative-tools > h1 { margin: 0 0 20px; }

.creative-tools__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr));
  gap: clamp(12px, 2vw, 24px);
}

.creative-tools__card {
  display: grid;
  align-content: start;
  overflow: hidden;
  border: 1px solid var(--tools-line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--tools-motion), background var(--tools-motion), transform var(--tools-motion);
}

.creative-tools__cover { display: block; overflow: hidden; background: var(--bg-card-2); }
.creative-tools__cover img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: transform 360ms cubic-bezier(.2, .7, .2, 1);
}

.creative-tools__card-content { position: relative; padding: 16px 48px 20px 18px; }
.creative-tools__card h2 { font: 700 1.25rem/1.2 var(--font-heading); color: var(--text); }
.creative-tools__card p { margin-top: .45em; color: var(--text-muted); line-height: 1.45; }

.creative-tools__card-content::after,
.creative-tools__back::before {
  content: '';
  width: 7px;
  height: 7px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(-45deg);
}

.creative-tools__card-content::after {
  position: absolute;
  top: 25px;
  right: 20px;
  color: var(--text-muted);
  transition: color var(--tools-motion), translate var(--tools-motion);
}

.creative-tools__card:focus-visible { border-color: var(--accent); }

@media (hover: hover) {
  .creative-tools__card:hover { background: var(--bg-card-2); border-color: var(--accent-line); transform: translateY(-3px); }
  .creative-tools__card:hover img { transform: scale(1.035); }
  .creative-tools__card:hover .creative-tools__card-content::after { color: var(--accent); translate: 3px; }
}

.creative-tools__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 16px;
}
.creative-tools__bar h1 { margin: 0; font-size: clamp(1.25rem, 3vw, 1.8rem); }

.creative-tools__back,
.creative-tools__expand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 14px;
  border: 1px solid var(--tools-line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: color var(--tools-motion), background var(--tools-motion), border-color var(--tools-motion);
}
.creative-tools__back::before { transform: rotate(135deg); }
.creative-tools__expand { margin-inline-start: auto; }

.creative-tools__back:hover,
.creative-tools__expand:hover,
.creative-tools__archive a:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}

.creative-tools :is(.creative-tools__card, .creative-tools__back, .creative-tools__expand, .creative-tools__notice a, .creative-tools__notice .btn, .creative-tools__compose summary, .creative-tools__compose select[data-starter-choice], .creative-tools__archive a):focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 3px;
}

.creative-tools__compose,
.creative-tools__notice {
  margin: 0 0 24px;
  padding: 16px clamp(12px, 2vw, 20px);
  border: 1px solid var(--tools-line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text-muted);
}

.creative-tools__notice a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.creative-tools__notice .btn { width: auto; margin-top: 12px; }

.creative-tools__compose summary {
  width: fit-content;
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  transition: color var(--tools-motion);
}
.creative-tools__compose summary:hover,
.creative-tools__compose[open] summary::marker { color: var(--accent); }
.creative-tools__compose > label { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 16px 0 12px; }
.creative-tools__compose select[data-starter-choice] {
  max-width: 100%;
  min-height: 44px;
  padding-inline: 10px;
  border: 1px solid var(--tools-line);
  border-radius: var(--radius-sm);
  background: var(--bg-card-2);
  color: var(--text);
  accent-color: var(--accent);
}
.creative-tools__compose > [role=status]:empty { display: none; }
.creative-tools__compose > [role=status]:not(:empty) { margin-top: 8px; }
.creative-tools__archive { margin-top: 24px; }
.creative-tools__archive nav { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.creative-tools__archive a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid var(--tools-line);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: color var(--tools-motion), background var(--tools-motion), border-color var(--tools-motion);
}

html:has(.formula-creative-main) { scrollbar-gutter: auto; }
.formula-creative-main { padding: 0; width: 100%; min-width: 0; }
.creative-tools--editor { width: 100%; padding: 0; }
.creative-tools--editor .creative-tools__bar { margin: 0; padding: 8px clamp(12px, 2vw, 24px); }
.creative-tools--editor > .creative-tools__notice { margin-inline: clamp(12px, 2vw, 24px); }
@media (max-width: 520px) {
  .creative-tools--editor .creative-tools__bar h1 { order: -1; flex-basis: 100%; }
}
body:has(.formula-creative-main) #formula-footer { display: none; }
body:has(.formula-creative-main) #formula-content { max-width: none; }
body:has(.creative-tools--expanded) > :is(.site-header, .formula-cabinet-navigation) { display: none; }
body:has(.creative-tools--expanded) #formula-content { padding-top: 0; margin-top: 0; }

@media (prefers-reduced-motion: no-preference) {
  .creative-tools__grid,
  .creative-tools__compose[open] > :not(summary) { animation: creative-tools-enter 200ms ease-out both; }
  @keyframes creative-tools-enter {
    from { opacity: 0; transform: translateY(4px); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .creative-tools { --tools-motion: 0s; }
  .creative-tools__card:hover,
  .creative-tools__card:hover img { transform: none; }
  .creative-tools__card:hover .creative-tools__card-content::after { translate: none; }
}
