/* socialpolitix beta — V0 vertical slice styles.
 * Intentionally minimal. Marton owns visual polish via Codex once
 * the wiring proves the loop works. */

:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-mute: #f1efe8;
  --border: #e1ddd2;
  --text: #1c1a16;
  --text-mute: #6c6960;
  --accent: #6b3fa0;        /* socialpolitix purple — sampled from logo */
  --accent-hover: #4f2c7a;
  --accent-soft: #f1ebf8;
  --error: #c0392b;
  --error-bg: #fbe9e7;
  --success: #2e7d32;
  --success-bg: #e8f5e9;
  --radius: 8px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-2: 0 4px 12px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

/* Author CSS for .topbar-user / .bootstrap-view sets display, which
 * overrides the UA's [hidden] { display: none } rule. Force hidden to
 * win regardless. */
[hidden] { display: none !important; }

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

a { color: var(--accent); }

.muted { color: var(--text-mute); font-size: 13px; margin: 4px 0 0; }

/* ─── Topbar ──────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.topbar-wordmark { font-weight: 600; font-size: 16px; }
.topbar-version {
  font-size: 11px;
  color: var(--text-mute);
  background: var(--surface-mute);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.topbar-user-email {
  font-size: 13px;
  color: var(--text-mute);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled {
  background: var(--text-mute);
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: var(--text-mute);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-mute); }
.btn-large { padding: 12px 24px; font-size: 15px; }

/* ─── Layout ──────────────────────────────────────────────────── */
.layout {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px;
}
.view { animation: fadeIn 0.15s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ─── Login view ──────────────────────────────────────────────── */
.login-view { display: flex; justify-content: center; padding-top: 60px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow-1);
}
.login-card h1 { margin: 0 0 8px; font-size: 24px; }
.login-card .lede { margin: 0 0 24px; color: var(--text-mute); }
.auth-error {
  margin: 16px 0 0;
  padding: 10px 12px;
  background: var(--error-bg);
  border: 1px solid var(--error);
  border-radius: var(--radius);
  color: var(--error);
  font-size: 13px;
  text-align: left;
}

/* ─── Workspace ──────────────────────────────────────────────── */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
@media (min-width: 900px) {
  .workspace-grid { grid-template-columns: 2fr 1fr; }
}
/* sasha-083: grid (and flex) items default to `min-width: auto`, which means
   they refuse to shrink below their content's min-content width. A wide child
   in the result column (chiefly the Beste-Zeiten heatmap table) then forces
   the column wider than the viewport, producing page-level horizontal scroll
   at narrower widths. Allowing the columns to shrink fixes the page overflow;
   the heatmap keeps its own `overflow-x: auto` container, so on very narrow
   screens it scrolls WITHIN itself while the page stays put. */
.workspace-grid > .primary-col,
.workspace-grid > .history-col {
  min-width: 0;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 20px; }
.card header h2 { margin: 0 0 4px; font-size: 17px; }

/* ─── Dropzone ───────────────────────────────────────────────── */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 16px 0 0;
  padding: 36px 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-mute);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.dropzone:hover, .dropzone:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}
.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone.is-busy {
  cursor: wait;
  opacity: 0.7;
}
.dropzone-icon {
  font-size: 28px;
  color: var(--accent);
}
.dropzone-label { font-size: 14px; color: var(--text); }
.dropzone-hint { font-size: 12px; color: var(--text-mute); }

.upload-status, .upload-error {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
}
.upload-status {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--accent);
}
.upload-error {
  background: var(--error-bg);
  border: 1px solid var(--error);
  color: var(--error);
}

/* ─── Result ─────────────────────────────────────────────────── */
.result-card { animation: slideUp 0.18s ease-out; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.result-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 12px 0 16px;
  font-size: 13px;
  color: var(--text-mute);
}
.result-meta-row strong { color: var(--text); font-weight: 600; }
.topic-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.topic-row {
  display: grid;
  grid-template-columns: 140px 1fr 56px;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.topic-row:first-child { border-top: 0; }
.topic-name { font-weight: 500; }
.topic-bar {
  height: 8px;
  background: var(--surface-mute);
  border-radius: 4px;
  overflow: hidden;
}
.topic-bar-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}
.topic-pct {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-mute);
  font-size: 13px;
}
.sample-section { margin-top: 20px; }
.sample-section h3 { margin: 0 0 8px; font-size: 14px; }
.sample-empty {
  padding: 12px;
  background: var(--surface-mute);
  border-radius: var(--radius);
  color: var(--text-mute);
  font-size: 13px;
  font-style: italic;
}

