:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e6e8ec;
  --border-strong: #d6d9df;
  --text: #1f2430;
  --text-2: #5b6472;
  --text-3: #949cab;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --success: #0f9d76;
  --success-soft: #e7f7f1;
  --warning: #c9851a;
  --warning-soft: #fdf4e3;
  --danger: #dc4c4c;
  --danger-soft: #fdecec;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 12px rgba(16, 24, 40, .05);
  --shadow-lg: 0 8px 30px rgba(16, 24, 40, .10);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.55; font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font-family: inherit; font-size: inherit; }
a { color: var(--primary); text-decoration: none; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 232px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 22px 20px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.brand-mark { width: 30px; height: 30px; background: var(--primary); border-radius: 9px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 15px; }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--text-3); margin-top: -2px; }
.nav { padding: 14px 12px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text-2); cursor: pointer; margin-bottom: 4px; font-weight: 500; transition: background .15s, color .15s; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item .ico { width: 18px; height: 18px; flex: none; }
.sidebar-foot { padding: 16px 20px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-3); }

.main { flex: 1; min-width: 0; }
.topbar { height: 64px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 30px; position: sticky; top: 0; z-index: 10; }
.topbar h1 { font-size: 17px; font-weight: 600; }
.topbar .sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.content { padding: 28px 30px 60px; max-width: 1180px; }

/* ---------- 通用组件 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 500; transition: all .15s; white-space: nowrap; }
.btn:hover { border-color: var(--text-3); background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-lg { padding: 11px 20px; }
.icon-btn { width: 32px; height: 32px; padding: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-draft { background: var(--surface-2); color: var(--text-2); }
.badge-published { background: var(--success-soft); color: var(--success); }
.badge-closed { background: var(--warning-soft); color: var(--warning); }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.section-head h2 { font-size: 15px; font-weight: 600; }
.muted { color: var(--text-2); }
.tiny { font-size: 12px; color: var(--text-3); }
.empty { text-align: center; padding: 70px 20px; color: var(--text-3); }
.empty .big { font-size: 34px; margin-bottom: 12px; opacity: .5; }

/* ---------- 问卷列表 ---------- */
.survey-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.survey-card { padding: 20px; display: flex; flex-direction: column; gap: 14px; transition: transform .15s, box-shadow .15s; }
.survey-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.survey-card .row1 { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.survey-card h3 { font-size: 15px; font-weight: 600; line-height: 1.35; }
.survey-card .desc { font-size: 12px; color: var(--text-2); min-height: 18px; }
.survey-card .meta { display: flex; gap: 16px; font-size: 12px; color: var(--text-3); }
.survey-card .meta b { color: var(--text); font-weight: 600; }
.survey-card .actions { display: flex; flex-wrap: wrap; gap: 7px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ---------- 设计器 ---------- */
.designer { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.design-main { min-width: 0; }
.design-side { position: sticky; top: 84px; }
.panel { padding: 20px; }
.panel h3 { font-size: 13px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.input, .textarea, .select { width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.textarea { resize: vertical; min-height: 64px; }

.q-list { display: flex; flex-direction: column; gap: 12px; }
.q-card { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.q-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.q-card-head { display: flex; align-items: center; gap: 10px; }
.q-num { width: 24px; height: 24px; border-radius: 7px; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex: none; }
.q-type-tag { font-size: 11px; color: var(--text-3); background: var(--surface-2); padding: 2px 8px; border-radius: 5px; border: 1px solid var(--border); }
.spacer { flex: 1; }
.q-card-body { margin: 12px 0 0 34px; }
.q-card-body .input { font-weight: 500; }
.opt-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.opt-row .input { flex: 1; }
.toolbox { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tool-btn { padding: 10px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 7px; transition: all .15s; }
.tool-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.tool-btn .ico { width: 15px; height: 15px; }

/* ---------- 统计 ---------- */
.stat-top { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-box { padding: 18px 20px; }
.stat-box .label { font-size: 12px; color: var(--text-2); }
.stat-box .value { font-size: 28px; font-weight: 600; margin-top: 4px; }
.stat-q { padding: 20px; margin-bottom: 16px; }
.stat-q h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.stat-q .qmeta { font-size: 11px; color: var(--text-3); margin-bottom: 16px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 46px; align-items: center; gap: 12px; margin-bottom: 10px; }
.bar-label { font-size: 12px; color: var(--text-2); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 22px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 5px; transition: width .4s ease; min-width: 2px; }
.bar-val { font-size: 12px; color: var(--text); font-weight: 500; text-align: right; }
.text-answers { margin-top: 8px; }
.text-answers .ta { padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; margin-bottom: 7px; color: var(--text-2); }

/* ---------- 答卷端 ---------- */
.survey-page { min-height: 100vh; background: var(--bg); }
.survey-hero { background: var(--surface); border-bottom: 1px solid var(--border); padding: 40px 20px 34px; text-align: center; }
.survey-hero .wrap { max-width: 640px; margin: 0 auto; }
.survey-hero h1 { font-size: 24px; font-weight: 600; letter-spacing: -.2px; }
.survey-hero p { color: var(--text-2); margin-top: 10px; font-size: 14px; }
.survey-hero .vtag { display: inline-block; font-size: 11px; color: var(--text-3); margin-top: 14px; }
.answer-wrap { max-width: 640px; margin: 0 auto; padding: 26px 20px 80px; }
.answer-card { padding: 22px 24px; margin-bottom: 16px; }
.q-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.q-title .req { color: var(--danger); margin-left: 3px; }
.q-desc { font-size: 12px; color: var(--text-3); margin-bottom: 16px; }
.choice { display: block; padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 9px; cursor: pointer; display: flex; align-items: center; gap: 11px; transition: all .15s; }
.choice:hover { border-color: var(--border-strong); background: var(--surface-2); }
.choice.checked { border-color: var(--primary); background: var(--primary-soft); }
.choice input { width: 16px; height: 16px; accent-color: var(--primary); }
.choice .txt { flex: 1; }
.rating-row { display: flex; gap: 8px; flex-wrap: wrap; }
.rating-dot { width: 42px; height: 42px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; display: flex; align-items: center; justify-content: center; font-weight: 600; color: var(--text-2); transition: all .15s; }
.rating-dot:hover { border-color: var(--primary); }
.rating-dot.checked { background: var(--primary); border-color: var(--primary); color: #fff; }
.submit-bar { text-align: center; padding: 12px 0 30px; }
.err-banner { background: var(--danger-soft); color: var(--danger); padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; }
.done { max-width: 520px; margin: 90px auto; text-align: center; padding: 40px; }
.done .check { width: 60px; height: 60px; border-radius: 50%; background: var(--success-soft); color: var(--success); font-size: 30px; display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; }
.done h2 { font-size: 20px; margin-bottom: 8px; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(16,24,40,.4); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--radius-lg, 14px); box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; padding: 24px; }
.modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.modal p { color: var(--text-2); font-size: 13px; margin-bottom: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 11px 18px; border-radius: 9px; font-size: 13px; z-index: 200; box-shadow: var(--shadow-lg); animation: toastIn .2s ease; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.hidden { display: none !important; }
