:root {
  /* Palette Discord (dark) */
  --bg: #313338;
  --bg-alt: #2b2d31;
  --bg-deep: #1e1f22;
  --bg-input: #1e1f22;
  --line: #3f4147;
  --line-soft: #2a2c31;
  --text: #dbdee1;
  --text-strong: #f2f3f5;
  --muted: #949ba4;
  --blurple: #5865f2;
  --blurple-hover: #4752c4;
  --green: #57f287;
  --red: #ed4245;
  --radius: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "gg sans", "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: #00a8fc; text-decoration: none; }
a:hover { text-decoration: underline; }

#app.loading {
  display: grid;
  place-items: center;
  min-height: 100vh;
  color: var(--muted);
}

/* ---------------- top bar ---------------- */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--bg-deep);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand svg { color: #fff; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 15px; color: var(--text-strong); font-weight: 600; white-space: nowrap; }
.brand-text span { font-size: 12px; color: var(--muted); }

.user { display: flex; align-items: center; gap: 10px; }
.user img { width: 28px; height: 28px; border-radius: 50%; background: var(--bg-deep); }
.user .name { font-size: 14px; color: var(--text-strong); }

/* ---------------- layout ---------------- */
main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.page-title { margin: 0 0 4px; font-size: 20px; font-weight: 600; color: var(--text-strong); }
.page-sub { margin: 0 0 20px; font-size: 14px; color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .preview-col { position: static; }
}

.card {
  background: var(--bg-alt);
  border-radius: var(--radius);
  padding: 16px;
}

.card + .card { margin-top: 16px; }

.card h2 {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------------- form ---------------- */
.field { margin-bottom: 14px; }

label {
  display: block;
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
}

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--bg-deep);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}

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

input:focus, textarea:focus, select:focus { border-color: var(--blurple); }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 620px) { .row { grid-template-columns: 1fr; } }

.hint { margin-top: 6px; font-size: 12px; color: var(--muted); }

.sections { display: grid; gap: 10px; margin-bottom: 14px; }

.section-block {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 10px 12px 12px;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
}

.section-head .dot { width: 6px; height: 6px; border-radius: 50%; }

.actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }

button {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }

.primary { background: var(--blurple); color: #fff; }
.primary:hover:not(:disabled) { background: var(--blurple-hover); }

.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.ghost:hover { background: var(--bg); }

.danger-btn {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--line);
  font-size: 13px;
  padding: 6px 10px;
}

/* ---------------- preview ---------------- */
.preview-col { position: sticky; top: 80px; }

.discord-embed {
  background: var(--bg);
  border-left: 4px solid var(--green);
  border-radius: 4px;
  padding: 12px 16px 16px;
  max-width: 520px;
}

.discord-embed .e-title { margin-bottom: 8px; font-size: 16px; font-weight: 600; color: #fff; }
.discord-embed .e-desc { font-size: 14px; color: var(--text); white-space: pre-wrap; }
.discord-embed .e-field { margin-top: 10px; }
.discord-embed .e-field .k { margin-bottom: 2px; font-size: 14px; font-weight: 600; color: #fff; }
.discord-embed .e-field .v { font-size: 14px; color: var(--text); white-space: pre-wrap; }
.discord-embed .e-image { display: block; max-width: 100%; margin-top: 12px; border-radius: 4px; }
.discord-embed .e-footer {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: 12px; font-size: 12px; color: var(--muted);
}

.empty-preview { font-size: 13px; color: var(--muted); }

/* ---------------- history ---------------- */
.history { margin-top: 16px; }

.patch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: var(--radius);
}
.patch-row + .patch-row { margin-top: 8px; }

.patch-main { min-width: 0; }
.patch-title { font-size: 14px; font-weight: 600; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.patch-meta { margin-top: 2px; font-size: 12px; color: var(--muted); }

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

.link-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
}
.link-btn:hover { background: var(--bg-alt); text-decoration: none; }

/* ---------------- states ---------------- */
.center-screen { display: grid; place-items: center; min-height: 90vh; padding: 24px; }

.panel {
  width: min(420px, 100%);
  padding: 32px;
  text-align: center;
  background: var(--bg-alt);
  border-radius: 12px;
}

.panel .brand { justify-content: center; margin-bottom: 18px; }

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
  color: #fff;
}

.login-note {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}

.panel h1 { margin: 0 0 8px; font-size: 20px; color: var(--text-strong); }
.panel p { margin: 0 0 20px; font-size: 14px; color: var(--muted); }

.discord-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: var(--blurple);
  border-radius: var(--radius);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
}
.discord-btn:hover { background: var(--blurple-hover); text-decoration: none; }

