:root {
  --paper: #f6f1e3;
  --card: #ffffff;
  --ink: #211e18;
  --muted: #736b5a;
  --rule: #c9d3e4;
  --margin: #be5c50;
  --accent: #2e6e63;
  --accent-dark: #204f47;
  --accent-soft: #e4eeeb;
  --danger: #a63e33;
  --danger-soft: #fbeae7;
  --radius: 3px;
  --shadow: 0 1px 2px rgba(33, 25, 15, 0.08), 0 8px 20px rgba(33, 25, 15, 0.07);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background-image:
    radial-gradient(circle at 15% 8%, rgba(190, 92, 80, 0.05), transparent 40%),
    radial-gradient(circle at 85% 92%, rgba(46, 110, 99, 0.06), transparent 40%);
}
.wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 36px 20px 90px;
}
header.top {
  margin-bottom: 28px;
}
header.top h1 {
  font-family: "Lora", serif;
  font-weight: 600;
  font-size: 30px;
  margin: 0 0 6px;
  letter-spacing: 0.2px;
}
header.top p {
  margin: 0;
  color: var(--muted);
  max-width: 60ch;
}
.tag-pill {
  display: inline-block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--accent-dark);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 20px;
  margin-bottom: 12px;
}

/* step tracker — a fan of little index cards */
.steps {
  display: flex;
  gap: 6px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}
.step-tab {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  background: #efe8d6;
  border: 1px solid #dfd5bc;
  border-bottom: none;
  padding: 9px 14px 8px;
  border-radius: 5px 5px 0 0;
  cursor: default;
  transform: translateY(4px);
  transition:
    transform 0.15s ease,
    color 0.15s ease,
    background 0.15s ease;
  user-select: none;
}
.step-tab .n {
  color: var(--margin);
  margin-right: 6px;
}
.step-tab.active {
  background: var(--card);
  color: var(--ink);
  transform: translateY(0);
  border-color: #dfd5bc;
  box-shadow: 0 -2px 0 var(--accent) inset;
  font-weight: 600;
}
.step-tab.done {
  color: var(--accent-dark);
  cursor: pointer;
}
.step-tab.done:hover {
  transform: translateY(1px);
}

.card {
  background-color: var(--card);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0 30px,
    var(--rule) 31px,
    transparent 32px
  );
  border-left: 3px solid var(--margin);
  border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: var(--shadow);
  padding: 26px 26px 26px 30px;
  margin-bottom: 20px;
}
.card h2 {
  font-family: "Lora", serif;
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 4px;
}
.card .hint {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 0 18px;
}
section[hidden] {
  display: none;
}

.dropzone {
  border: 2px dashed #cbb994;
  border-radius: 6px;
  padding: 34px 20px;
  text-align: center;
  background: #fcfaf3;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.dropzone:hover,
.dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone strong {
  display: block;
  font-size: 15.5px;
  margin-bottom: 4px;
}
.dropzone span {
  color: var(--muted);
  font-size: 13px;
}
input[type="file"] {
  display: none;
}

.btn {
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
  border-radius: 5px;
  padding: 10px 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition:
    transform 0.08s ease,
    background 0.15s ease;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-dark);
}
.btn-primary:disabled {
  background: #c8c1af;
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid #cbb994;
}
.btn-ghost:hover {
  background: #f1e9d3;
}
.btn-row {
  display: flex;
  justify-content: space-between;
  margin-top: 22px;
  gap: 10px;
}