/* ─── History list ──────────────────────────────────────────── */
.history-col h2 { margin: 0 0 12px; font-size: 15px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.history-list li.history-empty {
  color: var(--text-mute);
  font-size: 13px;
  font-style: italic;
}
.history-list a {
  display: block;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  font-size: 13px;
  transition: background 0.12s, border-color 0.12s;
}
.history-list a:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.history-list .history-time {
  display: block;
  color: var(--text-mute);
  font-size: 11px;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.history-list a.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 500;
}

/* ─── Bootstrap ─────────────────────────────────────────────── */
.bootstrap-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

/* ─── History sections (sasha-048: previous CSVs sibling list) ─ */
.history-section + .history-section { margin-top: 24px; }
.history-section h2 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-mute);
}

.csv-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.csv-history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}
.csv-history-meta { flex: 1; min-width: 0; }
.csv-history-name {
  display: block;
  font-weight: 500;
  color: var(--text);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.csv-history-sub {
  display: block;
  margin-top: 2px;
  color: var(--text-mute);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.csv-history-reanalyze {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent-soft);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.csv-history-reanalyze:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.csv-history-reanalyze:disabled {
  opacity: 0.5;
  cursor: wait;
}
.csv-history-empty {
  margin: 0;
  font-size: 12px;
  color: var(--text-mute);
  font-style: italic;
}

/* ─── Footer (sasha-048) ──────────────────────────────────── */
.page-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 16px 24px 24px;
  font-size: 12px;
  color: var(--text-mute);
}
.footer-link {
  color: var(--text-mute);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
  background: transparent;
}
.footer-link:hover { color: var(--text); text-decoration-color: currentColor; }
.footer-link-button {
  border: 0;
  font: inherit;
  cursor: pointer;
  padding: 0;
}
.footer-sep { color: var(--border); }
.footer-meta { color: var(--text-mute); opacity: 0.6; }

/* ─── Modal (privacy + delete-data) ──────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 26, 22, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
  animation: fadeIn 0.12s ease-out;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-2);
  animation: slideUp 0.15s ease-out;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-card h2 { margin: 0 0 8px; font-size: 18px; }
.modal-lede {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.55;
}
.modal-language-toggle {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-mute);
}
.modal-language-toggle summary {
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  color: var(--accent);
  list-style: none;
}
.modal-language-toggle summary::-webkit-details-marker { display: none; }
.modal-language-toggle summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.12s;
  margin-right: 4px;
}
.modal-language-toggle[open] summary::before {
  transform: rotate(90deg);
}
.modal-language-toggle p {
  margin: 8px 0 0;
  padding-left: 16px;
  border-left: 2px solid var(--border);
  color: var(--text-mute);
  line-height: 1.55;
}
.modal-policy-link {
  margin: 0 0 20px;
  font-size: 13px;
}
.modal-policy-link a { color: var(--accent); text-decoration: underline; }
.modal-todo {
  margin: 12px 0 16px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
}
.modal-todo a { color: var(--accent); text-decoration: underline; }
.modal-confirm-prompt {
  margin: 12px 0 8px;
  font-size: 13px;
  color: var(--text-mute);
}
.modal-email {
  display: inline-block;
  margin-left: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  color: var(--text);
}
.modal-input {
  width: 100%;
  padding: 8px 10px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-mute);
  color: var(--text);
}
.modal-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.modal-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.btn-danger {
  background: var(--error);
  color: #fff;
  border: 1px solid var(--error);
}
.btn-danger:hover { background: #a32c1f; }
.btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--text-mute);
  border-color: var(--text-mute);
}

/* ─── Accessibility helper ─────────────────────────────────────────── */
/* Visually hidden but available to screen readers (sasha-080). Used for
   table captions and axis labels that sighted users infer from layout. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─── Beste Posting-Zeiten view (sasha-080 / akira-143) ────────────── */
.posting-times {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.pt-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.posting-times h3 {
  margin: 0;
  font-size: 16px;
}

.pt-demo-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent-hover);
  background: var(--accent-soft);
  border: 1px solid #d8c8ee;
  border-radius: 999px;
  padding: 2px 9px;
  cursor: help;
}

.pt-caption {
  margin-top: 6px;
}

