/* Site Footer & Compliance Styles */
.site-footer {
  margin-top: 48px;
  padding: 24px 16px 36px 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.site-footer-inner {
  max-width: var(--site-max-width, 1080px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: inherit;
  text-decoration: none;
}

.footer-brand-symbol,
.footer-brand-wordmark {
  display: block;
  height: 34px;
  object-fit: contain;
}

.footer-brand-symbol {
  width: 34px;
}

.footer-brand-wordmark {
  width: 134px;
}

.footer-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 9999px;
  background: var(--chip-bg, #eee9dc);
  color: var(--chip-text, #444);
  font-weight: 500;
  font-size: 12px;
}

.footer-privacy-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--brand, #123f38);
  box-shadow: 0 0 0 3px rgba(18, 63, 56, 0.1);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}

.footer-link {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
}

.footer-link:hover {
  color: var(--text-primary, #1d1c1a);
  text-decoration: underline;
}

/* Compliance Modal */
.compliance-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.compliance-modal[hidden] {
  display: none;
}

.compliance-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.compliance-dialog {
  position: relative;
  background: var(--panel, #ffffff);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.15);
  z-index: 1;
}

.compliance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.compliance-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary, #1d1c1a);
}

.compliance-close-btn,
.history-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.compliance-close-btn:hover,
.history-close-btn:hover {
  color: var(--text-primary, #1d1c1a);
  background: rgba(0, 0, 0, 0.05);
}

.compliance-body {
  padding: 24px;
  overflow-y: auto;
  line-height: 1.65;
  font-size: 14px;
  color: var(--text-primary, #1d1c1a);
}

.compliance-intro {
  margin-top: 0;
  margin-bottom: 16px;
  font-weight: 500;
}

.compliance-section {
  margin-bottom: 18px;
}

.compliance-section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 4px 0;
}

.compliance-section-body {
  margin: 0;
  color: var(--muted);
  white-space: pre-line;
}

/* History Drawer */
.history-is-open {
  overflow: hidden;
}

.history-drawer {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  justify-content: flex-end;
}

.history-drawer[hidden] {
  display: none;
}

.history-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.history-panel {
  position: relative;
  background: var(--panel, #ffffff);
  width: 100%;
  max-width: 440px;
  height: 100vh;
  height: 100dvh;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  z-index: 1;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  min-width: 0;
}

.history-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.history-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.history-close-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
}

.history-close-btn:hover,
.history-close-btn:focus-visible {
  border-color: var(--brand);
  background: var(--panel-muted);
  outline: none;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

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

.history-empty p {
  font-size: 13px;
  margin-top: 6px;
}

.history-item-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: var(--card-bg, #fdfcf9);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.history-score-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.history-score-badge.tone-likely-ai { background: rgba(184, 50, 39, 0.14); color: #b83227; }
.history-score-badge.tone-elevated { background: rgba(217, 119, 6, 0.14); color: #d97706; }
.history-score-badge.tone-likely-human { background: rgba(43, 122, 75, 0.12); color: #2b7a4b; }
.history-score-badge.tone-uncertain { background: rgba(100, 100, 100, 0.1); color: #666; }

.history-item-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.history-item-context {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.history-item-kind {
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.history-item-preview {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-primary, #1d1c1a);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
}

.history-item-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 4px;
}

.history-item-actions .button {
  min-height: 42px;
  border-radius: 11px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 650;
}

.history-item-actions .button-quiet {
  min-width: 70px;
}

.history-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-alt, #faf8f5);
  flex: 0 0 auto;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.history-notice {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

.history-result-notice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  gap: 8px 12px;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(53, 95, 86, 0.2);
  border-radius: 12px;
  color: var(--text-secondary);
  background: rgba(53, 95, 86, 0.06);
  font-size: 13px;
  line-height: 1.5;
}

.history-result-notice strong {
  color: var(--brand);
  font-size: 13px;
}

.history-result-notice.is-summary-only {
  border-color: rgba(176, 126, 42, 0.24);
  background: rgba(176, 126, 42, 0.08);
}

.history-result-notice.is-summary-only strong {
  color: #8a5f1e;
}

/* Nav History Button: mirror the top navigation link treatment used by Return Home. */
.nav-history-btn {
  min-height: 44px;
  padding: 0 15px;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.nav-history-btn:hover,
.nav-history-btn:focus-visible {
  color: var(--text);
  border-color: var(--border);
  background: var(--panel-muted);
}

.nav-history-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(53, 95, 86, 0.06);
}

/* Export Actions in Result Page */
.export-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button-export {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.button-sm {
  padding: 4px 8px;
  font-size: 12px;
}

.button-xs {
  padding: 2px 6px;
  font-size: 11px;
}

/* Completed-result report controls live with the local signal map heading. */
body[data-page="result"] .analysis-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

body[data-page="result"] .analysis-heading h3 {
  min-width: 0;
  margin: 0;
}

body[data-page="result"] .analysis-heading .export-actions {
  flex: 0 0 auto;
  margin-left: auto;
  justify-content: flex-end;
  gap: 9px;
}

body[data-page="result"] .analysis-heading .button-sm {
  min-height: 36px;
  padding: 0 13px;
  border-radius: 10px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
  box-shadow: none;
}

body[data-page="result"] #copySummaryBtn {
  color: var(--text-secondary);
  border-color: var(--border);
  background: transparent;
}

body[data-page="result"] #copySummaryBtn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--panel-muted);
  box-shadow: none;
}

body[data-page="result"] #exportReportBtn {
  min-width: 108px;
  color: #f8f7f2;
  border-color: var(--brand);
  background: var(--brand);
  box-shadow: 0 4px 12px rgba(53, 95, 86, 0.12);
}

body[data-page="result"] #exportReportBtn:hover:not(:disabled) {
  color: #fff;
  border-color: var(--brand-hover);
  background: var(--brand-hover);
  box-shadow: 0 6px 15px rgba(41, 77, 70, 0.14);
}

@media (max-width: 520px) {
  .history-panel {
    max-width: none;
    box-shadow: none;
  }

  .history-header {
    padding: max(12px, env(safe-area-inset-top)) 14px 12px;
    gap: 10px;
  }

  .history-title {
    font-size: 18px;
  }

  .history-header-actions {
    gap: 6px;
  }

  .history-header-actions .button-sm {
    min-height: 44px;
    padding: 0 10px;
    font-size: 12px;
  }

  .history-list {
    padding: 14px;
    gap: 10px;
  }

  .history-item-card {
    padding: 13px;
  }

  .history-item-top {
    align-items: flex-start;
  }

  .history-item-context {
    align-items: flex-end;
    flex-direction: column;
    gap: 5px;
  }

  .history-item-preview {
    font-size: 14px;
    line-height: 1.5;
  }

  .history-item-actions .button {
    min-height: 46px;
  }

  .history-footer {
    padding: 12px 14px max(14px, env(safe-area-inset-bottom));
  }

  .history-notice {
    font-size: 12px;
  }

  .history-result-notice {
    grid-template-columns: 1fr;
    gap: 3px;
    margin-bottom: 12px;
  }

  body[data-page="result"] .analysis-heading {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
  }

  body[data-page="result"] .analysis-heading .export-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
}

@media (max-width: 350px) {
  .history-header {
    align-items: flex-start;
  }

  .history-title {
    padding-top: 11px;
    font-size: 16px;
  }

  .history-header-actions .button-sm {
    padding-inline: 8px;
  }

  .history-item-actions {
    grid-template-columns: 1fr;
  }

  .history-item-actions .button-quiet {
    width: 100%;
  }
}
