/* ============================================================
   问卷系统 · 设计系统
   ============================================================ */
:root {
  --canvas: #f6f6f3;
  --canvas-2: #efefea;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --ink: #14161b;
  --ink-2: #3d424d;
  --muted: #6b7280;
  --subtle: #9aa1ab;
  --line: #e5e4de;
  --line-strong: #d6d5cd;
  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-soft: #eef0ff;
  --brand-ink: #312e81;
  --on-brand: #ffffff;
  --amber: #d97706;
  --amber-soft: #fef6e7;
  --green: #0f766e;
  --green-soft: #ecfdf5;
  --red: #b91c1c;
  --red-soft: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(20, 22, 27, 0.05);
  --shadow: 0 2px 4px rgba(20, 22, 27, 0.04), 0 12px 28px -12px rgba(20, 22, 27, 0.18);
  --shadow-lg: 0 4px 10px rgba(20, 22, 27, 0.05), 0 28px 60px -24px rgba(20, 22, 27, 0.28);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0f1115;
    --canvas-2: #14171d;
    --surface: #191d24;
    --surface-2: #1f242c;
    --ink: #f2f3f5;
    --ink-2: #d4d7dd;
    --muted: #9aa3af;
    --subtle: #6f7885;
    --line: #2a303a;
    --line-strong: #3a424e;
    --brand: #818cf8;
    --brand-hover: #a5b4fc;
    --brand-soft: #232544;
    --brand-ink: #c7d2fe;
    /* 深色下 brand 偏亮，按钮文字改用深色才够对比度 */
    --on-brand: #131522;
    --amber: #fbbf24;
    --amber-soft: #2a2317;
    --green: #34d399;
    --green-soft: #12291f;
    --red: #f87171;
    --red-soft: #2a1717;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 2px 6px rgba(0, 0, 0, 0.35), 0 16px 32px -16px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.45), 0 32px 64px -24px rgba(0, 0, 0, 0.8);
  }
}

* {
  box-sizing: border-box;
}

/* hidden 属性优先级要压过组件自身的 display 规则（.gate/.console 都用 flex/grid） */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.28;
  color: var(--ink);
}

p {
  margin: 0;
}

a {
  color: var(--brand);
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--brand);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- 布局 ---------- */
.shell {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

.shell--narrow {
  max-width: 720px;
}

.nav {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  background: color-mix(in srgb, var(--canvas) 78%, transparent);
  border-bottom: 1px solid var(--line);
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 62px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 680;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-size: 15.5px;
}

.brand__mark {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--brand), #7c3aed 55%, #0ea5e9);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 15px;
  box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--brand) 70%, transparent);
  flex: none;
}

.nav__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- 按钮 ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-line: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--btn-line);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 14px;
  font-weight: 560;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    color 0.16s ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

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

.btn--primary {
  --btn-bg: var(--brand);
  --btn-fg: var(--on-brand);
  --btn-line: transparent;
  box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--brand) 80%, transparent);
}

.btn--primary:hover {
  --btn-bg: var(--brand-hover);
  --btn-fg: var(--on-brand);
  background: var(--brand-hover);
}

.btn--ghost {
  --btn-bg: transparent;
  --btn-line: transparent;
  color: var(--muted);
}

.btn--ghost:hover {
  background: var(--canvas-2);
  color: var(--ink);
  border-color: transparent;
}

.btn--danger {
  --btn-fg: var(--red);
  --btn-line: color-mix(in srgb, var(--red) 30%, transparent);
  --btn-bg: transparent;
}

.btn--danger:hover {
  background: var(--red-soft);
  border-color: color-mix(in srgb, var(--red) 45%, transparent);
}

.btn--sm {
  height: 32px;
  padding: 0 11px;
  font-size: 13px;
  border-radius: 8px;
}

.btn--lg {
  height: 48px;
  padding: 0 24px;
  font-size: 15.5px;
  border-radius: 12px;
}

.btn--block {
  width: 100%;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card--pad {
  padding: 22px;
}

.card--hover:hover {
  box-shadow: var(--shadow);
  border-color: var(--line-strong);
}

/* ---------- 表单 ---------- */
.field {
  display: block;
}

.field + .field {
  margin-top: 14px;
}

.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.hint {
  font-size: 12.5px;
  color: var(--subtle);
  margin-top: 6px;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14.5px;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
  outline: none;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--subtle);
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.textarea {
  resize: vertical;
  min-height: 84px;
  line-height: 1.6;
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) calc(50% + 1px),
    calc(100% - 12px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

/* 自定义勾选 / 单选 */
.opt {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  cursor: pointer;
  transition:
    border-color 0.14s ease,
    background 0.14s ease,
    box-shadow 0.14s ease;
  user-select: none;
}

.opt:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.opt input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.opt__dot {
  flex: none;
  width: 19px;
  height: 19px;
  margin-top: 2px;
  border: 1.6px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  display: grid;
  place-items: center;
  transition: all 0.15s ease;
}

.opt__dot::after {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--on-brand);
  transform: scale(0);
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.opt--multi .opt__dot {
  border-radius: 6px;
}

.opt--multi .opt__dot::after {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--on-brand);
  clip-path: polygon(14% 44%, 0 65%, 40% 100%, 100% 16%, 83% 0%, 39% 66%);
  transform: scale(0);
}

.opt input:checked + .opt__dot {
  border-color: var(--brand);
  background: var(--brand);
}

.opt input:checked + .opt__dot::after {
  transform: scale(1);
}

.opt:has(input:checked) {
  border-color: color-mix(in srgb, var(--brand) 55%, transparent);
  background: color-mix(in srgb, var(--brand-soft) 60%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 10%, transparent);
}

.opt__text {
  font-size: 14.5px;
  color: var(--ink);
  line-height: 1.5;
}

/* 自定义复选框（深色下原生样式辨识度差） */
input[type='checkbox'] {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  border-radius: 5px;
  border: 1.6px solid var(--line-strong);
  background: var(--surface);
  position: relative;
  cursor: pointer;
  flex: none;
  margin: 0;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

input[type='checkbox']:hover {
  border-color: var(--brand);
}

input[type='checkbox']:checked {
  background: var(--brand);
  border-color: var(--brand);
}

input[type='checkbox']:checked::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 8px;
  border: solid var(--on-brand);
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -58%) rotate(42deg);
}

