/* ─── Shared theme ───────────────────────────────────────────────────────── */

:root {
  --bg-page:        #f4f4f2;
  --bg-card:        #ffffff;
  --bg-surface:     #f9f9f7;
  --bg-hover:       #ffffff;
  --bg-selected:    #e6f1fb;
  --bg-success:     #eaf3de;

  --text-primary:   #1a1a18;
  --text-secondary: #3a3a38;
  --text-muted:     #4a4a47;
  --text-faint:     #6b6b67;
  --text-accent:    #185fa5;
  --text-success:   #3b6d11;
  --text-danger:    #a32d2d;

  --border-strong:  rgba(0,0,0,0.25);
  --border-mid:     rgba(0,0,0,0.18);
  --border-soft:    rgba(0,0,0,0.12);
  --border-faint:   rgba(0,0,0,0.08);
  --border-accent:  #b5d4f4;

  --badge-bg:       #e6f1fb;
  --badge-text:     #185fa5;
  --badge-border:   #b5d4f4;

  --accent-radio:   #185fa5;
  --accent-check:   #a32d2d;

  --radius-card:    12px;
  --radius-el:      8px;
  --radius-pill:    20px;
}

[data-theme="dark"] {
  --bg-page:        #1a1a18;
  --bg-card:        #242422;
  --bg-surface:     #2c2c2a;
  --bg-hover:       #333331;
  --bg-selected:    #0c447c;
  --bg-success:     #173404;

  --text-primary:   #e8e8e4;
  --text-secondary: #c8c6c2;
  --text-muted:     #a8a6a2;
  --text-faint:     #888780;
  --text-accent:    #85b7eb;
  --text-success:   #c0dd97;
  --text-danger:    #f09595;

  --border-strong:  rgba(255,255,255,0.25);
  --border-mid:     rgba(255,255,255,0.14);
  --border-soft:    rgba(255,255,255,0.09);
  --border-faint:   rgba(255,255,255,0.05);
  --border-accent:  #0c447c;

  --badge-bg:       #0c447c;
  --badge-text:     #b5d4f4;
  --badge-border:   #185fa5;

  --accent-radio:   #85b7eb;
  --accent-check:   #f09595;
}

/* ─── Base reset ─────────────────────────────────────────────────────────── */

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

body {
  font-family: Arial, sans-serif;
  font-size: 14px;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

/* ─── Dark mode toggle button ────────────────────────────────────────────── */

.theme-toggle {
  position: absolute;
  top: -14px;
  right: 14px;
  background: var(--bg-card);
  border: 0.5px solid var(--border-mid);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: 13px;
  font-family: Arial, sans-serif;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.theme-toggle:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}
.theme-toggle .toggle-icon { font-size: 15px; line-height: 1; }

/* ─── Shared card shell ──────────────────────────────────────────────────── */

.ff-wrap {
  position: relative;
  max-width: 860px;
  margin: 0 auto;
  padding: 2rem 1rem;
  padding-top: 2rem;
}

.ff-card {
  position: relative;
  background: var(--bg-card);
  border: 0.5px solid var(--border-mid);
  border-radius: var(--radius-card);
  overflow: visible;
  transition: background 0.2s, border-color 0.2s;
}

.ff-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 0.5px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.ff-header h1 {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
}
.ff-badge {
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--badge-bg);
  color: var(--badge-text);
  border: 0.5px solid var(--badge-border);
}

.ff-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.ff-section { display: flex; flex-direction: column; gap: 8px; }

.ff-section-label {
  font-size: 14px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.ff-box {
  background: var(--bg-surface);
  border: 0.5px solid var(--border-soft);
  border-radius: var(--radius-el);
  padding: 1rem 1.25rem;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 64px;
}

.ff-box.ff-error {
  text-align: center;
  min-height: unset;
}

.ff-opted-out {
  background: var(--bg-surface);
  border: 0.5px dashed var(--border-strong);
  border-radius: var(--radius-el);
  padding: 1rem 1.25rem;
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
}

.ff-divider {
  border: none;
  border-top: 0.5px solid var(--border-soft);
}

/* ─── Questions ──────────────────────────────────────────────────────────── */

.ff-questions { display: flex; flex-direction: column; gap: 1.25rem; }
.ff-q-group   { display: flex; flex-direction: column; gap: 8px; }

.ff-q-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}
.ff-q-label .tooltip {
  border-bottom: 1px dotted var(--text-muted);
  cursor: help;
  font-weight: 400;
}

/* ─── Likert rows ────────────────────────────────────────────────────────── */

.likert-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr 0.5px 1fr;
  align-items: stretch;
  background: var(--bg-surface);
  border: 0.5px solid var(--border-soft);
  border-radius: var(--radius-el);
  overflow: hidden;
}

.likert-sep {
  background: var(--border-soft);
  width: 0.5px;
}

