:root {
    --survey-ink: #27232a;
    --survey-muted: #68616b;
    --survey-line: #eae2e6;
    --survey-accent: #a51c42;
    --survey-accent-hover: #881437;
    --survey-paper: #fff;
    --survey-bg: #f8f5f6;
    font-family: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
    line-height: 1.55;
}
.survey-admin, .survey-public { margin: 0; color: var(--survey-ink); background: var(--survey-bg); }
.survey-admin *, .survey-public * { box-sizing: border-box; }
.survey-admin [hidden], .survey-public [hidden] { display: none !important; }
.survey-admin h1, .survey-admin h2, .survey-admin h3, .survey-public h1, .survey-public h2 { margin: 0; line-height: 1.3; }
.survey-admin h1 { font-size: 27px; }
.survey-admin h2, .survey-public h2 { font-size: 20px; overflow-wrap: anywhere; }
.survey-admin h3 { font-size: 18px; }
.survey-admin small, .survey-public small { color: var(--survey-muted); font-size: .83em; }
.survey-admin button, .survey-button, .survey-public button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 39px;
    padding: 7px 13px;
    border: 1px solid #d6cbd1;
    border-radius: 8px;
    background: var(--survey-paper);
    color: var(--survey-ink);
    font: inherit;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
}
.survey-admin button:hover:not(:disabled), .survey-button:hover { border-color: var(--survey-accent); color: var(--survey-accent); }
.survey-admin .survey-primary, .survey-public .survey-primary {
    color: #fff;
    border-color: var(--survey-accent);
    background: var(--survey-accent);
    font-weight: 650;
}
.survey-admin .survey-primary:hover:not(:disabled), .survey-public .survey-primary:hover:not(:disabled) {
    color: #fff;
    background: var(--survey-accent-hover);
    border-color: var(--survey-accent-hover);
}
.survey-admin button:disabled, .survey-public button:disabled { opacity: .55; cursor: default; }
.survey-admin :focus-visible, .survey-public :focus-visible { outline: 2px solid var(--survey-accent); outline-offset: 3px; }
.survey-admin :is(input, textarea, select), .survey-public :is(input, textarea) {
    padding: 9px 11px;
    max-width: 100%;
    border: 1px solid #d6cbd1;
    border-radius: 8px;
    color: var(--survey-ink);
    background: var(--survey-paper);
    font: inherit;
}
.survey-admin textarea, .survey-public textarea { resize: vertical; }
.survey-admin input[type="checkbox"], .survey-public :is(input[type="radio"],input[type="checkbox"]) {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--survey-accent);
    flex: none;
}
.survey-workspace { max-width: 1190px; margin: auto; padding: 24px clamp(14px, 4vw, 40px) 48px; }
.survey-toolbar, .survey-row, .survey-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}
.survey-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.survey-card { background: var(--survey-paper); border: 1px solid var(--survey-line); border-radius: 16px; }
#survey-list { margin-top: 16px; }
#survey-list:empty { display: none; }
.survey-row { padding: 16px 19px; }
.survey-row + .survey-row { border-top: 1px solid var(--survey-line); }
.survey-row-info { min-width: 0; }
.survey-row-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.survey-row-info p { margin: 5px 0 0; font-size: 13px; color: var(--survey-muted); }
.survey-state { display: inline-flex; font-size: 12px; padding: 2px 7px; border-radius: 6px; background: #f0ecf0; }
.survey-state-open { background: #edf5ee; color: #255530; }
.survey-pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; }
.survey-message { margin: 14px 0 0; color: var(--survey-muted); }
.survey-error { color: #91203d; }
.survey-admin dialog {
    width: min(690px, calc(100vw - 24px));
    max-height: min(88vh, 900px);
    padding: 0;
    border: 1px solid var(--survey-line);
    border-radius: 15px;
    color: var(--survey-ink);
    background: var(--survey-paper);
    box-shadow: 0 18px 75px #29132436;
}
.survey-admin dialog::backdrop { background: rgb(35 23 33 / .48); }
.survey-dialog-header, .survey-dialog-footer { padding: 14px clamp(13px, 4vw, 25px); background: var(--survey-paper); }
.survey-dialog-header { position: sticky; top: 0; border-bottom: 1px solid var(--survey-line); z-index: 1; }
.survey-dialog-header button { font-size: 21px; line-height: 1; }
.survey-dialog-body { padding: 17px clamp(13px, 4vw, 25px); }
.survey-dialog-footer { display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--survey-line); }
.survey-label { display: block; margin-bottom: 14px; font-weight: 600; }
.survey-label :is(input,textarea) { display: block; width: 100%; margin-top: 6px; font-weight: 400; }
.survey-builder-bar { margin: 21px 0 10px; flex-wrap: wrap; }
.survey-builder-field { margin: 0 0 12px; padding: 12px; min-width: 0; border: 1px solid var(--survey-line); border-radius: 10px; }
.survey-builder-field legend { padding: 0 5px; color: var(--survey-accent); }
.survey-checkbox { display: inline-flex; gap: 6px; align-items: center; padding: 4px 8px 4px 0; }
.survey-share-body img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.survey-share-body > p:not(.survey-message) { text-align: center; margin: 0 0 13px; overflow-wrap: anywhere; }
.survey-answer-values dt { font-weight: 650; }
.survey-answer-values dd { margin: 3px 0 12px; padding-bottom: 9px; border-bottom: 1px solid var(--survey-line); }
.survey-answer-values a { color: var(--survey-accent); }
.survey-masthead { background: var(--survey-paper); border-top: 3px solid var(--survey-accent); border-bottom: 1px solid var(--survey-line); }
.survey-masthead div { max-width: 760px; margin: auto; padding: 12px 18px; color: var(--survey-accent); font-weight: 800; }
.survey-fill { max-width: 760px; margin: auto; padding: 22px clamp(14px, 4vw, 28px) 40px; }
.survey-cover { padding: 24px clamp(16px, 4vw, 32px); margin-bottom: 15px; border-radius: 16px; background: #f3e8ec; border: 1px solid #eedfe7; }
.survey-cover h1 { font-size: clamp(24px, 4.5vw, 35px); overflow-wrap: anywhere; }
.survey-cover p { margin: 13px 0 0; }
.survey-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.survey-questions { padding: clamp(15px, 4vw, 29px); }
.survey-question { min-width: 0; margin: 0 0 22px; padding: 0 0 20px; border: 0; border-bottom: 1px solid var(--survey-line); }
.survey-question:last-child { margin-bottom: 0; padding-bottom: 0; border: none; }
.survey-question legend { max-width: 100%; margin: 0 0 10px; padding: 0; font-weight: 650; overflow-wrap: anywhere; }
.survey-question small { display: block; margin-top: 5px; }
.survey-number, .survey-required { color: var(--survey-accent); }
.survey-required { font-size: 12px; padding-inline: 3px; white-space: nowrap; }
.survey-choice { display: flex; gap: 10px; align-items: center; padding: 9px 12px; margin-bottom: 6px; min-height: 43px; border: 1px solid var(--survey-line); border-radius: 8px; overflow-wrap: anywhere; }
.survey-choice:has(input:checked) { border-color: var(--survey-accent); background: #fff6f8; }
.survey-question :is(textarea, input[type="text"], input[type="tel"]) { display: block; width: 100%; font-size: 16px; }
.survey-note { padding: 11px 14px; margin: 0 0 17px; background: #f8f3f5; border-left: 2px solid #c84d6d; }
.survey-submit { text-align: center; }
.survey-submit > p { margin: 12px 0; color: var(--survey-muted); font-size: 14px; }
.survey-submit > p.survey-error { color: #91203d; }
.survey-submit button { width: min(100%, 320px); min-height: 45px; }
.survey-result { margin-top: 15px; padding: 25px; text-align: center; }
.survey-result p { margin: 7px 0 0; }
@media (max-width: 560px) {
    .survey-row { align-items: flex-start; flex-direction: column; gap: 9px; padding: 13px; }
    .survey-admin h1 { font-size: 23px; }
    .survey-admin h2 { font-size: 18px; }
}

/* Questionnaire editor workspace */
.survey-admin #survey-editor { width: min(1120px, calc(100vw - 28px)); max-height: min(92vh, 940px); }
.survey-admin #survey-editor.survey-design-only { width: min(800px, calc(100vw - 28px)); }
#survey-editor-form { display: flex; flex-direction: column; height: min(90vh, 905px); }
.survey-design-only #survey-editor-form { height: auto; }
.survey-builder-layout { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(0, 2.25fr); flex: 1; min-height: 0; }
.survey-design-only .survey-builder-layout { grid-template-columns: minmax(0,1fr); }
.survey-builder-library { background: #f7f3f5; border-right: 1px solid var(--survey-line); min-height: 0; overflow: auto; padding: 15px; }
.survey-library-tabs { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 4px; margin-bottom: 15px; }
.survey-library-tabs button { padding: 6px; border-color: transparent; background: transparent; }
.survey-library-tabs button[aria-pressed=true] { color: var(--survey-accent); border-color: #e6c8d3; background: white; font-weight: 700; }
.survey-library-section { margin-bottom: 16px; }
.survey-library-section h3 { color: var(--survey-muted); font-size: 13px; letter-spacing: .025em; margin-bottom: 8px; }
.survey-library-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; }
.survey-library-grid .survey-type-button { border-color: #e9dfe3; background: white; padding: 5px 3px; font-size: 13px; }
.survey-type-button[draggable=true] { cursor: grab; }
.survey-empty-library { font-size: 13px; color: var(--survey-muted); }
#survey-library-content .survey-outline-entry { width: 100%; justify-content: flex-start; text-align: left; margin-bottom: 6px; overflow-wrap: anywhere; white-space: normal; line-height: 1.4; }
.survey-builder-canvas { min-width: 0; min-height: 0; overflow: auto; padding: 18px clamp(13px, 3vw, 26px); background: #fbf9fa; }
.survey-editor-intro, .survey-design-box { margin-bottom: 13px; border: 1px solid var(--survey-line); background: white; border-radius: 12px; }
.survey-editor-intro { padding: 15px 16px 0; }
.survey-design-box > summary { cursor: pointer; padding: 12px 15px; font-weight: 650; color: var(--survey-accent); }
.survey-design-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 16px; padding: 0 15px 15px; }
.survey-design-grid h3 { font-size: 15px; margin: 2px 0 10px; }
.survey-banner-preview { min-height: 125px; display: grid; place-items: center; padding: 4px; background: #f8f2f5; border: 1px dashed #e0c5d0; border-radius: 8px; }
.survey-banner-preview img { display: block; width: 100%; max-height: 210px; object-fit: contain; border-radius: 5px; }
.survey-banner-preview p { font-size: 13px; color: var(--survey-muted); }
.survey-share-preview { display: grid; grid-template-columns: minmax(0,1fr) 62px; align-items: start; gap: 10px; border: 1px solid var(--survey-line); border-radius: 9px; padding: 10px; }
.survey-share-preview strong { font-size: 13px; overflow-wrap: anywhere; }
.survey-share-preview p { font-size: 11px; color: var(--survey-muted); overflow-wrap: anywhere; margin: 3px 0 0; }
.survey-share-preview img { width: 62px; height: 62px; object-fit: contain; background: #f7f1f4; border-radius: 6px; }
.survey-image-actions { margin-top: 8px; }
.survey-image-actions .survey-button { cursor: pointer; position: relative; }
.survey-image-actions input { cursor: pointer; position: absolute; inset: 0; opacity: .001; padding: 0; width: 100%; height: 100%; }
.survey-image-actions .survey-button:focus-within { outline: 2px solid var(--survey-accent); outline-offset: 2px; }
#survey-draft-questions { border-radius: 10px; padding: 2px; }
#survey-draft-questions.survey-drag-ready { outline: 1px dashed #c789a0; outline-offset: 2px; }
#survey-draft-questions.survey-drag-over { background: #f8eaf0; outline-color: var(--survey-accent); }
#survey-empty-fields { text-align: center; padding: 25px 10px; margin: 0; border: 1px dashed #e0c5d0; color: var(--survey-muted); border-radius: 10px; font-size: 14px; }
#survey-fields .survey-builder-field { background: white; }
#survey-fields .survey-drop-before { box-shadow: 0 -3px 0 var(--survey-accent); }
.survey-field-tools { display: flex; flex-wrap: wrap; margin-bottom: 9px; }
.survey-field-tools button { min-height: 29px; padding: 2px 8px; font-size: 12px; }
.survey-grip { cursor: grab; align-self: center; color: var(--survey-accent); font-size: 21px; }
.survey-field-order { font-size: 12px; color: var(--survey-muted); margin-inline-end: auto; }
.survey-scale-editor { display: grid; grid-template-columns: minmax(0,.8fr) repeat(2,minmax(0,1fr)); gap: 8px; }
.survey-answer-signature { display: block; width: min(100%,500px); border: 1px solid var(--survey-line); }
.survey-answer-signature polyline { fill: none; stroke: var(--survey-ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.survey-public .survey-banner { display: block; width: 100%; max-height: 70vh; object-fit: contain; background: white; margin-bottom: 10px; border-radius: 14px; }
.survey-public select { display: block; max-width: 100%; width: 100%; min-height: 42px; border-radius: 8px; border: 1px solid #d6cbd1; padding: 6px 10px; color: var(--survey-ink); background: white; font: inherit; }
.survey-field-help { margin: 0 0 9px; color: var(--survey-muted); font-size: 14px; }
.survey-fill-group { display: grid; gap: 8px; }
.survey-fill-group label { display: block; font-size: 14px; }
.survey-fill-group label :is(input,select) { width: 100%; margin-top: 3px; }
.survey-scale { display: grid; grid-template-columns: repeat(auto-fit,minmax(48px,1fr)); gap: 5px; }
.survey-scale .survey-choice { padding: 5px; justify-content: center; flex-wrap: wrap; gap: 4px; margin: 0; }
.survey-scale-labels { display: flex; justify-content: space-between; gap: 12px; margin-top: 5px; color: var(--survey-muted); font-size: 12px; }
.survey-field-table { max-width: 100%; overflow-x: auto; }
.survey-field-table table { width: 100%; border-collapse: collapse; }
.survey-field-table :is(th,td) { padding: 6px; font-size: 13px; text-align: left; border-bottom: 1px solid var(--survey-line); }
.survey-field-table input { min-width: 130px; }
[data-survey-cascade] { display: grid; gap: 7px; }
[data-survey-signature] canvas { display: block; width: 100%; max-height: 155px; min-height: 104px; border: 1px solid #d6cbd1; border-radius: 8px; background: #fdfbfc; touch-action: none; margin: 6px 0; }
@media (max-width: 690px) {
    .survey-builder-layout { display: flex; flex-direction: column; }
    .survey-builder-library { max-height: 210px; flex-shrink: 0; border-right: 0; border-bottom: 1px solid var(--survey-line); padding: 10px; }
    .survey-builder-canvas { flex: 1; padding: 10px; }
    .survey-library-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
    .survey-design-grid { grid-template-columns: minmax(0,1fr); }
}

.survey-workspace .survey-row { align-items: flex-start; }
.survey-workspace .survey-row-info { flex: 1; }
.survey-workspace .survey-row > .survey-actions { max-width: 53%; }
.survey-inline-share { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 9px; }
.survey-inline-share input { flex: 1; min-width: 130px; min-height: 36px; font-size: 13px; color: var(--survey-muted); }
.survey-inline-share button { min-height: 36px; padding: 4px 9px; }
@media (max-width: 740px) {
    .survey-workspace .survey-row { flex-direction: column; }
    .survey-workspace .survey-row > .survey-actions { max-width: 100%; }
    .survey-workspace .survey-row-info { width: 100%; }
}
.survey-admin #survey-preview { width: min(840px, calc(100vw - 24px)); }
#survey-preview-frame { display: block; width: 100%; height: min(75vh, 800px); border: 0; background: var(--survey-bg); }
#survey-responses .survey-dialog-header { flex-wrap: wrap; }
#survey-editor .survey-dialog-footer { flex-wrap: wrap; }
