:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --panel2: #242833;
  --border: #2e3240;
  --text: #e7e9ee;
  --muted: #8a92a4;
  --accent: #5b8cff;
  --accent2: #4070dd;
  --ok: #4cd3a5;
  --warn: #ffb64a;
  --err: #ff6a6a;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
body.centered { min-height: 100vh; display: grid; place-items: center; }

header {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.8rem 1.2rem; border-bottom: 1px solid var(--border); background: var(--panel);
}
header .brand { font-weight: 600; letter-spacing: 0.02em; }
header nav { display: flex; gap: 0.25rem; margin-left: 1rem; }
header .right { margin-left: auto; display: flex; gap: 0.6rem; align-items: center; font-size: 0.9em; color: var(--muted); }

.tab { background: transparent; color: var(--muted); border: 1px solid transparent; padding: 0.35rem 0.7rem; border-radius: 6px; cursor: pointer; }
.tab.active { color: var(--text); background: var(--panel2); border-color: var(--border); }
.tab:hover { color: var(--text); }

main { padding: 1.2rem; max-width: 1400px; margin: 0 auto; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
h1 { font-size: 1.3rem; margin: 0 0 1rem 0; }
h2 { font-size: 1.1rem; margin: 0 0 0.6rem 0; }
h3 { font-size: 0.95rem; margin: 0 0 0.4rem 0; color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
form { display: grid; gap: 0.6rem; max-width: 700px; }
label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85em; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 0.4rem; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
input, select, textarea { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 0.45rem 0.6rem; }
textarea { width: 100%; height: 420px; font-family: ui-monospace, "SF Mono", monospace; font-size: 12.5px; white-space: pre; resize: vertical; }
button {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  padding: 0.45rem 0.9rem; cursor: pointer;
}
button:hover { background: #2f3542; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent2); color: #fff; }
button.primary:hover { background: var(--accent2); }
button.danger { background: #4d1a1a; border-color: #7a2828; color: #ffbdbd; }
button.danger:hover { background: #6a2525; }
.actions { display: flex; gap: 0.5rem; margin-top: 0.7rem; }
.hint { color: var(--muted); font-size: 0.85em; }
.status { color: var(--muted); padding: 0.4rem 0; min-height: 1.2em; }
.error { color: var(--err); }

.badge { border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.75em; font-weight: 600; }
.badge.idle { background: #1f3a2c; color: var(--ok); }
.badge.rebuilding { background: #3a2e1f; color: var(--warn); }
.badge.error { background: #3a1f1f; color: var(--err); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.match { border: 1px solid var(--border); border-radius: 6px; padding: 0.6rem 0.8rem; margin-bottom: 0.4rem; background: var(--panel2); }
.match .row { display: flex; justify-content: space-between; align-items: baseline; }
.match .name { font-weight: 600; }
.match .score { font-family: ui-monospace, monospace; color: var(--accent); font-size: 1.05em; }
.match .score.strong { color: var(--ok); }
.match .score.weak { color: var(--warn); }
.match .meta { color: var(--muted); font-size: 0.85em; margin-top: 0.2rem; }
.match .tags { margin-top: 0.3rem; display: flex; gap: 0.25rem; flex-wrap: wrap; }
.match .tag { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 0.08rem 0.5rem; font-size: 0.75em; color: var(--muted); }

.toolbar { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.8rem; flex-wrap: wrap; }
.toolbar input { min-width: 250px; }
#list-count { color: var(--muted); font-size: 0.85em; margin-left: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.9em; }
th, td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.05em; }
tr:hover td { background: var(--panel2); }
td .minibadge { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0.05rem 0.35rem; font-size: 0.8em; color: var(--muted); margin-right: 0.2rem; }
td button { padding: 0.2rem 0.5rem; font-size: 0.85em; }
.actions-cell { white-space: nowrap; }
.actions-cell button + button { margin-left: 0.25rem; }
.name-link { color: var(--text); text-decoration: none; border-bottom: 1px dotted var(--border); }
.name-link:hover { color: var(--accent); border-bottom-color: var(--accent); }

tr.inactive td { opacity: 0.5; }
tr.inactive td a.name-link { text-decoration: line-through; }
.status-pill { display: inline-block; padding: 0.08rem 0.45rem; border-radius: 999px; font-size: 0.75em; font-weight: 600; }
.status-pill.active { background: #1f3a2c; color: var(--ok); }
.status-pill.inactive { background: #3a2e1f; color: var(--warn); }

#detail-diff .diff-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.6rem; }
#diff-current, #diff-proposed { height: 500px; width: 100%; font-family: ui-monospace, "SF Mono", monospace; font-size: 12px; overflow: auto; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.6rem; white-space: pre; }
#diff-proposed { font-size: 12.5px; resize: vertical; }
#diff-changed-fields { font-family: ui-monospace, monospace; }
#diff-changed-fields span { background: var(--panel2); border: 1px solid var(--border); border-radius: 4px; padding: 0.05rem 0.4rem; margin-right: 0.2rem; font-size: 0.8em; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: grid; place-items: center; z-index: 50; }
.modal[hidden] { display: none; }
[hidden] { display: none !important; }
.modal-inner { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 1.2rem; max-width: 900px; width: 90%; max-height: 85vh; overflow: auto; position: relative; }
.modal-inner.modal-wide { max-width: 1400px; }
.modal .close { position: absolute; top: 0.6rem; right: 0.6rem; background: transparent; border: none; font-size: 1.4rem; color: var(--muted); cursor: pointer; }
.modal pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.7rem; overflow: auto; font-size: 12px; max-height: 60vh; }

progress { width: 100%; height: 10px; border-radius: 5px; }
progress::-webkit-progress-bar { background: var(--panel2); border-radius: 5px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 5px; }

#reembed-progress { margin-top: 0.8rem; display: grid; gap: 0.4rem; }
#reembed-text { font-size: 0.85em; color: var(--muted); font-family: ui-monospace, monospace; }

.locked-overlay { background: rgba(40, 30, 0, 0.15); border: 1px solid var(--warn); padding: 0.5rem 0.8rem; border-radius: 6px; color: var(--warn); margin-bottom: 1rem; font-size: 0.9em; }

.count-badge {
  display: inline-block; background: var(--accent); color: #fff; border-radius: 999px;
  padding: 0.05rem 0.45rem; font-size: 0.7em; font-weight: 600; margin-left: 0.3rem;
  min-width: 1.2em; text-align: center;
}
.draft-indicator {
  font-size: 0.7em; font-weight: 400; color: var(--muted);
  margin-left: 0.6rem; vertical-align: middle;
}
.draft-indicator.saving { color: var(--warn); }
.draft-indicator.saved { color: var(--ok); }
.draft-indicator.error { color: var(--err); }

