:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e1e8;
  --panel: #ffffff;
  --canvas: #f5f7f9;
  --nav: #19212b;
  --blue: #2666cf;
  --blue-dark: #174ea6;
  --green: #15845b;
  --green-soft: #dff5eb;
  --coral: #be4d36;
  --coral-soft: #fde8e2;
  --amber: #a66a00;
  --amber-soft: #fff4d6;
  --shadow: 0 10px 30px rgba(23, 32, 42, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
}

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

button,
a,
select,
input,
textarea {
  border-radius: 6px;
}

button {
  min-height: 40px;
  border: 1px solid transparent;
  padding: 0 14px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--blue-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

button.secondary:hover {
  border-color: #b8c3cf;
  background: #f8fafc;
}

button.danger {
  background: var(--coral);
}

button.danger:hover {
  background: #9d3b29;
}

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

button.ghost:hover {
  background: #eef3f7;
}

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

a:hover {
  text-decoration: underline;
}

.button-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 700;
}

.button-link:hover {
  border-color: #b8c3cf;
  background: #f8fafc;
  text-decoration: none;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(38, 102, 207, 0.14);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 38px);
  border-bottom: 1px solid rgba(217, 225, 232, 0.85);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-weight: 900;
  letter-spacing: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--nav);
  color: #ffffff;
  font-weight: 900;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  min-height: calc(100vh - 67px);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #ffffff;
  padding: 22px 18px;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.sidebar-head h1,
.page-title h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.sidebar-list {
  display: grid;
  gap: 8px;
}

.survey-nav-item {
  width: 100%;
  min-height: 56px;
  display: grid;
  gap: 4px;
  border: 1px solid transparent;
  padding: 10px 12px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
}

.survey-nav-item:hover,
.survey-nav-item.active {
  border-color: #c7d8f4;
  background: #f0f6ff;
}

.survey-nav-item strong,
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.survey-nav-item span {
  color: var(--muted);
  font-size: 0.82rem;
}

.main {
  min-width: 0;
  padding: clamp(18px, 4vw, 38px);
}

.content-grid {
  display: grid;
  gap: 22px;
}

.page-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.page-title p {
  max-width: 720px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.title-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2,
.section-title {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.panel-body {
  padding: 20px;
}

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

.form-grid .span-2 {
  grid-column: 1 / -1;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.stat {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 15px;
}

.stat span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 1.8rem;
  line-height: 1;
}

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

.survey-table th,
.survey-table td {
  border-bottom: 1px solid var(--line);
  padding: 13px 12px;
  text-align: left;
  vertical-align: middle;
}

.survey-table th {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.survey-table tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  background: #eef3f7;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: capitalize;
}

.badge.published {
  background: var(--green-soft);
  color: var(--green);
}

.badge.closed {
  background: var(--coral-soft);
  color: var(--coral);
}

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

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 42px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.tab:hover {
  background: #eef3f7;
  color: var(--ink);
}

.tab.active {
  border-bottom-color: var(--blue);
  color: var(--ink);
}

.question-list {
  display: grid;
  gap: 14px;
}

.question-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.question-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.question-card-header strong {
  min-width: 0;
}

.question-form {
  display: grid;
  gap: 15px;
  padding: 16px;
}

.choice-options,
.scale-options {
  display: none;
}

.question-form[data-type="multiple_choice"] .choice-options,
.question-form[data-type="checkbox"] .choice-options,
.question-form[data-type="rating"] .scale-options,
.question-form[data-type="nps"] .scale-options {
  display: grid;
}

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

.three-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 43px;
  color: var(--ink);
  font-weight: 700;
}

.check-row input {
  width: auto;
}

.share-box {
  display: grid;
  gap: 14px;
}

.link-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.results-grid {
  display: grid;
  gap: 16px;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
}

.result-card h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(80px, 180px) 1fr minmax(36px, auto);
  gap: 10px;
  align-items: center;
  margin: 9px 0;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef4;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.text-samples {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.text-samples li {
  border-left: 3px solid var(--blue);
  background: #f7faff;
  padding: 10px 12px;
  color: #344054;
}

.auth-screen,
.public-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: var(--canvas);
}

.auth-layout,
.public-layout {
  width: min(1060px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(340px, 1fr);
  gap: 28px;
  align-items: stretch;
}

.product-panel {
  border-radius: 8px;
  background: var(--nav);
  color: #ffffff;
  padding: clamp(26px, 5vw, 44px);
  display: grid;
  align-content: space-between;
  gap: 28px;
  min-height: 520px;
}

.product-panel h1 {
  margin: 28px 0 12px;
  max-width: 520px;
  font-size: 4.25rem;
  line-height: 0.95;
  letter-spacing: 0;
}

.product-panel p {
  max-width: 480px;
  margin: 0;
  color: #c9d4df;
  font-size: 1.05rem;
  line-height: 1.6;
}

.signal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.signal {
  min-height: 84px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.signal strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.25rem;
}

.signal span {
  color: #c9d4df;
  font-size: 0.82rem;
}

.auth-card,
.public-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: clamp(22px, 4vw, 34px);
}

.auth-card h2,
.public-card h1 {
  margin: 0 0 8px;
  font-size: 1.65rem;
}

.auth-card p,
.public-card p {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-form,
.public-form {
  display: grid;
  gap: 15px;
}

.public-layout {
  grid-template-columns: minmax(0, 740px);
  justify-content: center;
}

.public-card {
  width: 100%;
}

.survey-question {
  display: grid;
  gap: 10px;
  padding: 18px 0;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.survey-question:last-of-type {
  border-bottom: 0;
}

.survey-question legend {
  margin-bottom: 10px;
  color: var(--ink);
  font-weight: 900;
}

.survey-question small {
  color: var(--muted);
}

.choice-stack,
.scale-stack {
  display: grid;
  gap: 9px;
}

.choice-stack label,
.scale-stack label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
}

.choice-stack input,
.scale-stack input {
  width: auto;
}

.scale-stack {
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
}

.scale-stack label {
  min-height: 44px;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.scale-stack label:has(input:checked) {
  border-color: var(--blue);
  background: #eef5ff;
}

.empty-state {
  border: 1px dashed #b8c3cf;
  border-radius: 8px;
  padding: 30px;
  background: #ffffff;
  color: var(--muted);
  text-align: center;
}

.loading {
  min-height: 240px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  max-width: min(420px, calc(100vw - 40px));
  border-radius: 8px;
  background: var(--nav);
  color: #ffffff;
  padding: 13px 16px;
  box-shadow: var(--shadow);
  font-weight: 700;
}

.error-text {
  color: var(--coral);
  font-weight: 700;
}

@media (max-width: 980px) {
  .workspace,
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-list {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

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

@media (max-width: 720px) {
  .topbar,
  .page-title,
  .panel-header,
  .question-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .title-actions,
  .inline-actions {
    justify-content: stretch;
  }

  .topbar-actions button,
  .title-actions button,
  .inline-actions button,
  .link-row button {
    width: 100%;
  }

  .form-grid,
  .two-columns,
  .three-columns,
  .link-row,
  .stats-grid,
  .signal-grid {
    grid-template-columns: 1fr;
  }

  .survey-table,
  .survey-table tbody,
  .survey-table tr,
  .survey-table td {
    display: block;
    width: 100%;
  }

  .survey-table thead {
    display: none;
  }

  .survey-table tr {
    border-bottom: 1px solid var(--line);
    padding: 8px 0;
  }

  .survey-table td {
    border-bottom: 0;
    padding: 8px 12px;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .product-panel {
    min-height: auto;
  }

  .product-panel h1 {
    font-size: 2.35rem;
  }
}
