/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
  text-decoration: none;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn--sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn--primary {
  background: var(--color-brand-red);
  color: var(--color-white);
  border-color: var(--color-brand-red);
}

.btn--primary:hover {
  background: var(--color-brand-red-dark);
  border-color: var(--color-brand-red-dark);
  color: var(--color-white);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: var(--color-border);
}

.btn--ghost:hover {
  background: var(--color-cream);
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.btn--header {
  background: transparent;
  color: var(--color-white);
  border-color: rgba(255, 255, 255, 0.5);
}

.btn--header:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--color-white);
  border-color: var(--color-white);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card--flat:hover {
  transform: none;
  box-shadow: var(--shadow);
}

.card h3 {
  margin-bottom: 0.75rem;
  color: var(--color-brand-red);
}

/* Forms */
.contact-form__field {
  margin-bottom: 1rem;
}

.contact-form__field label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-brand-red);
}

.contact-form__field input,
.contact-form__field select,
.contact-form__field textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.4;
  color: var(--color-text);
  background: var(--color-cream);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.contact-form__field input:focus,
.contact-form__field select:focus,
.contact-form__field textarea:focus {
  outline: none;
  border-color: var(--color-brand-red-light);
  box-shadow: 0 0 0 3px var(--color-brand-red-soft);
}

.contact-form__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.25rem;
}

.contact-form__status {
  margin-bottom: 1rem;
  padding: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.45;
  border-radius: var(--radius);
  background: var(--color-brand-red-soft);
  color: var(--color-brand-red-deep);
}

.contact-form__status--error {
  background: rgba(208, 76, 76, 0.15);
}

