:root {
  --primary-red: #dc3545;
  --primary-red-dark: #bb2d3b;
  --primary-red-light: #ff4757;
  --bg: #0a0a0a;
  --surface: #1a1a1a;
  --surface-2: #2a2a2a;
  --ink: #ffffff;
  --muted: #b0b0b0;
  --muted-2: #6c757d;
  --line: #333333;
  --accent: var(--primary-red);
  --accent-soft: rgba(220, 53, 69, 0.14);
  --accent-ink: #ffffff;
  --warn: #f0b429;
  --danger: #ff4757;
  --ok: #3dd68c;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(220, 53, 69, 0.18);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(220, 53, 69, 0.12) 0%, transparent 42%),
    linear-gradient(135deg, #0a0a0a 0%, #1a0000 48%, #0a0a0a 100%);
  min-height: 100vh;
  color-scheme: dark;
}

a { color: var(--primary-red-light); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-red); text-decoration: underline; }

.shell { max-width: 1120px; margin: 0 auto; padding: 24px 20px 64px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand strong {
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.brand span { color: var(--muted); font-size: 0.85rem; }
.nav { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.nav a, .nav button {
  border: 1px solid var(--line);
  background: rgba(26, 26, 26, 0.92);
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  transition: var(--transition);
}
.nav a.active, .nav a:hover, .nav button:hover {
  border-color: rgba(220, 53, 69, 0.65);
  background: rgba(220, 53, 69, 0.16);
  color: var(--primary-red-light);
  text-decoration: none;
}

.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.stats-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid.two { grid-template-columns: 1.4fr 1fr; }
@media (max-width: 1000px) {
  .grid.stats-5 { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 900px) {
  .grid.stats, .grid.two { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .grid.stats, .grid.stats-5, .grid.two { grid-template-columns: 1fr; }
}

.card {
  background: linear-gradient(180deg, rgba(42, 42, 42, 0.55) 0%, rgba(26, 26, 26, 0.95) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card h1, .card h2, .card h3 { margin: 0 0 12px; letter-spacing: -0.02em; }
.card h1 { font-size: 1.5rem; }
.card h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.stat-value { font-size: 1.8rem; font-weight: 650; letter-spacing: -0.03em; }
.stat-label { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.95rem;
}
th { color: var(--muted-2); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.mono { font-family: var(--mono); font-size: 0.9rem; }
.truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(108, 117, 125, 0.2);
  color: var(--muted);
}
.badge.active { background: rgba(61, 214, 140, 0.16); color: var(--ok); }
.badge.paused { background: rgba(240, 180, 41, 0.16); color: var(--warn); }
.badge.expired { background: rgba(255, 71, 87, 0.16); color: var(--danger); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary-red) 0%, var(--primary-red-dark) 100%);
  color: var(--accent-ink);
  transition: var(--transition);
}
.btn:hover { filter: brightness(1.08); text-decoration: none; box-shadow: var(--shadow); }
.btn.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
.btn.secondary:hover {
  border-color: rgba(220, 53, 69, 0.65);
  color: var(--primary-red-light);
  background: rgba(220, 53, 69, 0.12);
}
.btn.danger {
  background: linear-gradient(135deg, var(--primary-red-light) 0%, var(--primary-red-dark) 100%);
  color: #fff;
}
.btn.small { padding: 6px 10px; font-size: 0.85rem; }

.form-grid { display: grid; gap: 14px; }
.form-row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .form-row { grid-template-columns: 1fr; } }
label { display: grid; gap: 6px; font-size: 0.9rem; font-weight: 600; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #111111;
  color: var(--ink);
  transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-red);
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.18);
}
input[type="color"] { padding: 4px; min-height: 44px; cursor: pointer; }
textarea { min-height: 100px; resize: vertical; }
.help { font-weight: 400; color: var(--muted-2); font-size: 0.8rem; }
.error { color: var(--danger); font-size: 0.85rem; margin-top: 4px; }
.flash {
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: rgba(220, 53, 69, 0.12);
  border: 1px solid rgba(220, 53, 69, 0.4);
  color: var(--primary-red-light);
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 160px; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 30% 40%, rgba(220, 53, 69, 0.12) 0%, transparent 50%),
    linear-gradient(135deg, #0a0a0a 0%, #1a0000 50%, #0a0a0a 100%);
}
.login-card { width: min(420px, 100%); }

.chart-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.chart-panel__range { margin: 4px 0 0; font-size: 0.85rem; }
.chart-panel__meta { display: flex; gap: 18px; flex-wrap: wrap; }
.chart-meta-value {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.1;
}
.chart-meta-label {
  color: var(--muted-2);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.chart-canvas-wrap { position: relative; width: 100%; height: 280px; }
.chart-empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}
.chart-empty p { margin: 0; }

.public-error {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 20%, rgba(220, 53, 69, 0.14) 0%, transparent 55%),
    linear-gradient(135deg, #0a0a0a 0%, #1a0000 50%, #0a0a0a 100%);
  color-scheme: dark;
}
.public-error .panel {
  background: linear-gradient(180deg, rgba(42, 42, 42, 0.6) 0%, rgba(26, 26, 26, 0.95) 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px 28px;
  max-width: 480px;
  box-shadow: var(--shadow);
}
.public-error h1 { margin: 0 0 8px; color: var(--ink); }
.public-error p { color: var(--muted); }

::selection {
  background: rgba(220, 53, 69, 0.35);
  color: #fff;
}

.mode-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 640px) {
  .mode-pick { grid-template-columns: 1fr; }
}
.mode-option {
  display: grid !important;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 17, 17, 0.9);
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
}
.mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.mode-option span.mode-title {
  font-size: 1.05rem;
  color: var(--ink);
}
.mode-option span.mode-desc {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.85rem;
}
.mode-option:hover {
  border-color: rgba(220, 53, 69, 0.45);
}
.mode-option:has(input:checked) {
  border-color: rgba(220, 53, 69, 0.75);
  background: rgba(220, 53, 69, 0.14);
  box-shadow: var(--shadow);
}
.mode-only-quiz[hidden],
.mode-only-form[hidden] {
  display: none !important;
}

.question-block {
  display: grid;
  gap: 8px;
  padding-bottom: 4px;
}
.question-head {
  display: grid;
  gap: 4px;
}
.question-title {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Star rating */
.star-rating {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 10px;
  user-select: none;
}
.star-rating__stars {
  display: inline-flex;
  flex-direction: row-reverse;
  gap: 4px;
  justify-content: flex-end;
}
.star-rating__stars input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.star-rating__stars label {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin: 0;
  padding: 0;
  cursor: pointer;
  border: none;
  background: transparent;
  font-weight: inherit;
}
.star-rating__stars label svg {
  width: 36px;
  height: 36px;
  display: block;
  fill: transparent;
  stroke: #5a5a5a;
  stroke-width: 1.6;
  transition: transform 0.18s cubic-bezier(0.34, 1.4, 0.64, 1),
              fill 0.18s ease, stroke 0.18s ease, filter 0.18s ease;
  filter: drop-shadow(0 0 0 transparent);
}
.star-rating__stars label:hover svg,
.star-rating__stars label:hover ~ label svg,
.star-rating__stars input:checked ~ label svg,
.star-rating__stars:hover label:hover svg,
.star-rating__stars:hover label:hover ~ label svg {
  fill: url(#jk-star-grad);
  stroke: #ff6b7a;
  filter: drop-shadow(0 4px 12px rgba(220, 53, 69, 0.45));
}
.star-rating__stars label:hover svg,
.star-rating__stars input:checked + label svg {
  transform: scale(1.12);
}
.star-rating__stars:not(:hover) input:checked ~ label svg {
  fill: url(#jk-star-grad);
  stroke: #ff6b7a;
  filter: drop-shadow(0 4px 12px rgba(220, 53, 69, 0.45));
}
.star-rating__value {
  min-width: 3.2rem;
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary-red-light);
  letter-spacing: 0.02em;
}
.star-rating__hint {
  width: 100%;
  color: var(--muted-2);
  font-size: 0.8rem;
  font-weight: 400;
}
@media (max-width: 480px) {
  .star-rating__stars label {
    width: 36px;
    height: 36px;
  }
  .star-rating__stars label svg {
    width: 30px;
    height: 30px;
  }
}

/* ===== Public fill (MS Forms-like) ===== */
.fill-shell {
  display: grid;
  gap: 16px;
}
.fill-hero {
  position: relative;
  overflow: hidden;
}
.fill-hero::before {
  content: "";
  position: absolute;
  inset: -40% -20% auto auto;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(220, 53, 69, 0.28), transparent 70%);
  pointer-events: none;
}
.fill-hero__meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  position: relative;
}
.fill-hero__title {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  letter-spacing: -0.03em;
  position: relative;
}
.fill-hero__desc {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
  position: relative;
  max-width: 52ch;
}
.fill-progress {
  margin-top: 18px;
  position: relative;
}
.fill-progress__track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  border: 1px solid var(--line);
}
.fill-progress__bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #bb2d3b, #dc3545, #ff6b7a);
  box-shadow: 0 0 18px rgba(220, 53, 69, 0.45);
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.fill-progress__label {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--muted-2);
  font-family: var(--mono);
}
.fill-form {
  display: grid;
  gap: 16px;
}
.fill-page {
  display: grid;
  gap: 22px;
  animation: fillIn 0.28s ease;
}
.fill-page[hidden] {
  display: none !important;
}
@keyframes fillIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.fill-section {
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.fill-section__title {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}
.fill-section__help {
  margin: 6px 0 0;
  color: var(--muted);
}
.question-num {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(220, 53, 69, 0.16);
  border: 1px solid rgba(220, 53, 69, 0.35);
  color: var(--primary-red-light);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
}
.field {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  background: rgba(12, 12, 12, 0.92);
  color: var(--ink);
  transition: var(--transition);
}
.field:focus {
  outline: none;
  border-color: var(--primary-red);
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.18);
}
.field--narrow { max-width: 280px; }
textarea.field { min-height: 120px; resize: vertical; }

