* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f7fa;
  display: flex;
  flex-direction: column;
}
.container, .container-full {
  width: 100%;
  margin: 0 auto;
}
.container {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  padding: 2rem;
  max-width: 700px;
}
.container-full {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  max-width: 1200px;
}
.container h1, .container-full h1 { text-align: center; margin-bottom: 1.5rem; color: #333; }

.progress {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 1rem;
  text-align: right;
}
.question-text {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: #222;
}
.question-category {
  font-size: 0.8rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}
.options { list-style: none; }
.options li { margin-bottom: 0.5rem; }
.options label {
  display: block;
  padding: 0.75rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.options label:hover { border-color: #4a90d9; background: #f0f6ff; }
.options input[type="radio"]:checked + label, .options input[type="checkbox"]:checked + label { border-color: #4a90d9; background: #e8f0fe; }
.options input[type="radio"] { display: none; }
.options.checkboxes input[type="checkbox"] { display: none; }
textarea {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  resize: vertical;
  min-height: 100px;
}
textarea:focus { outline: none; border-color: #4a90d9; }
.slider-wrap {
  padding: 1rem 0;
  text-align: center;
}
.slider-wrap input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #d0d8e0;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #4a90d9;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
}
.slider-wrap input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #4a90d9;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
}
.slider-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #333;
  margin-top: 0.75rem;
}
.textbox-wrap {
  text-align: center;
  padding: 1rem 0;
}
.textbox-wrap input[type="number"] {
  width: 300px;
  max-width: 100%;
  padding: 0.6rem 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  color: #333;
  -moz-appearance: textfield;
}
.textbox-wrap input[type="number"]::-webkit-outer-spin-button,
.textbox-wrap input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.textbox-wrap input[type="number"]:focus {
  outline: none;
  border-color: #4a90d9;
}
.textbox-unit {
  font-size: 1.1rem;
  font-weight: 600;
  color: #666;
  margin-left: 0.5rem;
}
.nav {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5rem;
}
button {
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  background: #4a90d9;
  color: #fff;
  transition: opacity 0.2s;
}
button:disabled { opacity: 0.4; cursor: default; }
button:hover:not(:disabled) { opacity: 0.85; }
.error { color: #d32f2f; font-size: 0.9rem; margin-top: 0.5rem; }
.btn-secondary {
  padding: 0.5rem 1.25rem;
  border: 2px solid #4a90d9;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  background: #fff;
  color: #4a90d9;
  transition: opacity 0.2s;
}
.btn-secondary:hover { opacity: 0.75; }

.rank-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}
.rank-list li {
  display: flex;
  align-items: center;
  padding: 0.7rem 0.75rem;
  margin-bottom: 0.4rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  cursor: grab;
  transition: border-color 0.2s, background 0.2s;
  user-select: none;
  user-select: none;
}
.rank-list li:active { cursor: grabbing; }
.rank-list li:hover { border-color: #4a90d9; background: #f0f6ff; }
.rank-handle {
  margin-right: 0.75rem;
  font-size: 1.2rem;
  color: #999;
  cursor: grab;
}
.rank-label { font-size: 1rem; color: #333; flex: 1; }
.rank-del {
  font-size: 1.2rem;
  color: #c62828;
  cursor: pointer;
  padding: 0 0.25rem;
  opacity: 0.6;
  line-height: 1;
}
.rank-del:hover { opacity: 1; }
.rank-add {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.rank-add input[type="text"] {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.95rem;
}
.rank-add input[type="text"]:focus { outline: none; border-color: #4a90d9; }
.rank-add-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  background: #4a90d9;
  color: #fff;
  white-space: nowrap;
}
.rank-add-btn:hover { opacity: 0.85; }
.rank-wrapper { margin: 1rem 0; }

.grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  flex: 1;
  align-content: stretch;
}
.grid-cell {
  border-radius: 12px;
  padding: 1.25rem;
  color: #fff;
  display: flex;
  flex-direction: column;
}
.grid-cell > h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  opacity: 0.9;
  text-align: center;
}
.grid-cell .cat-score {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.5rem;
}
.trend {
  font-size: 0.7rem;
  margin-left: 0.15rem;
  opacity: 0.75;
  line-height: 1;
}
.grid-cell .threshold-label {
  font-size: 0.7rem;
  text-align: center;
  opacity: 0.8;
  margin-bottom: 0.5rem;
}
.sub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  flex: 1;
}
.sub-cell {
  border-radius: 8px;
  padding: 0.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.15);
  cursor: pointer;
}
.sub-cell .stat-label {
  font-size: 0.6rem;
  opacity: 0.85;
  margin-bottom: 0.15rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.sub-cell .stat-score {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}
.sub-cell .stat-unit {
  font-size: 0.6rem;
  opacity: 0.8;
  line-height: 1.2;
  margin-top: 0.1rem;
}
.sub-cell .stat-unit-inline {
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.85;
}
.sub-cell .stat-top3 {
  font-size: 0.7rem;
  line-height: 1.4;
  text-align: center;
}

.legend {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin: 1rem 0;
  font-size: 0.85rem;
}
.legend-item { display: flex; align-items: center; gap: 0.4rem; }
.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.legend-dot.green { background: #2e7d32; }
.legend-dot.yellow { background: #f9a825; }
.legend-dot.red { background: #c62828; }

.action-bar { text-align: center; margin-top: 1.5rem; display: flex; gap: 0.75rem; justify-content: center; }
.btn-danger {
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  background: #c62828;
  color: #fff;
  transition: opacity 0.2s;
}
.btn-danger:hover { opacity: 0.85; }

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.active { display: flex; }
.modal-content {
  background: #1e1e2e;
  border-radius: 12px;
  padding: 1.5rem;
  width: 90vw;
  max-width: 600px;
  position: relative;
}
.modal-content h3 { color: #fff; text-align: center; margin-bottom: 0.75rem; font-size: 1rem; }
.modal-content canvas { display: block; margin: 0 auto; }
.modal-close {
  position: absolute;
  top: 0.5rem; right: 1rem;
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
}
.modal-close:hover { color: #fff; }
.chart-btns {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
}
.edit-answer-btn {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  background: #4a90d9;
  color: #fff;
  transition: opacity 0.2s;
}
.edit-answer-btn:hover { opacity: 0.85; }