:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #eef3f2;
  --ink: #1d2530;
  --muted: #667085;
  --border: #d8dee8;
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --amber: #b45309;
  --rose: #be123c;
  --blue: #2563eb;
  --shadow: 0 12px 30px rgba(29, 37, 48, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

a {
  color: var(--teal);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 42px;
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  outline: 3px solid rgba(15, 118, 110, 0.16);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #475467;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

td {
  font-size: 0.95rem;
}

.topbar,
.public-topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  display: flex;
  min-height: 64px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar {
  justify-content: space-between;
}

.public-topbar {
  justify-content: center;
}

.brand {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  font-weight: 800;
  gap: 10px;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  align-items: center;
  background: var(--teal);
  border-radius: 8px;
  color: white;
  display: inline-flex;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.topnav {
  align-items: center;
  display: flex;
  gap: 18px;
}

.topnav form {
  margin: 0;
}

.page {
  margin: 0 auto;
  max-width: 920px;
  padding: 32px 20px 64px;
}

.page-wide {
  max-width: 1280px;
}

.page-heading {
  align-items: flex-end;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-heading h1,
.public-heading h1,
.auth-panel h1,
.success-panel h1 {
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.05;
  margin: 4px 0 10px;
}

.section-heading {
  align-items: baseline;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-heading h2 {
  font-size: 1.1rem;
  margin: 0;
}

.eyebrow {
  color: var(--amber);
  font-size: 0.78rem;
  font-weight: 800;
  margin: 0;
  text-transform: uppercase;
}

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

.small {
  font-size: 0.83rem;
}

.stack {
  display: grid;
  gap: 16px;
}

.button,
.link-button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover,
.link-button:hover {
  text-decoration: none;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.button.primary {
  background: var(--teal);
  color: #fff;
}

.button.primary:hover {
  background: var(--teal-dark);
}

.button.secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--ink);
}

.button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--teal);
}

.icon-button {
  background: var(--surface-soft);
  color: var(--teal-dark);
  min-width: 72px;
}

.link-button {
  background: transparent;
  color: var(--teal);
  padding: 0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.notice {
  border-radius: 8px;
  font-weight: 700;
  margin-bottom: 18px;
  padding: 12px 14px;
}

.notice-info {
  background: #e8f5f2;
  color: var(--teal-dark);
}

.notice-error {
  background: #fff1f2;
  color: var(--rose);
}

.auth-panel,
.success-panel,
.public-form-shell,
.table-shell,
.editor-main,
.editor-side {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel,
.success-panel {
  display: grid;
  gap: 20px;
  margin: 48px auto 0;
  max-width: 520px;
  padding: 28px;
}

.public-form-shell {
  margin: 24px auto;
  max-width: 760px;
  padding: 28px;
}

.preview-toolbar {
  align-items: center;
  background: #e8f5f2;
  border: 1px solid #b9ddd5;
  border-radius: 8px;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin: 24px auto 0;
  max-width: 760px;
  padding: 16px 18px;
}

.preview-toolbar p {
  margin: 0;
}

.public-heading {
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  padding-bottom: 20px;
}

.public-heading p:last-child {
  color: var(--muted);
  font-size: 1.05rem;
  margin-bottom: 0;
}

.public-form {
  display: grid;
  gap: 18px;
}

.form-field {
  display: grid;
  gap: 8px;
}

.label-row {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.label-row span,
label > span {
  font-weight: 800;
}

.label-row em {
  color: var(--rose);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 800;
  text-transform: uppercase;
}

.field-help,
.field-error {
  font-size: 0.86rem;
  margin: 0;
}

.field-help {
  color: var(--muted);
}

.field-error {
  color: var(--rose);
  font-weight: 700;
}

.has-error input,
.has-error select,
.has-error textarea {
  border-color: var(--rose);
}

.choice-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.rating-grid {
  grid-template-columns: repeat(5, minmax(54px, 1fr));
}

.choice {
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
}

.choice input {
  min-height: auto;
  width: auto;
}

.submit-button {
  justify-self: start;
  min-width: 180px;
}

.metric-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 20px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}

.metric span {
  color: var(--teal-dark);
  display: block;
  font-size: 2rem;
  font-weight: 900;
}

.metric p {
  color: var(--muted);
  font-weight: 700;
  margin: 2px 0 0;
}

.table-shell {
  overflow: hidden;
  padding: 18px;
}

.table-wrap {
  overflow-x: auto;
}

.table-title {
  font-weight: 900;
  min-width: 180px;
}

.table-actions {
  white-space: nowrap;
}

.table-actions .button {
  margin: 3px;
}

.share-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(220px, 1fr) auto;
  min-width: 340px;
}

.share-row input {
  font-size: 0.86rem;
  min-height: 38px;
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 900;
  padding: 5px 10px;
  text-transform: capitalize;
}

.badge-published {
  background: #e8f5f2;
  color: var(--teal-dark);
}

.badge-draft {
  background: #fff7ed;
  color: var(--amber);
}

.badge-archived {
  background: #f1f5f9;
  color: #475467;
}

.empty {
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.editor-layout {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 360px;
}

.editor-main,
.editor-side {
  padding: 18px;
}

.editor-side {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 84px;
}

.builder-toolbar {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.builder-toolbar select {
  max-width: 240px;
}

.field-list {
  display: grid;
  gap: 12px;
}

.field-editor {
  background: #fbfcfd;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.field-editor-top {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(180px, 1fr) 180px auto;
  margin-bottom: 12px;
}

.field-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.field-actions button {
  min-width: 42px;
  padding-left: 10px;
  padding-right: 10px;
}

.field-editor-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-editor-grid label {
  display: grid;
  gap: 6px;
}

.field-editor-grid .wide-field {
  grid-column: 1 / -1;
}

.required-toggle {
  align-items: center;
  display: flex;
  gap: 8px;
  min-height: 42px;
}

.required-toggle input {
  min-height: auto;
  width: auto;
}

.detail-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  margin-bottom: 18px;
}

.answer-table th {
  min-width: 220px;
  text-transform: none;
}

.visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

@media (max-width: 980px) {
  .page-heading,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-layout,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .editor-side {
    position: static;
  }
}

@media (max-width: 720px) {
  .topbar,
  .public-topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 14px 18px;
  }

  .topnav {
    flex-wrap: wrap;
    gap: 12px;
  }

  .page {
    padding: 22px 14px 48px;
  }

  .public-form-shell,
  .auth-panel,
  .success-panel,
  .table-shell,
  .editor-main,
  .editor-side {
    padding: 16px;
  }

  .metric-grid,
  .field-editor-grid,
  .field-editor-top,
  .share-row {
    grid-template-columns: 1fr;
  }

  .rating-grid {
    grid-template-columns: repeat(5, minmax(44px, 1fr));
  }

  .button-row,
  .builder-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .builder-toolbar select {
    max-width: none;
  }
}