.choice-grid {
  display: grid;
  gap: 10px;
}
.choice-grid--duo {
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 520px) {
  .choice-grid--duo { grid-template-columns: 1fr; }
}
.choice-card {
  display: flex !important;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(42, 42, 42, 0.35), rgba(18, 18, 18, 0.92));
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
}
.choice-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.choice-card__text { flex: 1; }
.choice-card__radio,
.choice-card__check {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 2px solid #555;
  flex: 0 0 auto;
  position: relative;
  transition: var(--transition);
}
.choice-card__check { border-radius: 6px; }
.choice-card:hover {
  border-color: rgba(220, 53, 69, 0.45);
  transform: translateY(-1px);
}
.choice-card:has(input:checked) {
  border-color: rgba(220, 53, 69, 0.75);
  background: rgba(220, 53, 69, 0.14);
  box-shadow: 0 8px 24px rgba(220, 53, 69, 0.16);
}
.choice-card:has(input:checked) .choice-card__radio,
.choice-card:has(input:checked) .choice-card__check {
  border-color: var(--primary-red-light);
  background: var(--primary-red);
}
.choice-card:has(input:checked) .choice-card__radio::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 999px;
  background: #fff;
}
.choice-card:has(input:checked) .choice-card__check::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.choice-card__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
}
.choice-card--yes:has(input:checked) .choice-card__icon {
  background: rgba(61, 214, 140, 0.2);
  color: var(--ok);
}
.choice-card--no:has(input:checked) .choice-card__icon {
  background: rgba(255, 71, 87, 0.2);
  color: var(--danger);
}

