:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #1f2330;
  --muted: #7a818f;
  --accent: #6c5ce7;
  --accent-2: #00b894;
  --border: #e6e8f0;
  --danger: #e74c3c;
  --shadow: 0 2px 10px rgba(30, 35, 60, 0.06);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); font-size: 14px; min-height: 18px; }
button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
}
button.ghost { background: #eef0f7; color: var(--ink); }
button.link { background: none; color: var(--accent); padding: 0; }
input, select, textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
}

/* Login */
.login-wrap { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-card { width: 320px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.login-card h1 { margin: 0; font-size: 22px; }

/* Header */
header {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 22px; background: #fff; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; }
nav { display: flex; gap: 6px; flex: 1; }
.tab { background: transparent; color: var(--muted); }
.tab.active { background: #eef0f7; color: var(--ink); }
.who { font-size: 14px; color: var(--muted); display: flex; gap: 8px; align-items: center; }

.view { max-width: 1040px; margin: 22px auto; padding: 0 18px; }

/* Add bar */
.add-bar { display: flex; gap: 10px; margin-bottom: 18px; }
.add-bar input { flex: 1; }

/* Grid of name cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.name-card { display: flex; flex-direction: column; gap: 8px; }
.name-card .top { display: flex; align-items: baseline; justify-content: space-between; }
.name-card h3 { margin: 0; font-size: 20px; }
.gender-tag { font-size: 11px; padding: 2px 7px; border-radius: 20px; background: #eef0f7; color: var(--muted); }
.gender-F { background: #ffe3ef; color: #d63384; }
.gender-M { background: #e3f0ff; color: #2563eb; }
.summary { font-size: 14px; color: #3c4250; line-height: 1.4; min-height: 38px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; display: inline-block; }
.badge.pending { background: #fff4d6; color: #b8860b; }
.badge.done { background: #d8f5e6; color: #08885a; }
.badge.error { background: #ffe0dd; color: var(--danger); }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.card-actions button { padding: 6px 10px; font-size: 13px; }
.veto-on { background: var(--danger) !important; }
.spinner {
  width: 14px; height: 14px; border: 2px solid #ddd; border-top-color: var(--accent);
  border-radius: 50%; display: inline-block; animation: spin 0.8s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Ranking */
.rank-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.rank-item {
  display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow); cursor: grab;
}
.rank-item .pos { font-weight: 700; color: var(--accent); width: 28px; }
.rank-item .nm { flex: 1; font-size: 16px; }
.rank-item.vetoed .nm { text-decoration: line-through; color: var(--muted); }
.sortable-ghost { opacity: 0.4; }

/* Leaderboard */
.board { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.board th, .board td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.board th { background: #f1f2f8; color: var(--muted); font-weight: 600; }
.board .rankcell { font-weight: 700; color: var(--accent); }
.veto-x { color: var(--danger); font-weight: 700; }
.board tr.vetoed { opacity: 0.6; }

/* Costs */
.cost-totals { margin-bottom: 16px; }
.cost-totals h2 { margin: 0 0 4px; font-size: 30px; }
.cost-totals p { margin: 2px 0; }

/* Archived */
.archived-head { margin: 26px 0 10px; font-size: 15px; color: var(--muted); }
.archived-head .link { margin-left: 8px; font-size: 13px; }
#archived-grid .name-card { opacity: 0.72; }

/* AI ranking */
.board-actions { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.board-subhead { margin: 26px 0 10px; font-size: 16px; }
ol.ai-rank { margin: 0; padding-left: 24px; display: flex; flex-direction: column; gap: 8px; }
ol.ai-rank li { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); }
ol.ai-rank .ai-nm { font-weight: 700; font-size: 16px; margin-right: 10px; }
ol.ai-rank .ai-why { color: var(--muted); font-size: 14px; }

/* Selection + action bar */
.sel-check { width: 16px; height: 16px; vertical-align: middle; margin-right: 4px; accent-color: var(--accent); cursor: pointer; }
.action-bar {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; border-radius: 30px; padding: 10px 16px;
  display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 28px rgba(0,0,0,0.28); z-index: 40;
}
.action-bar #sel-count { font-size: 14px; padding-right: 4px; }
.action-bar button { padding: 7px 14px; font-size: 13px; }
.action-bar button.ghost { background: rgba(255,255,255,0.16); color: #fff; }
.action-bar button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Notes */
.note-card { margin-bottom: 16px; }
.note-prompt { font-style: italic; color: #555; margin: 6px 0 10px; }
.markdown { font-size: 15px; line-height: 1.6; }
.markdown h1, .markdown h2, .markdown h3 { margin: 16px 0 6px; }
.markdown h1 { font-size: 20px; } .markdown h2 { font-size: 18px; } .markdown h3 { font-size: 16px; }
.markdown ul, .markdown ol { padding-left: 22px; }
.markdown code { background: #f1f2f8; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.markdown table { border-collapse: collapse; margin: 10px 0; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 6px 10px; }
#analyze-result:not(:empty) { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
#analyze-prompt { width: 100%; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(20, 22, 35, 0.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal-card { background: #fff; border-radius: 14px; max-width: 720px; width: 100%; padding: 26px; position: relative; box-shadow: 0 12px 40px rgba(0,0,0,0.2); }
.modal-close { position: absolute; top: 14px; right: 14px; background: #eef0f7; color: var(--ink); width: 34px; height: 34px; border-radius: 50%; font-size: 20px; line-height: 1; padding: 0; }
.modal h2 { margin: 0 0 4px; font-size: 26px; }
.modal .section { margin-top: 18px; }
.modal .section h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { background: #eef0f7; border-radius: 20px; padding: 4px 11px; font-size: 13px; }
.pill.clickable { cursor: pointer; background: #e7e3ff; color: var(--accent); }
.proscons { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.proscons ul { margin: 6px 0 0; padding-left: 18px; font-size: 14px; line-height: 1.5; }
.pros h4 { color: var(--accent-2); }
.cons h4 { color: var(--danger); }
.model-line { font-size: 12px; color: var(--muted); margin-top: 4px; }
canvas { max-width: 100%; }
@media (max-width: 620px) { .proscons { grid-template-columns: 1fr; } nav { overflow-x: auto; } }
