:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #d8dee9;
  --text: #1a2332;
  --muted: #5c6b82;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --ok: #059669;
  --err: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header.app-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: var(--panel);
  box-shadow: var(--shadow);
}

header.app-header h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.badge {
  font-size: 0.7rem;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.route-toolbar {
  align-items: flex-end;
}

.route-select-wrap {
  flex: 1;
  min-width: 200px;
}

.route-select-wrap select {
  width: 100%;
}

.route-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

dialog.route-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-width: 480px;
  width: calc(100% - 2rem);
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.15);
}

dialog.route-dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

dialog.route-dialog input,
dialog.route-dialog select {
  width: 100%;
  padding: 0.5rem 0.65rem;
}

dialog.cities-dialog {
  max-width: 560px;
}

dialog.publish-dialog {
  max-width: 36rem;
  width: min(96vw, 36rem);
}

.publish-dialog-meta {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.publish-dialog-meta p {
  margin: 0.25rem 0;
}

.publish-dialog-body {
  max-height: 50vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  background: var(--bg);
}

.publish-summary-block + .publish-summary-block {
  margin-top: 0.75rem;
}

.publish-key-list {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.78rem;
}

.publish-key-list code {
  word-break: break-all;
}

.publish-history-panel summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}

.publish-history-list {
  margin-top: 0.5rem;
}

.publish-history-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.55rem;
  margin-bottom: 0.35rem;
  background: var(--panel);
}

.publish-history-item summary {
  cursor: pointer;
  font-size: 0.8rem;
}

.publish-history-detail {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
  font-size: 0.78rem;
}

.publish-history-when {
  font-weight: 600;
}

.cities-list {
  max-height: 45vh;
  overflow-y: auto;
  margin-bottom: 0.75rem;
}

.cities-list .field-block {
  margin-bottom: 0.65rem;
}

/* Seven Differences — placement visuel */
.seven-diff-visual-block {
  margin-bottom: 1rem;
}

.seven-diff-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #e8ecf2;
}

.seven-diff-base-img {
  display: block;
  max-width: 100%;
  height: auto;
  user-select: none;
}

.seven-diff-overlay {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}

