/* Public survey editor (Tangora.Public.SurveyEditor.js). Override the variables on .survey-editor to match the site. */
.survey-editor {
    --se-bg: #ffffff;
    --se-accent: #2f6f8f;
    --se-accent-text: #ffffff;
    --se-text: #1f2933;
    --se-muted: #5b6770;
    --se-line: #d5dbe0;
    --se-soft: #f5f8fa;
    --se-selected: #e8f1f6;
    --se-warn-bg: #fff6e8;
    --se-warn-line: #e8a45c;
    --se-error-bg: #fdeeea;
    --se-error-line: #c0532b;
    --se-ok: #2e8b57;
    --se-radius: 6px;
    color: var(--se-text);
    background: var(--se-bg);
    padding: .75em;
    font-size: 15px;
    line-height: 1.45;
    box-sizing: border-box;
}

    .survey-editor *, .survey-editor *::before, .survey-editor *::after {
        box-sizing: inherit;
    }

    .survey-editor h2 {
        font-size: 1.5em;
        margin: 0 0 .5em;
    }

    .survey-editor h3 {
        font-size: 1.1em;
        margin: 0;
    }

    .survey-editor input[type="text"], .survey-editor input[type="number"], .survey-editor input[type="date"],
    .survey-editor select, .survey-editor textarea {
        width: 100%;
        font: inherit;
        color: inherit;
        background: #fff;
        border: 1px solid var(--se-line);
        border-radius: 4px;
        padding: .4em .55em;
    }

    .survey-editor textarea {
        resize: vertical;
    }

    .survey-editor :focus-visible {
        outline: 2px solid var(--se-accent);
        outline-offset: 1px;
    }

    /* Buttons. Layout boxes style buttons by id (#layoutbox9 button); :not(#sd) matches everything but counts as an id,
   so these rules win without !important. */
    .survey-editor button:not(#sd) {
        all: unset;
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: .3em;
        cursor: pointer;
        font-family: inherit;
        line-height: 1.25;
    }

    .survey-editor button:focus-visible:not(#sd) {
        outline: 2px solid var(--se-accent);
        outline-offset: 1px;
    }

    .survey-editor .se-btn:not(#sd) {
        font-size: .93em;
        border-radius: 4px;
        padding: .45em .9em;
        border: 1px solid var(--se-line);
        background: #fff;
        color: var(--se-text);
    }

    .survey-editor .se-btn:disabled:not(#sd) {
        opacity: .5;
        cursor: default;
    }

    .survey-editor .se-btn-primary:not(#sd) {
        background: var(--se-accent);
        border-color: var(--se-accent);
        color: var(--se-accent-text);
        font-weight: 700;
    }

    .survey-editor .se-btn-small:not(#sd) {
        padding: .3em .7em;
        font-size: .87em;
    }

    .survey-editor .se-btn-link:not(#sd) {
        border: 0;
        background: none;
        color: var(--se-accent);
        padding: .2em .35em;
    }

    .survey-editor .se-danger:not(#sd) {
        color: var(--se-error-line);
    }

/* Top bar and band */
.se-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5em;
    padding-bottom: .75em;
    border-bottom: 1px solid var(--se-line);
}

    .se-top .se-name {
        flex: 1 1 16em;
        width: auto;
        font-size: 1.25em;
        font-weight: 700;
        border-color: transparent;
    }

        .se-top .se-name:hover, .se-top .se-name:focus {
            border-color: var(--se-line);
        }

.se-status {
    font-size: .85em;
    padding: .2em .65em;
    border-radius: 999px;
    background: var(--se-soft);
    color: var(--se-muted);
    white-space: nowrap;
}

    .se-status::before {
        content: "";
        display: inline-block;
        width: .55em;
        height: .55em;
        border-radius: 50%;
        margin-right: .4em;
        background: currentColor;
    }

    .se-status.is-draft, .se-status.is-dirty {
        color: #8a5a00;
        background: var(--se-warn-bg);
    }

    .se-status.is-saved {
        color: var(--se-ok);
    }

.se-band {
    display: flex;
    flex-direction: column;
    gap: .5em;
    margin: .75em 0;
}

    .se-band:empty {
        display: none;
    }

.se-notice {
    background: var(--se-soft);
    border-left: 3px solid var(--se-accent);
    padding: .5em .75em;
    font-size: .9em;
    margin: 0;
}

