:root {
    --accent: #6264a7;
    --accent-dark: #5051a0;
    --accent-soft: #e9eaf6;
    --bg: #f5f5f5;
    --card: #ffffff;
    --text: #242424;
    --muted: #616161;
    --line: #e1dfdd;
    --err: #c4314b;
    --ok: #0e7c3a;
    --star: #eaa300;
}
* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
img { max-width: 100%; height: auto; }
body {
    margin: 0;
    font-family: "Segoe UI", "Segoe UI Web (West European)", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
}
.home-body { background: #faf9f8; }
.fill-body, .builder-body { background: #f0ebf8; }
a { color: var(--accent); }
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: #fff;
    padding: 8px 20px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #323130; font-weight: 600; flex-shrink: 0; }
.brand-mark {
    width: 32px; height: 32px; border-radius: 6px; background: var(--accent); color: #fff;
    display: grid; place-items: center; font-size: 16px; font-weight: 700;
}
.topbar-actions, .nav-user { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.page { max-width: 980px; margin: 0 auto; padding: 28px 16px 64px; }
.page.narrow { max-width: 720px; }
.page.builder { max-width: 770px; }
.home-page { max-width: 1100px; }
h1 { font-size: 1.6rem; margin: 0 0 8px; font-weight: 600; }
.lead { color: var(--muted); margin: 0 0 24px; }
.section-label { font-size: 1rem; font-weight: 600; margin: 0 0 12px; color: #323130; }
.btn, button.btn {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent); color: #fff; border: 0; border-radius: 4px;
    padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover, button.btn:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { background: transparent; color: var(--err); }
.btn-danger:hover { background: #fde7e9; }
.icon-btn {
    background: transparent; border: 0; color: var(--muted); cursor: pointer;
    width: 36px; height: 36px; border-radius: 4px; font-size: 18px;
}
.icon-btn:hover { background: #f3f2f1; color: var(--text); }
.banner {
    display: flex; justify-content: space-between; gap: 12px; align-items: center;
    background: var(--accent-soft); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; font-size: 0.92rem;
}
.banner.ok { background: #e7f6ec; }
.banner.err { background: #fde7e9; color: var(--err); }
.banner a { color: var(--accent); font-weight: 600; text-decoration: none; }

.templates-block { margin-bottom: 32px; }
.tpl-row {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(160px, 1fr);
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
}
.tpl-card {
    background: #fff; border: 0; border-radius: 8px; text-align: left; cursor: pointer;
    padding: 0 0 12px; box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.04);
    min-width: 160px; font: inherit; color: inherit;
}
.tpl-card:hover { box-shadow: 0 8px 20px rgba(37,36,91,.12); }
.tpl-card:disabled { opacity: .55; cursor: not-allowed; }
.tpl-banner { display: block; height: 72px; border-radius: 8px 8px 0 0; background: var(--tpl, var(--accent)); }
.tpl-title { display: block; padding: 10px 12px 2px; font-weight: 600; font-size: 0.92rem; }
.tpl-hint { display: block; padding: 0 12px; color: var(--muted); font-size: 0.78rem; }

.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.form-tile {
    background: #fff; border-radius: 8px; padding: 0 0 14px; text-decoration: none; color: inherit;
    box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 0 0 1px rgba(0,0,0,.04);
    display: flex; flex-direction: column; gap: 8px; min-height: 180px; overflow: visible; position: relative;
}
.form-tile:hover { box-shadow: 0 8px 24px rgba(37,36,91,.12); }
.tile-open { display: flex; flex-direction: column; gap: 8px; flex: 1; text-decoration: none; color: inherit; min-height: 180px; }
.form-tile h2 { font-size: 1.05rem; margin: 0; padding: 0 16px; }
.form-tile p { margin: 0; padding: 0 16px; color: var(--muted); font-size: 0.85rem; flex: 1; }
.tile-banner { height: 86px; background: var(--accent); margin-bottom: 10px; border-radius: 8px 8px 0 0; overflow: hidden; }
.tile-banner img { width: 100%; height: 86px; object-fit: cover; display: block; }
.tile-meta { display: block; font-size: 0.8rem; color: var(--muted); padding: 0 16px 8px; }
.tile-more { position: absolute; top: 8px; right: 8px; z-index: 3; }
.tile-more > summary { list-style: none; background: rgba(255,255,255,.92); color: #323130; }
.tile-more > summary::-webkit-details-marker { display: none; }
.tile-menu {
    position: absolute; right: 0; top: 40px; min-width: 180px; background: #fff;
    border-radius: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.16); padding: 6px 0; display: grid;
}
.tile-menu a, .tile-menu button {
    display: block; width: 100%; text-align: left; background: none; border: 0;
    padding: 8px 14px; font: inherit; color: #323130; cursor: pointer; text-decoration: none;
}
.tile-menu a:hover, .tile-menu button:hover { background: #f3f2f1; }
.form-tile:has(.tile-more[open]) { z-index: 5; }
.side-panel label { display: block; font-size: 0.88rem; color: var(--muted); margin: 0 0 6px; }
.side-panel .share-row { margin: 0 0 12px; }
.side-panel .share-input { max-width: none; }
.side-panel p { margin: 0 0 14px; }
.empty { background: #fff; border-radius: 10px; padding: 48px 24px; text-align: center; color: var(--muted); }
.home-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.home-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.home-tab {
    padding: 10px 16px; text-decoration: none; color: var(--muted); font-weight: 600;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.home-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.editor-chrome { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.editor-tabs { display: flex; justify-content: center; gap: 8px; flex: 1; min-width: 180px; }
.editor-tab {
    padding: 10px 18px; text-decoration: none; color: var(--muted); font-weight: 600;
    border-bottom: 2px solid transparent; margin-bottom: -9px;
}
.editor-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.panel-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 40;
}
.side-panel {
    position: fixed; top: 0; right: 0; width: min(420px, 100%); height: 100%;
    background: #fff; z-index: 50; box-shadow: -8px 0 24px rgba(0,0,0,.12);
    padding: 20px 24px 32px; overflow: auto;
}
.side-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.side-panel-head h2 { margin: 0; font-size: 1.2rem; }
.collab-sub { font-size: 0.95rem; margin: 18px 0 10px; }
.collab-select-label { display: block; font-size: 0.88rem; color: var(--muted); margin-bottom: 6px; }
#collaborate-mode { max-width: none; }
.collab-chips { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.collab-chips li {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--accent-soft); border-radius: 16px; padding: 4px 4px 4px 10px;
    font-size: 0.85rem;
}
.collab-chips .icon-btn { width: 28px; height: 28px; }
.collab-template { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
.settings-stack .boxed { max-width: none; }
.resp-head { margin-bottom: 8px; }
.resp-count { font-size: 1.15rem; font-weight: 600; margin: 0 0 8px; }
.resp-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.resp-tools .tabs { margin: 0; }
.rank-table-wrap { overflow: auto; margin-top: 16px; border: 1px solid var(--line); border-radius: 8px; }
.rank-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; background: #fff; }
.rank-table th, .rank-table td { padding: 10px 12px; border-bottom: 1px solid #eee; text-align: left; vertical-align: top; }
.rank-table th { background: #faf9f8; color: var(--muted); font-weight: 600; white-space: nowrap; }
.rank-table tr:nth-child(even) td { background: #fafafa; }
.rank-more { position: relative; }
.rank-more-btn, .rank-stat-btn {
    border: 1px solid var(--line); background: #fff; border-radius: 16px;
    padding: 2px 10px; font: inherit; cursor: pointer; color: var(--accent); font-weight: 600;
}
.rank-tip {
    display: none; position: absolute; z-index: 8; right: 0; top: 100%;
    min-width: 220px; max-width: 320px; padding: 10px 12px;
    background: #fff; border: 1px solid var(--line); border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12); font-size: 0.85rem; line-height: 1.45;
}
.rank-more:hover .rank-tip, .rank-stat:hover .rank-tip, .rank-more:focus-within .rank-tip, .rank-stat:focus-within .rank-tip {
    display: block;
}
.rank-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.rank-stat { position: relative; }
.assigned-pill {
    display: inline-block; background: var(--accent-soft); color: inherit;
    border-radius: 12px; padding: 2px 8px; font-weight: 600;
}
.rank-answer { margin: 6px 0 0; padding-left: 18px; }

.q-card, .title-card, .bar-card {
    background: var(--card); border-radius: 8px; padding: 24px 24px 20px; margin-bottom: 12px;
    box-shadow: 0 1.6px 3.6px rgba(0,0,0,.13), 0 0.3px 0.9px rgba(0,0,0,.1);
}
.title-card { border-top: 10px solid var(--accent); overflow: hidden; }
.cover-wrap { margin: 0 -24px 8px; }
.cover-photo, .cover-wrap .cover-photo {
    width: 100%; max-height: 200px; object-fit: cover; display: block;
}
.title-card > .cover-photo { width: calc(100% + 48px); margin: 0 -24px 16px; max-height: 220px; }
.cover-btn { margin: 8px 0; }
.section-card { border-left: 6px solid var(--accent); }
.section-card h2 { margin: 0 0 4px; font-size: 1.15rem; }
.q-title { font-size: 1rem; font-weight: 600; margin-bottom: 14px; line-height: 1.4; }
.q-hint { margin: -8px 0 14px; color: var(--muted); font-size: 0.88rem; }
.q-photo { display: block; max-width: 100%; max-height: 280px; border-radius: 6px; margin: 0 0 14px; object-fit: contain; background: #f3f2f1; }
.req { color: var(--err); }
input.underline, textarea.underline, .plain-input {
    width: 100%; border: 0; border-bottom: 1px dotted #9e9e9e; border-radius: 0;
    padding: 8px 0; font: inherit; background: transparent; color: inherit;
}
input.underline:focus, textarea.underline:focus, .plain-input:focus {
    outline: none; border-bottom: 2px solid var(--accent);
}
.title-input { font-size: 1.7rem; font-weight: 700; border-bottom-style: solid; }
.desc-input { color: var(--muted); }
input.boxed, select, .builder select {
    width: 100%; max-width: 280px; padding: 8px 12px; border: 1px solid var(--line);
    border-radius: 4px; font: inherit; background: #fff;
}
.file-input { display: block; margin: 8px 0; }
input[readonly] { color: var(--muted); }
.choices { display: grid; gap: 2px; }
.choice {
    display: flex; align-items: center; gap: 12px; margin: 0; padding: 8px 4px;
    font-weight: 400; cursor: pointer; border-radius: 4px;
}
.choice:hover { background: #f7f7fb; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .mark, .scale-point .mark {
    width: 20px; height: 20px; border: 2px solid #616161; border-radius: 50%;
    flex-shrink: 0; display: grid; place-items: center; background: #fff;
}
.choice input[type="checkbox"] + .mark { border-radius: 4px; }
.choice input:checked + .mark, .scale-point input:checked + .mark { border-color: var(--accent); }
.choice input[type="radio"]:checked + .mark::after, .scale-point input:checked + .mark::after {
    content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
}
.choice input[type="checkbox"]:checked + .mark { background: var(--accent); border-color: var(--accent); }
.choice input[type="checkbox"]:checked + .mark::after {
    content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg) translate(-1px, -1px);
}
.other-choice { flex-wrap: wrap; }
.other-text {
    flex: 1; min-width: 160px; border: 0; border-bottom: 1px solid #9e9e9e;
    padding: 4px 0; font: inherit; background: transparent;
}
.other-text:focus { outline: none; border-bottom: 2px solid var(--accent); }
.other-text:disabled { opacity: .45; }
.scale-grid { display: grid; grid-template-columns: minmax(72px,1fr) auto minmax(72px,1fr); gap: 8px; align-items: end; }
.scale-end { font-size: 0.8rem; color: var(--muted); padding-bottom: 6px; }
.scale-end.right { text-align: right; }
.scale-points { display: flex; gap: 8px; justify-content: center; }
.scale-point { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 0; cursor: pointer; min-width: 36px; }
.scale-num { font-size: 0.85rem; color: var(--muted); }
.scale-point input { position: absolute; opacity: 0; pointer-events: none; }
.rating { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 4px; }
.rating input { position: absolute; opacity: 0; pointer-events: none; }
.rating label { font-size: 1.8rem; color: #d1d1d1; cursor: pointer; line-height: 1; }
.rating input:checked + label, .rating input:checked ~ label,
.rating label:hover, .rating label:hover ~ label { color: var(--star); }
.has-error { box-shadow: 0 0 0 2px #f1b9be, 0 1px 2px rgba(0,0,0,.06); }
.error { color: var(--err); font-size: 0.82rem; margin: 12px 0 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.save-status { font-size: 0.85rem; color: var(--muted); min-width: 90px; }
.save-status.ok { color: var(--ok); }
.save-status.err { color: var(--err); }

.builder-card { padding: 16px 18px 12px; }
.builder-card.active { box-shadow: 0 0 0 2px var(--accent), 0 8px 24px rgba(37,36,91,.08); }
.q-head { display: grid; grid-template-columns: 1fr 200px; gap: 12px; margin-bottom: 12px; }
.opt-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.opt-row .plain-input { flex: 1; }
.opt-limit { max-width: 78px; }
.choice.full { opacity: .5; cursor: not-allowed; }
.quota { margin-left: auto; font-size: 0.78rem; color: var(--muted); }
.quota.booked { color: var(--accent); font-weight: 600; }
.q-foot {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line);
}
.toggle { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.toggle input { width: auto; }
.settings-row { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 16px; }
.device-code {
    font-size: 2rem; font-weight: 700; letter-spacing: 0.16em;
    margin: 12px 0 20px; user-select: all; word-break: break-all;
}
.share-box { margin-top: 18px; }
.share-box label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.share-row { display: flex; gap: 8px; align-items: center; }
.share-input { max-width: none; flex: 1; color: var(--text); cursor: text; user-select: all; }
.more-settings { margin-top: 16px; color: var(--muted); }
.more-settings summary { cursor: pointer; font-weight: 600; color: var(--accent); }
#collaborate-groups { min-height: 72px; resize: vertical; margin-bottom: 8px; }
.thanks-card {
    background: #fff; border-radius: 8px; padding: 28px 24px; margin-bottom: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,.06); border-top: 10px solid var(--accent);
}
.thanks-card h2 { margin: 0 0 8px; }
.thanks-card p { margin: 0; color: var(--muted); }
.editor-bar { position: static; }
.fill-page { padding-top: 32px; }
.builder-sec-label {
    font-size: 0.82rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    color: var(--accent); margin: 18px 0 8px;
}
.opt-goto, .sec-goto { max-width: 180px; font-size: 0.8rem; }
.fill-section[hidden] { display: none !important; }
.fill-nav { justify-content: space-between; }
.fill-nav-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.fill-progress { color: var(--muted); font-weight: 600; }
.add-q { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 24px; }
.resp-card { margin-bottom: 12px; }
.resp-card h3 { margin: 0 0 10px; font-size: 1rem; }
.resp-row { display: grid; grid-template-columns: 180px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid #f0f0f0; font-size: 0.92rem; }
.resp-row dt { color: var(--muted); }
.tabs { display: flex; gap: 8px; margin: 0 0 20px; border-bottom: 1px solid var(--line); }
.tab {
    padding: 10px 16px; text-decoration: none; color: var(--muted); font-weight: 600;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.chart-card h3 { margin: 0 0 4px; font-size: 1.05rem; }
.bars { display: grid; gap: 10px; margin-top: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 180px) 1fr auto; gap: 10px; align-items: center; }
.bar-label { font-size: 0.9rem; }
.bar-track { height: 12px; background: #edebe9; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 6px; min-width: 0; }
.bar-count { font-size: 0.85rem; white-space: nowrap; }
.choice.assigned { background: var(--accent-soft); }
.rank-list { display: grid; gap: 8px; }
.rank-item {
    display: grid; grid-template-columns: auto 28px 1fr auto auto auto; gap: 8px; align-items: center;
    padding: 10px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: grab;
}
.rank-item.dragging { opacity: .55; }
.rank-item.full { opacity: .7; background: #f3f2f1; }
.rank-item .quota { margin-left: 0; }
.rank-handle { color: #a19f9d; letter-spacing: -2px; font-weight: 700; }
.rank-num {
    width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff;
    display: grid; place-items: center; font-size: 0.85rem; font-weight: 700;
}
.rank-label { font-weight: 600; }
@media (max-width: 720px) {
    .q-head, .resp-row, .scale-grid, .bar-row { grid-template-columns: 1fr; }
    .dash-head, .banner, .topbar, .editor-chrome, .home-toolbar { flex-direction: column; align-items: flex-start; }
    .editor-chrome { display: flex; }
    .editor-tabs { justify-content: flex-start; }
    .tpl-row { grid-auto-columns: 160px; }
}
