/* ===========================================
   SSI Standards-Quiz
   Baut auf /style.css (pf-tool-main / pf-tool-frame) auf.
   =========================================== */

.sq-body {
  --sq-primary: #3b22a3;
  --sq-primary-dark: #2c1b80;
  --sq-primary-soft: rgba(59, 34, 163, 0.07);
  --sq-primary-line: rgba(59, 34, 163, 0.22);
  --sq-accent: #f4c542;
  --sq-ink: #1f1d2b;
  --sq-muted: #5d5a70;
  --sq-line: #e3e0ec;
  --sq-surface: #ffffff;
  --sq-surface-2: #f7f6fb;
  --sq-ok: #1f7a4d;
  --sq-ok-soft: #e5f4ec;
  --sq-mid: #9a6700;
  --sq-mid-soft: #fff5d6;
  --sq-bad: #b3261e;
  --sq-bad-soft: #fdeceb;
  --sq-radius: 14px;
  --sq-radius-sm: 10px;
  --sq-shadow: 0 1px 2px rgba(31, 29, 43, 0.06), 0 6px 24px rgba(59, 34, 163, 0.07);
  --sq-focus: 0 0 0 3px rgba(59, 34, 163, 0.3);
}

.sq-main.pf-tool-main { max-width: 1040px; }
.pf-tool-frame.sq-frame {
  max-width: none;
  padding: 0;
  overflow: hidden;
  border-radius: var(--sq-radius);
  box-shadow: var(--sq-shadow);
  color: var(--sq-ink);
}

/* ---------- Kopf ---------- */
.sq-hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px 24px;
  padding: 28px 28px 26px;
  color: #fff;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(244, 197, 66, 0.28) 0%, rgba(244, 197, 66, 0) 45%),
    linear-gradient(135deg, #2c1b80 0%, #3b22a3 55%, #5234c9 100%);
}
.sq-hero h1, .pf-tool-frame .sq-hero h1:first-of-type {
  margin: 8px 0 6px;
  font-size: clamp(1.5rem, 3.2vw, 2rem);
  line-height: 1.15;
  color: #fff;
  letter-spacing: -0.01em;
}
.sq-intro { margin: 0; max-width: 60ch; line-height: 1.55; color: rgba(255, 255, 255, 0.88); }
.sq-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.sq-user { display: flex; gap: 12px; align-items: center; font-size: 0.9rem; color: rgba(255, 255, 255, 0.85); }
.sq-user a { color: var(--sq-accent); font-weight: 600; }

/* ---------- Hinweise ---------- */
.sq-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  margin: 20px 28px 0;
  padding: 14px 18px;
  border: 1px solid var(--sq-primary-line);
  border-radius: var(--sq-radius-sm);
  background: var(--sq-primary-soft);
}
.sq-note strong { color: var(--sq-primary); }
.sq-note p { margin: 3px 0 0; line-height: 1.5; max-width: 72ch; }
.sq-note--accent { border-color: #ecd48a; background: #fffaeb; }
.sq-note--accent p { margin: 0; }
.sq-note--inline { margin: 16px 0 0; }
.sq-note[hidden] { display: none; }

/* ---------- App-Fläche ---------- */
.sq-app { padding: 24px 28px 30px; }
.sq-app h2 { margin: 0 0 16px; font-size: 1.3rem; color: var(--sq-ink); }
.sq-app h3 { margin: 0 0 6px; font-size: 1.05rem; color: var(--sq-primary); }
.sq-hint { margin: 0 0 12px; color: var(--sq-muted); font-size: 0.9rem; line-height: 1.5; }
.sq-error { margin: 12px 0 0; color: var(--sq-bad); font-weight: 600; }
.sq-error[hidden] { display: none; }
.sq-good { margin: 0; padding: 12px 14px; border-radius: var(--sq-radius-sm); background: var(--sq-ok-soft); color: var(--sq-ok); font-weight: 600; }

.sq-panel {
  margin-top: 22px;
  padding: 20px;
  border: 1px solid var(--sq-line);
  border-radius: var(--sq-radius);
  background: var(--sq-surface);
}
.sq-panel:empty { display: none; }

/* ---------- Start ---------- */
.sq-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.sq-modes [data-slot] { display: contents; }
.sq-mode {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  text-align: left;
  border: 1px solid var(--sq-line);
  border-radius: var(--sq-radius);
  background: var(--sq-surface);
  color: var(--sq-ink);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.sq-mode:hover:not(:disabled) { border-color: var(--sq-primary); box-shadow: var(--sq-shadow); transform: translateY(-2px); }
.sq-mode:focus-visible { outline: none; box-shadow: var(--sq-focus); }
.sq-mode:disabled { cursor: not-allowed; opacity: 0.6; background: var(--sq-surface-2); }
.sq-mode-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--sq-primary-soft);
  color: var(--sq-primary);
  font-size: 1.3rem;
  font-weight: 800;
}
.sq-mode:not(:disabled):hover .sq-mode-icon { background: var(--sq-primary); color: #fff; }
.sq-mode-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sq-mode-text strong { font-size: 1rem; }
.sq-mode-text span { font-size: 0.86rem; color: var(--sq-muted); line-height: 1.35; }

/* ---------- Frage ---------- */
.sq-qhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.sq-counter { font-size: 0.85rem; font-weight: 700; color: var(--sq-muted); letter-spacing: 0.02em; text-transform: uppercase; }
.sq-progress { height: 6px; border-radius: 999px; background: var(--sq-line); overflow: hidden; margin-bottom: 18px; }
.sq-progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--sq-primary), #6d4fe0); transition: width 0.35s ease; }

