:root {
  --bg: #f6f6f6;
  --panel: #ffffff;
  --line: #d9d9d9;
  --line-strong: #a2a9b1;
  --text: #202122;
  --muted: #54595d;
  --link: #0645ad;
  --surface: #f8f9fa;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

body {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--line-strong);
  background: #ffffff;
}

.actions-wrap {
  display: flex;
  gap: 0.5rem;
}

.actions-wrap button,
#close-editor-btn,
.form-actions button {
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--text);
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  font-size: 0.86rem;
}

.actions-wrap button:hover,
#close-editor-btn:hover,
.form-actions button:hover {
  background: var(--surface);
}

.site-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.page-select-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-select-wrap label {
  color: var(--muted);
  font-size: 0.9rem;
}

#page-select {
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  color: var(--text);
  padding: 0.4rem 0.5rem;
}

.wiki-layout {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 1.1rem;
}

.toc-panel,
.content {
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
}

.toc-panel {
  padding: 0.85rem 0.8rem;
  position: sticky;
  top: 62px;
  align-self: start;
}

.toc-panel h2 {
  margin: 0 0 0.65rem 0;
  font-size: 0.98rem;
  font-weight: 600;
}

.toc {
  font-size: 0.92rem;
  line-height: 1.35;
}

.toc ul {
  margin: 0;
  padding-left: 1rem;
}

.toc li {
  margin: 0.3rem 0;
}

.toc a {
  color: var(--link);
  text-decoration: none;
}

.toc a:hover {
  text-decoration: underline;
}

.fact-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.fact-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}

.fact-list li:last-child {
  border-bottom: none;
}

.fact-label {
  color: var(--muted);
}

.content {
  padding: 1rem 1.2rem;
  min-height: 70vh;
}

#article-body {
  font-family: Georgia, "Times New Roman", Times, serif;
}

.summary-box {
  float: right;
  width: 320px;
  margin: 0 0 1rem 1.2rem;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  padding: 0.65rem;
}

.summary-box h2 {
  margin: 0 0 0.4rem 0;
  font-size: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.3rem;
}

.summary-box p {
  margin: 0.45rem 0 0.7rem 0;
  color: var(--text);
  line-height: 1.45;
  font-size: 0.95rem;
}

.summary-box img {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  background: #fff;
}

.content-title {
  margin: 0 0 0.65rem 0;
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.25;
  font-family: Georgia, "Times New Roman", Times, serif;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.25rem;
}

.content h2,
.content h3,
.content h4 {
  margin-top: 1.4rem;
  margin-bottom: 0.6rem;
  font-weight: 500;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.2rem;
}

.content p {
  margin: 0 0 0.9rem 0;
  line-height: 1.7;
  font-size: 1.02rem;
}

.content figure {
  margin: 1rem 0;
}

.content img {
  width: 100%;
  max-width: 720px;
  height: auto;
  border: 1px solid var(--line);
  background: #fff;
}

.content figcaption {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.item-list {
  margin: 0;
  padding-left: 1rem;
}

.item-list a {
  color: var(--link);
  text-decoration: none;
}

.item-list a:hover {
  text-decoration: underline;
}

/* Liens inline dans les paragraphes: syntaxe [[slug]] ou [[slug|label]] */
#article-body p a,
.summary-box p a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid #a3b8d8;
}

#article-body p a:hover,
.summary-box p a:hover {
  text-decoration: none;
  border-bottom-color: var(--link);
}

.empty {
  color: var(--muted);
}

.content::after {
  content: "";
  display: block;
  clear: both;
}

.editor-panel {
  max-width: 1440px;
  margin: 0 auto 1rem auto;
  padding: 1rem;
  border: 1px solid var(--line);
  background: #fff;
}

.editor-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.editor-panel-header h2 {
  margin: 0;
  font-size: 1rem;
}

.editor-status {
  min-height: 1.2rem;
  margin-bottom: 0.6rem;
  font-size: 0.92rem;
}

.editor-status.success {
  color: #1d6a2f;
}

.editor-status.error {
  color: #8d1f1f;
}

.editor-form h3 {
  margin: 0 0 0.6rem 0;
  font-size: 0.98rem;
}

.editor-form h4 {
  margin: 0.8rem 0 0.5rem 0;
  font-size: 0.95rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.7rem;
}

.editor-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
}

.editor-form input,
.editor-form select,
.editor-form textarea {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0.42rem;
  font-size: 0.9rem;
}

.editor-form textarea {
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.4;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.2rem;
}

.block-editor-list {
  display: grid;
  gap: 0.7rem;
}

.block-card {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0.6rem;
}

.block-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.block-card-actions {
  display: flex;
  gap: 0.35rem;
}

.block-move-btn,
.block-remove-btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  padding: 0.2rem 0.45rem;
  cursor: pointer;
}

.block-move-btn:hover,
.block-remove-btn:hover {
  background: #f3f3f3;
}

.add-block-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.7rem;
  margin-bottom: 0.4rem;
}

.add-block-row select,
.add-block-row button {
  border: 1px solid var(--line-strong);
  background: #fff;
  padding: 0.4rem 0.55rem;
}

.add-block-row button {
  cursor: pointer;
}

.add-block-row button:hover {
  background: #f3f3f3;
}

.hidden {
  visibility: hidden;
}

.not_displayed {
  display: none;
}

@media (max-width: 940px) {
  .wiki-layout {
    grid-template-columns: 1fr;
  }

  .toc-panel {
    position: static;
  }

  .summary-box {
    float: none;
    width: 100%;
    margin: 0 0 1rem 0;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }

  .actions-wrap {
    width: 100%;
  }
}

.link-button {
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--text);
  padding: 0.35rem 0.55rem;
  font-size: 0.86rem;
  text-decoration: none;
}

.link-button:hover {
  background: var(--surface);
}

.new-page-layout {
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem;
}