.se-messages {
    background: var(--se-error-bg);
    border-left: 3px solid var(--se-error-line);
    padding: .5em .75em;
    font-size: .92em;
}

    .se-messages:empty {
        display: none;
    }

    .se-messages ul {
        margin: .3em 0 0;
        padding-left: 1.2em;
    }

    .se-messages p {
        margin: 0;
    }

.se-hint {
    display: block;
    font-size: .83em;
    color: var(--se-muted);
    margin: .35em 0 0;
}

.se-label {
    display: block;
    font-weight: 700;
    font-size: .88em;
    margin-bottom: .25em;
}

/* Columns: list, preview, inspector. They wrap by themselves on narrow screens. */
.se-cols {
    display: flex;
    flex-wrap: wrap;
    gap: 1em;
    align-items: flex-start;
    margin-top: .75em;
}

.se-list {
    flex: 1 1 17em;
    min-width: 0;
}

.se-preview {
    flex: 2 1 22em;
    min-width: 0;
}

.se-inspector {
    flex: 1 1 19em;
    min-width: 0;
    border: 1px solid var(--se-line);
    border-radius: var(--se-radius);
    padding: .9em;
    display: flex;
    flex-direction: column;
    gap: .75em;
    position: sticky;
    top: .5em;
    transition: margin-top .15s ease;
}

@media (prefers-reduced-motion: reduce) {
    .se-inspector {
        transition: none;
    }
}

/* List */
.se-list-head {
    margin-bottom: .5em;
}

.se-group {
    border: 1px solid var(--se-line);
    border-radius: var(--se-radius);
    padding: .4em;
    margin-bottom: .6em;
    background: #fff;
}

    .se-group.is-drop {
        border-color: var(--se-accent);
        background: var(--se-selected);
    }

.se-group-none {
    background: var(--se-soft);
}

.se-group-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .25em .75em;
    padding: .35em .45em;
    border-radius: 4px;
    cursor: pointer;
}

    .se-group-head.is-selected {
        background: var(--se-selected);
    }

    .se-group-head[draggable="true"] {
        cursor: grab;
    }

.se-group.is-dragging {
    opacity: .45;
}

.se-group.is-drop-before, .se-add-group.is-drop-before {
    box-shadow: 0 -3px 0 var(--se-accent);
}

.se-group.is-drop-after {
    box-shadow: 0 3px 0 var(--se-accent);
}

.se-group-head.is-drop-after {
    box-shadow: inset 0 -3px 0 var(--se-accent);
}

.se-group-name {
    font-weight: 700;
}

.se-q {
    display: flex;
    align-items: flex-start;
    gap: .45em;
    padding: .45em;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid transparent;
    background: #fff;
}

    .se-q:hover {
        border-color: var(--se-line);
    }

    .se-q.is-selected {
        background: var(--se-selected);
        border-color: var(--se-accent);
    }

    .se-q.is-dragging {
        opacity: .4;
    }

    .se-q.is-drop {
        box-shadow: inset 0 3px 0 var(--se-accent);
    }

    .se-q.is-drop-before {
        box-shadow: inset 0 3px 0 var(--se-accent);
    }

    .se-q.is-drop-after {
        box-shadow: inset 0 -3px 0 var(--se-accent);
    }

.se-grip {
    color: var(--se-muted);
    cursor: grab;
    letter-spacing: -.2em;
    user-select: none;
}

.se-q-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.se-q-name {
    overflow-wrap: anywhere;
}

.se-q-meta {
    font-size: .8em;
    color: var(--se-muted);
}

.se-q.is-conditional {
    border-left: 3px dashed var(--se-warn-line);
}

.se-cond-badge {
    display: inline-block;
    align-self: flex-start;
    margin-top: .2em;
    font-size: .78em;
    padding: .05em .55em;
    border-radius: 999px;
    background: var(--se-warn-bg);
    color: #8a5a00;
}

    .se-cond-badge.is-invalid {
        background: var(--se-error-bg);
        color: var(--se-error-line);
    }

.se-add {
    position: relative;
    padding: .35em .45em;
}