.likert-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  cursor: pointer;
  border-right: 0.5px solid var(--border-faint);
  transition: background 0.1s;
}
.likert-opt:last-child { border-right: none; }
.likert-opt:hover      { background: var(--bg-hover); }
.likert-opt.selected   { background: var(--bg-selected); }

.opt-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.3;
}
.likert-opt.selected .opt-label { color: var(--text-accent); }

.likert-opt input[type="radio"] {
  accent-color: var(--accent-radio);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.na-opt .opt-label            { color: var(--text-muted); }
.na-opt.selected              { background: var(--bg-surface); }
.na-opt.selected .opt-label   { color: var(--text-secondary); }

/* Mobile: stack likert vertically */
@media (max-width: 580px) {
  .likert-row {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }
  .likert-sep {
    height: 0.5px;
    width: 100%;
  }
  .likert-opt {
    flex-direction: row;
    justify-content: flex-start;
    padding: 10px 14px;
    gap: 12px;
    border-right: none;
    border-bottom: 0.5px solid var(--border-faint);
  }
  .likert-opt:last-child { border-bottom: none; }
  .opt-label {
    text-align: left;
    font-size: 13px;
  }
}

/* ─── Checkbox row ───────────────────────────────────────────────────────── */

.ff-checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 0.5px solid var(--border-soft);
  border-radius: var(--radius-el);
  cursor: pointer;
  transition: background 0.1s;
}
.ff-checkbox-row:hover { background: var(--bg-hover); }
.ff-checkbox-row input {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent-check);
}
.ff-checkbox-row label {
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
}

/* ─── Free text ──────────────────────────────────────────────────────────── */

.ff-textarea-wrap { display: flex; flex-direction: column; gap: 6px; }

.ff-textarea {
  width: 100%;
  min-height: 72px;
  max-height: 200px;
  resize: vertical;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-el);
  padding: 10px 12px;
  font-family: Arial, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: border-color 0.15s, background 0.15s;
  outline: none;
}
.ff-textarea:focus {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}
.ff-textarea::placeholder { color: var(--text-faint); }

.ff-char {
  font-size: 12px;
  color: var(--text-faint);
  text-align: right;
}

/* ─── Footer / submit ────────────────────────────────────────────────────── */

.ff-footer {
  padding: 1rem 1.5rem;
  border-top: 0.5px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
}

.ff-submit {
  background: var(--text-primary);
  color: var(--bg-card);
  border: none;
  border-radius: var(--radius-el);
  padding: 8px 20px;
  font-size: 14px;
  font-family: Arial, sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.ff-submit:hover    { opacity: 0.75; }
.ff-submit:disabled { opacity: 0.3; cursor: not-allowed; }

/* ─── Confirmation ───────────────────────────────────────────────────────── */

#confirmation {
  display: none;
  padding: 1.25rem 1.5rem;
  text-align: center;
  font-size: 14px;
  color: var(--text-success);
  font-weight: 500;
  align-items: center;
  justify-content: center;
}
#confirmation.show { display: flex; }

/* ─── Disclaimer ─────────────────────────────────────────────────────────── */

.ff-disclaimer {
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 12px;
  padding-bottom: 1rem;
}

/* ─── Markdown content ───────────────────────────────────────────────────── */

.ff-markdown h1,
.ff-markdown h2,
.ff-markdown h3,
.ff-markdown h4 {
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 1.1em;
  margin-bottom: 0.35em;
  line-height: 1.3;
}
.ff-markdown h1 { font-size: 1.15em; }
.ff-markdown h2 { font-size: 1.05em; }
.ff-markdown h3 { font-size: 1em; }
.ff-markdown h4 { font-size: 0.95em; }

.ff-markdown p { margin-bottom: 0.75em; }
.ff-markdown p:last-child { margin-bottom: 0; }

.ff-markdown ul,
.ff-markdown ol {
  padding-left: 1.5em;
  margin-bottom: 0.75em;
}
.ff-markdown li { margin-bottom: 0.3em; }

.ff-markdown code {
  font-family: monospace, monospace;
  font-size: 0.9em;
  background: var(--bg-page);
  border: 0.5px solid var(--border-soft);
  border-radius: 4px;
  padding: 1px 5px;
}

.ff-markdown pre {
  background: var(--bg-page);
  border: 0.5px solid var(--border-soft);
  border-radius: var(--radius-el);
  padding: 0.75rem 1rem;
  overflow-x: auto;
  margin-bottom: 0.75em;
}
.ff-markdown pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85em;
}

.ff-markdown blockquote {
  border-left: 3px solid var(--border-mid);
  padding: 0.25rem 0.75rem;
  margin: 0.5em 0 0.75em;
  color: var(--text-secondary);
}

.ff-markdown a { color: var(--text-accent); }

.ff-markdown > *:first-child { margin-top: 0; }

