:root {
  --bg: #0f172a;
  --card: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --success: #4ade80;
  --danger: #f87171;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  /* Reserve space for the fixed contents panel so it never covers questions.
     24px (right offset) + 240px (panel width) + 24px (gap) */
  padding-right: calc(24px + 240px + 24px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at 20% 20%, #1e293b 0%, var(--bg) 60%);
  color: var(--text);
}

.contents {
  position: fixed;
  top: 24px;
  right: 24px;
  bottom: 24px;
  width: 240px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  z-index: 10;
}

.contents-title {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
}

.contents-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.contents-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s ease, color 0.15s ease;
}

.contents-item:hover,
.contents-item:focus-visible {
  background: var(--bg);
  color: var(--accent);
  outline: none;
}

.contents-item--dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.card {
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.lead {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.5;
}

.survey-title {
  margin: 0 0 16px;
  font-size: 1.2rem;
}

.fields {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

.field {
  display: grid;
  gap: 6px;
}

.field__label {
  font-size: 0.85rem;
  color: var(--muted);
}

.field input,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.submit-form {
  /* Block layout: questions are prepended into this form, so a flex row
     would lay them all out horizontally (overflowing the card and pushing
     the submit button under the fixed contents panel). */
  display: block;
}

.submit-form__button {
  width: 100%;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #082f49;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.submit-form__button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(56, 189, 248, 0.35);
}

.submit-form__button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status {
  margin: 16px 0 0;
  min-height: 1.2em;
  text-align: center;
  color: var(--success);
}

.status--error {
  color: var(--danger);
}

.export {
  width: 100%;
  margin-top: 12px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.export:hover,
.export:focus-visible {
  background: var(--bg);
  border-color: var(--accent);
  outline: none;
}

.q {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 0 16px;
  scroll-margin-top: 24px;
}

.q-title {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0 6px;
}

.q-body:empty {
  min-height: 24px;
}

.q-config {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.q-config-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.q-config input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.q-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  font-size: 0.95rem;
  cursor: pointer;
}

.q-option input[type="radio"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.q-body select.q-answer {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.q-body select.q-answer:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.q-body .star {
  display: inline-block;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.1s ease, transform 0.1s ease;
}

.q-body .star:hover {
  transform: scale(1.15);
}

.q-body .star.active {
  color: var(--accent);
}

/* The star/score radios live inside their .star/.score labels; the label
   is the visible control, so the radios are collapsed to zero size (kept
   focusable so the label keeps activating them). */
.q-body .star input[type="radio"],
.q-body .score input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  border: none;
  padding: 0;
  width: 0;
  height: 0;
}

.q-body .score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: color 0.1s ease, border-color 0.1s ease, background 0.1s ease, transform 0.1s ease;
}

.q-body .score:hover {
  transform: scale(1.1);
  border-color: var(--accent);
}

.q-body .score.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #082f49;
  font-weight: 600;
}

.ranking-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin: 2px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.95rem;
  cursor: grab;
  user-select: none;
}

.ranking-item::before {
  content: '⠿';
  color: var(--muted);
}

.ranking-item--dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.likert {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.likert th,
.likert td {
  border: 1px solid var(--border);
  padding: 4px 6px;
  text-align: center;
}

.likert thead th,
.likert th[scope="col"] {
  color: var(--muted);
  font-weight: 600;
}

.likert th[scope="row"] {
  text-align: left;
  color: var(--text);
}

.likert input[type="radio"] {
  accent-color: var(--accent);
  cursor: pointer;
}
