:root {
  --yellow: #f6bd60;
  --cream: #f9eadb;
  --pink: #f5cac3;
  --teal: #84a59d;
  --teal-dark: #466a62;
  --coral: #f28482;
  --ink: #18212d;
  --muted: #3f4654;
  --line: #d9c9c1;
  --panel: #ffffff;
  --page: #fffaf6;
  --blue: #3b82f6;
  --shadow: 0 18px 45px rgba(52, 64, 84, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  background:
    linear-gradient(180deg, rgba(132, 165, 157, 0.08) 0, transparent 330px),
    var(--page);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: inherit;
}

.app-shell,
.admin-shell {
  min-height: 100vh;
  padding-bottom: 48px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(230, 217, 211, 0.82);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 430px);
  gap: 24px;
  align-items: center;
}

.brand {
  min-width: 0;
}

.brand-title {
  margin: 0;
  color: var(--teal-dark);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-subtitle {
  margin: 2px 0 0;
  color: #384252;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-wrap {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--cream);
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--yellow), var(--coral), var(--teal));
  transition: width 280ms ease;
}

.container {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 28px 20px 0;
}

.narrow {
  width: min(100%, 860px);
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(230, 217, 211, 0.88);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section {
  padding: 28px;
}

.section + .section {
  margin-top: 20px;
}

.fade-in {
  animation: fadeInUp 320ms ease both;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero {
  text-align: center;
}

.status-icon,
.small-icon {
  display: inline-grid;
  place-items: center;
  color: var(--teal-dark);
  background: rgba(132, 165, 157, 0.14);
  border: 1px solid rgba(132, 165, 157, 0.25);
}

.status-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin-bottom: 14px;
}

.small-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.2;
}

h2 {
  margin: 0 0 18px;
  font-size: clamp(22px, 3vw, 28px);
  line-height: 1.25;
}

h3 {
  margin: 0 0 14px;
  font-size: 18px;
  line-height: 1.35;
}

.lead {
  margin: 0 auto;
  max-width: 720px;
  color: #384252;
  font-weight: 520;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.info-block {
  padding: 16px;
  border: 1px solid rgba(245, 202, 195, 0.68);
  border-radius: var(--radius);
  background: rgba(247, 237, 226, 0.45);
  color: #2e3745;
}

.info-block strong {
  display: block;
  margin-bottom: 4px;
}

.consent-list,
.question-stack {
  display: grid;
  gap: 12px;
}

.check-row,
.radio-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 13px 14px;
  border: 1px solid rgba(230, 217, 211, 0.9);
  border-radius: var(--radius);
  background: #fff;
  transition: border-color 180ms ease, background 180ms ease;
}

.check-row:hover,
.radio-row:hover {
  border-color: rgba(132, 165, 157, 0.62);
  background: rgba(132, 165, 157, 0.05);
}

.check-row input,
.radio-row input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: var(--teal);
  flex: 0 0 auto;
}

.field-group {
  margin-bottom: 26px;
}

.field-label {
  display: block;
  margin-bottom: 10px;
  color: var(--ink);
  font-weight: 800;
}

.hint {
  color: #3f4654;
  font-size: 13px;
  font-weight: 650;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.option-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.choice-button,
.chip-button {
  min-height: 42px;
  border: 1px solid #cfbcb4;
  border-radius: var(--radius);
  background: #fff;
  color: #202a36;
  font-weight: 800;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.choice-button {
  padding: 9px 12px;
}

.chip-button {
  padding: 9px 14px;
}

.choice-button:hover,
.chip-button:hover {
  border-color: var(--teal);
}

.choice-button.selected,
.chip-button.selected {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
}

.likert-box {
  padding: 16px;
  border: 1px solid rgba(216, 183, 175, 0.72);
  border-radius: var(--radius);
  background: rgba(249, 234, 219, 0.42);
}

.likert-question {
  margin: 0 0 12px;
  color: #18212d;
  font-weight: 760;
}

.likert-scale {
  display: grid;
  grid-template-columns: 92px 1fr 92px;
  gap: 12px;
  align-items: center;
}

.scale-label {
  color: #18212d;
  font-size: 15px;
  font-weight: 900;
}

.scale-label.left {
  text-align: right;
}

.scale-label.right {
  text-align: left;
}

.scale-buttons {
  display: grid;
  grid-template-columns: repeat(5, minmax(38px, 1fr));
  gap: 8px;
}

.score-button {
  min-height: 42px;
  border: 1px solid #d1beb7;
  border-radius: var(--radius);
  background: #fff;
  color: #2f3948;
  font-weight: 900;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.score-button:hover {
  color: var(--coral);
  border-color: var(--coral);
}

.score-button.selected {
  color: #fff;
  border-color: var(--coral);
  background: var(--coral);
  transform: translateY(-1px);
}

.task-head {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
}

.task-tag {
  width: max-content;
  max-width: 100%;
  padding: 5px 10px;
  border-radius: 999px;
  color: #8a560c;
  background: rgba(246, 189, 96, 0.24);
  font-size: 13px;
  font-weight: 900;
}

.scenario {
  border-left: 4px solid var(--teal);
  border-radius: var(--radius);
  padding: 16px;
  background: rgba(247, 237, 226, 0.58);
}

.scenario p {
  margin: 6px 0;
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.model-block {
  overflow: hidden;
  border: 1px solid rgba(230, 217, 211, 0.9);
  border-radius: var(--radius);
  background: #fff;
}

.model-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 10px 14px;
  color: #fff;
  font-weight: 900;
}

.model-title.a {
  background: var(--teal);
}

.model-title.b {
  background: var(--coral);
}

.model-title span:last-child {
  font-size: 12px;
  opacity: 0.92;
}

.image-frame {
  padding: 12px;
  border-bottom: 1px solid rgba(230, 217, 211, 0.72);
  background: #fdfdfd;
}

.survey-image {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid rgba(230, 217, 211, 0.72);
  border-radius: 6px;
  background: #fff;
}

.zoomable-image {
  cursor: zoom-in;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
}

.image-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 33, 45, 0.72);
}

.image-modal-content {
  position: relative;
  z-index: 1;
  max-width: min(96vw, 1280px);
  max-height: 92vh;
  padding: 12px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.image-modal-content img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 24px);
  object-fit: contain;
}