.se-typemenu {
    position: absolute;
    z-index: 10;
    left: .45em;
    top: 100%;
    width: min(22em, 90vw);
    background: #fff;
    border: 1px solid var(--se-line);
    border-radius: var(--se-radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    padding: .3em 0;
    display: flex;
    flex-direction: column;
}

.survey-editor .se-typemenu button:not(#sd) {
    text-align: left;
    background: none;
    padding: .4em .8em;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    white-space: normal;
}

.survey-editor .se-typemenu button:hover:not(#sd), .survey-editor .se-typemenu button:focus:not(#sd) {
    background: var(--se-soft);
}

.se-typemenu span {
    font-size: .8em;
    color: var(--se-muted);
}

/* Inspector */
.se-insp-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .25em;
}

.se-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: .1em;
}

.se-field label {
    display: block;
}

.se-check {
    display: flex;
    align-items: center;
    gap: .4em;
    font-size: .93em;
}

.se-section {
    border-top: 1px solid var(--se-line);
    padding-top: .65em;
    display: flex;
    flex-direction: column;
    gap: .45em;
}

.se-row {
    display: flex;
    flex-wrap: wrap;
    gap: .5em;
    align-items: center;
}

.se-row-between {
    justify-content: space-between;
}

.se-options {
    display: flex;
    flex-direction: column;
    gap: .3em;
}

.se-option {
    display: flex;
    align-items: center;
    gap: .2em;
}

    .se-option.is-hidden input {
        color: var(--se-muted);
        text-decoration: line-through;
    }

.se-cond {
    display: flex;
    flex-direction: column;
    gap: .35em;
}

.se-grid2 {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .5em .75em;
    align-items: center;
}

.se-grid2-fields {
    grid-template-columns: repeat(auto-fit, minmax(8em, 1fr));
}

.se-grid2 > .se-seg {
    justify-self: start;
}

.se-warn {
    font-size: .8em;
    color: #8a5a00;
}

.se-grid3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(5.5em, 1fr));
    gap: .5em;
}

/* Segmented control */
.se-seg {
    display: inline-flex;
    flex-wrap: wrap;
    border: 1px solid var(--se-line);
    border-radius: 4px;
    overflow: hidden;
}

.survey-editor .se-seg button:not(#sd) {
    font-size: .87em;
    background: #fff;
    color: var(--se-text);
    padding: .3em .75em;
}

.survey-editor .se-seg button + button:not(#sd) {
    border-left: 1px solid var(--se-line);
}

.survey-editor .se-seg button.is-active:not(#sd) {
    background: var(--se-accent);
    color: var(--se-accent-text);
}

/* Preview */
.se-preview-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .5em;
    margin-bottom: .5em;
}

.se-preview-frame {
    border: 1px solid var(--se-line);
    border-radius: var(--se-radius);
    padding: 1em 1.25em;
    background: #fff;
    margin: 0 auto;
    max-width: 100%;
}

.se-preview-title p {
    color: var(--se-muted);
    margin: 0 0 1em;
}

.se-preview-survey section[data-question] {
    cursor: pointer;
    border-radius: 4px;
    padding: .25em .4em;
    margin: 0 -.4em;
}

.se-preview-survey section.se-preview-selected {
    background: var(--se-selected);
    box-shadow: inset 3px 0 0 var(--se-accent);
}

.se-preview-survey .se-preview-cond {
    border-left: 3px dashed var(--se-warn-line);
    padding-left: .6em;
}

.se-preview-condlabel {
    font-size: .8em;
    color: #8a5a00;
    margin-bottom: .25em;
}

/* Start (new survey) */
.se-start {
    max-width: 48em;
    display: flex;
    flex-direction: column;
    gap: .8em;
}

.se-choices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10.5em, 1fr));
    gap: .5em;
}

.se-choice {
    border: 1px solid var(--se-line);
    border-radius: var(--se-radius);
    padding: .7em .8em;
    display: flex;
    flex-direction: column;
    gap: .35em;
    cursor: pointer;
}

    .se-choice span {
        font-size: .85em;
        color: var(--se-muted);
    }

    .se-choice.is-active {
        border: 2px solid var(--se-accent);
        background: var(--se-soft);
        padding: calc(.7em - 1px) calc(.8em - 1px);
    }

.se-describe {
    display: flex;
    flex-direction: column;
    gap: .6em;
}