.sq-card {
  padding: 22px;
  border: 1px solid var(--sq-line);
  border-radius: var(--sq-radius);
  background: var(--sq-surface);
  box-shadow: var(--sq-shadow);
}
.sq-statement {
  position: relative;
  margin: 0 0 22px;
  padding: 4px 0 4px 20px;
  border-left: 4px solid var(--sq-accent);
  font-size: 1.12rem;
  line-height: 1.6;
  color: var(--sq-ink);
}

.sq-choice, .sq-ref { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.sq-choice legend, .sq-ref legend { padding: 0; margin-bottom: 8px; font-weight: 700; font-size: 0.95rem; }
.sq-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sq-choice legend { grid-column: 1 / -1; }
.sq-choice-opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: 2px solid var(--sq-line);
  border-radius: var(--sq-radius-sm);
  background: var(--sq-surface);
  cursor: pointer;
  font-weight: 600;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.sq-choice-opt input { position: absolute; opacity: 0; pointer-events: none; }
.sq-choice-opt::before {
  content: "";
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border: 2px solid #b9b5c9;
  border-radius: 50%;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sq-choice-opt:hover { border-color: var(--sq-primary-line); }
.sq-choice-opt:has(input:checked) { border-color: var(--sq-primary); background: var(--sq-primary-soft); }
.sq-choice-opt:has(input:checked)::before { border-color: var(--sq-primary); box-shadow: inset 0 0 0 4px #fff; background: var(--sq-primary); }
.sq-choice-opt:has(input:focus-visible) { box-shadow: var(--sq-focus); }
.sq-choice-opt:has(input:disabled) { cursor: default; }
.sq-choice .sq-choice-opt.is-correct { border-color: var(--sq-ok); background: var(--sq-ok-soft); color: var(--sq-ok); }
.sq-choice .sq-choice-opt.is-wrong { border-color: var(--sq-bad); background: var(--sq-bad-soft); color: var(--sq-bad); }
.sq-choice .sq-choice-opt.is-correct:has(input:checked)::before { border-color: var(--sq-ok); background: var(--sq-ok); box-shadow: inset 0 0 0 4px var(--sq-ok-soft); }
.sq-choice .sq-choice-opt.is-wrong::before { border-color: var(--sq-bad); background: var(--sq-bad); box-shadow: inset 0 0 0 4px var(--sq-bad-soft); }
.sq-choice .sq-choice-opt.is-correct:not(:has(input:checked))::before { border-color: var(--sq-ok); }

.sq-ref { padding: 16px; border-radius: var(--sq-radius-sm); background: var(--sq-surface-2); }
.sq-ref legend { float: left; width: 100%; margin-bottom: 2px; }
.sq-ref .sq-hint { clear: both; margin-bottom: 10px; font-size: 0.84rem; }
.sq-ref-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.sq-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sq-field > span { font-size: 0.8rem; font-weight: 600; color: var(--sq-muted); }
.sq-field.is-hidden { display: none; }
.sq-ref-grid:has(.sq-field.is-hidden) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sq-input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 30px 9px 11px;
  border: 1px solid #cdc9da;
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 0.92rem;
  color: var(--sq-ink);
  cursor: pointer;
}
.sq-input:focus { outline: none; border-color: var(--sq-primary); box-shadow: var(--sq-focus); }
.sq-input:disabled { cursor: default; background: #f1f0f5; color: #77738a; }

.sq-shake { animation: sq-shake 0.45s ease; }
@keyframes sq-shake { 0%, 100% { transform: none; } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------- Rückmeldung ---------- */
.sq-feedback { margin-top: 18px; display: grid; gap: 10px; animation: sq-in 0.25s ease; }
.sq-feedback[hidden] { display: none; }
.sq-feedback:focus { outline: none; }
@keyframes sq-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.sq-fb-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--sq-radius-sm); }
.sq-fb-row p { margin: 0; line-height: 1.5; }
.sq-fb-row.is-ok { background: var(--sq-ok-soft); }
.sq-fb-row.is-part { background: var(--sq-mid-soft); }
.sq-fb-row.is-bad { background: var(--sq-bad-soft); }
.sq-fb-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
}
.is-ok > .sq-fb-icon { background: var(--sq-ok); }
.is-part > .sq-fb-icon { background: var(--sq-mid); }
.is-bad > .sq-fb-icon { background: var(--sq-bad); }
.sq-path { margin: 6px 0 0 !important; font-size: 0.9rem; font-weight: 600; color: var(--sq-ink); }
.sq-path span { display: block; font-size: 0.78rem; font-weight: 600; color: var(--sq-muted); }
.sq-path--mine { font-weight: 400; color: var(--sq-muted); }
.sq-expl { padding: 14px 16px; border-radius: var(--sq-radius-sm); border: 1px solid var(--sq-line); background: var(--sq-surface-2); }
.sq-expl h3 { margin: 0 0 6px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--sq-muted); }
.sq-expl p { margin: 0; line-height: 1.6; }

