:root {
  color-scheme: light;
  --bg: #f6fbfa;
  --surface: #ffffff;
  --surface-soft: #eef9f7;
  --line: #d6ebe7;
  --line-strong: #a5d6cf;
  --ink: #14312e;
  --muted: #60706d;
  --tosca: #0f8f84;
  --tosca-deep: #09675f;
  --tosca-soft: #dcf7f3;
  --gold: #d99518;
  --blue: #2176ae;
  --rose: #d14f6a;
  --violet: #7657c8;
  --green: #2f9e44;
  --shadow: 0 16px 40px rgba(18, 67, 61, 0.1);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(15, 143, 132, 0.12), transparent 300px),
    var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1180px;
  padding: 1.25rem clamp(1rem, 4vw, 2rem) 1rem;
}

.topbar:has(.view-tabs:empty) {
  justify-content: flex-start;
}

.eyebrow {
  color: var(--tosca-deep);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 0.3rem;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  letter-spacing: 0;
  line-height: 1.16;
  margin: 0;
}

h1 {
  font-size: clamp(1.4rem, 3vw, 2.25rem);
}

h2 {
  font-size: clamp(1.28rem, 2.2vw, 1.9rem);
}

.view-tabs {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: flex;
  gap: 0.25rem;
  padding: 0.3rem;
}

.tab-link {
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
  padding: 0.75rem 1rem;
  text-decoration: none;
  white-space: nowrap;
}

.tab-link.is-active {
  background: var(--tosca);
  color: #fff;
}

main {
  margin: 0 auto;
  max-width: 1180px;
  padding: 0 clamp(1rem, 4vw, 2rem) 3rem;
}

.view-shell {
  animation: fadeIn 180ms ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.intro-strip,
.dashboard-head,
.metrics-row,
.notice-line,
.reflection-form,
.lock-panel,
.respondent-panel,
.chart-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.intro-strip {
  align-items: center;
  background: var(--surface);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 1.15rem;
}

.intro-strip p,
.private-note p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0.45rem 0 0;
}

.status-pill {
  background: var(--tosca-soft);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--tosca-deep);
  flex: 0 0 auto;
  font-size: 0.9rem;
  font-weight: 800;
  padding: 0.7rem 0.9rem;
}

.status-pill.is-error {
  background: #fff3d9;
  border-color: #f0c879;
  color: #8a5700;
}

.reflection-form {
  background: var(--surface);
  display: grid;
  gap: 1.1rem;
  margin-top: 1rem;
  padding: 1.15rem;
}

.lock-panel {
  background: var(--surface);
  margin: 0 auto;
  max-width: 34rem;
  padding: 1.25rem;
}

.lock-panel p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0.5rem 0 0;
}

.pin-form {
  display: grid;
  gap: 0.8rem;
  margin-top: 1.1rem;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 0;
  padding: 1rem;
}

legend {
  color: var(--tosca-deep);
  font-weight: 900;
  padding: 0 0.35rem;
}

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

.identity-grid legend,
.private-note legend {
  grid-column: 1 / -1;
}

label {
  color: var(--ink);
  display: grid;
  font-size: 0.98rem;
  font-weight: 800;
  gap: 0.45rem;
}

input,
textarea {
  background: #fbfefd;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  outline: none;
  padding: 0.85rem 0.9rem;
  width: 100%;
}

input:focus,
textarea:focus {
  border-color: var(--tosca);
  box-shadow: 0 0 0 4px rgba(15, 143, 132, 0.12);
}

.question-list {
  display: grid;
  gap: 1rem;
}

.question-title {
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 900;
  line-height: 1.4;
  margin-bottom: 0.35rem;
}

.choice-hint {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.35;
  margin: 0 0 0.85rem;
}

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

.choice-option {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  gap: 0.65rem;
  min-height: 3.2rem;
  padding: 0.75rem 0.8rem;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.choice-option:hover {
  border-color: var(--tosca);
  transform: translateY(-1px);
}

.choice-option:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.55;
}

.choice-option:has(input:disabled):hover {
  border-color: var(--line);
  transform: none;
}

.choice-option input {
  accent-color: var(--tosca);
  height: 1.05rem;
  width: 1.05rem;
}

.choice-option:has(input:checked) {
  background: var(--tosca-soft);
  border-color: var(--tosca);
}

.choice-option span {
  font-weight: 800;
  line-height: 1.25;
}

.private-note textarea {
  margin-top: 0.8rem;
  min-height: 8rem;
  resize: vertical;
}

.form-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.primary-button,
.ghost-button,
.danger-button {
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 900;
  min-height: 2.9rem;
  padding: 0.8rem 1rem;
}

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

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--tosca-deep);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.ghost-button {
  background: #fff;
  border: 1px solid var(--line-strong);
  color: var(--tosca-deep);
}

.ghost-button:hover,
.ghost-button:focus-visible {
  background: var(--surface-soft);
}

.danger-button {
  background: #fff1f1;
  border: 1px solid #f0b4bd;
  color: #a3172d;
}

.danger-button:hover,
.danger-button:focus-visible {
  background: #ffe2e5;
}

.danger-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.form-message {
  color: var(--muted);
  font-weight: 800;
  margin: 0;
}

.form-message.is-success {
  color: var(--green);
}

.form-message.is-error {
  color: #b42318;
}

.dashboard-message {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  margin: 0;
  min-height: 1.3rem;
  text-align: right;
}

.dashboard-message.is-success {
  color: var(--green);
}

.dashboard-message.is-error {
  color: #b42318;
}

.dashboard-head {
  align-items: center;
  background: var(--surface);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 1.1rem;
}

.dashboard-toolbox {
  display: grid;
  gap: 0.45rem;
  justify-items: end;
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: flex-end;
}

