/* ─── Reset & tokens ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #4f46e5;
  --primary-dark:  #4338ca;
  --primary-bg:    #eef2ff;
  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text:          #0f172a;
  --text-2:        #475569;
  --text-3:        #94a3b8;
  --green-bg:      #dcfce7;
  --green-text:    #15803d;
  --blue-bg:       #dbeafe;
  --blue-text:     #1d4ed8;
  --red-text:      #dc2626;
  --red-bg:        #fef2f2;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow-sm:     0 1px 2px rgba(0,0,0,.05);
  --shadow:        0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --nav-h:         54px;
  --sidebar-w:     256px;
}

html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Nav ─────────────────────────────────────────────────────────────────── */
.nav {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 1.5rem; gap: 1.5rem;
  z-index: 200; box-shadow: var(--shadow-sm);
}
.nav-brand {
  font-size: .9375rem; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: .375rem;
}
.nav-brand span { color: var(--primary); }
.nav-links { display: flex; gap: .25rem; margin-left: auto; }
.nav-link {
  padding: .375rem .75rem; border-radius: var(--radius);
  font-size: .875rem; color: var(--text-2);
  transition: background .12s, color .12s;
}
.nav-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-bg); color: var(--primary); font-weight: 500; }

/* nav user / logout */
.nav-user { display: flex; align-items: center; gap: .625rem; margin-left: 1rem; padding-left: 1rem; border-left: 1px solid var(--border); }
.nav-user-name { font-size: .8125rem; color: var(--text-2); max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-logout-form { margin: 0; }
.nav-logout {
  background: none; border: 1px solid var(--border); color: var(--text-2);
  font-size: .8125rem; padding: .25rem .625rem; border-radius: var(--radius);
  cursor: pointer; transition: background .12s, color .12s, border-color .12s;
}
.nav-logout:hover { background: var(--red-bg); border-color: #fecaca; color: var(--red-text); }

/* ─── Login page ──────────────────────────────────────────────────────────── */
.login-body {
  background: var(--bg); min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}
.login-shell { width: 100%; padding: 1.5rem; display: flex; justify-content: center; }
.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2rem 1.75rem;
  box-shadow: var(--shadow);
}
.login-brand { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.login-brand span { color: var(--primary); }
.login-sub { font-size: .875rem; color: var(--text-2); margin: .375rem 0 1.5rem; }
.login-error {
  background: var(--red-bg); color: var(--red-text);
  border: 1px solid #fecaca; border-radius: var(--radius);
  padding: .625rem .875rem; font-size: .875rem; margin-bottom: 1rem;
}
.login-form { display: flex; flex-direction: column; gap: .875rem; }
.login-field { display: flex; flex-direction: column; gap: .375rem; }
.login-field span { font-size: .8125rem; color: var(--text-2); font-weight: 500; }
.login-field input {
  padding: .5625rem .875rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .9375rem; outline: none; color: var(--text); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.login-field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.login-form .btn { margin-top: .5rem; width: 100%; padding: .625rem; }

/* ─── Page wrapper ────────────────────────────────────────────────────────── */
.page { margin-top: var(--nav-h); }

/* ─── Docs: two-column layout ─────────────────────────────────────────────── */
.docs-layout { display: flex; height: calc(100vh - var(--nav-h)); overflow: hidden; }

.docs-sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto; display: flex; flex-direction: column;
}

.sidebar-search {
  padding: .875rem .875rem .625rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-search input {
  width: 100%; padding: .4375rem .625rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .8125rem; background: var(--bg); color: var(--text); outline: none;
  transition: border-color .15s, background .15s;
}
.sidebar-search input:focus { border-color: var(--primary); background: white; }

.sidebar-tree { padding: .625rem 0; flex: 1; }

.sidebar-readme { list-style: none; border-bottom: 1px solid var(--border); padding-bottom: .375rem; margin-bottom: .375rem; }
.sidebar-readme li a {
  display: block; padding: .3125rem .875rem;
  font-size: .8125rem; color: var(--text-2);
  border-left: 2px solid transparent;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color .1s, background .1s;
}
.sidebar-readme li a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.sidebar-readme li a.active { background: var(--primary-bg); color: var(--primary); border-left-color: var(--primary); font-weight: 500; }

.tree-group { margin-bottom: .125rem; }
.tree-group-label {
  padding: .4375rem .875rem .25rem;
  font-size: .6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--text-3);
}
.tree-group ul { list-style: none; }
.tree-group li a {
  display: block; padding: .3125rem .875rem .3125rem 1.375rem;
  font-size: .8125rem; color: var(--text-2);
  border-left: 2px solid transparent;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color .1s, background .1s;
}
.tree-group li a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.tree-group li a.active { background: var(--primary-bg); color: var(--primary); border-left-color: var(--primary); font-weight: 500; }

/* search results in sidebar */
.sidebar-results { padding: .5rem 0; }
.sidebar-result { padding: .375rem .875rem; }
.sidebar-result a { font-size: .8125rem; color: var(--text-2); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-result a:hover { color: var(--primary); text-decoration: none; }
.sidebar-result .snippet { font-size: .75rem; color: var(--text-3); margin-top: .125rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sidebar-result .snippet mark { background: #fef08a; color: var(--text); border-radius: 2px; padding: 0 .1em; font-style: normal; }
.sidebar-no-results { padding: 1rem .875rem; font-size: .8125rem; color: var(--text-3); }

/* docs main content */
.docs-main {
  flex: 1; overflow-y: auto;
  padding: 2.5rem 3rem;
}

.docs-main-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text-3); font-size: .9375rem; flex-direction: column; gap: .5rem;
}

.doc-breadcrumb {
  display: flex; align-items: center; gap: .375rem;
  font-size: .8125rem; color: var(--text-3); margin-bottom: 1.75rem;
}
.doc-breadcrumb a { color: var(--text-3); }
.doc-breadcrumb a:hover { color: var(--primary); }
.doc-breadcrumb span { color: var(--text-2); }
.doc-breadcrumb .doc-gitlab-link {
  margin-left: auto;
  padding: .125rem .5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .75rem;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
}
.doc-breadcrumb .doc-gitlab-link:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* ─── Document header ────────────────────────────────────────────────────── */
.doc-header {
  max-width: 800px;
  padding-bottom: 1.25rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}
.doc-title {
  font-size: 1.625rem; font-weight: 700; color: var(--text);
  line-height: 1.3; margin-bottom: .75rem;
}
.doc-meta-list {
  display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 0;
  font-size: .8rem; margin-top: .5rem; color: var(--text-2);
}
.doc-meta-item { display: inline-flex; align-items: baseline; gap: .25rem; color: var(--text-2); }
.doc-meta-item + .doc-meta-item::before { content: "·"; color: var(--text-3); margin-right: .25rem; }
.doc-meta-key { color: var(--text-3); font-weight: 500; font-size: .75rem; }

/* ─── Markdown rendering ──────────────────────────────────────────────────── */
.doc-content { max-width: 800px; line-height: 1.8; }
.doc-content h1 { font-size: 1.75rem; font-weight: 700; margin: 0 0 1rem; line-height: 1.3; }
.doc-content h2 { font-size: 1.25rem; font-weight: 600; margin: 2rem 0 .75rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
.doc-content h3 { font-size: 1.0625rem; font-weight: 600; margin: 1.5rem 0 .5rem; }
.doc-content h4 { font-size: .9375rem; font-weight: 600; margin: 1.25rem 0 .375rem; color: var(--text-2); }
.doc-content p { margin-bottom: .875rem; }
.doc-content ul, .doc-content ol { margin: .625rem 0 .875rem 1.375rem; }
.doc-content li { margin-bottom: .25rem; }
.doc-content code { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; font-size: .85em; background: #f1f5f9; padding: .15em .4em; border-radius: 4px; }
.doc-content pre { background: #1e293b; color: #e2e8f0; padding: 1.125rem 1.375rem; border-radius: var(--radius); overflow-x: auto; margin: 1rem 0; }
.doc-content pre code { background: none; padding: 0; color: inherit; font-size: .8125rem; }
.doc-content table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .875rem; }
.doc-content th { background: var(--bg); font-weight: 600; text-align: left; padding: .5rem .875rem; border: 1px solid var(--border); }
.doc-content td { padding: .4375rem .875rem; border: 1px solid var(--border); }
.doc-content tr:nth-child(even) td { background: #fafafa; }
.doc-content blockquote { border-left: 3px solid var(--primary); padding: .75rem 1rem; background: var(--primary-bg); border-radius: 0 var(--radius) var(--radius) 0; margin: 1rem 0; color: var(--text-2); }
.doc-content hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.doc-content a { color: var(--primary); }

/* ─── Search modal ────────────────────────────────────────────────────────── */
.search-trigger {
  display: flex; align-items: center; gap: .5rem;
  padding: .3125rem .75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text-2);
  font-size: .8125rem; cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
  white-space: nowrap;
}
.search-trigger:hover { border-color: var(--primary); color: var(--text); }
.search-trigger kbd {
  display: inline-flex; align-items: center;
  padding: .1rem .35rem;
  font-size: .7rem; font-family: inherit;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text-3);
  line-height: 1.4;
}

.search-modal {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 10vh;
}
.search-modal[hidden] { display: none; }

.search-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(2px);
}

.search-dialog {
  position: relative; z-index: 1;
  width: 100%; max-width: 600px; margin: 0 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  overflow: hidden;
  animation: modal-in .14s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(-8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.search-input-wrap {
  display: flex; align-items: center; gap: .625rem;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border);
}
.search-input-icon { color: var(--text-3); flex-shrink: 0; font-size: 1rem; }
.search-input {
  flex: 1; border: none; outline: none;
  font-size: 1rem; color: var(--text); background: transparent;
  font-family: inherit;
}
.search-input::placeholder { color: var(--text-3); }
.search-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 1.25rem; padding: 0 .25rem; line-height: 1;
  transition: color .1s;
}
.search-close:hover { color: var(--text); }

.search-results-area {
  max-height: 420px; overflow-y: auto;
  padding: .375rem 0;
}
.search-results-area:empty { display: none; }

.modal-group { padding: .25rem 0; }
.modal-group + .modal-group { border-top: 1px solid var(--border); }

.modal-group-label {
  padding: .5rem 1rem .25rem;
  font-size: .6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--text-3);
}

.modal-result-item {
  display: flex; flex-direction: column; gap: .125rem;
  padding: .5rem 1rem;
  text-decoration: none; color: inherit;
  cursor: pointer;
  transition: background .08s;
  border-left: 2px solid transparent;
}
.modal-result-item:hover,
.modal-result-item.active {
  background: var(--primary-bg);
  border-left-color: var(--primary);
  text-decoration: none;
}

.modal-result-title {
  font-size: .875rem; font-weight: 500; color: var(--text);
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.modal-result-item.active .modal-result-title { color: var(--primary); }

.modal-result-snippet {
  font-size: .75rem; color: var(--text-3); display: block;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.modal-result-snippet mark {
  background: #fef08a; color: var(--text); border-radius: 2px;
  padding: 0 .1em; font-style: normal;
}

.modal-no-results {
  padding: 1.5rem 1rem; text-align: center;
  font-size: .875rem; color: var(--text-3);
}

.search-footer {
  display: flex; gap: 1rem; align-items: center;
  padding: .5rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
  font-size: .75rem; color: var(--text-3);
}
.search-footer kbd {
  display: inline-flex; align-items: center;
  padding: .1rem .3rem;
  font-size: .7rem; font-family: inherit;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 3px; color: var(--text-3);
}
.search-footer-hint { display: flex; align-items: center; gap: .25rem; }

/* ─── Reviews: single column ──────────────────────────────────────────────── */
.reviews-page { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }

.page-header { margin-bottom: 2rem; }
.page-header h2 { font-size: 1.375rem; font-weight: 700; margin-bottom: .25rem; }
.page-header p { color: var(--text-2); font-size: .9375rem; }

/* run form */
.form-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem 1.5rem;
  margin-bottom: 1.75rem; box-shadow: var(--shadow-sm);
}
.form-card-title { font-size: .875rem; font-weight: 600; color: var(--text-2); margin-bottom: .75rem; }
.input-row { display: flex; gap: .5rem; }
.input-row input {
  flex: 1; padding: .5625rem .875rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .9375rem; outline: none; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.btn {
  padding: .5625rem 1.125rem;
  background: var(--primary); color: white;
  border: none; border-radius: var(--radius);
  font-size: .9375rem; font-weight: 500;
  cursor: pointer; transition: background .12s; white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); }
.btn-sm { padding: .375rem .75rem; font-size: .8125rem; }

/* run cards */
.section-title { font-size: .8125rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; margin-bottom: .75rem; }

.run-card {
  display: flex; align-items: center; gap: 1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: .875rem 1.25rem;
  margin-bottom: .5rem; box-shadow: var(--shadow-sm);
  transition: border-color .12s, box-shadow .12s, transform .12s;
  text-decoration: none; color: inherit; cursor: pointer;
}
.run-card:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); text-decoration: none; transform: translateY(-1px); }

.run-key { font-weight: 700; font-size: .9375rem; color: var(--primary); min-width: 6.5rem; }
.run-meta { flex: 1; font-size: .8125rem; color: var(--text-2); }
.run-date { font-size: .8125rem; color: var(--text-3); white-space: nowrap; }

.badge { display: inline-flex; align-items: center; padding: .1875rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-mr      { background: var(--green-bg);  color: var(--green-text); }
.badge-merged  { background: #ddd6fe; color: #5b21b6; }
.badge-none    { background: var(--bg); color: var(--text-3); }
.badge-webhook { background: #dbeafe; color: #1d4ed8; }
.badge-manual  { background: var(--bg); color: var(--text-2); }
.badge-warn    { background: #fef9c3; color: #854d0e; }

.run-history { display: flex; flex-direction: column; gap: .375rem; padding: .75rem 1rem; }
.run-history-row { display: flex; align-items: center; gap: .5rem; font-size: .875rem; }
.run-history-row .run-date { color: var(--text-2); min-width: 10rem; }
.run-history-row .run-meta { color: var(--text-3); margin-left: auto; }

/* ─── Task polling ────────────────────────────────────────────────────────── */
.task-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem 1.5rem;
  margin-top: 1rem; box-shadow: var(--shadow-sm);
}
.task-running { display: flex; align-items: center; gap: .75rem; color: var(--text-2); font-size: .9375rem; }
.task-hint { font-size: .8125rem; color: var(--text-3); margin-top: .375rem; padding-left: 1.625rem; }
.task-done { display: flex; align-items: center; gap: .75rem; font-size: .9375rem; }
.task-done a { color: var(--primary); font-weight: 500; }
.task-error { font-size: .9375rem; color: var(--red-text); }
.task-error pre { margin-top: .5rem; font-size: .8rem; background: var(--red-bg); padding: .75rem; border-radius: var(--radius); white-space: pre-wrap; word-break: break-all; }

.spinner {
  width: 16px; height: 16px; flex-shrink: 0;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-check { color: var(--green-text); font-size: 1.125rem; }

/* ─── Detail page ─────────────────────────────────────────────────────────── */
.detail-page { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }

.detail-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: .75rem; margin-bottom: 1.5rem;
}
.detail-top h2 { font-size: 1.375rem; font-weight: 700; }
.detail-top p { font-size: .875rem; color: var(--text-2); margin-top: .2rem; }

.detail-top-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.mr-badge { display: inline-flex; align-items: center; gap: .375rem; padding: .5rem 1rem; background: var(--green-bg); color: var(--green-text); border-radius: var(--radius); font-size: .875rem; font-weight: 600; transition: background .12s; }
.mr-badge:hover { background: #bbf7d0; text-decoration: none; }
.mr-badge-none { padding: .5rem 1rem; background: var(--bg); color: var(--text-3); border-radius: var(--radius); font-size: .875rem; }
.mr-badge-merged { background: #e0e7ff; color: #3730a3; cursor: default; }
.mr-badge-merged:hover { background: #e0e7ff; }
.mr-missing { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.btn-create-mr { background: var(--primary); color: #fff; border: none; padding: .4375rem 1rem; border-radius: var(--radius); font-size: .875rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn-create-mr:hover { opacity: .88; }
.btn-danger { background: #ef4444; color: #fff; border: none; padding: .4375rem 1rem; border-radius: var(--radius); font-size: .875rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn-danger:hover { background: #dc2626; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  margin-bottom: 1rem; box-shadow: var(--shadow-sm);
}
.card-header {
  padding: .875rem 1.25rem; background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: .9375rem; display: flex; align-items: center; gap: .5rem;
}
.card-body { padding: 1.25rem 1.5rem; }

.file-row {
  display: flex; align-items: center; gap: .625rem;
  padding: .625rem 1.25rem; border-bottom: 1px solid var(--border);
  font-size: .875rem;
}
.file-row:last-child { border-bottom: none; }
.file-row code { font-size: .8125rem; color: var(--text-2); font-family: monospace; }
.file-row .sep { color: var(--text-3); }
.file-row .change { color: var(--text-3); font-size: .8125rem; }

.tag { display: inline-flex; padding: .15rem .5rem; border-radius: 4px; font-size: .75rem; font-weight: 700; }
.tag-create { background: var(--green-bg); color: var(--green-text); }
.tag-update { background: var(--blue-bg);  color: var(--blue-text); }

/* MR Status card */
.mr-status-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.mr-status-header { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1.25rem; font-weight: 600; font-size: .875rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.mr-status-body { display: flex; align-items: center; gap: 1rem; padding: .875rem 1.25rem; flex-wrap: wrap; }
.mr-status-badges { display: flex; gap: .5rem; flex-wrap: wrap; flex: 1; }
.status-badge { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .75rem; border-radius: 20px; font-size: .8125rem; font-weight: 500; }
.badge-conflict { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }
.badge-comment  { background: #cfe2ff; color: #0c4a6e; border: 1px solid #93c5fd; }
.badge-ok       { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.badge-error    { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.gitlab-error-banner { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; font-size: .875rem; }
.btn-sync { background: var(--primary); color: #fff; border: none; padding: .4375rem 1rem; border-radius: var(--radius); font-size: .875rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn-sync:hover { opacity: .88; }
.btn-refresh { display: inline-flex; align-items: center; gap: .3rem; background: none; border: 1px solid var(--border); border-radius: var(--radius); padding: .25rem .625rem; font-size: .8125rem; color: var(--text-2); cursor: pointer; }
.btn-refresh:hover { background: var(--bg); color: var(--text-1); }
.refresh-spin { display: none; }
.htmx-request .refresh-spin { display: inline; animation: spin .7s linear infinite; }
.htmx-request .refresh-label { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
#sync-area { padding: 0 1.25rem 1rem; }

/* File details (collapsible) */
.files-section { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.files-section-header { padding: .75rem 1.25rem; font-weight: 600; font-size: .875rem; background: var(--surface); border-bottom: 1px solid var(--border); color: var(--text-1); }
.file-detail { border-bottom: 1px solid var(--border); }
.file-detail:last-child { border-bottom: none; }
.file-detail-summary {
  display: flex; align-items: center; gap: .625rem;
  padding: .625rem 1.25rem; font-size: .875rem;
  cursor: pointer; list-style: none; background: var(--surface);
  user-select: none;
}
.file-detail-summary::-webkit-details-marker { display: none; }
.file-detail-summary::before {
  content: "▶"; font-size: .625rem; color: var(--text-3);
  transition: transform .15s; flex-shrink: 0;
}
.file-detail[open] > .file-detail-summary::before { transform: rotate(90deg); }
.file-detail-summary:hover { background: var(--bg); }
.file-path { font-size: .8125rem; color: var(--text-2); font-family: monospace; }
.file-change-summary { color: var(--text-3); font-size: .8125rem; margin-left: auto; }
.file-detail-body { padding: 1.25rem 1.5rem; background: var(--bg); border-top: 1px solid var(--border); max-width: none; }
.file-detail-body.doc-content { max-width: none; }
.file-detail-empty { padding: .875rem 1.5rem; color: var(--text-3); font-size: .875rem; background: var(--bg); border-top: 1px solid var(--border); }

/* Revise form */
.revise-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem 1.5rem; box-shadow: var(--shadow-sm); }
.revise-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: .25rem; }
.revise-card > p { color: var(--text-2); font-size: .875rem; margin-bottom: 1rem; }
.revise-form textarea {
  width: 100%; padding: .625rem .875rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .9375rem; resize: vertical; outline: none;
  font-family: inherit; color: var(--text); min-height: 100px;
  transition: border-color .15s, box-shadow .15s; margin-bottom: .75rem;
}
.revise-form textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }

/* Clarify form */
.clarify-card .card-body { padding: 1rem 1.25rem; }
.clarify-desc { color: var(--text-2); font-size: .875rem; margin-bottom: 1.25rem; }
.clarify-form { display: flex; flex-direction: column; gap: 1.25rem; }
.clarify-item { display: flex; flex-direction: column; gap: .5rem; }
.clarify-question {
  display: flex; align-items: flex-start; gap: .625rem;
  font-size: .9375rem; font-weight: 500; color: var(--text);
}
.clarify-index {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.375rem; height: 1.375rem; flex-shrink: 0;
  background: var(--primary-bg); color: var(--primary);
  border-radius: 50%; font-size: .75rem; font-weight: 700; margin-top: .1rem;
}
.clarify-answer {
  width: 100%; padding: .5625rem .875rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .9375rem; resize: vertical; outline: none;
  font-family: inherit; color: var(--text); min-height: 72px;
  transition: border-color .15s, box-shadow .15s;
}
.clarify-answer:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.btn-clarify { align-self: flex-start; margin-top: .25rem; }
.clarify-empty { color: var(--text-2); font-size: .875rem; padding: .5rem 0; }

/* Clarify: suggestion choices */
.clarify-choices { display: flex; flex-direction: column; gap: .375rem; }
.clarify-choice {
  display: flex; align-items: center; gap: .625rem;
  padding: .5rem .875rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .9375rem; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.clarify-choice:has(input:checked) {
  border-color: var(--primary); background: var(--primary-bg);
}
.clarify-choice input[type="radio"] { accent-color: var(--primary); flex-shrink: 0; }
.clarify-choice span { color: var(--text); }
.clarify-choice-custom { align-items: flex-start; }
.clarify-custom-input {
  width: 100%; padding: .5625rem .875rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .9375rem; resize: vertical; outline: none;
  font-family: inherit; color: var(--text); min-height: 64px;
  margin-top: .375rem;
  transition: border-color .15s, box-shadow .15s;
}
.clarify-custom-input:not(:disabled):focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.clarify-custom-input:disabled { background: var(--bg); color: var(--text-3); cursor: not-allowed; }

/* back link */
.back-link { display: inline-flex; align-items: center; gap: .375rem; font-size: .875rem; color: var(--text-2); margin-bottom: 1.5rem; }
.back-link:hover { color: var(--primary); text-decoration: none; }

/* empty state */
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-3); }
.empty p { margin-bottom: .375rem; }
.empty a { color: var(--primary); }