/* ---------- Auswertung ---------- */
.sq-scoreline { display: flex; flex-wrap: wrap; align-items: center; gap: 20px 32px; }
.sq-ring {
  --p: 0;
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  width: 148px;
  height: 148px;
  border-radius: 50%;
  background: conic-gradient(var(--sq-primary) calc(var(--p) * 1%), var(--sq-line) 0);
}
.sq-ring::before { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--sq-surface); }
.sq-ring > * { position: relative; }
.sq-ring strong { font-size: 2.3rem; line-height: 1; color: var(--sq-primary); }
.sq-ring strong small { font-size: 1rem; margin-left: 2px; }
.sq-ring span { font-size: 0.8rem; color: var(--sq-muted); font-weight: 600; }
.sq-kpis { display: flex; flex-wrap: wrap; gap: 14px; }
.sq-kpi { min-width: 150px; padding: 14px 18px; border-radius: var(--sq-radius); background: var(--sq-surface-2); border: 1px solid var(--sq-line); }
.sq-kpi strong { display: block; font-size: 1.7rem; line-height: 1.1; }
.sq-kpi strong small { font-size: 1rem; color: var(--sq-muted); font-weight: 600; }
.sq-kpi span { font-size: 0.85rem; color: var(--sq-muted); }
.sq-ready { margin: 16px 0 0; padding: 12px 14px; border-radius: var(--sq-radius-sm); background: #fffaeb; border: 1px solid #ecd48a; }

.sq-results-grid, .sq-hist-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 0 22px; }
.sq-results-grid .sq-panel { margin-top: 22px; }
.sq-hist-grid > div + div { border-left: 1px solid var(--sq-line); padding-left: 22px; }