/* AI revision ("Ret med AI") */
.se-ai {
    border: 1px solid var(--se-line);
    border-radius: var(--se-radius);
    background: var(--se-soft);
    padding: .75em;
    display: flex;
    flex-direction: column;
    gap: .5em;
}

    .se-ai .se-hint {
        margin: 0;
    }

.se-ai-result {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .25em .5em;
}

.survey-editor .se-btn.is-active:not(#sd) {
    background: var(--se-selected);
    border-color: var(--se-accent);
}

/* Canvas: the preview is where questions are edited; the outline (question list) is folded away for small surveys. */
.se-cols.is-outline-closed .se-list {
    display: none;
}

/* "Vis som respondent": only the survey, full width. */
.se-cols.is-respondent .se-list,
.se-cols.is-respondent .se-inspector {
    display: none;
}

.se-preview-head .se-row {
    gap: .35em;
}

.se-canvas .se-cv-q {
    position: relative;
    cursor: pointer;
}

    .se-canvas .se-cv-q > [inert] {
        pointer-events: none;
    }

    .se-canvas .se-cv-q:hover {
        box-shadow: 0 0 0 1px var(--se-line);
    }

    .se-canvas .se-cv-q:focus-visible {
        outline: 2px solid var(--se-accent);
        outline-offset: 2px;
    }

    .se-canvas .se-cv-q.is-dragging {
        opacity: .4;
    }

    .se-canvas .se-cv-q.is-drop-before {
        box-shadow: inset 0 3px 0 var(--se-accent);
    }

    .se-canvas .se-cv-q.is-drop-after {
        box-shadow: inset 0 -3px 0 var(--se-accent);
    }

.se-canvas .se-cv-bar {
    position: absolute;
    z-index: 5;
    right: .35em;
    top: .35em;
    max-width: 60%;
    display: none;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: .1em;
    background: #fff;
    border: 1px solid var(--se-line);
    border-radius: 4px;
    padding: .05em .3em;
    font-size: .8rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
}

/* The actions belong to the selected question and sit inside it; its title gets room on the right. */
.se-canvas .se-cv-q.se-preview-selected > .se-cv-bar,
.se-canvas .se-cv-q:focus-visible > .se-cv-bar {
    display: inline-flex;
}

.se-canvas .se-cv-q.se-preview-selected > h3 {
    padding-right: min(14rem, 45%);
}

/* The drag handle shows in the left margin on hover. */
.se-canvas .se-cv-grip {
    position: absolute;
    left: -1.25em;
    top: .3em;
    display: none;
    padding: .1em .15em;
    cursor: grab;
}

.se-canvas .se-cv-q:hover > .se-cv-grip,
.se-canvas .se-cv-q:focus-within > .se-cv-grip,
.se-canvas .se-cv-q.se-preview-selected > .se-cv-grip {
    display: block;
}

.se-canvas .se-cv-meta {
    color: var(--se-muted);
    padding: 0 .4em;
    white-space: nowrap;
}

.se-canvas .se-cv-bar .se-typemenu {
    left: auto;
    right: 0;
}

.se-canvas .se-cv-g {
    position: relative;
}

    .se-canvas .se-cv-g.se-preview-selected {
        background: var(--se-selected);
    }

    .se-canvas .se-cv-g.is-dragging {
        opacity: .45;
    }

    .se-canvas .se-cv-g.is-drop {
        background: var(--se-selected);
    }

    .se-canvas .se-cv-g.is-drop-before {
        box-shadow: 0 -3px 0 var(--se-accent);
    }

    .se-canvas .se-cv-g.is-drop-after {
        box-shadow: 0 3px 0 var(--se-accent);
    }

.se-canvas .se-cv-gbar {
    display: flex;
    align-items: center;
    gap: .4em;
    font-size: .8rem;
    color: var(--se-muted);
    margin: 0 0 .3em;
}

    .se-canvas .se-cv-gbar.is-drop-after {
        box-shadow: inset 0 -3px 0 var(--se-accent);
    }

.se-cv-foot {
    display: flex;
    flex-wrap: wrap;
    gap: .5em;
    align-items: center;
    margin-top: 1em;
    padding: .4em;
    border-radius: 4px;
}

    .se-cv-foot.is-drop {
        background: var(--se-selected);
    }

.se-canvas .se-cv-gempty {
    border: 1px dashed var(--se-line);
    border-radius: 4px;
    padding: .5em .6em;
    margin: 0 0 1.2em;
}
