:root {
  /* Palette: warm cream ground, ink text, royal-blue accent, light-blue lines, rust for alerts, tan for AI-filled */
  --bg: #fdfaef; --card: #ffffff; --card-soft: #f7f8fb; --text: #0b0e13; --muted: #4f5460; --muted-2: #696a6e;
  --line: #c4cfe6; --line-strong: #90addc; --line-warm: #e5dbc4;
  --accent: #34549e; --accent-hover: #27407c; --accent-soft: #eceff8; --accent-soft-2: #dce3f3;
  --rust: #a44a30; --rust-soft: #f9ece7;
  --ai: #f6edda; --ai-line: #d9c8a7; --ai-text: #6b4c1e;
  --danger: #a44a30; --danger-soft: #f9ece7; --ok: #2f6b4f; --ok-soft: #e6f1ea; --warn: #8a5a1c; --warn-soft: #f6edda;
  --radius: 14px; --font: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font: 500 14.5px/1.55 var(--font); background: var(--bg); color: var(--text); padding-bottom: 88px; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
code { font-size: 12px; background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }
h2 { font-size: 17px; font-weight: 800; margin: 0; letter-spacing: -.01em; }
p { margin: 0; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 0 20px; height: 60px; background: rgba(253,250,239,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line-warm); }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.tabs { display: flex; gap: 2px; }
.tab { border: 0; background: transparent; padding: 8px 12px; border-radius: 8px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab:hover { color: var(--accent); background: var(--accent-soft); }
.tab.active { color: var(--accent); font-weight: 800; background: var(--accent-soft); }
#editBtn.active { background: var(--accent-soft); border-color: var(--line-strong); }
.badge { background: var(--rust); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 11px; margin-left: 2px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; display: inline-flex; font: inherit; }
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn[hidden] { display: none; }
#pdfBtn[hidden] { display: none; }
.field textarea[readonly] { background: var(--card-soft); color: var(--muted-2); }
.lock-note { font-size: 12.5px; color: var(--muted-2); margin-bottom: 10px; }
.notice-bar { background: var(--rust-soft); color: var(--rust); border-left: 4px solid var(--rust); padding: 8px 20px; font-size: 13px; text-align: center; }

main { max-width: 920px; margin: 0 auto; padding: 20px 16px; }
.view[hidden] { display: none; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
#photoCard { background: var(--accent-soft); border-color: var(--accent-soft-2); }
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 16px; margin-bottom: 16px; }
.card-head > div:first-child { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head .sub { flex-basis: 100%; font-size: 13px; color: var(--muted); }
.step { font-size: 12px; font-weight: 800; color: var(--accent); letter-spacing: .06em; }
.step::after { content: " ·"; color: var(--line-strong); }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.section-toggle { display: flex; align-items: center; flex: 1; min-width: 0; background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: inherit; text-align: left; gap: 10px; }
.sec-hint { font-size: 13px; color: var(--muted-2); margin-bottom: 12px; }
.sec-status:empty { display: none; }
.sec-tools { display: flex; gap: 6px; flex-shrink: 0; align-items: center; justify-content: flex-end; }
.sec-tools.disabled { opacity: .45; pointer-events: none; }
.tool { position: relative; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 1.5px solid var(--accent); border-radius: 9px; background: #fff; color: var(--accent); cursor: pointer; padding: 0; font: inherit; transition: .15s; flex-shrink: 0; }
.tool:hover { background: var(--accent-soft); }
.tool-ai { border-color: var(--line); color: var(--muted-2); }
.tool-ai.ready { border-color: var(--rust); color: var(--rust); background: var(--rust-soft); animation: pulse 1.6s ease-in-out infinite; }
.sec-thumbs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sec-thumbs:empty { display: none; }
.sthumb { position: relative; width: 36px; height: 36px; border-radius: 8px; overflow: hidden; border: 1.5px solid var(--line); cursor: zoom-in; background: #000; flex-shrink: 0; }
.sthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sthumb .x { position: absolute; top: -1px; right: -1px; width: 15px; height: 15px; border-radius: 0 6px 0 6px; border: 0; background: var(--rust); color: #fff; font-size: 9px; line-height: 15px; padding: 0; cursor: pointer; }
.tool-badge[hidden] { display: none; }
.tool-badge { position: absolute; top: -6px; right: -6px; min-width: 16px; height: 16px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(164,74,48,.35); } 50% { box-shadow: 0 0 0 5px rgba(164,74,48,0); } }
.card.collapsed .section-head { margin-bottom: 0; }
.card.collapsed .sec-hint, .card.collapsed .sec-status { display: none; }
.section-toggle h2 { flex: 1; }
.section-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.section-toggle .chev { color: var(--muted); transition: transform .2s; font-size: 11px; }
.card.collapsed .section-toggle .chev { transform: rotate(-90deg); }
.card.collapsed .grid, .card.collapsed .likert-grid { display: none; }
.chip { font-size: 12px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); padding: 3px 10px; border-radius: 999px; white-space: nowrap; background: #fff; }
.chip.on { color: var(--accent); border-color: var(--line-strong); }
.chip.local { color: var(--accent); border-color: #b9d4dd; background: var(--accent-soft); }

/* Fields */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; position: relative; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.field label .req { color: var(--danger); }
.input, .field input, .field select, .field textarea { width: 100%; font: inherit; font-size: 14px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s; }
.input-sm { padding: 6px 9px; font-size: 13px; width: 180px; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input[readonly] { background: var(--card-soft); color: var(--muted-2); }
.field textarea { min-height: 72px; resize: vertical; }
.field.ai input, .field.ai select, .field.ai textarea, .field.ai .checks { background: var(--ai); border-color: var(--ai-line); }
.field .ai-tag { display: none; position: absolute; right: 0; top: -1px; font-size: 10px; font-weight: 800; background: var(--ai-line); color: var(--ai-text); padding: 1px 7px; border-radius: 999px; letter-spacing: .04em; }
.field.ai .ai-tag { display: inline-block; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; }
.checks label { font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; background: var(--card-soft); border-radius: 999px; cursor: pointer; border: 1px solid transparent; }
.checks label:has(input:checked) { background: var(--accent-soft); border-color: var(--line-strong); color: var(--accent); }
/* Compact Likert matrix: statement left, 1–5 on the same row */
.likert-grid { display: flex; flex-direction: column; gap: 2px; }
.likert-head { display: grid; grid-template-columns: 1fr 190px; gap: 12px; align-items: end; padding: 0 0 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: 11px; font-weight: 800; color: var(--accent); }
.likert-head .scale { display: grid; grid-template-columns: repeat(5, 1fr); text-align: center; }
.likert-head .scale span:first-child, .likert-head .scale span:last-child { font-size: 10px; color: var(--muted-2); font-weight: 700; }
.likert-field { display: grid !important; grid-template-columns: 1fr 190px; gap: 12px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line-warm); }
.likert-field:last-child { border-bottom: 0; }
.likert-field label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.likert-field .ai-tag { display: none !important; }
.likert { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.likert label { display: flex; align-items: center; justify-content: center; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-weight: 700; font-size: 13px; color: var(--muted); position: relative; }
.likert label:hover { border-color: var(--line-strong); color: var(--accent); }
.likert label:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }
.likert input { position: absolute; opacity: 0; width: 0; height: 0; }
.field.ai.likert-field .likert label:has(input:checked) { background: var(--ai-text); border-color: var(--ai-text); }
.checks input { accent-color: var(--accent); width: auto; margin: 0; }
.field.invalid input, .field.invalid select { border-color: var(--danger); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 10px; padding: 8px 15px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; transition: .15s; white-space: nowrap; text-decoration: none; line-height: 1.3; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--accent-hover); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--accent); }
.btn-outline:not(:disabled):hover { background: var(--accent-soft); border-color: var(--line-strong); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent); }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-lg { padding: 11px 28px; font-size: 15px; font-weight: 800; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-row.end { justify-content: flex-end; margin-top: 6px; }
.inline-form { display: flex; gap: 8px; max-width: 480px; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; }
.photo-actions h2 { flex: 1; min-width: 140px; }
.photo-actions .btn-primary { margin-left: auto; }
#photoCard .thumb-strip { margin: 12px 0 0; }
#photoCard .status { margin: 6px 0 0; }
#photoCard .status:empty { display: none; }
.photo-count { font-size: 13px; color: var(--muted); }

/* Thumbs */
.thumb-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.thumb-strip:empty { display: none; }
.thumb { position: relative; width: 96px; height: 96px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #000; cursor: zoom-in; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .x { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--rust); color: #fff; font-size: 11px; cursor: pointer; line-height: 20px; padding: 0; }
.thumb .sz { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 10px; text-align: center; padding: 1px 0; }
.thumb.stamped::after { content: "GPS"; position: absolute; top: 4px; left: 4px; font-size: 9px; font-weight: 700; background: var(--ok); color: #fff; padding: 1px 5px; border-radius: 3px; }

.status { font-size: 13px; color: var(--muted); min-height: 18px; margin-bottom: 6px; }
.status.ok { color: var(--ok); } .status.err { color: var(--danger); }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-line { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.progress-line > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* Action bar */
.action-bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: rgba(253,250,239,.94); backdrop-filter: blur(8px); border-top: 1px solid var(--line-warm); }
.action-bar[hidden] { display: none; }
.action-bar > * { flex-shrink: 0; }
.progress { flex: 1; min-width: 60px; position: relative; height: 8px; background: var(--accent-soft-2); border-radius: 999px; overflow: visible; }
#progressFill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .3s; }
#progressText { position: absolute; top: -18px; right: 0; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.table-wrap:has(table:empty) { display: none; }
.table { border-collapse: collapse; width: 100%; font-size: 13px; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th { background: var(--card-soft); font-weight: 800; font-size: 12px; color: var(--muted); position: sticky; top: 0; }
.table tbody tr:hover { background: var(--card-soft); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.pill.synced { background: var(--ok-soft); color: var(--ok); } .pill.pending { background: var(--warn-soft); color: var(--warn); } .pill.failed { background: var(--danger-soft); color: var(--danger); } .pill.sample { background: var(--accent-soft); color: var(--accent); }
.table .mini { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; display: block; cursor: zoom-in; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 13px; padding: 0; }
.link-btn.danger { color: var(--danger); }

/* Admin */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 24px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--accent); font-weight: 700; }
.breakdowns { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.bd h3 { font-size: 12px; font-weight: 800; color: var(--rust); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .06em; }
.bd .row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 6px; }
.bd .bar { grid-column: 1 / -1; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bd .bar > div { height: 100%; background: var(--accent); }
.bd .n { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Dialogs */
dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 0; width: min(560px, 94vw); max-height: 92vh; box-shadow: 0 24px 60px rgba(11,14,19,.25); color: var(--text); background: var(--bg); }
dialog::backdrop { background: rgba(11,14,19,.5); }
.dlg { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.dlg h2 { font-size: 20px; }
.dlg fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 14px; margin: 0; display: flex; flex-direction: column; gap: 12px; background: #fff; }
.dlg legend { font-size: 12px; font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; padding: 0 6px; }
.dlg label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; }
.dlg small { font-weight: 400; color: var(--muted); font-size: 12px; }
.dlg .check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.dlg .check input { width: auto; accent-color: var(--accent); }
.photo-dlg { width: min(1100px, 96vw); background: #111; border: 0; }
.photo-dlg-body { padding: 12px; }
.photo-dlg-head { display: flex; justify-content: space-between; align-items: center; color: #ddd; font-size: 13px; margin-bottom: 8px; }
.photo-dlg-head .icon-btn { color: #ddd; }
.gallery { display: flex; flex-direction: column; gap: 10px; max-height: 80vh; overflow: auto; }
.gallery img { max-width: 100%; border-radius: 6px; display: block; margin: 0 auto; }
.gallery figcaption { color: #aaa; font-size: 12px; text-align: center; margin-top: 4px; }

/* Toasts */
.toasts { position: fixed; top: 68px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(420px, 92vw); pointer-events: none; }
.toast { background: var(--text); color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.18); animation: fade .2s; }
.toast.ok { background: var(--ok); } .toast.err { background: var(--danger); }
@keyframes fade { from { opacity: 0; transform: translateY(-6px); } }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 10px 6px; gap: 6px 8px; }
  .brand { flex: 1; }
  #pdfBtn { padding: 6px 9px; font-size: 12.5px; }
  .tabs { order: 10; flex-basis: 100%; justify-content: space-between; background: var(--card-soft); border-radius: 10px; padding: 3px; }
  .tab { flex: 1; text-align: center; padding: 7px 4px; font-size: 13px; }
  .toasts { top: 104px; }
  .section-head { flex-wrap: wrap; }
  .section-toggle { flex-basis: 100%; }
  .sec-tools { width: 100%; }
  .sec-tools .sec-thumbs { margin-right: auto; }
  main { padding: 12px; }
  .card { padding: 16px; }
  .photo-actions h2 { flex-basis: 100%; }
  .photo-count { display: none; }
  .photo-actions .btn { flex: 1; }
  .photo-actions .btn-primary { margin-left: auto; }
  .inline-form { flex-direction: column; }
  .input-sm { width: 100%; }
}

/* Analysis tab */
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.check-inline input { accent-color: var(--accent); }
.an-card h2 { font-size: 16px; }
.an-h3 { font-size: 13px; font-weight: 800; margin: 20px 0 8px; color: var(--accent); }
.an-h3 small { font-weight: 400; color: var(--muted); }
.an-note { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }
.an-note.warn { background: var(--rust-soft); color: var(--rust); border-left: 4px solid var(--rust); padding: 10px 12px; border-radius: 8px; margin-bottom: 16px; }
.an-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px 24px; margin-top: 8px; }
.report p { margin: 0 0 10px; font-size: 14px; line-height: 1.6; }
.report b { color: var(--rust); }
.dim { color: var(--muted); }
.sig { color: var(--ok); font-weight: 600; } .bad { color: var(--danger); }
.stats.fit { margin-bottom: 8px; }
.stats.fit .stat .v { font-size: 18px; }
.table.heat td, .table.heat th { text-align: center; padding: 6px 8px; font-size: 12px; font-variant-numeric: tabular-nums; }
.table.heat th:first-child { text-align: left; }
.table.heat td.diag { background: var(--bg); color: var(--muted); }
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 38%) 1fr auto; gap: 8px; align-items: center; font-size: 12.5px; }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #374151; }
.bar-track { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.bar-val { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.chart { width: 100%; height: auto; max-height: 220px; display: block; }
.chart.path { max-height: 360px; }
.svg-bar { fill: var(--accent); opacity: .85; }
.svg-tick { font-size: 10px; fill: var(--muted); font-family: var(--font); }
.svg-ref { stroke: var(--danger); stroke-dasharray: 4 3; stroke-width: 1; }
.svg-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.svg-dot { fill: var(--accent); }
.svg-box { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.svg-box-t { font-size: 12px; font-weight: 600; fill: var(--accent-hover); font-family: var(--font); }
.svg-r2 { font-size: 10px; fill: var(--muted); font-family: var(--font); }
.svg-arrow { stroke: var(--text); stroke-width: 1.5; }
.svg-arrow.ns { stroke: #9ca3af; stroke-dasharray: 5 4; }
.svg-ah { fill: var(--text); }
.svg-lbl-bg { fill: #fff; stroke: var(--line); }
.svg-lbl { font-size: 11px; font-weight: 600; fill: var(--text); font-family: var(--font); }
.svg-lbl.ns { fill: #9ca3af; font-weight: 400; }
@media (max-width: 640px) {
  .likert-head { display: none; }
  .likert-field { grid-template-columns: 1fr; gap: 6px; }
  .an-grid { grid-template-columns: 1fr; }
  .chart.path { max-height: none; }
}

/* Onboarding (empty questionnaire) */
.onboarding { text-align: center; padding: 34px 22px; }
.onboarding h2 { font-size: 22px; margin-bottom: 6px; }
.ob-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 20px; }
.ob-tile { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 20px 16px; text-align: left; cursor: pointer; font: inherit; color: var(--text); display: flex; flex-direction: column; gap: 6px; transition: .15s; }
.ob-tile:hover { border-color: var(--accent); box-shadow: 0 8px 24px rgba(52,84,158,.12); transform: translateY(-1px); }
.ob-tile b { font-size: 15px; } .ob-tile span:last-child { font-size: 12.5px; color: var(--muted); }
.ob-ic { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; margin-bottom: 4px; }
.action-bar.disabled { opacity: .5; pointer-events: none; }

/* Linear scale in the form */
.likert { display: grid; grid-template-columns: auto repeat(var(--n, 5), minmax(28px, 34px)) auto; gap: 4px; align-items: center; }
.lk-end { font-size: 11px; color: var(--muted-2); max-width: 90px; line-height: 1.2; }
.lk-end.lo { text-align: right; padding-right: 4px; } .lk-end.hi { padding-left: 4px; }
.likert-head { grid-template-columns: 1fr auto; }
.likert-field { grid-template-columns: 1fr auto; }

/* Questionnaire designer — minimal, modern */
.field label .help { display: block; font-weight: 500; color: var(--muted-2); font-size: 12px; margin-top: 2px; }
.gtop { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 2px 14px; }
.gtop-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gtop-title { font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.gtop .status { margin: 0; }
.gtop-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.gbtn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid transparent; background: #fff; color: var(--muted); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; transition: .15s; box-shadow: 0 1px 2px rgba(11,14,19,.05); }
.gbtn:hover { color: var(--accent); background: var(--accent-soft); }
.gbtn.primary { background: var(--accent); color: #fff; } .gbtn.primary:hover { background: var(--accent-hover); } .gbtn:disabled { opacity: .4; cursor: not-allowed; }
.gsep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.gform { display: grid; grid-template-columns: 1fr 52px; gap: 14px; align-items: start; }
.gform-main { min-width: 0; }
.gmodel { background: #fff; border-radius: 12px; padding: 12px 16px; margin-top: 4px; box-shadow: 0 1px 2px rgba(11,14,19,.05); }
.gmodel:empty { display: none; }
.gform-tools { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 4px; background: #fff; border-radius: 999px; padding: 6px; box-shadow: 0 6px 20px rgba(11,14,19,.08); }
.gtool { width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: .15s; }
.gtool:hover { background: var(--accent-soft); color: var(--accent); }
.gempty { background: #fff; border-radius: 16px; padding: 40px 24px; text-align: center; box-shadow: 0 1px 3px rgba(11,14,19,.06); }
.gempty h2 { font-size: 22px; margin-bottom: 6px; }
.gsec { background: #fff; border-radius: 14px; margin-bottom: 14px; overflow: hidden; box-shadow: 0 1px 3px rgba(11,14,19,.06); transition: box-shadow .2s; }
.gsec:hover { box-shadow: 0 4px 14px rgba(11,14,19,.08); }
.gsec.dragging, .gq.dragging { opacity: .45; }
.gsec.drop-before { box-shadow: 0 -3px 0 var(--accent); } .gsec.drop-after { box-shadow: 0 3px 0 var(--accent); }
.gform-head { border-top: 8px solid var(--accent); padding: 20px 24px 16px; }
.gform-title, .gform-desc, .gsec-title, .gsec-desc { border: 0; border-bottom: 1px solid transparent; border-radius: 0; padding: 4px 0; background: transparent; }
.gform-title { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.gform-desc { color: var(--muted); font-size: 14px; }
.gform-title:hover, .gform-desc:hover, .gsec-title:hover, .gsec-desc:hover { border-bottom-color: var(--line); }
.gform-title:focus, .gform-desc:focus, .gsec-title:focus, .gsec-desc:focus, .gq-label:focus, .gq-helpin:focus, .gq-opt .input:focus, .gq-scale-lbl:focus { border-bottom-color: var(--accent); box-shadow: none; border-radius: 0; }
.gsec-chip { display: flex; align-items: center; justify-content: space-between; color: var(--accent); background: var(--accent-soft); font-size: 11.5px; font-weight: 800; padding: 6px 16px; letter-spacing: .05em; text-transform: uppercase; }
.gsec-tools { display: flex; gap: 2px; } .gsec-tools .icon-btn { color: var(--accent); padding: 2px 6px; font-size: 13px; }
.gsec-head { padding: 14px 24px 4px; display: flex; flex-direction: column; gap: 2px; }
.gsec-head h2 { font-size: 20px; }
.gsec-title { font-size: 20px; font-weight: 800; }
.gsec-desc { font-size: 13px; color: var(--muted); }
.gq-list { padding: 8px 14px; display: flex; flex-direction: column; gap: 8px; min-height: 30px; }
.gq-empty { color: var(--muted-2); font-size: 13px; padding: 14px 8px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; }
.gsec-foot { padding: 2px 14px 14px; }
.gq { position: relative; background: #fff; border: 1px solid transparent; border-radius: 12px; padding: 14px 18px 14px 30px; cursor: pointer; transition: box-shadow .2s, border-color .2s, transform .2s; animation: gq-in .18s ease-out; }
@keyframes gq-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.gq:hover { border-color: var(--line); }
.gq.active { cursor: default; border-color: var(--line); border-left: 5px solid var(--accent); padding-left: 25px; box-shadow: 0 10px 30px rgba(11,14,19,.10); }
.gq.drop-before { box-shadow: 0 -3px 0 var(--accent); } .gq.drop-after { box-shadow: 0 3px 0 var(--accent); }
.gq-grip { position: absolute; left: 9px; top: 13px; color: var(--line-strong); cursor: grab; font-size: 13px; letter-spacing: -2px; user-select: none; opacity: 0; transition: .15s; }
.gq:hover .gq-grip, .gq.active .gq-grip { opacity: 1; }
.gq-title { font-weight: 600; font-size: 14.5px; margin-bottom: 8px; }
.gq-help { font-size: 12.5px; color: var(--muted-2); margin: -4px 0 8px; }
.gq-edit { display: grid; grid-template-columns: 1fr 200px; gap: 12px; align-items: center; margin-bottom: 8px; }
.gq-label { font-size: 15px; font-weight: 600; background: var(--card-soft); border: 0; border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; padding: 12px; }
.gq-type { font-weight: 600; border-radius: 10px; }
.gq-helpin { font-size: 13px; margin-bottom: 8px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 6px 2px; background: transparent; }
.gq-opts { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 8px; }
.gq-opt { display: flex; align-items: center; gap: 10px; }
.gq-opt .input { border: 0; border-bottom: 1px solid transparent; border-radius: 0; padding: 6px 2px; background: transparent; }
.gq-opt .input:hover { border-bottom-color: var(--line); }
.gq-opt .icon-btn { opacity: 0; } .gq-opt:hover .icon-btn { opacity: 1; }
.gq-opt.add .link-btn { color: var(--muted-2); }
.pv-radio, .pv-check { width: 16px; height: 16px; border: 2px solid var(--line-strong); display: inline-block; flex-shrink: 0; }
.pv-radio { border-radius: 50%; } .pv-check { border-radius: 4px; }
.pv-opts { display: flex; flex-direction: column; gap: 7px; font-size: 14px; color: var(--muted); }
.pv-opts div { display: flex; align-items: center; gap: 10px; }
.pv-line { border-bottom: 1px dotted var(--line-strong); color: var(--muted-2); font-size: 13px; padding-bottom: 4px; width: 50%; }
.pv-line.long { width: 85%; }
.pv-scale { display: flex; align-items: center; gap: 8px; font-size: 12px; flex-wrap: wrap; }
.pv-num { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); flex-shrink: 0; }
.pv-num.sm { width: 26px; height: 26px; font-size: 12px; }
.gq-scale { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 8px; }
.gq-scale-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.gq-scale-lbl { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 5px 2px; max-width: 320px; background: transparent; }
.gq-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.input-xs { width: 70px; padding: 4px 6px; font-size: 12px; display: inline-block; }
.input-xs.wide { width: 150px; }
.gq-foot { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; flex-wrap: wrap; position: relative; }
.gq-foot .icon-btn { font-size: 17px; }
.gq-sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { width: 34px; height: 18px; border-radius: 999px; background: var(--line-strong); position: relative; transition: .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: .15s; }
.switch input:checked + span { background: var(--accent); } .switch input:checked + span::after { left: 18px; }
.gq-more { position: absolute; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; z-index: 5; box-shadow: 0 8px 24px rgba(11,14,19,.12); font-size: 12.5px; }
.approve-bar { position: sticky; bottom: 12px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding: 10px 16px; border-radius: 999px; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); box-shadow: 0 10px 30px rgba(11,14,19,.14); }
.approve-bar > div:first-child { flex: 1; min-width: 160px; font-size: 13px; padding-left: 6px; }
.approve-hint { font-size: 12px; color: var(--muted); }
.dpage.thumb { width: 64px; height: 84px; }
@media (max-width: 640px) {
  .gform { grid-template-columns: 1fr; }
  .gform-tools { position: static; flex-direction: row; justify-content: center; order: -1; border-radius: 999px; width: max-content; margin: 0 auto 10px; }
  .gq-edit { grid-template-columns: 1fr; }
  .gform-title { font-size: 21px; }
  .gtop-right { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .approve-bar { bottom: 8px; border-radius: 16px; padding: 10px 12px; }
  .approve-hint { display: none; }
  .approve-bar .btn-row { width: 100%; justify-content: flex-end; }
  .likert { grid-template-columns: repeat(var(--n, 5), 1fr); }
  .lk-end { grid-column: span calc(var(--n, 5) / 2); max-width: none; }
  .lk-end.lo { grid-column: 1 / span 2; text-align: left; } .lk-end.hi { grid-column: -3 / -1; text-align: right; }
}