.sq-bars { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 12px; }
.sq-bar-label { display: flex; justify-content: space-between; gap: 10px; font-size: 0.9rem; font-weight: 600; }
.sq-bars small { color: var(--sq-muted); font-size: 0.78rem; }
.sq-bar { display: block; height: 8px; margin: 4px 0 2px; border-radius: 999px; background: var(--sq-line); overflow: hidden; }
.sq-bar span { display: block; height: 100%; border-radius: inherit; }
.sq-bar[data-level="good"] span { background: var(--sq-ok); }
.sq-bar[data-level="mid"] span { background: #d69e00; }
.sq-bar[data-level="low"] span { background: var(--sq-bad); }

.sq-weak { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.sq-weak-item { padding: 12px 14px; border: 1px solid var(--sq-line); border-radius: var(--sq-radius-sm); background: var(--sq-surface); }
.sq-weak-head { display: flex; gap: 12px; align-items: flex-start; }
.sq-weak-head strong { display: block; font-size: 0.93rem; line-height: 1.4; }
.sq-meter {
  --p: 0;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  margin-top: 2px;
  border-radius: 50%;
  --c: var(--sq-bad);
  background: radial-gradient(closest-side, var(--sq-surface) 62%, transparent 64%), conic-gradient(var(--c) calc(var(--p) * 1%), var(--sq-line) 0);
}
.sq-meter[data-level="mid"] { --c: #d69e00; }
.sq-meter[data-level="good"] { --c: var(--sq-ok); }
.sq-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.sq-tag { padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.sq-tag--rule { background: var(--sq-bad-soft); color: var(--sq-bad); }
.sq-tag--ref { background: var(--sq-mid-soft); color: var(--sq-mid); }
.sq-weak-count { font-size: 0.78rem; color: var(--sq-muted); }
.sq-confused { margin: 6px 0 0; font-size: 0.83rem; color: var(--sq-muted); }

.sq-review { display: grid; gap: 8px; }
.sq-review-item { border: 1px solid var(--sq-line); border-radius: var(--sq-radius-sm); background: var(--sq-surface); }
.sq-review-item summary { padding: 12px 14px; cursor: pointer; line-height: 1.5; list-style-position: outside; margin-left: 14px; }
.sq-review-item[open] summary { border-bottom: 1px solid var(--sq-line); }
.sq-review-item > p { margin: 10px 16px; line-height: 1.55; }

.sq-save { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 18px; }
.sq-status { font-size: 0.9rem; color: var(--sq-muted); }
.sq-status.is-ok { color: var(--sq-ok); font-weight: 600; }
.sq-status.is-error { color: var(--sq-bad); font-weight: 600; }
p.sq-status { margin: 18px 0 0; }
.sq-note--accent p.sq-status { margin: 0; }

.sq-hist { list-style: none; margin: 10px 0 12px; padding: 0; display: grid; gap: 8px; }
.sq-hist li { display: grid; grid-template-columns: auto minmax(0, 1fr) 80px auto; align-items: center; gap: 10px; font-size: 0.88rem; }
.sq-hist-date { color: var(--sq-muted); font-variant-numeric: tabular-nums; }
.sq-hist-mode { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sq-hist strong { font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }
.sq-bar--mini { margin: 0; height: 6px; }

/* ---------- Buttons ---------- */
.sq-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.sq-actions--tight { margin-top: 0; }
.sq-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border: 1px solid var(--sq-primary);
  border-radius: 999px;
  background: var(--sq-primary);
  color: #fff;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}
.sq-btn:hover { background: var(--sq-primary-dark); box-shadow: 0 4px 12px rgba(59, 34, 163, 0.25); }
.sq-btn:active { transform: translateY(1px); }
.sq-btn:focus-visible { outline: none; box-shadow: var(--sq-focus); }
.sq-btn:disabled { opacity: 0.6; cursor: progress; box-shadow: none; }
.sq-btn--ghost { background: #fff; color: var(--sq-primary); }
.sq-btn--ghost:hover { background: var(--sq-primary-soft); box-shadow: none; }
.sq-btn--danger { background: var(--sq-bad); border-color: var(--sq-bad); }
.sq-btn--danger:hover { background: #8c1d17; box-shadow: none; }
.sq-link {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--sq-primary);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.sq-link:focus-visible { outline: none; box-shadow: var(--sq-focus); border-radius: 4px; }
.sq-link--danger { color: var(--sq-bad); }

.sq-dialog { border: 0; border-radius: var(--sq-radius); padding: 22px 24px; max-width: 400px; box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25); }
.sq-dialog::backdrop { background: rgba(20, 10, 60, 0.4); }
.sq-dialog p { margin: 0; line-height: 1.55; }
.sq-dialog .sq-actions { justify-content: flex-end; }

@media (prefers-reduced-motion: reduce) {
  .sq-body * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ===========================================
   Responsive
   =========================================== */

@media (max-width: 860px) {
  .sq-modes { grid-template-columns: minmax(0, 1fr); }
  .sq-results-grid, .sq-hist-grid { grid-template-columns: minmax(0, 1fr); }
  .sq-hist-grid > div + div { border-left: 0; padding-left: 0; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--sq-line); }
  .sq-ref-grid, .sq-ref-grid:has(.sq-field.is-hidden) { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .pf-tool-frame.sq-frame { border-radius: 0; box-shadow: none; }
  .sq-hero { padding: 22px 16px 20px; }
  .sq-note { margin: 16px 16px 0; }
  .sq-note--inline { margin: 16px 0 0; }
  .sq-app { padding: 18px 16px 24px; }
  .sq-card, .sq-panel { padding: 16px; }
  .sq-statement { font-size: 1.02rem; padding-left: 14px; }
  .sq-choice { grid-template-columns: minmax(0, 1fr); }
  .sq-ring { width: 124px; height: 124px; }
  .sq-ring strong { font-size: 1.9rem; }
  .sq-kpi { min-width: 0; flex: 1 1 120px; }
  .sq-actions .sq-btn { flex: 1 1 auto; }
  .sq-hist li { grid-template-columns: auto minmax(0, 1fr) auto; }
  .sq-hist .sq-bar--mini { display: none; }
}
