* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: #0c0c0b;
  color: #f3f2ef;
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
}

button,
.button-link {
  align-items: center;
  background: #f1f0eb;
  border: 1px solid #f1f0eb;
  border-radius: 4px;
  color: #11110f;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  min-height: 34px;
  padding: 7px 10px;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.button-link:hover {
  background: #fff;
  border-color: #fff;
}

.button-secondary {
  background: transparent;
  border-color: #484843;
  color: #e7e5df;
}

.button-secondary:hover {
  background: #252522;
  border-color: #6f6c64;
}

.button-danger {
  background: transparent;
  border-color: #794340;
  color: #ffb6ad;
}

.button-danger:hover {
  background: #3b1d1b;
  border-color: #b06058;
}

.admin-top {
  align-items: center;
  background: rgba(12, 12, 11, 0.96);
  border-bottom: 1px solid #2b2b27;
  display: flex;
  gap: 28px;
  min-height: 60px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0;
  text-decoration: none;
}

.admin-top nav {
  align-items: center;
  display: flex;
  flex: 1;
  gap: 18px;
}

.admin-top nav a {
  color: #c9c7c0;
  text-decoration: none;
}

.admin-top nav a:hover {
  color: #fff;
}

.admin-top form {
  margin: 0;
}

.admin-main {
  margin: 0 auto;
  max-width: 1180px;
  padding: 34px 24px 72px;
}

.tutorial-heading {
  align-items: flex-start;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 24px;
}

.tutorial-access {
  border: 1px solid #3a7351;
  border-radius: 999px;
  color: #a9dbb8;
  flex: 0 0 auto;
  font-size: 12px;
  line-height: 1;
  padding: 7px 9px;
}

.tutorial-video {
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid #2b2b27;
  display: block;
  height: auto;
  max-width: 100%;
  width: 100%;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: 30px;
  font-weight: 600;
  margin-bottom: 6px;
}

h2 {
  font-size: 21px;
  font-weight: 600;
  margin-bottom: 4px;
}

.management-heading {
  align-items: flex-start;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 28px;
}

.admin-intro,
.section-heading p,
.field-help,
.record-meta,
.deleted-records > p {
  color: #aaa79e;
}

.admin-intro,
.section-heading p {
  margin-bottom: 0;
}

.text-link,
.back-link {
  color: #d8d6cf;
  text-underline-offset: 3px;
}

.back-link {
  display: inline-block;
  font-size: 14px;
  margin-bottom: 10px;
}

.admin-section {
  border-top: 1px solid #2b2b27;
  padding: 34px 0;
  scroll-margin-top: 76px;
}

.section-heading {
  align-items: flex-end;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-create-form {
  flex: 0 0 auto;
  margin: 0;
}

.count-badge {
  background: #282824;
  border: 1px solid #41413b;
  border-radius: 999px;
  color: #cfcdc4;
  display: inline-flex;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  margin-left: 5px;
  min-width: 22px;
  padding: 4px 7px;
  vertical-align: 2px;
}

.record-list {
  display: grid;
  gap: 8px;
}

.record-row {
  align-items: center;
  background: #151513;
  border: 1px solid #2b2b27;
  border-radius: 6px;
  display: grid;
  gap: 14px;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  min-width: 0;
  padding: 12px;
}

.record-row:not(.sortable-item) {
  grid-template-columns: minmax(0, 1fr) auto;
}

.record-row.is-dragging {
  background: #22221e;
  border-color: #d7d4c8;
  opacity: 0.72;
}

.record-main {
  min-width: 0;
}

.record-main-link {
  color: inherit;
  text-decoration: none;
}

.record-main-link:hover .record-title {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.record-title {
  color: #fff;
  display: inline-block;
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
  text-decoration: none;
}

a.record-title:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.record-meta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.status {
  border: 1px solid #474740;
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  line-height: 1;
  padding: 4px 7px;
}

.status.is-published {
  border-color: #3a7351;
  color: #a9dbb8;
}

.status.is-unpublished {
  border-color: #6d6141;
  color: #ddce98;
}

.record-actions,
.editor-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.record-actions form,
.editor-actions form {
  margin: 0;
}

.drag-handle {
  align-self: stretch;
  background: transparent;
  border: 0;
  border-radius: 3px;
  color: #aaa79e;
  cursor: grab;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px;
  letter-spacing: 1px;
  min-height: 0;
  padding: 0;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle:hover {
  background: #252522;
  color: #fff;
}

.sort-status {
  color: #aaa79e;
  margin: 0 0 10px;
}

.sort-status[data-state="success"] {
  color: #a9dbb8;
}

.sort-status[data-state="error"] {
  color: #ffb6ad;
}

.deleted-records {
  border-top: 1px solid #2b2b27;
  margin-top: 20px;
  padding-top: 15px;
}

.deleted-records summary {
  color: #d7d4cb;
  cursor: pointer;
  list-style: none;
  width: fit-content;
}

.deleted-records summary::-webkit-details-marker {
  display: none;
}

.deleted-records summary::before {
  content: "+";
  display: inline-block;
  width: 18px;
}

.deleted-records[open] summary::before {
  content: "-";
}

.deleted-list {
  margin-top: 12px;
}

.inline-editor {
  border-top: 1px solid #353530;
  display: grid;
  gap: 14px;
  grid-column: 2 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 4px;
  padding-top: 16px;
}

.page-record .inline-editor {
  grid-column: 1 / -1;
}

.inline-editor label:nth-of-type(2) {
  grid-column: 1 / -1;
}

.inline-editor .field-help,
.inline-editor .editor-actions {
  grid-column: 1 / -1;
  margin: 0;
}

.settings-form,
.series-form,
.detail-form {
  background: #151513;
  border: 1px solid #2b2b27;
  border-radius: 6px;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 18px;
}

.settings-form label:nth-of-type(3),
.settings-form label:nth-of-type(4),
.settings-form label:nth-of-type(6),
.series-form label:nth-of-type(3),
.series-form .check,
.series-form .editor-actions,
.settings-form .editor-actions,
.detail-form label,
.detail-form .field-help,
.detail-form .editor-actions {
  grid-column: 1 / -1;
}

.rich-field {
  grid-column: 1 / -1;
  min-width: 0;
}

.field-label {
  color: #cbc9c1;
  display: block;
  margin-bottom: 6px;
}

.rich-editor {
  min-width: 0;
  position: relative;
}

.rich-toolbar,
.rich-surface {
  display: none;
}

.rich-editor.is-enhanced {
  background: #0a0a09;
  border: 1px solid #3a3a34;
  border-radius: 4px;
}

.rich-editor.is-enhanced:focus-within {
  border-color: #d8d6cd;
  outline: 1px solid #d8d6cd;
  outline-offset: 1px;
}

.rich-editor.is-enhanced .rich-toolbar {
  align-items: center;
  border-bottom: 1px solid #30302b;
  display: flex;
  gap: 4px;
  padding: 6px;
}

.rich-toolbar button {
  background: transparent;
  border-color: transparent;
  color: #d7d5cd;
  min-height: 32px;
  min-width: 34px;
  padding: 5px 8px;
}

.rich-toolbar button:hover,
.rich-toolbar button[aria-pressed="true"] {
  background: #292925;
  border-color: #494942;
  color: #fff;
}

.rich-editor.is-enhanced .rich-surface {
  color: #f7f6f1;
  display: block;
  line-height: 1.6;
  min-height: 190px;
  overflow-wrap: anywhere;
  padding: 12px;
}

.rich-surface:empty::before {
  color: #77746c;
  content: "Saisir le texte";
  pointer-events: none;
}

.rich-surface p {
  margin: 0 0 0.85rem;
}

.rich-surface p:last-child {
  margin-bottom: 0;
}

.rich-surface a {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.rich-editor.is-enhanced .rich-source {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.rich-status {
  color: #c7b978;
  display: block;
  font-size: 13px;
  min-height: 0;
  padding: 0 12px;
}

.rich-status:not(:empty) {
  padding-bottom: 10px;
}

label {
  color: #cbc9c1;
  display: block;
  min-width: 0;
}

input,
textarea {
  background: #0a0a09;
  border: 1px solid #3a3a34;
  border-radius: 4px;
  color: #f7f6f1;
  display: block;
  margin-top: 6px;
  padding: 9px 10px;
  width: 100%;
}

input:focus,
textarea:focus {
  border-color: #d8d6cd;
  outline: 1px solid #d8d6cd;
  outline-offset: 1px;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

.check {
  align-items: center;
  display: flex;
  gap: 8px;
}

.check input {
  margin: 0;
  width: auto;
}

.photo-editor-list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}

.photo-editor-row {
  align-items: stretch;
  background: #151513;
  border: 1px solid #2b2b27;
  border-radius: 6px;
  display: grid;
  gap: 8px;
  grid-template-columns: 24px minmax(0, 1fr);
  min-width: 0;
  padding: 8px;
}

.photo-editor-row.is-dragging {
  border-color: #d7d4c8;
  opacity: 0.72;
}

.photo-thumb {
  background: #090909;
  border: 0;
  border-radius: 3px;
  display: block;
  grid-column: 2;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  width: 100%;
}

.photo-thumb:hover {
  background: #090909;
}

.photo-thumb:focus-visible {
  outline: 2px solid #f1f0eb;
  outline-offset: 3px;
}

.photo-thumb img {
  aspect-ratio: 4 / 3;
  display: block;
  object-fit: cover;
  width: 100%;
}

.photo-dialog {
  background: #151513;
  border: 1px solid #4a4942;
  border-radius: 6px;
  color: #f3f2ef;
  max-height: calc(100vh - 32px);
  max-width: calc(100vw - 32px);
  overflow: auto;
  padding: 0;
  width: 620px;
}

.photo-dialog::backdrop {
  background: rgba(0, 0, 0, 0.82);
}

.photo-dialog-form {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 20px;
}

.photo-dialog-form label:nth-of-type(3),
.photo-dialog-form .dialog-heading,
.photo-dialog-form .dialog-photo-preview,
.photo-dialog-form .check,
.photo-dialog-form .editor-actions {
  grid-column: 1 / -1;
}

.dialog-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.dialog-heading h2 {
  margin: 0;
}

.dialog-close {
  background: transparent;
  border: 0;
  color: #ddd;
  font-size: 24px;
  line-height: 1;
  min-height: 32px;
  padding: 0;
  width: 32px;
}

.dialog-close:hover {
  background: #2a2a26;
  border-color: transparent;
}

.dialog-photo-preview {
  background: #090909;
  display: block;
  max-height: 260px;
  object-fit: contain;
  width: 100%;
}

.photo-delete-button {
  margin-left: auto;
}

.cover-setting {
  background: #151513;
  border: 1px solid #2b2b27;
  border-radius: 6px;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(260px, 0.9fr) minmax(280px, 1.1fr);
  margin-bottom: 16px;
  padding: 18px;
}

.cover-preview {
  aspect-ratio: 16 / 9;
  background: #090909;
  border: 1px solid #2b2b27;
  margin: 0;
  overflow: hidden;
}

.cover-preview img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.cover-upload {
  align-content: center;
  display: grid;
  gap: 14px;
}

.cover-upload button {
  justify-self: start;
}

.notice {
  border-radius: 4px;
  margin-bottom: 18px;
  padding: 11px 12px;
}

.notice-success {
  background: #183421;
  border: 1px solid #3a7351;
  color: #a9dbb8;
}

.security-setting {
  border-top: 1px solid #2b2b27;
  margin-top: 28px;
  padding-top: 24px;
}

.security-setting h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 14px;
}

.password-form label:nth-of-type(3),
.password-form .editor-actions {
  grid-column: 1 / -1;
}

.mfa-setting {
  border-top: 1px solid #2b2b27;
  margin-top: 24px;
  padding-top: 24px;
}

.mfa-setup {
  background: #151513;
  border: 1px solid #2b2b27;
  border-radius: 6px;
  padding: 18px;
}

.mfa-setup code {
  background: #090908;
  border: 1px solid #3d3d38;
  display: block;
  font-size: 16px;
  overflow-wrap: anywhere;
  padding: 12px;
}

.mfa-form {
  margin-top: 16px;
}

.photo-upload {
  border-top: 1px solid #2b2b27;
  display: grid;
  gap: 14px;
  margin-top: 24px;
  padding-top: 20px;
}

.upload-dropzone {
  align-items: center;
  background: #11110f;
  border: 1px dashed #57564f;
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  gap: 4px;
  justify-items: center;
  margin: 0;
  min-height: 150px;
  padding: 24px;
  position: relative;
  text-align: center;
  transition: background 160ms ease, border-color 160ms ease;
}

.upload-dropzone:hover,
.upload-dropzone.is-dragover {
  background: #1b1b18;
  border-color: #d8d6cd;
}

.upload-dropzone:focus-within {
  outline: 2px solid #d8d6cd;
  outline-offset: 2px;
}

.upload-dropzone.is-uploading {
  opacity: 0.65;
  pointer-events: none;
}

.upload-dropzone input[type="file"] {
  cursor: pointer;
  inset: 0;
  margin: 0;
  opacity: 0;
  padding: 0;
  position: absolute;
}

.upload-dropzone strong {
  color: #fff;
  font-size: 17px;
}

.upload-dropzone span,
.upload-selection {
  color: #aaa79e;
}

.upload-actions {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.upload-preview-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.upload-preview-grid[hidden] {
  display: none;
}

.upload-preview-item {
  background: #11110f;
  border: 1px solid #2b2b27;
  border-radius: 6px;
  margin: 0;
  min-width: 0;
  overflow: hidden;
}

.upload-preview-item img {
  aspect-ratio: 4 / 3;
  display: block;
  object-fit: cover;
  width: 100%;
}

.upload-preview-item figcaption {
  color: #aaa79e;
  font-size: 12px;
  line-height: 1.25;
  overflow: hidden;
  padding: 7px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-selection {
  margin: 0;
}

[data-upload-submit] {
  font-weight: 600;
  min-width: 190px;
}

[data-upload-submit]:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.error {
  background: #371b19;
  border: 1px solid #794340;
  border-radius: 4px;
  color: #ffb6ad;
  margin-bottom: 18px;
  padding: 11px 12px;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-box {
  background: #151513;
  border: 1px solid #2b2b27;
  border-radius: 6px;
  padding: 24px;
  width: min(420px, calc(100vw - 32px));
}

.login-box h1 {
  margin-bottom: 22px;
}

@media (max-width: 760px) {
  .admin-top {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px;
  }

  .admin-top nav {
    flex-wrap: wrap;
  }

  .admin-main {
    padding: 26px 16px 54px;
  }

  .management-heading,
  .section-heading,
  .tutorial-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .record-row,
  .record-row:not(.sortable-item) {
    align-items: flex-start;
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .record-row:not(.sortable-item) {
    grid-template-columns: minmax(0, 1fr);
  }

  .record-actions {
    grid-column: 2 / -1;
  }

  .record-row:not(.sortable-item) .record-actions {
    grid-column: 1 / -1;
  }

  .inline-editor {
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
  }

  .settings-form,
  .series-form,
  .detail-form,
  .photo-dialog-form {
    grid-template-columns: 1fr;
  }

  .settings-form label,
  .settings-form label:nth-of-type(n),
  .series-form label,
  .series-form label:nth-of-type(n) {
    grid-column: 1;
  }

  .upload-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .cover-setting {
    grid-template-columns: 1fr;
  }

  .photo-editor-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