.badge {
  display: inline-block;
  margin-bottom: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(237, 66, 69, 0.15);
  color: #ff9496;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------------- toast ---------------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  padding: 10px 16px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 30;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok { border-color: rgba(87, 242, 135, .5); }
#toast.err { border-color: rgba(237, 66, 69, .55); }

/* ---------------- anti-sélection / glisser ---------------- */
* {
  -webkit-user-select: none;
  user-select: none;
}

input,
textarea,
.point-input,
.e-desc,
.e-field-value {
  -webkit-user-select: text;
  user-select: text;
}

::selection {
  background: rgba(88, 101, 242, 0.5);
  color: #fff;
}

img,
a {
  -webkit-user-drag: none;
  user-drag: none;
}

/* ---------------- blocs éditeur ---------------- */
.block { margin-bottom: 16px; }

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.block-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.toolbar { display: flex; gap: 4px; }

.tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 28px;
  padding: 0 7px;
  font-size: 13px;
  line-height: 1;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.tool:hover { background: var(--bg); }

/* ---------------- points ---------------- */
.point-list { display: flex; flex-direction: column; gap: 6px; }

.point-row { display: flex; align-items: center; gap: 6px; }

.point-input { flex: 1; padding: 8px 10px; font-size: 14px; }

.icon-btn {
  flex: none;
  width: 32px;
  height: 34px;
  padding: 0;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.icon-btn:hover { color: var(--red); border-color: rgba(237, 66, 69, 0.45); }

.add-point {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 6px;
}
.add-point:hover { color: var(--text); border-color: var(--blurple); }
.add-point .plus { font-size: 16px; line-height: 1; }

/* ---------------- dropzone ---------------- */
.dropzone {
  padding: 18px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover,
.dropzone.over { border-color: var(--blurple); background: rgba(88, 101, 242, 0.06); }

.dz-icon { margin-bottom: 6px; font-size: 22px; }
.dz-text { font-size: 13px; color: var(--muted); }

.dz-preview {
  display: block;
  max-width: 100%;
  max-height: 220px;
  margin-bottom: 8px;
  border-radius: 8px;
}

.small { padding: 6px 10px; font-size: 13px; }

/* ---------------- rendu markdown dans l'aperçu ---------------- */
.e-desc code,
.e-field-value code {
  padding: 1px 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: #1e1f22;
  border-radius: 4px;
}

.e-field-value { font-size: 14px; color: var(--text); }
.e-line { white-space: pre-wrap; }

/* ---------------- bulle de mise en forme ---------------- */
.fmt-bubble {
  position: fixed;
  z-index: 60;
  display: flex;
  gap: 0;
  padding: 0;
  background: #232428;
  border: 0;
  border-radius: 6px;
  box-shadow: none;
  overflow: hidden;
}

.fmt-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 32px;
  padding: 0;
  color: #b5bac1;
  background: transparent;
  border: 0;
  border-radius: 0;
}
.fmt-btn svg { display: block; }
.fmt-btn:hover { background: #35373c; color: #fff; }
.fmt-btn.active { background: #4e5058; color: #fff; }

.fmt-sep {
  width: 1px;
  align-self: stretch;
  background: #3f4147;
}

/* ---------------- vignettes ---------------- */
.img-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.thumb {
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-deep);
}

.thumb img { width: 100%; height: 100%; object-fit: cover; }

.thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  padding: 0;
  font-size: 11px;
  line-height: 1;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 50%;
}
.thumb-remove:hover { background: var(--red); }

.dz-hint { margin-top: 4px; font-size: 11.5px; color: #6d6f78; }

/* ---------------- spoiler + embeds multiples ---------------- */
.spoiler {
  padding: 0 3px;
  background: #1e1f22;
  border-radius: 4px;
  color: transparent;
  cursor: pointer;
}
.spoiler:hover { color: inherit; background: transparent; }

.discord-embed.extra { margin-top: 6px; padding: 8px; }
.discord-embed.extra .e-image { margin-top: 0; }

.fmt-bubble[hidden] { display: none; }

.e-h2 {
  margin: 10px 0 4px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}
.e-h2:first-child { margin-top: 0; }
.e-intro { margin-bottom: 6px; }

/* ---------------- éditeur riche ---------------- */
.rich {
  min-height: 44px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--bg-deep);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  outline: none;
  cursor: text;
  -webkit-user-select: text;
  user-select: text;
}

.rich:focus { border-color: var(--blurple); }

.rich.single {
  min-height: 36px;
  padding: 7px 10px;
  white-space: pre;
  overflow-x: auto;
  overflow-y: hidden;
}

.rich:empty::before {
  content: attr(data-placeholder);
  color: #6d6f78;
  pointer-events: none;
}

.rich code {
  padding: 1px 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: #1e1f22;
  border-radius: 4px;
}

.rich .spoiler {
  padding: 0 3px;
  color: transparent;
  background: #1e1f22;
  border-radius: 4px;
}
.rich .spoiler:hover { color: inherit; background: transparent; }

.point-row .rich { flex: 1; }

.rich blockquote {
  margin: 4px 0;
  padding-left: 10px;
  border-left: 3px solid #4e5058;
  color: #b5bac1;
}

.e-quote {
  display: block;
  margin: 2px 0;
  padding-left: 8px;
  border-left: 3px solid #4e5058;
  color: #b5bac1;
}

/* marqueurs markdown visibles en gris */
.md-mark {
  color: #6d6f78;
  font-weight: 400;
  font-style: normal;
  text-decoration: none;
}

.fmt-text { display: inline; }
.fmt-bold { font-weight: 800; }
.fmt-italic { font-style: italic; }
.fmt-underline { text-decoration: underline; text-underline-offset: 2px; }
.fmt-strike { text-decoration: line-through; }
.fmt-code {
  padding: 1px 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: #1e1f22;
  border-radius: 4px;
}
.fmt-spoiler {
  padding: 0 2px;
  background: #1e1f22;
  border-radius: 4px;
}
