:root {
  --bg: #f2f1ec;
  --card: #ffffff;
  --ink: #202020;
  --accent: #0f766e;
  --muted: #666666;
  --border: #d7d4cc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Source Serif Pro", Georgia, serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f2f1ec, #ece7dc);
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 16px 80px;
}

.hero {
  padding: 24px 0 8px;
}

.hero h1 {
  font-size: 36px;
  margin: 0 0 6px;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-top: 16px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.06);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.row.full label {
  flex: 1 1 100%;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

input, textarea, select, button {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

textarea {
  min-height: 90px;
}

button {
  cursor: pointer;
  background: var(--accent);
  color: white;
  border: none;
}

button.secondary {
  background: #333;
}

.status {
  margin-top: 8px;
  color: var(--muted);
}

.status.error {
  color: #b91c1c;
}

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.progress.hidden {
  display: none;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #cbd5e1;
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 1s linear infinite;
}

.spinner.small {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

.bar {
  flex: 1;
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.collapsible > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 18px;
  margin: -6px 0 12px;
  list-style: none;
}

.collapsible > summary::-webkit-details-marker {
  display: none;
}

.collapsible > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.2s ease;
}

.collapsible[open] > summary::before {
  transform: rotate(90deg);
}

.ref-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none;
}

.bar-fill {
  width: 30%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #22c55e);
  animation: glide 1.8s ease-in-out infinite;
}

.progress-text {
  font-size: 13px;
  color: var(--muted);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes glide {
  0% { transform: translateX(-60%); }
  50% { transform: translateX(60%); }
  100% { transform: translateX(-60%); }
}

.author {
  border: 1px dashed var(--border);
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 10px;
}

.section {
  border: 1px dashed var(--border);
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 10px;
}

.subsection {
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 10px;
  margin-top: 8px;
  background: #f8fafc;
}

.subsection-block {
  margin-top: 8px;
}

.subsection-header {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.reference {
  border: 1px dashed var(--border);
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 10px;
}

.reference[open] .reference-header::before {
  transform: rotate(90deg);
}

.reference-header {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
}

.reference-header::-webkit-details-marker {
  display: none;
}

.reference-header::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.2s ease;
}

.reference-body {
  margin-top: 10px;
}
.reference.ai-processed {
  background: #e6f7e9;
  border-color: #7acb8a;
}

.reference.ai-processed .parse-ref-ai {
  opacity: 0.6;
  cursor: not-allowed;
}
.reference-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.reference-actions {
  display: flex;
  gap: 6px;
}

.reference-counter {
  font-weight: 600;
}

.ref-author {
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: 8px;
  margin-top: 6px;
  background: #f8fafc;
}

.ref-authors-header {
  font-size: 13px;
  color: var(--muted);
  margin: 8px 0 6px;
}

select[data-field="credit"] {
  min-height: 140px;
}

.missing {
  border: 2px solid #dc2626 !important;
  background: #fff5f5;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.issue-section {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  align-items: center;
}

.issue-articles {
  margin-top: 8px;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 3px solid #cbd5f5;
}

.issue-article {
  background: #ffffff;
  border: 1px dashed #d7dde5;
  border-radius: 8px;
  padding: 6px 8px;
  align-items: center;
  gap: 8px;
}

.issue-article-title {
  font-size: 14px;
  color: #111827;
  flex: 1;
}

.issue-article.status-final {
  border-color: #16a34a;
  background: #ecfdf3;
}

.issue-article.status-draft {
  border-color: #f59e0b;
  background: #fff7ed;
}

.disabled {
  opacity: 0.55;
  pointer-events: none;
}

.fig-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.fig-card img {
  width: 120px;
  height: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: zoom-in;
}

.fig-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fig-preview-wrap {
  max-width: 90vw;
  max-height: 70vh;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

#fig-preview-img {
  transform-origin: top left;
}

pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 10px;
  overflow: auto;
}

@media (max-width: 720px) {
  .hero h1 { font-size: 28px; }
}