.pt-lowdata {
  margin: 14px 0 0;
  padding: 12px 14px;
  background: var(--surface-mute);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-mute);
  font-size: 14px;
}

/* Top-window chips — the plain-language takeaway, Akira's German verbatim. */
.pt-windows {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pt-chip {
  font-size: 13px;
  line-height: 1.35;
  color: var(--text);
  background: var(--accent-soft);
  border: 1px solid #e2d5f4;
  border-radius: var(--radius);
  padding: 7px 12px;
}

/* Heatmap — a semantic table; colour is supplementary to the printed ×. */
.pt-heatmap-wrap {
  margin-top: 16px;
  overflow-x: auto;
}

.pt-heatmap {
  border-collapse: separate;
  border-spacing: 4px;
  width: 100%;
  min-width: 360px;
}

.pt-heatmap th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mute);
  text-align: center;
  padding: 2px;
}

.pt-heatmap th.pt-rowhead {
  text-align: right;
  padding-right: 6px;
  white-space: nowrap;
}

.pt-heatmap th.pt-rowhead abbr {
  text-decoration: none;
  cursor: help;
}

.pt-cell {
  text-align: center;
  vertical-align: middle;
  height: 38px;
  min-width: 52px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.pt-cell--empty {
  background: var(--surface-mute);
  color: var(--text-mute);
  font-weight: 400;
}

.pt-legend {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.5;
}

/* ─── Risiko view (sasha-081 / akira-144) ──────────────────────────── */
.risk-view {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.risk-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.risk-view h3 {
  margin: 0;
  font-size: 16px;
}

.risk-caption {
  margin-top: 6px;
}

/* Risk badge — band conveyed by TEXT label + colour (not colour-only). */
.risk-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: #ffffff;
  border-radius: 999px;
  padding: 4px 9px;
  white-space: nowrap;
}
.risk-badge--red { background: #c0392b; }
.risk-badge--amber { background: #a86b00; }
.risk-badge--green { background: #2e7d32; }

.risk-dist {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 14px 0 0;
  padding: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.risk-dist-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.risk-topics {
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--surface-mute);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.risk-topics h4 {
  margin: 0 0 6px;
  font-size: 14px;
}
.risk-topics ul {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
}
.risk-topics ul li { margin: 2px 0; }
.risk-topics-placeholder { margin: 0; font-size: 13px; }

.risk-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
}
.risk-list-title { font-size: 14px; font-weight: 600; }

.risk-sort {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  cursor: pointer;
}
.risk-sort:hover { background: var(--accent-soft); border-color: #d8c8ee; }

.risk-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}
.risk-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--surface);
}
.risk-row-main {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}
.risk-score {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  text-align: right;
  color: var(--text);
}
.risk-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.risk-text--id { color: var(--text-mute); font-style: italic; }

.risk-why-toggle {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  white-space: nowrap;
}
.risk-why-toggle:hover { text-decoration: underline; }

.risk-why {
  padding: 0 12px 12px 12px;
  border-top: 1px solid var(--border);
}
.risk-why-signals {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 16px;
  justify-content: start;
  margin: 12px 0 0;
  font-size: 13px;
}
.risk-why-signals dt { color: var(--text-mute); }
.risk-why-signals dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.risk-why-note { margin-top: 8px; font-size: 12px; }
.risk-empty { margin-top: 14px; }

/* ─── Empfehlungen capstone (sasha-082 / akira-145) ────────────────── */
.recs {
  margin: 0 0 8px;
  padding: 16px;
  background: var(--accent-soft);
  border: 1px solid #e2d5f4;
  border-radius: var(--radius);
}

.recs-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.recs h3 {
  margin: 0;
  font-size: 17px;
  color: var(--accent-hover);
}
.recs-sub { margin-top: 4px; }

.recs-lowdata,
.recs-needs-topics {
  margin: 12px 0 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-mute);
  font-size: 14px;
  line-height: 1.5;
}
.recs-needs-topics strong { color: var(--text); }

.recs-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.rec-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.rec-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
}
.rec-text--placeholder { color: var(--text-mute); font-style: italic; }

.rec-meta {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.rec-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 5px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.rec-tag--topic {
  color: var(--accent-hover);
  background: var(--accent-soft);
  border: 1px solid #d8c8ee;
}
.rec-tag--time {
  color: var(--text);
  background: var(--surface-mute);
  border: 1px solid var(--border);
}
.rec-tag--muted { color: var(--text-mute); font-style: italic; }