/* Modal */
.contact-modal {
  width: min(560px, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  color: var(--color-text);
}

.contact-modal--wide {
  width: min(720px, calc(100% - 2rem));
}

.contact-modal--history {
  width: min(1100px, calc(100% - 2rem));
}

.contact-modal[open] {
  position: fixed;
  inset: 0;
  height: fit-content;
  margin: auto;
}

.contact-modal::backdrop {
  background: rgba(42, 36, 56, 0.6);
  backdrop-filter: blur(2px);
}

.contact-modal__inner {
  padding: 2rem 1.75rem 1.75rem;
  overflow-y: auto;
  max-height: calc(100dvh - 2rem);
}

.contact-modal__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.contact-modal__close:hover {
  background: var(--color-brand-red-soft);
  color: var(--color-brand-red);
}

.contact-modal__title {
  margin-bottom: 0.35rem;
  font-size: 1.5rem;
}

.contact-modal__lead {
  margin-bottom: 1.5rem;
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

/* Publish history */
.history-browser {
  display: grid;
  grid-template-columns: minmax(200px, 260px) 1fr;
  gap: 1rem;
  min-height: 0;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  max-height: 60dvh;
  overflow-y: auto;
  padding: 0;
  margin: 0;
}

.history-list button {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.history-list button:hover {
  background: var(--color-cream);
}

.history-list button[aria-current="true"] {
  border-color: var(--color-brand-red);
  background: var(--color-brand-red-soft);
}

.history-list__when {
  display: block;
  font-weight: 600;
}

.history-list__meta {
  display: block;
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

.history-preview {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.history-preview iframe {
  width: 100%;
  height: 60dvh;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #fff;
}

@media (max-width: 720px) {
  .history-browser {
    grid-template-columns: 1fr;
  }

  .history-list {
    max-height: 30dvh;
  }

  .history-preview iframe {
    height: 45dvh;
  }
}

/* File list / events */
.events-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.event {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--color-cream);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.9375rem;
}

.event:hover {
  border-color: var(--color-brand-red);
  box-shadow: var(--shadow);
}

.event.is-active {
  border-color: var(--color-brand-red);
  background: var(--color-brand-red-soft);
  box-shadow: var(--shadow);
}

.event__details h3 {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
  color: var(--color-brand-red-deep);
}

.event__details p {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.breadcrumb button {
  background: none;
  border: none;
  color: var(--color-brand-red);
  cursor: pointer;
  font-family: var(--font-body);
  padding: 0;
}

.breadcrumb span {
  color: var(--color-text-muted);
}

/* Badge */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--color-gold);
  color: var(--color-navy);
}

.badge--unsaved {
  background: var(--color-brand-red-soft);
  color: var(--color-brand-red-deep);
}

/* Media manager */
.media-manager {
  position: relative;
}

.media-manager__actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.media-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1.25rem;
  margin-top: 1rem;
}

@media (max-width: 900px) {
  .media-layout {
    grid-template-columns: 1fr;
  }
}

.media-side__heading {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-brand-red);
}

.media-folders {
  margin-bottom: 1.25rem;
}

.media-folder {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.35rem 0.15rem calc(0.35rem + var(--depth, 0) * 0.9rem);
  border-radius: 8px;
  font-size: 0.875rem;
}

.media-folder.is-active {
  background: var(--color-brand-red-soft);
  font-weight: 600;
}

.media-folder.is-drop {
  outline: 2px dashed var(--color-brand-red);
}

.media-folder__name {
  flex: 1;
  min-width: 0;
  padding: 0.3rem 0;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-folder__count {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.media-folder__tool {
  padding: 0 0.25rem;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.7rem;
  color: var(--color-brand-red-deep);
  text-decoration: underline;
  cursor: pointer;
}

.media-tagcloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.media-tag {
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--surface);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.media-tag span {
  color: var(--color-text-muted);
}

.media-tag.is-active {
  background: var(--color-brand-red);
  border-color: var(--color-brand-red);
  color: var(--color-white);
}

.media-tag.is-active span {
  color: inherit;
}

.media-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.media-toolbar input,
.media-toolbar select,
.media-bulk input,
.media-bulk select,
.media-detail__path input {
  padding: 0.45rem 0.65rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text);
  background: var(--surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.media-toolbar input[type="search"] {
  flex: 1 1 200px;
  min-width: 0;
}

.media-view {
  display: inline-flex;
  gap: 0.25rem;
}

.media-view .is-active {
  background: var(--color-brand-red-soft);
  border-color: var(--color-brand-red);
}

.media-bulk {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-brand-red);
  border-radius: var(--radius);
  background: var(--color-brand-red-soft);
}

.media-bulk input[type="text"] {
  width: 12rem;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.media-grid--pick {
  max-height: 55vh;
  overflow-y: auto;
}

.media-item {
  position: relative;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.media-item:hover {
  border-color: var(--color-brand-red);
  box-shadow: var(--shadow);
}

.media-item.is-selected {
  border-color: var(--color-brand-red);
  box-shadow: 0 0 0 2px var(--color-brand-red);
}

.media-item__open {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.media-item__open img,
.media-item__file {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  width: 100%;
  object-fit: cover;
  background: var(--color-cream);
  font-weight: 700;
  color: var(--color-text-muted);
}

.media-item__check {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  width: 1.15rem;
  height: 1.15rem;
  opacity: 0;
  cursor: pointer;
}

.media-item:hover .media-item__check,
.media-item.is-selected .media-item__check,
.media-item__check:focus-visible {
  opacity: 1;
}

.media-item__name,
.media-item__meta,
.media-item__tags {
  display: block;
  padding: 0 0.5rem;
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-item__name {
  padding-top: 0.5rem;
  color: var(--color-text);
  font-weight: 600;
}

.media-item__meta,
.media-item__tags {
  color: var(--color-text-muted);
}

.media-item__tags {
  padding-bottom: 0.25rem;
}

.media-item__meta {
  padding-bottom: 0.5rem;
}

.media-item__tags + .media-item__meta,
.media-item__meta:has(+ .media-item__tags) {
  padding-bottom: 0;
}

.media-item__draft {
  font-weight: 400;
  color: var(--color-text-muted);
}

.media-grid--list {
  grid-template-columns: 1fr;
  gap: 0.35rem;
}

.media-grid--list .media-item__open {
  display: grid;
  grid-template-columns: 56px minmax(0, 2fr) minmax(0, 1.5fr) minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  padding-left: 2rem;
}

.media-grid--list .media-item__open img,
.media-grid--list .media-item__file {
  width: 56px;
  height: 56px;
  aspect-ratio: auto;
  font-size: 0.7rem;
}

.media-grid--list .media-item__name,
.media-grid--list .media-item__meta,
.media-grid--list .media-item__tags {
  padding: 0;
}

.media-grid--list .media-item__check {
  top: 50%;
  transform: translateY(-50%);
  opacity: 1;
}

.media-empty {
  padding: 2rem 0;
  text-align: center;
}

.media-more {
  margin-top: 1rem;
  text-align: center;
}

/* Upload queue */
.media-uploads {
  display: grid;
  gap: 0.35rem;
  margin: 0.75rem 0;
}

.media-upload {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.6rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.8125rem;
}

.media-upload__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-upload__bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--color-cream);
}

.media-upload__bar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--color-brand-red);
  transition: width 0.15s;
}

.media-upload.is-done .media-upload__bar span {
  background: #2f8f5b;
}

.media-upload.is-failed {
  border-color: var(--color-brand-red);
}

.media-upload.is-failed .media-upload__state {
  color: var(--color-brand-red-deep);
  font-weight: 600;
}

.media-upload__x {
  border: none;
  background: none;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
}

/* Drop target */
.media-drop {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px dashed var(--color-brand-red);
  border-radius: var(--radius);
  background: rgba(250, 247, 245, 0.92);
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--color-brand-red);
  pointer-events: none;
}

#modal-media-pick.is-dropping {
  outline: 3px dashed var(--color-brand-red);
}

/* Media details dialog */
.media-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 1.5rem;
}