input[type='checkbox']:focus-visible {
  outline: 2px solid var(--ring, var(--brand));
  outline-offset: 2px;
}

.opt-grid {
  display: grid;
  gap: 10px;
}

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

@media (max-width: 560px) {
  .opt-grid--2 {
    grid-template-columns: 1fr;
  }
}

/* 评分 */
.stars {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.star {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.14s ease;
}

.star:hover {
  border-color: var(--brand);
  color: var(--brand);
  transform: translateY(-1px);
}

.star[aria-checked='true'] {
  background: var(--amber-soft);
  border-color: color-mix(in srgb, var(--amber) 55%, transparent);
  color: var(--amber);
}

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

.scale .star {
  width: 100%;
  height: 40px;
  border-radius: 9px;
  font-size: 13.5px;
}

/* ---------- 标签 / 徽标 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: var(--canvas-2);
  color: var(--muted);
  border: 1px solid transparent;
}

.badge--brand {
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.badge--green {
  background: var(--green-soft);
  color: var(--green);
}
.badge--amber {
  background: var(--amber-soft);
  color: var(--amber);
}
.badge--red {
  background: var(--red-soft);
  color: var(--red);
}

/* ---------- 数据可视化 ---------- */
.bars {
  display: grid;
  gap: 12px;
}

.bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: baseline;
}

.bar__label {
  font-size: 14px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar__val {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.bar__track {
  grid-column: 1 / -1;
  height: 9px;
  border-radius: 99px;
  background: var(--canvas-2);
  overflow: hidden;
}

.bar__fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--brand), #7c3aed);
  transition: width 0.7s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 2px;
}

.bar--lead .bar__fill {
  background: linear-gradient(90deg, var(--brand), #0ea5e9);
}

.bar--lead .bar__label {
  color: var(--ink);
  font-weight: 600;
}

.cols {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 132px;
  padding-top: 8px;
}

.col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  height: 100%;
  position: relative;
}

.col__track {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: flex-end;
  border-radius: 7px 7px 3px 3px;
  background: var(--canvas-2);
  overflow: hidden;
}

.col__fill {
  width: 100%;
  background: linear-gradient(180deg, #7c3aed, var(--brand));
  border-radius: 7px 7px 3px 3px;
  transition: height 0.7s cubic-bezier(0.16, 1, 0.3, 1);
  min-height: 3px;
}

.col__label {
  font-size: 11.5px;
  color: var(--subtle);
  font-variant-numeric: tabular-nums;
}

.col__count {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* 统计摘要 */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.stat {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
}

.stat__k {
  font-size: 12px;
  color: var(--muted);
}

.stat__v {
  font-size: 24px;
  font-weight: 680;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  color: var(--ink);
}

/* ---------- 杂项 ---------- */
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row--between {
  justify-content: space-between;
}

.row--wrap {
  flex-wrap: wrap;
}

.stack {
  display: grid;
  gap: 16px;
}

.muted {
  color: var(--muted);
}
.subtle {
  color: var(--subtle);
}
.small {
  font-size: 13px;
}
.mono {
  font-family: var(--mono);
  font-size: 12.5px;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 20px 0;
}

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

.empty__icon {
  font-size: 28px;
  opacity: 0.55;
  margin-bottom: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  z-index: 200;
  background: var(--ink);
  color: var(--canvas);
  padding: 11px 18px;
  border-radius: 11px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: min(90vw, 460px);
}

.toast[data-show='1'] {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast[data-kind='error'] {
  background: var(--red);
  color: #fff;
}

/* 弹层 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 17, 21, 0.45);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.modal[data-open='1'] {
  opacity: 1;
  pointer-events: auto;
}

.modal__panel {
  width: min(520px, 100%);
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  padding: 26px;
  transform: translateY(10px) scale(0.98);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal[data-open='1'] .modal__panel {
  transform: none;
}

/* 页脚 */
.foot {
  border-top: 1px solid var(--line);
  margin-top: 64px;
  padding: 26px 0 40px;
  color: var(--subtle);
  font-size: 13px;
}

.foot__inner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