.seven-diff-marker {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #ef4444;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.22);
  transform: translate(-50%, -50%);
  cursor: grab;
  touch-action: none;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.seven-diff-marker-num {
  font-weight: 700;
  line-height: 1;
  color: #fff;
  text-shadow:
    0 0 4px rgba(0, 0, 0, 0.9),
    0 1px 2px rgba(0, 0, 0, 0.85);
  pointer-events: none;
  user-select: none;
}

.seven-diff-marker.dragging {
  cursor: grabbing;
  z-index: 3;
}

.seven-diff-marker.selected {
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.28);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.seven-diff-marker:active {
  cursor: grabbing;
}

.seven-diff-meta,
.seven-diff-hint {
  font-size: 0.8rem;
  margin: 0.5rem 0 0;
}

.list-item .asset-key-picker,
.hint-asset-row .asset-key-picker,
.mcq-asset-row .asset-key-picker {
  margin-top: 0.35rem;
}

.list-item .asset-row select {
  min-width: 0;
}

.muted { color: var(--muted); font-size: 0.85rem; }

main { padding: 1rem 1.25rem 2rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card h2 { margin: 0 0 0.75rem; font-size: 1rem; }

label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  font-weight: 500;
}

input, select, textarea, button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

input, select {
  padding: 0.5rem 0.65rem;
  width: 100%;
}

textarea {
  width: 100%;
  min-height: 4.5rem;
  padding: 0.6rem 0.7rem;
  line-height: 1.45;
  resize: vertical;
}

button {
  cursor: pointer;
  padding: 0.5rem 1rem;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}

button:hover { filter: brightness(1.05); }
button.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

.row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.row > * { flex: 1; min-width: 140px; }
.row > .shrink { flex: 0; }

.hidden { display: none !important; }

.status {
  font-size: 0.85rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  margin-top: 0.75rem;
}

.status.ok { background: #d1fae5; color: var(--ok); }
.status.err { background: #fee2e2; color: var(--err); }
.status.info { background: var(--accent-soft); color: var(--accent); }

#connectScreen {
  max-width: 440px;
  margin: 3rem auto;
}

.toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.layout-split {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 1rem;
  min-height: 65vh;
}

@media (max-width: 900px) {
  .layout-split { grid-template-columns: 1fr; }
}

.nav-tree {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: auto;
  overflow-anchor: auto;
  max-height: 70vh;
  min-height: 0;
  padding: 0.35rem 0;
  display: flex;
  flex-direction: column;
}

.tree-toolbar {
  display: flex;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem 0.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tree-toolbar .tree-action {
  flex: 1;
  padding: 0.3rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 500;
}

.tree-root {
  flex: 1;
  min-height: 0;
  padding: 0.25rem 0 0.5rem;
}

.tree-row {
  display: flex;
  align-items: stretch;
  min-height: 1.85rem;
}

.tree-toggle,
.tree-toggle-spacer {
  flex: 0 0 1.35rem;
  width: 1.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tree-toggle {
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  cursor: pointer;
  border-radius: 4px;
}

.tree-toggle:hover {
  background: #eef2f8;
  color: var(--text);
  filter: none;
}

.tree-toggle-spacer {
  flex-shrink: 0;
}

.tree-label {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--text);
  padding: 0.35rem 0.5rem 0.35rem 0;
  font-weight: 400;
  font-size: 0.84rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-depth-0 > .tree-label {
  font-weight: 600;
  font-size: 0.86rem;
}

.tree-label.tree-branch {
  color: var(--text);
}

.tree-children {
  margin-left: 0.65rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--border);
}

.tree-label:hover { background: #f0f4fa; }
.tree-label.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.editor-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 1rem;
  overflow: auto;
  max-height: 70vh;
}

.editor-panel h3 {
  margin: 0 0 1rem;
  font-size: 1rem;
}

.list-group {
  margin-bottom: 0.5rem;
}

.list-group-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.list-item {
  margin-bottom: 0;
}

.list-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.list-item-head .field-label {
  margin-bottom: 0;
}

.list-item-head .btn-list-remove {
  flex-shrink: 0;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.list-group .toolbar {
  margin-top: 0.5rem;
}

.list-group .toolbar .step-type-select {
  flex: 1;
  min-width: 10rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
}

.field-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  background: #fafbfc;
}

.field-block .field-label {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.field-block .field-key {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  word-break: break-all;
}

.lang-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

@media (max-width: 700px) {
  .lang-row { grid-template-columns: 1fr; }
}

.lang-tag {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.lang-tag .char-count {
  font-weight: 400;
  opacity: 0.85;
}

.asset-preview {
  display: block;
  max-width: 200px;
  max-height: 140px;
  margin-top: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: contain;
  background: #fff;
}

.asset-preview--empty {
  max-width: 200px;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  margin-top: 0.5rem;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  background: linear-gradient(transparent, var(--panel) 25%);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}

details.dev-panel {
  margin-top: 1rem;
  font-size: 0.85rem;
}

details.dev-panel summary {
  cursor: pointer;
  color: var(--muted);
}

.empty-state {
  color: var(--muted);
  padding: 2rem 1rem;
  text-align: center;
}

table.loc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.loc-table th, .loc-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.35rem;
  vertical-align: top;
}

.loc-table th { color: var(--muted); font-weight: 500; text-align: left; }
.key-cell {
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  max-width: 220px;
  word-break: break-all;
}

.tabs { display: flex; gap: 0.35rem; margin-bottom: 1rem; }
.tabs button {
  flex: 0;
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}
.tabs button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.asset-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.asset-upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.35rem;
}

.asset-upload-row input[type="text"] {
  flex: 1;
  min-width: 120px;
  padding: 0.45rem 0.6rem;
}

.asset-upload-row input[type="file"] {
  max-width: 200px;
  font-size: 0.8rem;
}

.upload-hint { margin: 0.35rem 0 0; font-size: 0.75rem; }

.field-key-pending {
  color: var(--warn, #b45309);
  background: #fffbeb;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  margin-bottom: 0.35rem;
}

button.danger {
  border-color: var(--err);
  color: var(--err);
  background: #fff;
}

.marcel-group h3 { margin: 0 0 0.75rem; font-size: 1rem; }
.marcel-line { margin-bottom: 0.75rem; }

/* Carnet Marcel (C1+) */
.notebook-nav {
  padding: 0.5rem;
  max-height: 70vh;
}

.notebook-nav-root {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.notebook-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.75rem;
  background: #fff;
  color: var(--text);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 0.88rem;
}

.notebook-nav-item:hover {
  background: var(--accent-soft);
  border-color: var(--border);
}

.notebook-nav-item.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.notebook-nav-item.dirty::after {
  content: "•";
  color: var(--warn, #b45309);
  margin-left: 0.35rem;
}

.notebook-nav-badge {
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg);
  color: var(--muted);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  margin-left: 0.5rem;
}

.notebook-stat-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.notebook-stat {
  flex: 1;
  min-width: 100px;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.notebook-stat-n {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.route-overview-panel h4.notebook-subhead {
  margin-top: 1.25rem;
}

.tree-label.tree-overview {
  font-style: italic;
  color: var(--muted);
}

.tree-label.tree-overview.active {
  color: #fff;
  font-style: normal;
}

.notebook-overview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.notebook-overview-table th,
.notebook-overview-table td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

.notebook-overview-table th {
  color: var(--muted);
  font-weight: 500;
}

.notebook-placeholder {
  margin-top: 1rem;
  background: var(--bg);
}

.notebook-dirty-tag {
  font-size: 0.75rem;
  color: var(--warn, #b45309);
  font-weight: 600;
}

.notebook-categories-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.75rem;
}

.notebook-category {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  background: #fff;
}

.notebook-category-badges {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}

.notebook-fixed-tag {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.notebook-poi-count {
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--bg);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.notebook-subhead {
  margin: 1rem 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.notebook-subcats {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.notebook-subcat {
  background: var(--bg);
  margin-bottom: 0;
}

.notebook-tech-details {
  font-size: 0.85rem;
}

.notebook-tech-details summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
}

.notebook-poi-toolbar {
  margin: 0.75rem 0 1rem;
}

.notebook-poi-layout {
  display: grid;
  grid-template-columns: minmax(200px, 280px) 1fr;
  gap: 1rem;
  min-height: 50vh;
  align-items: start;
}

@media (max-width: 900px) {
  .notebook-poi-layout {
    grid-template-columns: 1fr;
  }
}

.notebook-poi-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  max-height: 65vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.notebook-poi-list-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: #fff;
  color: var(--text);
  border: none;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  cursor: pointer;
}

.notebook-poi-list-item:hover {
  background: var(--accent-soft);
}

.notebook-poi-list-item.active {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
}

.notebook-poi-list-name {
  font-size: 0.88rem;
}

.notebook-poi-list-meta {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 400;
  margin-top: 0.15rem;
}

.notebook-poi-detail-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 0.85rem 1rem;
  max-height: 65vh;
  overflow: auto;
}

.notebook-illustrations {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.notebook-illustration-row {
  background: var(--bg);
  margin-bottom: 0;
}

.notebook-img-preview {
  display: block;
  max-width: 200px;
  max-height: 140px;
  margin-top: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: contain;
  background: #fff;
}

.notebook-img-preview--empty {
  max-width: 200px;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  margin-top: 0.5rem;
}

.key-hunt-ok {
  color: #0d6b3a;
  margin: 0;
}

.key-hunt-warn {
  color: #b45309;
  margin: 0;
}

.key-hunt-warnings {
  margin: 0.25rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.85rem;
}

.key-hunt-warnings li.warn {
  color: #b45309;
}

.field-block [data-reward-custom].hidden {
  display: none;
}

.video-zone {
  margin-top: 1rem;
}

.video-zone h4 {
  margin: 0;
  font-size: 0.95rem;
}

.video-zone-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.video-toolbar {
  margin-bottom: 0.75rem;
}

.video-table-wrap {
  overflow: auto;
  max-height: 42vh;
}

.video-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.video-table th,
.video-table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.video-table th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.75rem;
}

.video-link-cell {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  min-width: 12rem;
}

.video-link-input {
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  padding: 0.25rem 0.4rem;
}

.video-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  white-space: nowrap;
}

.btn-replace-video input {
  display: none;
}
