:root {
  --bg: #08080a;
  --panel: #111114;
  --panel-border: #232326;
  --text: #e9e7e2;
  --text-dim: #9c9a95;
  --gold: #c6a568;
  --blue: #3b82f6;
  --green: #1f9d55;
  --red: #b5473a;
  --danger-bg: #2a1414;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

.serif { font-family: Georgia, "Times New Roman", serif; }

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

header.top {
  text-align: center;
  margin-bottom: 32px;
}
header.top .logo { font-size: 13px; letter-spacing: 0.2em; color: var(--gold); margin-bottom: 6px; }
header.top h1 { font-family: Georgia, serif; font-size: 30px; margin: 6px 0; }
header.top p { color: var(--text-dim); max-width: 640px; margin: 0 auto; }

.tabs { display: flex; justify-content: center; gap: 8px; margin: 24px 0; }
.tab-btn {
  background: transparent; border: 1px solid var(--panel-border); color: var(--text-dim);
  padding: 8px 18px; border-radius: 999px; cursor: pointer; font-size: 14px;
}
.tab-btn.active { color: var(--bg); background: var(--gold); border-color: var(--gold); font-weight: 600; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 18px;
}
.panel h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.red { background: var(--red); }
.dot.green { background: var(--green); }

textarea {
  width: 100%; min-height: 260px; resize: vertical;
  background: #0c0c0f; color: var(--text); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 12px; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13.5px; line-height: 1.5;
}
textarea:focus { outline: 1px solid var(--gold); }

.row-between { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--text-dim); font-size: 12.5px; }

button {
  cursor: pointer; border: none; border-radius: 8px; padding: 9px 16px; font-size: 13.5px; font-weight: 600;
}
.btn-ghost { background: #17171b; color: var(--text); border: 1px solid var(--panel-border); }
.btn-ghost:hover { background: #1c1c21; }
.btn-blue { background: var(--blue); color: #fff; width: 100%; padding: 12px; margin-top: 12px; font-size: 14px; }
.btn-blue:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-green { background: var(--green); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-gold { background: var(--gold); color: #201a0d; }

.preview-outer { background: #0c0c0f; border: 1px solid var(--panel-border); border-radius: 8px; padding: 20px; display: flex; justify-content: center; min-height: 260px; }
.preview-page {
  background: #fff; color: #111; width: 233px; padding: 16px 14px; font-family: Georgia, serif;
  font-size: 11.5px; line-height: 1.45; box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.avis-communes { font-weight: 700; text-transform: uppercase; text-align: center; margin-bottom: 10px; }
.avis-proches { text-align: center; margin-bottom: 10px; }
.avis-nom { font-weight: 700; text-align: center; font-size: 12.5px; margin-top: 4px; }
.avis-nee { font-style: italic; text-align: center; margin-bottom: 10px; }
.avis-corps { text-align: justify; margin-bottom: 10px; }
.avis-footer { font-weight: 700; font-style: italic; text-align: center; margin-top: 6px; }

.hint { text-align: center; color: #999; font-style: italic; margin-top: 40px; }

.fields-panel { margin-top: 24px; }
.fields-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
@media (max-width: 900px) { .fields-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.span2 { grid-column: 1 / -1; }
.field label { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; }
.field input, .field select, .field textarea.small {
  background: #0c0c0f; border: 1px solid var(--panel-border); color: var(--text);
  border-radius: 6px; padding: 8px 10px; font-size: 13.5px;
}
.field textarea.small { min-height: 60px; font-family: inherit; }

.proche-row { display: flex; gap: 6px; margin-bottom: 6px; }
.proche-row input { flex: 1; }

.stats-bar {
  display: flex; justify-content: center; gap: 28px; margin: 28px 0 8px; flex-wrap: wrap;
}
.stat { text-align: center; }
.stat .n { font-size: 22px; font-weight: 700; color: var(--gold); font-family: Georgia, serif; }
.stat .label { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }

.conseils { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 10px; padding: 18px 20px; margin-top: 28px; }
.conseils h3 { margin: 0 0 10px; font-size: 14px; }
.conseils ul { margin: 0; padding-left: 18px; color: var(--text-dim); font-size: 13.5px; line-height: 1.7; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; padding: 32px; width: 340px; text-align: center; }
.login-card h1 { font-family: Georgia, serif; font-size: 22px; margin: 6px 0 24px; }
.login-card input { width: 100%; background: #0c0c0f; border: 1px solid var(--panel-border); color: var(--text); border-radius: 8px; padding: 11px 12px; margin-bottom: 14px; font-size: 14px; }
.login-card button { width: 100%; background: var(--gold); color: #201a0d; padding: 11px; font-size: 14px; }
.error-msg { color: #ef4444; font-size: 13px; margin-top: 8px; min-height: 18px; }

/* Mémoire tab */
table.examples { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.examples th, table.examples td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--panel-border); }
table.examples th { color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; }
table.examples tr:hover { background: #141417; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.seed { background: #2a2410; color: var(--gold); }
.badge.user { background: #142a1c; color: #4ade80; }
.badge.inactive { background: #2a1414; color: #f87171; }
.actions-cell { display: flex; gap: 6px; }
.actions-cell button { padding: 5px 10px; font-size: 12px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #17171b; border: 1px solid var(--panel-border); color: var(--text);
  padding: 12px 20px; border-radius: 8px; font-size: 13.5px; z-index: 50;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.toast.ok { border-color: var(--green); }
.toast.err { border-color: var(--red); }

.hidden { display: none !important; }
