:root {
  --bg: #fafaf9;
  --card: #ffffff;
  --border: #e7e5e4;
  --text: #1c1917;
  --muted: #78716c;
  --accent: #0f766e;
  --accent-soft: #ccfbf1;
  --accent-strong: #134e4a;
  --warn: #b45309;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --radius: 14px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

main.wide {
  max-width: 1100px;
}

header {
  margin-bottom: 32px;
}

h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 4px;
}

.lede {
  color: var(--muted);
  font-size: 16px;
  margin: 0;
}

.section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.section.highlight {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-soft) 0%, #ffffff 60%);
}

.section h2 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section .section-sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 20px;
}

.question {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.question:first-of-type {
  border-top: none;
  padding-top: 4px;
}

.question .label {
  font-size: 16px;
  margin-bottom: 14px;
  font-weight: 500;
}

/* --- Weather scale ----------------------------------------------------- */

.weather {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.weather button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 4px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  color: var(--muted);
  -webkit-tap-highlight-color: transparent;
}

.weather button:hover {
  border-color: var(--muted);
  color: var(--text);
}

.weather button.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  transform: scale(1.04);
}

.weather button svg {
  width: 20px;
  height: 20px;
}

.section h2 svg,
h3 svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.heatmap .row-label svg {
  width: 14px;
  height: 14px;
}

.btn svg {
  width: 14px;
  height: 14px;
}

.weather .lbl {
  font-size: 11px;
  font-weight: 500;
}

/* --- Open questions / textarea ----------------------------------------- */

.open-question {
  position: relative;
}

textarea {
  width: 100%;
  min-height: 120px;
  padding: 14px 50px 14px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  transition: border-color 0.15s ease;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: white;
}

.mic {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.mic:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.mic.recording {
  background: #dc2626;
  border-color: #dc2626;
  color: white;
  animation: pulse 1.2s infinite;
}

.mic svg {
  width: 14px;
  height: 14px;
}

.mic-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

/* --- Buttons ----------------------------------------------------------- */

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.btn {
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--text);
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

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

/* --- Progress ---------------------------------------------------------- */

.progress {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 12px 0;
  z-index: 10;
  margin: -12px 0 24px;
}

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

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.progress-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

/* --- Thank you screen -------------------------------------------------- */

.thanks {
  text-align: center;
  padding: 48px 24px;
}

.thanks svg {
  width: 44px;
  height: 44px;
  color: var(--accent);
  margin-bottom: 16px;
}

/* --- Results dashboard ------------------------------------------------- */

.metric-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
}

.metric-big {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
  line-height: 1;
}

.metric-label {
  color: var(--muted);
  font-size: 14px;
}

.heatmap {
  display: grid;
  grid-template-columns: 100px repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.heatmap .cell {
  padding: 16px 8px;
  text-align: center;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.heatmap .head {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  background: transparent;
  text-align: center;
  padding: 8px;
}

.heatmap .row-label {
  font-weight: 500;
  font-size: 14px;
  text-align: left;
  padding: 16px 8px;
  display: flex;
  align-items: center;
}

.heatmap .val {
  font-size: 22px;
}

.heatmap .val .small {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.75;
  margin-top: 2px;
}

.histogram {
  margin: 12px 0 20px;
}

.hist-q {
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--text);
}

.hist-bars {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  align-items: end;
  height: 70px;
}

.hist-bar {
  background: var(--accent-soft);
  border-radius: 4px 4px 0 0;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-height: 4px;
}

.hist-bar .fill {
  background: var(--accent);
  width: 100%;
  border-radius: 4px 4px 0 0;
  transition: height 0.4s ease;
}

.hist-bar .count {
  position: absolute;
  top: -18px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

.hist-axis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-top: 4px;
}

.hist-axis .ax {
  text-align: center;
  font-size: 10px;
  color: var(--muted);
}

.hist-summary {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

/* --- Open answers / themes -------------------------------------------- */

.theme {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.theme-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.theme-label {
  font-weight: 600;
  font-size: 14px;
}

.theme-mentions {
  font-size: 12px;
  color: var(--muted);
  background: white;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.theme-summary {
  font-size: 14px;
  color: var(--text);
}

.outlier {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
  border-left: 2px solid var(--border);
  padding-left: 10px;
  margin: 6px 0;
}

.tension {
  background: #fef3c7;
  border-left: 3px solid var(--warn);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  margin-top: 8px;
}

.headline {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
  padding: 16px 20px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent);
}

.raw-answer {
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 4px 0;
}

details summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
  margin-top: 8px;
}

details summary:hover {
  color: var(--text);
}

details[open] summary {
  margin-bottom: 8px;
}

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

.notice {
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 12px;
}

.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-top: 8px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 720px) {
  main { padding: 16px 14px 80px; }
  h1 { font-size: 24px; }
  .section { padding: 18px; }
  .heatmap { grid-template-columns: 80px repeat(3, 1fr); }
  .heatmap .cell { padding: 12px 4px; }
  .heatmap .val { font-size: 18px; }
  .split { grid-template-columns: 1fr; }
  .weather button { padding: 10px 2px; }
  .weather button svg { width: 16px; height: 16px; }
  .weather .lbl { font-size: 10px; }
}
