:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #15803d;
  --danger: #b91c1c;
  --soft: #eef2ff;
  --soft-2: #f8fbff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
.container { max-width: 1200px; margin: 20px auto 48px; padding: 0 14px; }
.header {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: white;
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.header h1 { margin: 0 0 8px; font-size: clamp(24px, 3vw, 32px); line-height: 1.15; }
.header p { margin: 0; opacity: .95; font-size: clamp(14px, 1.4vw, 16px); }
.step-nav { display:flex; flex-wrap:wrap; gap:10px; margin:0 0 18px; }
.step-chip {
  display:inline-flex; align-items:center; justify-content:center; min-height:42px; padding:8px 14px;
  border-radius:999px; background:#e5e7eb; color:#111827; text-decoration:none; font-weight:700; font-size:14px;
}
.step-chip.active { background: var(--primary); color: white; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  overflow: hidden;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 16px; font-size: clamp(20px, 2.2vw, 24px); line-height: 1.2; }
.card h3 { margin: 18px 0 10px; font-size: clamp(17px, 1.8vw, 19px); line-height: 1.25; }
.small-note { color: var(--muted); font-size: 14px; margin-top: -4px; margin-bottom: 12px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field { display:flex; flex-direction:column; gap:6px; min-width:0; }
label { font-weight:700; font-size:14px; line-height:1.25; }
input[type="text"], input[type="number"], input[type="date"], input[type="url"], textarea, select {
  width:100%; max-width:100%; border:1px solid var(--border); border-radius:10px; padding:11px 12px; font:inherit; font-size:16px; background:white; color:var(--text);
}
textarea { min-height:100px; resize:vertical; }
.inline-options { display:flex; flex-wrap:wrap; gap:12px; align-items:center; padding-top:6px; }
.participant-selector-bar {
  display:grid; grid-template-columns:repeat(auto-fit, minmax(74px, 1fr)); gap:10px; margin-top:14px; margin-bottom:8px;
}
.participant-pill {
  display:inline-flex; align-items:center; justify-content:center; min-height:46px; padding:10px 12px; border:1px solid #cbd5e1; border-radius:999px;
  background:white; color:var(--text); font-size:14px; font-weight:700; cursor:pointer; user-select:none; transition:all .15s ease; text-align:center; width:100%;
}
.participant-pill:hover { border-color: var(--primary); background:#eff6ff; }
.participant-pill input { display:none; }
.participant-pill.active { background:var(--primary); color:white; border-color:var(--primary); }
.participant-pill.disabled { background:#f3f4f6; color:#9ca3af; border-color:#e5e7eb; cursor:not-allowed; }
.participant-selection-status { margin-top:8px; font-size:14px; color:var(--muted); line-height:1.35; }
.participant-card { border:1px solid #e5e7eb; border-radius:14px; padding:16px; background:#fcfcff; overflow:hidden; margin-bottom:14px; }
.participant-header { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px; }
.participant-title { font-size:18px; font-weight:700; margin:0; line-height:1.2; }
.function-grid { display:grid; gap:10px; }
.function-head {
  display:grid; grid-template-columns:minmax(180px, 1.7fr) repeat(5, minmax(78px, 1fr)); gap:10px; align-items:center; margin-bottom:4px;
  color:var(--muted); font-size:13px; font-weight:700; padding:0 4px;
}
.function-head > div:first-child { color:transparent; user-select:none; }
.function-row {
  display:grid; grid-template-columns:minmax(180px, 1.7fr) 1fr; gap:12px; align-items:start; border:1px solid #e5e7eb; border-radius:12px; padding:12px; background:white;
}
.function-name { font-weight:700; line-height:1.3; min-width:0; word-break:break-word; }
.function-choices { display:grid; grid-template-columns:repeat(5, minmax(78px, 1fr)); gap:8px; min-width:0; }
.role-choice {
  display:flex; align-items:center; justify-content:center; gap:6px; border:1px solid #dbeafe; background:var(--soft-2); padding:10px 8px; border-radius:10px;
  font-size:13px; text-align:center; min-height:56px; cursor:pointer; line-height:1.2;
}
.role-choice span { display:inline-block; min-width:0; word-break:break-word; }
.score-row {
  display:grid; grid-template-columns:minmax(220px, 1fr) minmax(120px, 160px); gap:12px; align-items:center; border:1px solid #e5e7eb; border-radius:12px;
  padding:10px 12px; background:white; margin-bottom:10px;
}
.actions { display:flex; flex-wrap:wrap; gap:12px; justify-content:flex-end; align-items:stretch; }
button, .button-link {
  border:0; border-radius:12px; padding:12px 18px; font:inherit; font-weight:700; cursor:pointer; min-height:46px; text-decoration:none; display:inline-flex; align-items:center; justify-content:center;
}
.btn-secondary { background:#e5e7eb; color:#111827; }
.btn-primary { background:var(--primary); color:white; }
.btn-primary:hover { background:var(--primary-dark); }
.btn-danger { background:#fee2e2; color:#991b1b; }
.status-box { margin-top:10px; padding:12px 14px; border-radius:12px; font-size:14px; white-space:pre-wrap; line-height:1.4; }
.status-info { background:#eff6ff; color:#1d4ed8; }
.status-success { background:#f0fdf4; color:var(--success); }
.status-error { background:#fef2f2; color:var(--danger); }
.hidden { display:none !important; }
details summary { cursor:pointer; font-weight:700; margin-bottom:8px; line-height:1.3; }
pre {
  background:#0f172a; color:#e2e8f0; border-radius:12px; padding:14px; overflow:auto; font-size:13px; max-width:100%; white-space:pre-wrap; word-break:break-word;
}
.list-table { width:100%; border-collapse:collapse; }
.list-table th, .list-table td { padding:12px 10px; border-bottom:1px solid #e5e7eb; text-align:left; vertical-align:top; }
.badge { display:inline-block; padding:4px 10px; border-radius:999px; background:#eff6ff; color:#1d4ed8; font-weight:700; font-size:12px; }
.muted { color: var(--muted); }

@media (max-width: 980px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .function-head { display:none; }
  .function-row { grid-template-columns:1fr; gap:10px; }
  .function-choices { grid-template-columns: repeat(3, minmax(90px, 1fr)); }
  .role-choice { justify-content:flex-start; text-align:left; padding-left:12px; }
}
@media (max-width: 760px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .container { margin:12px auto 28px; padding:0 10px; }
  .header { padding:18px 16px; border-radius:14px; }
  .card { padding:16px; border-radius:14px; }
  .small-note, label { font-size:13px; }
  .participant-card { padding:14px; }
  .participant-title { font-size:17px; }
  .function-row { padding:10px; }
  .function-name { font-size:15px; }
  .function-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); gap:8px; }
  .role-choice { min-height:48px; font-size:13px; }
  .score-row { grid-template-columns:1fr; }
  .actions { flex-direction:column; }
  .actions button, .actions .button-link { width:100%; }
  pre { font-size:12px; padding:12px; }
}
@media (max-width: 360px) {
  .function-choices { grid-template-columns:1fr; }
  .participant-selector-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
