:root {
    color-scheme: dark;
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
    color: #f6f7ff;
    background: #11132b;
    --bg: #11132b;
    --card: #171b3d;
    --input: #11152e;
    --line: #363c65;
    --text: #f6f7ff;
    --muted: #bac1e0;
    --hint: #a8b1d4;
    --violet: #7537f5;
    --violet-light: #bda4ff;
    --cyan: #68ddff;
    --green: #6eefa9;
    --danger: #ffb4c4;
    --radius: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; line-height: 1.55; }
body.public { background: radial-gradient(ellipse at 50% -120px, #27204d, transparent 630px), var(--bg); }
body.admin { background: radial-gradient(ellipse at 10% 0, #202047, transparent 670px), var(--bg); }
button, input, select, textarea { font: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .53; }
a { color: var(--violet-light); text-underline-offset: .2em; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { overflow-wrap: anywhere; line-height: 1.15; }
h1 { font-size: clamp(1.9rem, 4.2vw, 3.25rem); letter-spacing: -.045em; }
h2 { font-size: 1.25rem; letter-spacing: -.025em; }
h3 { font-size: 1.12rem; letter-spacing: -.02em; }
fieldset { padding: 0; margin: 0; border: 0; min-width: 0; }
legend { padding: 0; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
textarea { resize: vertical; min-height: 90px; }
::selection { background: #744af2; color: white; }
.sr-only, .skip:not(:focus) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.skip:focus { position: fixed; inset: 12px auto auto 12px; z-index: 20; padding: 10px 16px; background: var(--card); }
.shell { width: min(1120px, calc(100% - 48px)); margin: 0 auto; }
.narrow { width: min(760px, calc(100% - 40px)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.stack { display: grid; gap: 14px; }
.muted, .intro { color: var(--muted); }
.hint { font-size: .85rem; color: var(--hint); font-weight: 400; }
.intro { margin-top: 10px; font-size: 1.02rem; line-height: 1.65; white-space: pre-line; }
.eyebrow { color: var(--violet-light); font-size: .72rem; font-weight: 750; letter-spacing: .15em; margin-bottom: 9px; }
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 42px;
    padding: 8px 15px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    font-size: .88rem;
    font-weight: 650;
    text-decoration: none;
    white-space: nowrap;
}
.button.primary { background: #7039e9; border-color: #976aff; color: white; box-shadow: 0 6px 18px #15092f50; }
.button.primary:hover:not(:disabled) { background: #7b46f2; }
.button.secondary { background: #23284e; border-color: #424978; }
.button.secondary:hover:not(:disabled), .button.subtle:hover:not(:disabled) { background: #303561; }
.button.subtle { color: var(--muted); }
.button.remove { color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tag {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 3px 9px;
    border: 1px solid #434973;
    border-radius: 999px;
    background: #242849;
    color: var(--muted);
    font-size: .73rem;
    font-weight: 650;
    width: fit-content;
    white-space: nowrap;
}
.tag.published { background: #163832; border-color: #295749; color: var(--green); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.notice { padding: 12px 15px; border: 1px solid #575288; border-radius: 10px; background: #272448; color: var(--text); }
.notice.danger { color: var(--danger); background: #392341; border-color: #78455d; }
.notice.success { color: var(--green); background: #163832; border-color: #295749; }
.notice.preview { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.brand-link { color: inherit; text-decoration: none; }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand img { display: block; object-fit: contain; }
.brand-name { display: grid; gap: 4px; font-size: 1.08rem; font-weight: 750; line-height: 1; letter-spacing: -.025em; }
.brand-name small { color: var(--cyan); font-size: .61rem; letter-spacing: .035em; font-weight: 600; }
.admin .brand-name small, .auth .brand-name small { letter-spacing: .11em; }
label { color: var(--text); font-size: .91rem; font-weight: 600; }
label small { color: var(--hint); font-size: .75rem; font-weight: 400; }
input:not([type="checkbox"], [type="radio"], [type="hidden"]), select, textarea {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #434a75;
    border-radius: 9px;
    background: var(--input);
    color: var(--text);
    font-size: .94rem;
    font-weight: 400;
}
label > :is(input:not([type="checkbox"], [type="radio"]), textarea, select) { margin-top: 5px; }
input::placeholder, textarea::placeholder { color: #9ba3c5; opacity: 1; }
input[type="radio"], input[type="checkbox"] { accent-color: #986dff; margin: 3px 0 0; width: 17px; height: 17px; flex: 0 0 auto; }
select { padding-right: 8px; }

.auth { width: min(430px, calc(100% - 32px)); padding: min(12vh, 120px) 0 44px; }
.auth > .brand { margin-bottom: 20px; }
.auth-card { padding: clamp(20px, 5vw, 32px); box-shadow: 0 18px 75px #070a1d7a; }
.auth-card h1 { font-size: 2.2rem; margin-bottom: 8px; }
.auth-card .stack, .auth-card .notice { margin-top: 18px; }
.auth-card .stack .notice { margin: 0; font-size: .85rem; }

.respondent-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 24px 0 18px; }
.form-hero {
    position: relative;
    overflow: hidden;
    padding: clamp(22px, 5.5vw, 42px);
    margin-bottom: 15px;
    background: radial-gradient(ellipse at 95% -45%, #4c2f86, transparent 65%), #1a1d41;
    border-top: 3px solid var(--violet);
    box-shadow: 0 14px 45px #080a2270;
}
.form-hero h1 { max-width: 610px; font-size: clamp(1.9rem, 5vw, 2.9rem); }
.form-hero .intro { max-width: 620px; }
.hero-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 19px; }
.respondent-form { display: grid; gap: 12px; margin-top: 12px; }
.progress-card {
    position: sticky;
    top: 6px;
    z-index: 2;
    background: #171b36f5;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 16px 12px;
    backdrop-filter: blur(14px);
}
.progress-card > div { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 5px; }
.progress-card label, .progress-card span { font-size: .77rem; color: var(--muted); }
.progress-card span { color: var(--violet-light); font-variant-numeric: tabular-nums; }
progress { display: block; width: 100%; height: 5px; border: 0; border-radius: 9px; background: #383d65; overflow: hidden; }
progress::-webkit-progress-bar { background: #383d65; }
progress::-webkit-progress-value { background: linear-gradient(90deg, #9c6eff, #52caf1); }
progress::-moz-progress-bar { background: #9c6eff; }
.section-heading { display: flex; align-items: flex-start; gap: 11px; margin: 15px 0 1px; }
.section-heading > span, .field-number {
    display: grid; place-items: center; min-width: 32px; height: 32px; border-radius: 8px;
    color: var(--violet-light); background: #28234c; font-weight: 750; font-size: .78rem;
}
.section-heading p { color: var(--hint); font-size: .87rem; margin-top: 4px; }
.section-heading h2 { padding-top: 3px; }
.question { padding: 17px 20px; scroll-margin-top: 82px; min-width: 0; }
.question-title, .question legend { display: block; font-size: .98rem; font-weight: 650; margin-bottom: 7px; }
.question .hint { margin-bottom: 9px; }
.question .consent + .hint { margin: 8px 0 0 31px; }
.required { color: #ffacc5; }
.choices { display: grid; gap: 7px; }
.choice { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.choices .choice { background: #151932; border: 1px solid #363d65; border-radius: 8px; padding: 9px 11px; font-weight: 450; }
.choices .choice:has(input:checked) { background: #29214c; border-color: #9c75fa; }
.choices .choice:hover { border-color: #7976ab; }
.upload input[type="file"] { border-style: dashed; padding: 12px; }
.upload input::file-selector-button {
    border: 1px solid #58528b; color: var(--text); background: #29244a;
    border-radius: 7px; padding: 7px 10px; margin-right: 10px; cursor: pointer;
}
.question.invalid { border-color: #b8698b; }
.field-error { color: var(--danger); margin-top: 8px; font-size: .84rem; }
.submit-row { margin-top: 10px; }
.submit-row .button { min-height: 49px; padding-inline: 24px; }
.submit-row .hint { margin-top: 9px; }
.page-footer { text-align: center; color: var(--hint); padding: 28px 0 24px; font-size: .75rem; }
.message { text-align: center; padding: clamp(20px, 6vw, 52px); margin-top: 12px; }
.message h1 { font-size: clamp(1.55rem, 4vw, 2.3rem); }
.message .again { margin-top: 20px; }
.success-icon {
    display: grid; place-items: center; margin: 0 auto 18px; width: 56px; height: 56px;
    border-radius: 50%; color: var(--green); background: #1b453b; font-size: 1.55rem;
}

.topbar { background: #151831; border-bottom: 1px solid #363b5f; }
.topbar-inner, .topbar-actions { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.topbar-inner { min-height: 68px; }
.workspace { padding: 28px 0 58px; }
.dashboard-hero, .page-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; padding: 21px 0 25px; }
.dashboard-hero h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
.page-heading h1 { font-size: clamp(1.6rem, 4vw, 2.5rem); margin-bottom: 8px; }
.page-heading > :first-child { min-width: 0; }
.page-heading .actions { justify-content: flex-end; flex: 0 0 auto; }
.create-card { margin: 5px 0 27px; padding: 15px 18px; scroll-margin-top: 12px; }
.create-card summary { cursor: pointer; font-weight: 650; }
.create-card summary .muted { display: inline-block; margin-left: 8px; font-size: .81rem; font-weight: 400; }
.create-form { display: grid; grid-template-columns: 1fr minmax(220px, .75fr) auto; gap: 12px; align-items: end; margin-top: 14px; }
.create-card .notice { margin-top: 10px; }
.section-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-bar h2 + p { margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-tile { display: flex; flex-direction: column; align-items: flex-start; padding: clamp(16px, 3vw, 24px); }
.tile-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; margin-bottom: 13px; }
.tile-icon {
    display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px;
    background: #35265d; color: #d0baff; font-weight: 780; font-size: .8rem;
}
.tile-icon.cyan { background: #1b3b55; color: var(--cyan); }
.form-tile h3 a { color: var(--text); text-decoration: none; }
.form-tile h3 a:hover { text-decoration: underline; }
.tile-description { color: var(--muted); font-size: .86rem; margin: 9px 0 14px; overflow-wrap: anywhere; }
.tile-meta { color: var(--hint); font-size: .86rem; margin: auto 0 12px; padding-top: 7px; }
.tile-meta strong { color: var(--text); }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: .86rem; text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.tabs { display: flex; gap: 16px; border-bottom: 1px solid var(--line); margin-bottom: 19px; }
.tabs a { text-decoration: none; color: var(--muted); padding: 8px 4px 10px; border-bottom: 2px solid transparent; font-size: .91rem; }
.tabs a[aria-current] { border-color: #ac85ff; color: var(--text); font-weight: 700; }
.editor { margin-top: 14px; }
.editor-grid { display: grid; grid-template-columns: minmax(250px, 1fr) minmax(0, 1.85fr); gap: 16px; align-items: start; }
.editor-settings, .responses-card { padding: 18px; }
.editor-fields { min-width: 0; }
.editor-field summary { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 10px 12px; list-style: none; }
.editor-field summary::-webkit-details-marker { display: none; }
.editor-field summary::after { content: '+'; color: var(--violet-light); font-weight: 750; font-size: 1.08rem; }
.editor-field[open] summary::after { content: '−'; }
.editor-field summary strong { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .9rem; }
.editor-field .field-editor { border-top: 1px solid var(--line); padding: 15px; }
.field-editor-top { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; }
.conditions { border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.conditions legend { padding-inline: 4px; color: var(--muted); font-size: .82rem; }
.savebar {
    position: sticky; bottom: 8px; z-index: 3; display: flex; justify-content: flex-end;
    align-items: end; gap: 12px; margin-top: 16px; padding: 11px 15px; box-shadow: 0 6px 30px #080a247f;
}
.savebar select { min-width: 142px; }
.savebar .button { min-height: 44px; }
.toast {
    position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 10;
    max-width: calc(100% - 26px); width: max-content; padding: 11px 15px; border: 1px solid #8069b3;
    border-radius: 10px; background: #302753; box-shadow: 0 6px 25px #080a247f;
}
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric { display: grid; gap: 4px; padding: 15px 18px; }
.metric span { color: var(--hint); font-size: .84rem; }
.metric strong { font-size: clamp(1.1rem, 3vw, 1.6rem); }
.empty { padding: 24px 12px; text-align: center; color: var(--muted); }
.empty p { margin-top: 4px; }
.search { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.search input { max-width: 370px; }
.table-scroll { max-width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
th { color: var(--muted); font-size: .78rem; font-weight: 650; }
td { font-size: .89rem; }
td:first-child { white-space: nowrap; }
.pagination { justify-content: end; padding-top: 12px; }
.answer-list { max-width: 850px; }
.answer { padding: 15px 17px; overflow-wrap: anywhere; }
.answer dt { font-weight: 700; margin-bottom: 4px; }
.answer dd { color: var(--muted); white-space: pre-wrap; }
.answer a { white-space: normal; }

@media (max-width: 740px) {
    .shell { width: calc(100% - 30px); }
    .dashboard-hero, .page-heading { flex-direction: column; align-items: flex-start; }
    .page-heading .actions { justify-content: flex-start; }
    .form-grid, .editor-grid, .create-form { grid-template-columns: 1fr; }
    .workspace { padding-top: 16px; }
    .create-card summary .muted { display: block; margin-left: 0; }
    .savebar { justify-content: space-between; }
    .respondent-header { padding-top: 17px; }
    .question { padding: 14px; }
}

@media (max-width: 440px) {
    .private-tag, .editor-field summary .tag { display: none; }
    .field-editor-top { grid-template-columns: 1fr; }
    .search { flex-wrap: wrap; }
    .responses-card .section-bar { align-items: flex-start; flex-direction: column; }
    .notice.preview { flex-direction: column; }
    .submit-row .button { width: 100%; }
    .savebar { gap: 8px; padding: 8px; }
    .savebar select { min-width: 0; }
}