@media (max-width: 800px) {
  .media-detail {
    grid-template-columns: 1fr;
  }
}

.media-detail__preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  max-height: 60vh;
  border-radius: var(--radius);
  background: var(--color-cream);
  overflow: hidden;
}

.media-detail__preview img,
.media-detail__preview video {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
}

.media-detail__preview audio {
  width: 100%;
  margin: 2rem 1rem;
}

.media-detail__preview iframe {
  width: 100%;
  height: 60vh;
  border: 0;
}

.media-detail__font {
  padding: 1.5rem;
  font-size: 1.75rem;
  line-height: 1.4;
}

.media-detail__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
}

.media-detail__path {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.media-detail__path input {
  flex: 1;
  min-width: 0;
}

.media-detail__heading {
  font-size: 0.875rem;
  margin: 1rem 0 0.25rem;
}

.media-detail__usage {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.875rem;
}
/* Version history: tabs, actions, compare and diffs */
.history-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.history-tabs button {
  padding: 0.5rem 0.875rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--color-text-muted);
  font: inherit;
  cursor: pointer;
}

.history-tabs button[aria-selected="true"] {
  border-bottom-color: var(--color-brand-red);
  color: inherit;
  font-weight: 600;
}

.history-list__name {
  display: block;
  font-weight: 700;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.history-actions__compare {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-left: auto;
}

.history-actions[hidden],
.history-compare[hidden],
.history-preview iframe[hidden] {
  display: none;
}

.history-compare {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 60dvh;
  overflow-y: auto;
}

.history-compare__frames {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.history-compare__frames figure {
  margin: 0;
  min-width: 0;
}

.history-compare__frames figcaption {
  margin-bottom: 0.25rem;
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

.history-compare__frames iframe {
  height: 28dvh;
}

.history-diff {
  font-size: 0.8125rem;
  overflow-x: auto;
}

.history-diff h4 {
  margin: 0.75rem 0 0.375rem;
}

.history-diff__settings {
  margin: 0;
  padding-left: 1.25rem;
}

.history-diff__hunks {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--surface);
}

.history-diff__line {
  display: flex;
  gap: 0.5rem;
  padding: 0 0.5rem;
}

.history-diff__line code {
  white-space: pre-wrap;
  word-break: break-word;
}

.history-diff__line--add {
  background: #e6f6e6;
}

.history-diff__line--del {
  background: #fbe9e7;
}

.history-diff__gap {
  padding: 0 0.5rem;
  color: var(--color-text-muted);
  background: var(--color-cream);
}

@media (max-width: 720px) {
  .history-compare__frames {
    grid-template-columns: 1fr;
  }
}

.media-focus__stage {
  position: relative;
  display: inline-block;
  line-height: 0;
  cursor: crosshair;
}

.media-focus__dot {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.media-focus__crop {
  position: absolute;
  border: 2px dashed #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.media-focus__crop[data-crop-box='md'] {
  border-color: #ffd54a;
}

.media-focus__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.media-focus__crops {
  display: grid;
  gap: 0.25rem;
  margin-top: 0.5rem;
}
