*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang HK", "PingFang TC", "Noto Sans HK", "Noto Sans TC", "Microsoft JhengHei", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.65;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }

button, label, .choice, .scale-opt { touch-action: manipulation; }

img { max-width: 100%; }

h1, h2, h3 { text-wrap: balance; }

p {
  text-align: justify;
  text-justify: inter-character;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

:focus-visible {
  outline: 2px solid var(--accent, #1f5aa6);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Public form ---------- */

body.public {
  min-height: 100dvh;
  color: var(--text, #172033);
  background:
    linear-gradient(var(--bg-2, #173b6c), var(--bg-2, #173b6c)) top / 100% 232px no-repeat,
    var(--bg, #eef2f7);
  font-size: 16px;
}

body.public .loading {
  margin: 48px 0;
  color: var(--on-band, #fff);
  text-align: center;
}

.wrap {
  width: min(680px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 calc(48px + env(safe-area-inset-bottom));
}

.site-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 0 2px 16px;
  color: var(--on-band, #fff);
}

.mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--card, #fff);
  color: var(--accent, #1d4f91);
  font-size: 15px;
  font-weight: 700;
}

.brand {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.card {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 28px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px -12px rgba(16, 24, 40, 0.14);
}

.form-head {
  border-top: 4px solid var(--accent);
  padding-top: 26px;
}

.form-kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}

.form-title {
  margin: 0;
  font-size: clamp(1.35rem, 1.05rem + 1.2vw, 1.8rem);
  font-weight: 700;
  line-height: 1.38;
  letter-spacing: 0.015em;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.form-title:focus { outline: none; }

.cover { margin: 18px 0 0; }

.cover img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--accent-soft);
}

.prose p { margin: 0; overflow-wrap: anywhere; }
.prose-block + .prose-block { margin-top: 0.8em; }
.prose-item { padding-left: 1.5em; text-indent: -1.5em; }

.form-desc {
  margin-top: 18px;
  color: var(--text-soft);
  font-size: 15.5px;
  line-height: 1.85;
}

.section-title {
  margin: 22px 0 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.req-legend {
  margin: 20px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13.5px;
  text-align: left;
}

.closed-note {
  margin: 18px 0 0;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
}

.page-count {
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
}

.progress {
  height: 4px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.3s ease;
}

.form-body { margin-top: 12px; }
.form-body > .card + .card { margin-top: 12px; }

.q { padding: 22px 26px 24px; transition: border-color 0.15s, box-shadow 0.15s; }

.q-head { display: flex; gap: 12px; align-items: flex-start; }
.q-head-text { min-width: 0; flex: 1; }

.q-no {
  flex: 0 0 auto;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  margin-top: 1px;
  border-radius: 99px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.q-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.req { color: var(--danger); font-weight: 700; }

.hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.q-note .q-title { font-size: 1rem; }

.note-copy {
  margin-top: 10px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.85;
}

.note-copy .prose-block + .prose-block { margin-top: 0.6em; }
.note-copy p + p { margin-top: 0.45em; }

.note-image {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 12px;
  border-radius: 12px;
}

.control {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  padding: 11px 14px;
  border: 1px solid var(--field-line);
  border-radius: 10px;
  background: var(--input);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.control:hover { border-color: var(--muted); }

.control:focus {
  outline: 2px solid transparent;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.control::placeholder { color: var(--muted); opacity: 0.8; }

textarea.control { min-height: 112px; resize: vertical; }

select.control {
  appearance: none;
  padding-right: 40px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 52%, calc(100% - 14px) 52%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.choices.is-long { grid-template-columns: 1fr; }

.choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--input);
  line-height: 1.5;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.choice:hover { border-color: var(--field-line); }

.choice.checked {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--accent-ring); }

.choice input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.choice input:focus-visible { outline: none; }

.choice span { min-width: 0; overflow-wrap: anywhere; }

.scale { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.scale-opt { position: relative; width: 46px; height: 46px; }

.scale-opt input {
  appearance: none;
  width: 46px;
  height: 46px;
  margin: 0;
  border: 1px solid var(--field-line);
  border-radius: 50%;
  background: var(--input);
  cursor: pointer;
}

.scale-opt span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 600;
  pointer-events: none;
}

.scale-opt input:checked { background: var(--accent); border-color: var(--accent); }
.scale-opt input:checked + span { color: var(--on-accent); }

.scale-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.q.has-error {
  border-color: var(--danger);
  box-shadow: inset 3px 0 0 var(--danger), 0 1px 2px rgba(16, 24, 40, 0.05);
}

.q.has-error .control,
.q.has-error .upload-btn { border-color: var(--danger); }

.q-error {
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}

.uploads { margin-top: 14px; }

.upload-btn {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 64px;
  padding: 10px 16px;
  border: 1.5px dashed var(--field-line);
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.upload-btn:hover:not(:disabled) { border-color: var(--accent); }
.upload-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.upload-plus {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 17px;
  line-height: 1;
}

.upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.upload-tile {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--input);
}

.upload-tile img,
.upload-busy {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--accent-soft);
}

.upload-busy {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.upload-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 8px 4px;
  color: var(--muted);
  font-size: 12px;
}

.upload-remove {
  appearance: none;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.upload-note { margin: 8px 0 0; color: var(--muted); font-size: 13px; text-align: left; }
.upload-note.is-error { color: var(--danger); }

.banner {
  margin: 12px 0 0;
  padding: 12px 14px;
  border: 1px solid #fecdca;
  border-radius: 10px;
  background: #fef3f2;
  color: #b42318;
  font-size: 14px;
  text-align: left;
}

body.public .banner {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.submit-row {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

body.public .btn {
  min-height: 50px;
  padding: 0 26px;
  border-radius: 12px;
  font-size: 16px;
}

body.public .btn-primary {
  min-width: 168px;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12);
}

body.public .btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

body.public .btn-ghost {
  background: var(--card);
  color: var(--text);
  border-color: var(--field-line);
}

body.public .btn-ghost:hover:not(:disabled) { background: var(--accent-soft); }

.submit-row .btn-ghost { margin-right: auto; }

.success { text-align: center; padding: 40px 28px 34px; }
.success .form-title { margin-top: 4px; }

.success-copy {
  max-width: 34em;
  margin: 10px auto 24px;
  color: var(--muted);
  text-align: center;
}

.success-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}

.ended {
  text-align: center;
  padding: 42px 32px 36px;
}

.ended p {
  text-align: center;
  text-justify: auto;
}

.ended-kicker {
  margin: 2px 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.ended .form-title {
  max-width: 16em;
  margin-inline: auto;
}

.ended-lead {
  max-width: 22em;
  margin: 18px auto 0;
  color: var(--text);
  font-size: 16.5px;
  line-height: 1.75;
}

.ended-note {
  max-width: 22em;
  margin: 8px auto 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.ended-shop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: min(100%, 280px);
  margin: 22px auto 0;
  padding: 14px 16px 13px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent, #fff);
  text-decoration: none;
}

.ended-shop span {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  opacity: 0.86;
}

.ended-shop strong {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.ended-shop:hover { filter: brightness(1.08); }

@media (max-width: 640px) {
  .ended { padding: 32px 20px 28px; }
  .ended-lead, .ended-note { font-size: 15px; }
}

.fatal { margin-top: 56px; }

.picker-note { margin: 10px 0 0; color: var(--muted); }

.picker-list { display: grid; gap: 12px; margin-top: 12px; }

.picker-card {
  display: block;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.picker-card:hover { border-color: var(--accent); }
.picker-card h2 { margin: 0 0 6px; font-size: 1.1rem; line-height: 1.45; }
.picker-card p { margin: 0; color: var(--muted); font-size: 14.5px; }
.picker-go { display: inline-block; margin-top: 12px; color: var(--accent); font-size: 14px; font-weight: 600; }

@media (max-width: 600px) {
  body.public {
    background:
      linear-gradient(var(--bg-2, #173b6c), var(--bg-2, #173b6c)) top / 100% 168px no-repeat,
      var(--bg, #eef2f7);
  }
  .wrap { width: calc(100% - 20px); padding-top: 10px; }
  .site-head { margin-bottom: 12px; }
  .card { padding: 20px 18px; border-radius: 14px; }
  .form-head { padding-top: 20px; }
  .q { padding: 18px 16px 20px; }
  .q-head { gap: 10px; }
  .q-title { font-size: 1rem; }
  .form-desc { font-size: 15px; line-height: 1.8; }
  .note-copy { font-size: 13.5px; }
  .choices { grid-template-columns: 1fr; }
  .submit-row .btn { flex: 1 1 0; min-width: 0; }
  .submit-row .btn-ghost { margin-right: 0; }
  .success { padding: 32px 18px 26px; }
}

@media print {
  body.public { background: white; }
  .card { box-shadow: none; }
  .submit-row, .site-head { display: none; }
}

/* ---------- Admin ---------- */

body.admin {
  --a-bg: #f5f6f8;
  --a-panel: #ffffff;
  --a-line: #e4e7ec;
  --a-line-strong: #d0d5dd;
  --a-text: #1d2433;
  --a-muted: #5f6b7a;
  --a-soft: #f2f4f7;
  --a-accent: #1f5aa6;
  --a-accent-hover: #194c8e;
  --a-accent-soft: #eaf1fb;
  --a-danger: #b42318;
  --a-danger-soft: #fef3f2;
  --accent: var(--a-accent);
  min-height: 100dvh;
  background: var(--a-bg);
  color: var(--a-text);
  font-size: 14.5px;
  color-scheme: light;
}

body.admin .loading { padding: 24px; color: var(--a-muted); }

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card { width: min(400px, 100%); padding: 28px; }
.login-card .side-mark { margin-bottom: 14px; }
.login-card .btn { width: 100%; min-height: 44px; }

.admin-shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: 100dvh;
}

.side {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 12px;
  background: var(--a-panel);
  border-right: 1px solid var(--a-line);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}

.side-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--a-accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.side-nav { display: flex; flex-direction: column; gap: 2px; }

.nav-btn {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--a-muted);
  font-size: 14.5px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.nav-btn:hover { background: var(--a-soft); color: var(--a-text); }
.nav-btn.active { background: var(--a-accent-soft); color: var(--a-accent); font-weight: 650; }
.nav-logout { margin-top: auto; }

.admin-main {
  min-width: 0;
  max-width: 1240px;
  padding: 24px 32px 0;
}

#formbar { margin-bottom: 22px; }

.formbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 12px;
  padding: 14px 16px;
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  border-radius: 12px;
}

.formbar-pick { display: flex; flex-direction: column; gap: 4px; flex: 1 1 280px; min-width: 0; }
.formbar-label { font-size: 12px; font-weight: 600; color: var(--a-muted); }
.form-picker { width: 100%; }
.formbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.form-link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex-basis: 100%;
  padding-top: 10px;
  border-top: 1px solid var(--a-line);
  color: var(--a-muted);
  font-size: 13px;
}

.form-link-label { font-weight: 600; color: var(--a-text); }

.page-switch {
  display: inline-flex;
  flex: 0 0 auto;
  margin-left: auto;
  border: 1px solid var(--a-line-strong);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

body.admin .eye-btn {
  width: 38px;
  min-height: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--a-muted);
  background: #fff;
}

body.admin .eye-btn + .eye-btn { border-left: 1px solid var(--a-line); }
body.admin .eye-btn.is-open,
body.admin .eye-btn.is-open:hover { background: var(--a-accent-soft); color: var(--a-accent); }
body.admin .eye-btn.is-closed,
body.admin .eye-btn.is-closed:hover { background: var(--a-danger-soft); color: var(--a-danger); }
.eye-ico, .eye-ico svg { display: block; width: 18px; height: 18px; }
.form-link-url { min-width: 0; flex: 1 1 200px; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

.page-head { margin-bottom: 18px; }
.page-title { margin: 0; font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
.page-note { margin: 6px 0 18px; color: var(--a-muted); max-width: 60em; }

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi, .panel, .response {
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  border-radius: 12px;
}

.kpi { padding: 16px 18px; }
.kpi span { color: var(--a-muted); font-size: 13px; font-weight: 500; }
.kpi b { display: block; margin-top: 4px; font-size: 1.75rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi small { display: block; margin-top: 4px; color: var(--a-muted); font-size: 12px; }

.muted { color: var(--a-muted); }

.panel { padding: 20px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 6px; font-size: 1rem; font-weight: 700; }
.panel h2 + .muted, .panel-note { margin: 0 0 16px; font-size: 13.5px; }
.panel h3 { margin: 18px 0 10px; font-size: 13.5px; font-weight: 650; color: var(--a-text); }

.chart-scroll { overflow-x: auto; padding-bottom: 4px; }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-width: 560px;
  height: 190px;
  padding-top: 8px;
  border-bottom: 1px solid var(--a-line);
}

.chart-col {
  flex: 1;
  min-width: 28px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.chart-pair { display: flex; align-items: flex-end; justify-content: center; gap: 3px; width: 100%; height: 150px; }
.chart-bar, .chart-view { width: 10px; min-height: 0; border-radius: 4px 4px 0 0; }
.chart-bar { background: var(--a-accent); }
.chart-view { background: #c7d3e3; }
.chart-label { color: var(--a-muted); font-size: 11px; font-variant-numeric: tabular-nums; }

.legend { display: flex; gap: 16px; margin-top: 10px; color: var(--a-muted); font-size: 13px; }
.swatch { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; }
.swatch-response { background: var(--a-accent); }
.swatch-view { background: #c7d3e3; }

.device-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.device-stat { padding: 12px 14px; border-radius: 10px; background: var(--a-soft); }
.device-stat b { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }

.hrow {
  display: grid;
  grid-template-columns: minmax(96px, 1.2fr) minmax(80px, 2fr) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.htrack { height: 8px; border-radius: 99px; background: var(--a-soft); overflow: hidden; }
.hfill { display: block; height: 100%; border-radius: 99px; background: var(--a-accent); }
.hcount { color: var(--a-muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.samples { margin: 0; padding-left: 18px; }
.samples li { margin: 6px 0; }

.latest-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--a-line);
}

.latest-row span,
.response-top div { min-width: 0; overflow-wrap: anywhere; }

.latest-row + .btn, .panel > .btn:last-child { margin-top: 12px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .field-input { flex: 1 1 220px; max-width: 320px; }

body.admin .btn-primary { background: var(--a-accent); color: #fff; }
body.admin .btn-primary:hover:not(:disabled) { background: var(--a-accent-hover); }
body.admin .btn-ghost { background: var(--a-panel); color: var(--a-text); border-color: var(--a-line-strong); }
body.admin .btn-ghost:hover:not(:disabled) { background: var(--a-soft); }
body.admin .btn-danger { background: var(--a-panel); color: var(--a-danger); border-color: #fecdca; }
body.admin .btn-danger:hover:not(:disabled) { background: var(--a-danger-soft); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-label { font-size: 13px; font-weight: 600; color: #344054; }

.field-input {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--a-line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--a-text);
  font-size: 14.5px;
  line-height: 1.55;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field-input:focus {
  outline: 2px solid transparent;
  border-color: var(--a-accent);
  box-shadow: 0 0 0 3px rgba(31, 90, 166, 0.16);
}

textarea.field-input { min-height: 96px; resize: vertical; }

select.field-input {
  appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--a-muted) 50%),
    linear-gradient(135deg, var(--a-muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

body.admin input[type="color"].field-input { width: 100%; height: 40px; padding: 3px; cursor: pointer; }

.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  margin-bottom: 12px;
  cursor: pointer;
}

.checkline input { width: 18px; height: 18px; accent-color: var(--a-accent); }

.inline-actions, .q-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.presets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 10px;
}

.preset {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 8px 8px 10px;
  border: 1px solid var(--a-line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--a-text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.preset:hover { border-color: var(--a-muted); }
.preset.active { border-color: var(--a-accent); box-shadow: 0 0 0 2px var(--a-accent); }

.preset-swatch {
  display: grid;
  grid-template-rows: 18px 18px;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.preset-swatch i:first-child { grid-column: 1 / -1; }

.theme-mock {
  max-width: 460px;
  margin: 16px 0;
  padding: 0 0 18px;
  overflow: hidden;
  border: 1px solid var(--a-line);
  border-radius: 12px;
  background:
    linear-gradient(var(--bg-2), var(--bg-2)) top / 100% 64px no-repeat,
    var(--bg);
}

.theme-mock-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  color: var(--on-band);
  font-size: 13px;
  font-weight: 600;
}

.theme-mock-brand .mark { width: 24px; height: 24px; border-radius: 6px; font-size: 12px; }

.theme-mock-card {
  margin: 0 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
}

.theme-mock-card strong { display: block; font-size: 1.05rem; line-height: 1.4; }
.theme-mock-cover { display: block; width: 100%; height: 120px; margin-top: 10px; object-fit: cover; object-position: top; border-radius: 8px; }
.theme-mock-field { height: 34px; margin-top: 12px; border: 1px solid var(--field-line); border-radius: 8px; background: var(--input); }

.theme-mock-btn {
  display: inline-flex;
  margin-top: 12px;
  padding: 7px 16px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 600;
}

.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 0 12px; }

.cover-field {
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.cover-preview {
  display: grid;
  place-items: center;
  min-height: 120px;
  overflow: hidden;
  border: 1px dashed var(--a-line-strong);
  border-radius: 10px;
  background: var(--a-soft);
}

.cover-preview img { display: block; width: 100%; height: auto; }
.cover-preview .muted { padding: 16px; font-size: 13px; text-align: center; }
.cover-side p { margin: 0 0 12px; font-size: 13.5px; }
.cover-status { margin-top: 10px !important; }

.cover-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px;
  border: 1px solid var(--a-line);
  border-radius: 10px;
  background: var(--a-soft);
}

.cover-inline img { width: 56px; height: 56px; flex: 0 0 auto; object-fit: cover; object-position: top; border-radius: 6px; background: #fff; }
.cover-inline div { min-width: 0; flex: 1; }
.cover-inline strong { display: block; font-size: 13px; }
.cover-inline span { color: var(--a-muted); font-size: 12.5px; }

.option-row { display: flex; gap: 8px; margin-bottom: 8px; }
.option-row .field-input { flex: 1; }

.edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
  gap: 20px;
  align-items: start;
}

.preview-col { position: sticky; top: 24px; }
.preview-col .page-note { margin: 0 0 8px; font-size: 13px; }

.preview-frame {
  width: 100%;
  height: min(calc(100dvh - 120px), 820px);
  border: 1px solid var(--a-line);
  border-radius: 12px;
  background: #fff;
}

.q-list { display: flex; flex-direction: column; gap: 8px; }

.q-row {
  border: 1px solid var(--a-line);
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.q-row:hover { border-color: var(--a-line-strong); }
.q-row.open { border-color: var(--a-accent); box-shadow: 0 0 0 3px rgba(31, 90, 166, 0.1); }

.q-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 6px;
}

.q-row-title {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 4px 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.q-row-title:hover { background: var(--a-soft); }

.q-row-no {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--a-soft);
  color: var(--a-muted);
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.q-row.open .q-row-no { background: var(--a-accent); color: #fff; }

.q-row-text { display: flex; flex-direction: column; min-width: 0; }
.q-row-name { font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
.q-row-type { color: var(--a-muted); font-size: 12px; }

.q-row-actions { display: flex; flex: 0 0 auto; gap: 4px; }

.q-mini { min-height: 32px; padding: 0 10px; border-radius: 7px; font-size: 13px; }
.q-icon { width: 32px; padding: 0; font-size: 15px; }

.q-row-body { padding: 4px 16px 8px 46px; border-top: 1px solid var(--a-line); }
.q-row-body > .field:first-child { margin-top: 14px; }

.add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--a-line-strong);
}

.add-row .field-input { width: min(100%, 200px); }

.savebar {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 8px -32px 0;
  padding: 12px 32px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--a-line);
  backdrop-filter: blur(6px);
}

#save-status { color: var(--a-muted); font-size: 13.5px; }
.savebar .btn { min-width: 140px; }

.response { padding: 14px 16px; margin-bottom: 10px; }
.response-top { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; align-items: center; }
.response-top strong { font-variant-numeric: tabular-nums; }
.response-summary {
  display: block;
  width: 100%;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.response-summary .response-top { margin-bottom: 0; }
.response-chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--a-muted);
  border-bottom: 2px solid var(--a-muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s ease;
}
.response-side { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
.response-card.is-open .response-chevron { transform: rotate(225deg) translateY(1px); }
.response-card.is-verified { border-color: #9dceba; }
.verify-tick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--a-line);
  border-radius: 8px;
  background: #fff;
  color: var(--a-text);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
.verify-tick input { width: 18px; height: 18px; margin: 0; accent-color: #1f6b4f; }
.response-card.is-verified .verify-tick { border-color: #1f6b4f; background: #eef6f1; color: #1f5a43; }
.response-leads {
  display: grid;
  grid-template-columns: minmax(6.5em, 0.8fr) minmax(7.5em, 0.9fr) minmax(0, 1.8fr);
  gap: 10px 16px;
  margin: 0 0 12px;
  padding-top: 10px;
  border-top: 1px solid var(--a-line);
}
.response-lead { margin: 0; min-width: 0; }
.response-lead b {
  display: block;
  margin-bottom: 2px;
  color: var(--a-muted);
  font-size: 12px;
  font-weight: 650;
}
.response-lead span {
  display: block;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 14.5px;
  line-height: 1.45;
}

.answer-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-top: 1px solid var(--a-line);
  align-items: flex-start;
}

.answer-line b { max-width: 46%; font-weight: 600; color: #344054; }
.answer-line > span { text-align: right; overflow-wrap: anywhere; white-space: pre-wrap; }
.response > .muted { margin: 10px 0 0; font-size: 12px; overflow-wrap: anywhere; }

.device-pill {
  flex: 0 0 auto;
  align-self: flex-start;
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--a-accent-soft);
  color: var(--a-accent);
  font-size: 12px;
  font-weight: 600;
}

.device-pill.archived { background: var(--a-danger-soft); color: var(--a-danger); }

.thumb-grid { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; min-width: 0; }

.thumb {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--a-line);
  background: #fff;
}

.response-detail .answer-line { flex-direction: column; gap: 6px; }
.response-detail .answer-line b { max-width: none; }
.response-detail .answer-line > span { text-align: left; }
.response-detail .thumb-grid { justify-content: flex-start; }
.response-detail .thumb {
  width: min(100%, 420px);
  height: auto;
  max-height: 520px;
  object-fit: contain;
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(16, 24, 40, 0.48);
}

.gate-card {
  width: min(420px, 100%);
  margin: 0;
  padding: 22px 22px 18px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(16, 24, 40, 0.22);
}

.gate-card h2 { margin: 0 0 8px; font-size: 1.15rem; }
.gate-card .muted { margin: 0 0 16px; line-height: 1.65; }
.gate-card .field { margin-bottom: 12px; }
.gate-card .banner { margin: 0 0 12px; }
.gate-actions { display: flex; justify-content: flex-end; gap: 8px; }
.gate-card .field-input { font-size: 16px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: calc(100% - 24px);
  padding: 10px 16px;
  border-radius: 10px;
  background: #1d2433;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.2);
  transform: translateX(-50%);
}

@media (max-width: 1100px) {
  .edit-grid { grid-template-columns: 1fr; }
  .preview-col { display: none; }
}

@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .side {
    z-index: 6;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--a-line);
    scrollbar-width: none;
  }
  .side::-webkit-scrollbar { display: none; }
  .side-brand { padding: 0 6px 0 0; }
  .side-nav { flex-direction: row; gap: 2px; }
  .nav-btn { flex: 0 0 auto; padding: 0 11px; }
  .nav-logout { margin-top: 0; margin-left: auto; flex: 0 0 auto; }
  .admin-main { padding: 18px 20px 0; }
  .savebar { margin: 8px -20px 0; padding-left: 20px; padding-right: 20px; }
  .kpis, .device-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  body.admin { font-size: 14.5px; }
  .side-brand > span:last-child { display: none; }
  .admin-main { padding: 14px 12px 0; }
  #formbar { margin-bottom: 16px; }
  .formbar { padding: 12px; }
  .formbar-actions { width: 100%; }
  .formbar-actions .btn { flex: 1 1 0; }
  .form-link-label { margin-right: auto; }
  .form-link-url { order: 3; flex-basis: 100%; }
  .page-switch { order: 2; margin-left: 0; }
  .field-input { font-size: 16px; }
  .page-title { font-size: 1.3rem; }
  .panel { padding: 16px; }
  .savebar { margin: 8px -12px 0; padding-left: 12px; padding-right: 12px; }
  .savebar .btn { flex: 1 1 auto; }
  .q-row-head { flex-wrap: wrap; padding: 6px; }
  .q-row-title { flex-basis: 100%; }
  .q-row-actions { width: 100%; justify-content: flex-end; padding: 0 2px 4px; }
  .q-row-body { padding: 4px 12px 8px; }
  .cover-field { grid-template-columns: 112px minmax(0, 1fr); gap: 12px; }
  .cover-side p { font-size: 13px; }
  .hrow { grid-template-columns: 1fr auto; }
  .htrack { grid-column: 1 / -1; }
  .toolbar .field-input { max-width: none; flex-basis: 100%; }
  .toolbar .btn { flex: 1 1 auto; }
  .response-top { flex-wrap: wrap; }
  .response-leads { grid-template-columns: 1fr 1fr; }
  .response-lead:last-child { grid-column: 1 / -1; }
  .answer-line { flex-direction: column; gap: 4px; }
  .answer-line b { max-width: none; }
  .answer-line > span { text-align: left; }
  .thumb-grid { justify-content: flex-start; }
}

@media (max-width: 420px) {
  .kpis, .device-grid { grid-template-columns: 1fr 1fr; }
  .kpi { padding: 12px 14px; }
  .kpi b { font-size: 1.45rem; }
}
