:root {
  --fg: #1b1f23;
  --fg-muted: #57606a;
  --bg: #ffffff;
  --bg-soft: #f6f8fa;
  --bg-softer: #fafbfc;
  --border: #d0d7de;
  --accent: #0969da;
  --accent-soft: #ddf4ff;
  --danger: #cf222e;
  --success: #1a7f37;
  --warning: #9a6700;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.5;
  font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  padding: 1px 5px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.9em;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

.muted { color: var(--fg-muted); }
.small { font-size: 0.85em; }

.app-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.app-header .brand { font-weight: 600; color: var(--fg); }
.app-header nav a {
  margin-left: 4px;
  margin-right: 12px;
  color: var(--fg-muted);
}
.app-header nav a:hover { color: var(--accent); }
.app-header .header-actions { margin-left: auto; }

.header-worker {
  display: flex;
  gap: 8px;
  align-items: center;
}
.worker-status {
  font-size: 0.85em;
  color: var(--fg-muted);
  padding: 4px 8px;
  background: var(--bg);
  border-radius: 4px;
}

main { max-width: 1400px; margin: 0 auto; padding: 20px; }

.scaffold-banner {
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.btn {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.88em;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-soft); text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #0550ae; border-color: #0550ae; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #a40e26; border-color: #a40e26; color: #fff; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #116329; border-color: #116329; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--fg-muted); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--fg); }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.tag, .chip {
  display: inline-block;
  padding: 1px 8px;
  margin-right: 4px;
  border-radius: 10px;
  font-size: 0.78em;
  background: var(--bg-soft);
  color: var(--fg-muted);
  border: 1px solid var(--border);
}
.chip { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }

.status {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.78em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-pending   { background: #fff8c5; color: #9a6700; }
.status-skipped   { background: #eaeef2; color: #57606a; }
.status-draft     { background: #ddf4ff; color: #0969da; }
.status-reviewed  { background: #dafbe1; color: #1a7f37; }
.status-approved  { background: #1a7f37; color: #fff; }
.status-migrated  { background: #9a6700; color: #fff; }

/* Two-column list layout */
.list-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
}
.facets h3 {
  margin: 16px 0 6px;
  font-size: 0.78em;
  text-transform: uppercase;
  color: var(--fg-muted);
  letter-spacing: 0.05em;
}
.facets .facet-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}
.facets .facet-list li {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  border-radius: 4px;
}
.facets .facet-list li:hover { background: var(--bg-soft); }
.facets .facet-list a { color: var(--fg); }
.facets .facet-list a.active { font-weight: 600; color: var(--accent); }
.facets .count { color: var(--fg-muted); font-size: 0.85em; }

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.search-bar input[type="search"] {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: inherit;
}

.result-summary {
  color: var(--fg-muted);
  margin-bottom: 8px;
  font-size: 0.9em;
}

.article-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.article-table th, .article-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.article-table th {
  background: var(--bg-soft);
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}
.article-table tr:last-child td { border-bottom: none; }
.article-table tr:hover { background: var(--bg-softer); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
}

.empty {
  padding: 40px 20px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

/* Detail view */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 20px;
}
.detail-header h1 { margin: 0 0 6px; font-size: 1.4em; }
.detail-header .breadcrumb { white-space: nowrap; }
.skip-reason {
  padding: 8px 12px;
  background: #eaeef2;
  border-left: 3px solid var(--fg-muted);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--fg-muted);
}

.panes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}
.pane {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  background: var(--bg);
  min-height: 60vh;
}
.pane-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.pane h2 {
  margin: 0 0 12px;
  font-size: 1em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}

.thread-transcript .msg {
  padding: 8px 0;
  border-bottom: 1px solid var(--bg-soft);
}
.thread-transcript .msg:last-child { border-bottom: none; }
.msg-head { display: flex; gap: 8px; align-items: baseline; }
.pseudonym { font-weight: 600; }
.msg-body { white-space: pre-wrap; word-wrap: break-word; }
.msg-att {
  margin-top: 4px;
  padding: 4px 8px;
  background: var(--bg-soft);
  border-radius: 4px;
  font-size: 0.9em;
  display: inline-block;
}
.msg-att .mime { color: var(--fg-muted); margin-right: 6px; font-size: 0.85em; }
.msg-att .vision { margin-top: 2px; font-style: italic; }

.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.view-toggle button {
  padding: 4px 12px;
  border: none;
  background: var(--bg);
  color: var(--fg-muted);
  cursor: pointer;
  font-size: inherit;
}
.view-toggle button.active { background: var(--accent); color: #fff; }

.md-preview { line-height: 1.6; }
.md-preview h1 { font-size: 1.4em; }
.md-preview h2 { font-size: 1.15em; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.md-preview pre { background: var(--bg-soft); padding: 10px; border-radius: 4px; overflow-x: auto; }
.md-preview img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.md-source {
  width: 100%;
  min-height: 55vh;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-softer);
  resize: vertical;
}

.section-label {
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  margin: 0 0 8px;
}

.chip-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip-list li a {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--fg);
  text-decoration: none;
  background: var(--bg);
}
.chip-list li a:hover { background: var(--bg-soft); }
.chip-list .count { color: var(--fg-muted); font-size: 0.85em; }

.editor-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}

.actions-strip {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.actions-sep {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}
.actions-note {
  font-style: italic;
  color: var(--fg-muted);
  font-size: 0.85em;
  margin-right: 4px;
}
.actions-note a { font-style: normal; }
.actions-strip .flash {
  width: 100%;
  padding: 6px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius);
  font-size: 0.9em;
  margin-bottom: 4px;
}
.actions-strip .flash-error {
  background: #ffebe9;
  color: var(--danger);
  border: 1px solid #ffcecb;
  white-space: pre-wrap;
  word-break: break-word;
}