.image-modal-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--coral);
  font-size: 26px;
  line-height: 1;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

.rating-stack {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.choice-panel {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(245, 202, 195, 0.85);
  border-radius: var(--radius);
  background: rgba(247, 237, 226, 0.56);
}

.choice-panel h3 {
  text-align: center;
}

.choice-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 220px));
  gap: 12px;
  justify-content: center;
}

.big-choice {
  min-height: 54px;
  border: 2px solid rgba(132, 165, 157, 0.38);
  border-radius: var(--radius);
  background: #fff;
  color: var(--teal-dark);
  font-size: 17px;
  font-weight: 900;
}

.big-choice.b {
  color: #c95250;
  border-color: rgba(242, 132, 130, 0.36);
}

.big-choice.selected {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

.big-choice.b.selected {
  background: var(--coral);
  border-color: var(--coral);
}

.compare-wrap {
  margin-top: 16px;
}

.compare-wrap summary {
  width: max-content;
  max-width: 100%;
  color: var(--teal-dark);
  font-weight: 850;
  cursor: pointer;
}

.compare-wrap .survey-image {
  margin-top: 12px;
}

.text-area {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  padding: 12px 13px;
  border: 1px solid rgba(230, 217, 211, 0.95);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.text-area:focus,
.choice-button:focus-visible,
.chip-button:focus-visible,
.score-button:focus-visible,
.btn:focus-visible,
.big-choice:focus-visible {
  outline: 3px solid rgba(132, 165, 157, 0.32);
  outline-offset: 2px;
}

.nav-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 26px;
}

.nav-row .btn:last-child {
  margin-left: auto;
}

.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 900;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.btn.primary {
  color: #fff;
  background: var(--teal);
  box-shadow: 0 12px 26px rgba(132, 165, 157, 0.22);
}

.btn.primary:hover {
  background: var(--teal-dark);
}

.btn.secondary {
  color: var(--ink);
  background: var(--pink);
}

.btn.ghost {
  color: var(--teal-dark);
  border-color: rgba(132, 165, 157, 0.42);
  background: #fff;
}

.btn.danger {
  color: #fff;
  background: var(--coral);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.48;
  box-shadow: none;
}

.alert {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(242, 132, 130, 0.42);
  background: rgba(245, 202, 195, 0.22);
  color: #8f3432;
  font-weight: 750;
}

.success-note {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(132, 165, 157, 0.35);
  background: rgba(132, 165, 157, 0.11);
  color: var(--teal-dark);
  font-weight: 750;
}

.result-grid,
.admin-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.metric {
  min-height: 116px;
  display: grid;
  gap: 6px;
  justify-items: center;
  align-content: center;
  padding: 18px;
  border: 1px solid rgba(230, 217, 211, 0.86);
  border-radius: var(--radius);
  background: #fff;
  text-align: center;
}

.metric-value {
  color: var(--ink);
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1;
  font-weight: 950;
}

.metric-value.model-name {
  max-width: 100%;
  font-size: clamp(20px, 2.6vw, 28px);
  line-height: 1.25;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.chart-panel {
  margin-top: 18px;
  padding: 20px;
  border: 1px solid rgba(230, 217, 211, 0.86);
  border-radius: var(--radius);
  background: #fff;
}

.chart-title {
  margin: 0 0 14px;
  text-align: center;
  font-weight: 900;
}

.radar {
  width: 100%;
  min-height: 340px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: middle;
}

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 0 6px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid rgba(132, 165, 157, 0.35);
  border-radius: 999px;
  color: var(--teal-dark);
  background: rgba(132, 165, 157, 0.1);
  font-size: 12px;
  font-weight: 900;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
}

.status-dot.offline {
  background: var(--coral);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(230, 217, 211, 0.78);
  text-align: left;
  vertical-align: top;
}

th {
  color: #253142;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: rgba(247, 237, 226, 0.48);
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  gap: 6px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #2f3948;
  font-size: 13px;
  font-weight: 780;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(247, 237, 226, 0.85);
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: var(--teal);
}

.bar-fill.coral {
  background: var(--coral);
}

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

.analysis-list li {
  padding: 12px 14px;
  border: 1px solid rgba(230, 217, 211, 0.72);
  border-radius: var(--radius);
  background: #fff;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .topbar-inner,
  .dashboard-grid,
  .model-grid {
    grid-template-columns: 1fr;
  }

  .brand-subtitle {
    white-space: normal;
  }

  .info-grid,
  .result-grid,
  .admin-metric-grid {
    grid-template-columns: 1fr;
  }

  .admin-header {
    display: grid;
  }

  .admin-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .container {
    padding-inline: 14px;
  }

  .topbar-inner {
    padding-inline: 14px;
  }

  .section {
    padding: 20px 16px;
  }

  .option-grid,
  .option-grid.two,
  .choice-actions {
    grid-template-columns: 1fr;
  }

  .likert-scale {
    grid-template-columns: 1fr;
  }

  .scale-label.left,
  .scale-label.right {
    text-align: left;
  }

  .scale-label.right {
    margin-top: -6px;
  }

  .nav-row {
    display: grid;
  }

  .nav-row .btn:last-child {
    margin-left: 0;
  }

  .radar {
    min-height: 300px;
  }
}
