:root {
  --anthracite: #2c2c30c8;
  --gray-medium: #9a9aa1;
  --white: #ffffff;
  --text: #222226;
  --accent: #3a6ea5;
  --accent-dark: #2c557f;
  --danger: #c0392b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--anthracite);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: flex-end;
  padding: 14px 24px 0;
}

.admin-link {
  color: #f2f2f2;
  text-decoration: none;
  font-size: 0.9rem;
  opacity: 0.85;
}

.admin-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.page {
  max-width: 900px;
  margin: 16px auto 40px;
  padding: 24px;
  background: var(--gray-medium);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--white);
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.card-title h1 {
  margin: 0;
  font-size: 1.35rem;
  text-align: center;
  line-height: 1.4;
}

.card-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-group-grow {
  flex: 1;
  min-width: 220px;
}

.field-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
}

.field-group .radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 16px;
  font-weight: normal;
}

.field-group .radio[hidden] {
  display: none;
}

select,
input[type="text"],
input[type="password"] {
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
}

.tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 6px 8px;
  min-width: 220px;
}

.token {
  background: var(--accent);
  color: #fff;
  padding: 4px 8px;
  border-radius: 14px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.token button {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0;
}

#keyword-input {
  border: none;
  outline: none;
  flex: 1;
  min-width: 120px;
  padding: 4px;
}

.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 1.5em;
}

.results-list li a {
  color: var(--accent);
  text-decoration: none;
}

.results-list li a:hover {
  text-decoration: underline;
  color: var(--accent-dark);
}

.results-empty {
  color: #777;
  font-style: italic;
}

.results-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.add-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
}

.add-btn:hover {
  background: var(--accent-dark);
}

.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.popup-overlay[hidden] {
  display: none;
}

.popup {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  max-width: 700px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.assist-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.popup-content {
  overflow-y: auto;
}

.popup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.popup-actions button {
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #f2f2f2;
  cursor: pointer;
  font-size: 0.9rem;
}

.popup-actions button:hover {
  background: #e6e6e6;
}

.danger-btn {
  margin-right: auto;
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.danger-btn:hover {
  background: #a53225;
}

#admin-ok-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#admin-ok-btn:hover {
  background: var(--accent-dark);
}

.popup-admin {
  max-width: 360px;
}

.popup-admin label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
}

.popup-edit {
  max-width: 640px;
}

.popup-fields-row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.popup-edit input[type="text"] {
  width: 100%;
}

#edit-titre {
  font-weight: 700;
}

.editor {
  border: 1px solid #ccc;
  border-radius: 8px;
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px;
  background: #f2f2f2;
  border-bottom: 1px solid #ccc;
}

.editor-toolbar button {
  min-width: 30px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
}

.editor-toolbar button:hover {
  background: #e0e0e0;
  border-color: #ccc;
}

.editor-toolbar select {
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  font-size: 0.85rem;
  font-family: inherit;
}

#editor-font-name {
  max-width: 140px;
}

#editor-font-size {
  max-width: 64px;
}

.editor-content {
  min-height: 220px;
  max-height: 45vh;
  overflow-y: auto;
  padding: 10px 12px;
  font-family: "Trebuchet MS", sans-serif;
  font-size: 16px;
}

.editor-content:focus {
  outline: none;
}

.editor-content img {
  max-width: 100%;
}

#edit-validate-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#edit-validate-btn:hover {
  background: var(--accent-dark);
}

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0;
}

@media print {
  body * {
    visibility: hidden;
  }

  #assist-title,
  #assist-content,
  #assist-content * {
    visibility: visible;
  }

  #assist-title {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
  }

  #assist-content {
    position: absolute;
    top: 2.5em;
    left: 0;
    width: 100%;
  }
}

@media (max-width: 600px) {
  .page {
    padding: 16px;
    border-radius: 12px;
    margin: 12px auto 24px;
  }

  .card {
    padding: 16px;
  }

  .card-filters {
    flex-direction: column;
    gap: 16px;
  }

  .popup {
    padding: 16px;
  }
}