table.map-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.6px;
}
table.map-table th {
  text-align: left;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--muted);
  font-weight: 500;
  padding: 6px 8px;
  border-bottom: 1px solid #e7dec7;
}
table.map-table td {
  padding: 7px 8px;
  border-bottom: 1px solid #f0eada;
  vertical-align: middle;
}
table.map-table td.label {
  white-space: nowrap;
}
table.map-table td.label .req {
  color: var(--margin);
  margin-left: 3px;
}
table.map-table td.label .label-text {
  cursor: help;
  border-bottom: 1px dotted var(--muted);
}
select,
input[type="text"] {
  font-family: "Inter", sans-serif;
  font-size: 13.6px;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid #d3c9ae;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
select:focus,
input[type="text"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
select:disabled,
input[type="text"]:disabled {
  background: #f1ede0;
  color: var(--muted);
  cursor: not-allowed;
}
.fixed-input {
  margin-top: 5px;
}

details.nt-block {
  margin-bottom: 18px;
  border: 1px solid #e7dec7;
  border-radius: 5px;
  overflow: hidden;
}
details.nt-block summary {
  cursor: pointer;
  padding: 10px 14px;
  background: #fbf7ec;
  font-weight: 600;
  font-size: 14px;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
details.nt-block summary::-webkit-details-marker {
  display: none;
}
details.nt-block summary .count {
  font-weight: 400;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--muted);
}
details.nt-block .nt-body {
  padding: 14px;
}

.checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}
.checklist label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #ede6d2;
  border-radius: 5px;
  background: #fcfaf3;
  font-size: 13.8px;
  cursor: pointer;
}
.checklist label:hover {
  border-color: #d3c9ae;
}
.checklist .meta {
  margin-left: auto;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
}
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag-chips .chip {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  background: #fcfaf3;
  border: 1px solid #ede6d2;
  border-radius: 20px;
  padding: 4px 10px;
  color: var(--accent-dark);
}
.tag-chips .chip .n {
  color: var(--muted);
  margin-left: 5px;
}
.tag-chips .none {
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

.bulk-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: #fcfaf3;
  border: 1px solid #ede6d2;
  border-radius: 5px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.bulk-row label {
  font-size: 13.6px;
  font-weight: 600;
}
.bulk-row select {
  width: auto;
  min-width: 170px;
  flex: 0 0 auto;
}
.bulk-row .btn {
  padding: 7px 14px;
  font-size: 13px;
}
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f0eada;
}
.toggle-row:last-child {
  border-bottom: none;
}
.toggle-row input {
  margin-top: 3px;
}
.toggle-row .t-label {
  font-weight: 600;
  font-size: 13.8px;
}
.toggle-row .t-desc {
  color: var(--muted);
  font-size: 12.8px;
  margin-top: 1px;
}

table.topics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.6px;
}
table.topics-table th {
  text-align: left;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  padding: 6px 8px;
  border-bottom: 1px solid #e7dec7;
}
table.topics-table th.drag-col {
  width: 36px;
}
table.topics-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #f0eada;
}
table.topics-table td.name {
  font-weight: 600;
  white-space: nowrap;
}
table.topics-table td.drag-handle-cell {
  width: 36px;
  padding: 2px;
  text-align: center;
}
.drag-handle {
  cursor: grab;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  display: inline-block;
  padding: 8px 10px;
  border-radius: 4px;
  touch-action: none;
}
.drag-handle:hover {
  background: #f1e9d3;
  color: var(--ink);
}
.drag-handle:active {
  cursor: grabbing;
}
table.topics-table tr.dragging {
  opacity: 0.35;
}
table.topics-table tr.drag-over-top td {
  box-shadow: inset 0 2px 0 var(--accent);
}
table.topics-table tr.drag-over-bottom td {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.preview-wrap {
  overflow: auto;
  border: 1px solid #e7dec7;
  border-radius: 5px;
  max-height: 380px;
}
table.preview {
  border-collapse: collapse;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  min-width: 100%;
}
table.preview th {
  position: sticky;
  top: 0;
  background: #2a2620;
  color: #f3ebd8;
  text-align: left;
  padding: 7px 10px;
  white-space: nowrap;
}
table.preview td {
  padding: 6px 10px;
  border-bottom: 1px solid #efe9d8;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.preview tr:nth-child(even) td {
  background: #fbf8ef;
}
table.preview td.invalid {
  background: var(--danger-soft) !important;
  color: var(--danger);
  font-weight: 600;
}

.validation-panel {
  margin: 14px 0;
}
.validation-panel .msg {
  margin-top: 0;
}
.validation-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  font-size: 13px;
}
.validation-list li {
  padding: 5px 0;
  border-top: 1px solid #ecc9c2;
}
.validation-list li:first-child {
  border-top: none;
}
.validation-list .vtopic {
  font-weight: 600;
}
.validation-list .vreason {
  color: var(--danger);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
}

.stat-row {
  display: flex;
  gap: 18px;
  margin: 14px 0 4px;
  flex-wrap: wrap;
}
.stat {
  background: #fcfaf3;
  border: 1px solid #ede6d2;
  border-radius: 5px;
  padding: 10px 16px;
  min-width: 120px;
}
.stat .num {
  font-family: "Lora", serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--accent-dark);
}
.stat .lbl {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.msg {
  padding: 12px 14px;
  border-radius: 5px;
  font-size: 13.6px;
  margin-top: 14px;
}
.msg.error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #ecc9c2;
}
.msg.info {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid #c7ddd6;
}
.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid #d3c9ae;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -3px;
  margin-right: 8px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

footer.credit {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 26px;
  line-height: 1.7;
}
footer.credit a {
  color: var(--accent-dark);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid #c7ddd6;
}
footer.credit a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
@media (max-width: 640px) {
  table.map-table thead {
    display: none;
  }
  table.map-table tr {
    display: block;
    padding: 10px 0;
    border-bottom: 1px solid #efe7cf;
  }
  table.map-table td {
    display: block;
    border: none;
    padding: 4px 0;
  }
  table.map-table td.label {
    font-weight: 600;
  }
}