.likert {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}
.likert__item {
  display: grid !important;
  gap: 6px;
  justify-items: center;
  text-align: center;
  margin: 0;
  padding: 12px 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(17, 17, 17, 0.9);
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
}
.likert__item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.likert__num {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-weight: 700;
}
.likert__label {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
  font-weight: 400;
}
.likert__item:hover,
.likert__item:has(input:checked) {
  border-color: rgba(220, 53, 69, 0.65);
  background: rgba(220, 53, 69, 0.14);
}
.likert__item:has(input:checked) .likert__num {
  background: linear-gradient(135deg, #dc3545, #bb2d3b);
  border-color: transparent;
  color: #fff;
}

.rank-list { display: grid; gap: 10px; }
.rank-row {
  display: grid !important;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-weight: 600;
}
.rank-row__pos {
  font-family: var(--mono);
  color: var(--primary-red-light);
}

.file-drop {
  display: grid !important;
  gap: 6px;
  justify-items: center;
  text-align: center;
  margin: 0;
  padding: 28px 18px;
  border-radius: 16px;
  border: 1px dashed rgba(220, 53, 69, 0.45);
  background:
    radial-gradient(circle at 50% 0%, rgba(220, 53, 69, 0.12), transparent 55%),
    rgba(17, 17, 17, 0.85);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
}
.file-drop:hover {
  border-color: rgba(220, 53, 69, 0.8);
  box-shadow: var(--shadow);
}
.file-drop input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.file-drop__title { font-weight: 650; }
.file-drop__hint { color: var(--muted-2); font-size: 0.8rem; font-weight: 400; }
.file-drop__name {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--primary-red-light);
}

.fill-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.fill-nav__spacer { flex: 1; }

.public-state {
  text-align: center;
  padding: 28px 18px;
}
.public-state__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  background: rgba(220, 53, 69, 0.14);
  border: 1px solid rgba(220, 53, 69, 0.35);
  box-shadow: var(--shadow);
}
.public-state h1 { margin-bottom: 8px; }
.score-pill {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 18px;
  padding: 16px 22px;
  border-radius: 16px;
  background: rgba(220, 53, 69, 0.12);
  border: 1px solid rgba(220, 53, 69, 0.35);
}
.score-pill .stat-value { font-size: 2rem; }

.admin-section-row {
  border: 1px dashed rgba(220, 53, 69, 0.45) !important;
  background: rgba(220, 53, 69, 0.08) !important;
}

.winner-chip {
  display: grid;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(240, 180, 41, 0.12);
  border: 1px solid rgba(240, 180, 41, 0.45);
  text-align: right;
}
.winner-chip__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--warn);
  font-weight: 700;
}
.rank-badge {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(108, 117, 125, 0.25);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.85rem;
}
.rank-badge--gold { background: rgba(240, 180, 41, 0.28); color: var(--warn); }
.rank-badge--silver { background: rgba(176, 176, 176, 0.28); color: #ddd; }
.rank-badge--bronze { background: rgba(205, 127, 50, 0.28); color: #e0a06a; }
.ranking-row--winner td {
  background: rgba(240, 180, 41, 0.06);
}
.avg-stars {
  display: inline-flex;
  gap: 2px;
  letter-spacing: 0;
}
.avg-star {
  color: #444;
  font-size: 1rem;
}
.avg-star.is-full {
  color: #f0b429;
  text-shadow: 0 0 10px rgba(240, 180, 41, 0.35);
}