.metrics-row {
  background: var(--surface);
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 1rem;
  padding: 1rem;
}

.metric-box {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 6rem;
  padding: 0.9rem;
}

.metric-box span {
  color: var(--muted);
  display: block;
  font-size: 0.88rem;
  font-weight: 800;
}

.metric-box strong {
  display: block;
  font-size: clamp(1.25rem, 3vw, 2rem);
  margin-top: 0.35rem;
}

.notice-line {
  background: #fff9e8;
  border-color: #f0d99a;
  color: #765000;
  font-weight: 800;
  line-height: 1.45;
  margin-top: 1rem;
  padding: 0.9rem 1rem;
}

.respondent-panel {
  align-items: start;
  background: var(--surface);
  display: grid;
  gap: 0.9rem;
  grid-template-columns: minmax(12rem, 0.35fr) 1fr;
  margin-top: 1rem;
  padding: 1rem;
}

.respondent-panel h3 {
  font-size: 1.05rem;
}

.initial-list {
  align-content: start;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  max-height: 10.5rem;
  overflow: auto;
  padding-right: 0.2rem;
}

.initial-chip {
  background: var(--tosca-soft);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--tosca-deep);
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
  min-width: 2.45rem;
  padding: 0.55rem 0.65rem;
  text-align: center;
}

.initial-chip.is-muted {
  background: #eef2f1;
  border-color: var(--line);
  color: var(--muted);
}

.dashboard-grid {
  align-items: start;
  display: grid;
  gap: 1rem;
  grid-auto-rows: auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1rem;
}

.chart-panel {
  background: var(--surface);
  height: auto;
  min-height: 23rem;
  min-width: 0;
  padding: 1rem;
}

.chart-panel.is-bar {
  min-height: 28rem;
}

.chart-panel.is-donut {
  min-height: 23rem;
}

.chart-panel h3 {
  font-size: 1.05rem;
  line-height: 1.35;
  min-height: 3rem;
  overflow-wrap: anywhere;
}

.chart-meta {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  margin: 0.35rem 0 1rem;
}

.donut-layout {
  align-items: center;
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(8.25rem, 10.5rem) minmax(0, 1fr);
  min-width: 0;
}

.donut-ring {
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  width: min(100%, 10.5rem);
}

.donut-ring::after {
  background: var(--surface);
  border-radius: 50%;
  content: "";
  inset: 23%;
  position: absolute;
}

.donut-ring strong {
  font-size: 1.8rem;
  position: relative;
  z-index: 1;
}

.legend-list {
  display: grid;
  gap: 0.58rem;
  min-width: 0;
}

.legend-item,
.bar-row {
  align-items: center;
  display: grid;
  gap: 0.55rem;
}

.legend-item {
  grid-template-columns: 0.8rem minmax(0, 1fr) auto;
  min-width: 0;
}

.color-dot {
  border-radius: 50%;
  height: 0.8rem;
  width: 0.8rem;
}

.legend-label,
.bar-label {
  font-weight: 800;
  line-height: 1.25;
  min-width: 0;
  overflow-wrap: anywhere;
}

.legend-value,
.bar-count {
  color: var(--muted);
  font-weight: 900;
  white-space: nowrap;
}

.bar-list {
  display: grid;
  gap: 0.68rem;
  min-width: 0;
}

.bar-row {
  grid-template-columns: minmax(7.5rem, 1.05fr) minmax(7rem, 2fr) minmax(4.8rem, auto);
  min-width: 0;
}

.bar-count {
  justify-self: end;
}

.bar-track {
  background: #e8f1ef;
  border-radius: 999px;
  height: 0.85rem;
  overflow: hidden;
}

.bar-fill {
  background: var(--tosca);
  border-radius: inherit;
  height: 100%;
  min-width: 0.2rem;
  transition: width 240ms ease;
}

.empty-state {
  align-items: center;
  background: rgba(238, 249, 247, 0.7);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  display: flex;
  font-weight: 800;
  justify-content: center;
  min-height: 12rem;
  padding: 1rem;
  text-align: center;
}

@media (max-width: 820px) {
  .topbar,
  .intro-strip,
  .dashboard-head {
    align-items: stretch;
    flex-direction: column;
  }

  .view-tabs,
  .dashboard-toolbox,
  .dashboard-actions {
    width: 100%;
  }

  .tab-link,
  .dashboard-actions .ghost-button,
  .dashboard-actions .danger-button {
    flex: 1;
    text-align: center;
  }

  .dashboard-message {
    text-align: left;
  }

  .identity-grid,
  .metrics-row,
  .dashboard-grid,
  .respondent-panel,
  .donut-layout {
    grid-template-columns: 1fr;
  }

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

  .chart-panel h3 {
    min-height: auto;
  }
}

@media (max-width: 1080px) {
  .dashboard-grid,
  .donut-layout {
    grid-template-columns: 1fr;
  }

  .chart-panel,
  .chart-panel.is-bar,
  .chart-panel.is-donut {
    min-height: auto;
  }

  .donut-ring {
    justify-self: center;
  }
}

@media (min-width: 980px) {
  body.dashboard-active .topbar {
    max-width: 1400px;
  }

  body.dashboard-active main {
    max-width: 1400px;
  }
}

#dashboard-content:fullscreen {
  background: var(--bg);
  overflow: auto;
  padding: 1rem;
}

body.is-presentation .dashboard-head,
body.is-presentation .metrics-row,
body.is-presentation .notice-line,
body.is-presentation .respondent-panel,
body.is-presentation .dashboard-grid {
  box-shadow: none;
}

body.is-presentation .dashboard-grid {
  gap: 0.85rem;
}
