/* =============================================================================
   AI Content Risk Scanner — design tokens (light default)
   ============================================================================= */
:root {
  color-scheme: light;

  /* Reference breakpoints (documented; queries use literal px for clarity) */
  --bp-320: 320px;
  --bp-360: 360px;
  --bp-390: 390px;
  --bp-480: 480px;
  --bp-600: 600px;
  --bp-768: 768px;
  --bp-1024: 1024px;
  --bp-1280: 1280px;
  --bp-1440: 1440px;
  --bp-1920: 1920px;

  --layout-max-width: min(1380px, 100%);
  --sidebar-left-width: 220px;
  --sidebar-right-width: 260px;
  --workspace-gap: clamp(12px, 2vw, 20px);

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #f8fafc;

  /* Transparent so the tool blends into host pages when embedded */
  --surface-page: transparent;
  --surface-elevated: #ffffff;
  --surface-panel: #ffffff;
  --surface-tool: #ffffff;
  --surface-input: #ffffff;
  --surface-code: #eef2f7;
  --surface-muted: #f8fafc;
  --surface-history: #f8fafc;
  --surface-overlay: rgba(15, 23, 42, 0.55);

  --border-default: #cbd5e1;
  --border-soft: #e2e8f0;
  --border-panel: #e2e8f0;
  --border-divider: #e2e8f0;
  --border-history: #e2e8f0;

  --accent-green: #16a34a;
  --accent-green-dark: #15803d;
  --accent-brand: #22c55e;
  --accent-purple: #7c3aed;
  --accent-sky: #0ea5e9;
  --accent-ink: #111827;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.12);
  --shadow-panel: 0 8px 22px rgba(15, 23, 42, 0.07);
  --shadow-panel-hover: 0 14px 32px rgba(15, 23, 42, 0.1);

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;

  --space-page: clamp(12px, 3vw, 28px);
  --space-panel: clamp(14px, 3.2vw, 22px);
  --space-tool: clamp(16px, 3.5vw, 32px);
  --touch-min: 44px;

  --transition-fast: 0.15s ease;
  --transition-theme: background 0.25s ease, color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

body.dark {
  color-scheme: dark;

  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  --surface-page: transparent;
  --surface-elevated: #111827;
  --surface-panel: #151c2c;
  --surface-tool: #111827;
  --surface-input: #1e293b;
  --surface-code: #1e293b;
  --surface-muted: #1e293b;
  --surface-history: #1a2332;
  --surface-overlay: rgba(0, 0, 0, 0.65);

  --border-default: #334155;
  --border-soft: #2d3a4f;
  --border-panel: #2d3a4f;
  --border-divider: #2d3a4f;
  --border-history: #334155;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
  --shadow-panel: 0 10px 28px rgba(0, 0, 0, 0.4);
  --shadow-panel-hover: 0 16px 36px rgba(0, 0, 0, 0.5);
}

@media (min-width: 1920px) {
  :root {
    --layout-max-width: min(1480px, 92vw);
    --workspace-gap: 22px;
  }
}

@media (min-width: 1440px) and (max-width: 1919px) {
  :root {
    --layout-max-width: min(1380px, 94vw);
  }
}

/* =============================================================================
   Reset & base
   ============================================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

button,
textarea,
input,
label.switch {
  touch-action: manipulation;
}

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: clamp(15px, 0.45vw + 14px, 17px);
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--surface-page);
  transition: var(--transition-theme);
  
}

body.dark {
  color: var(--text-primary);
}

.page-root {
  width: 100%;
  max-width: 100%;
}

.wrapper {
  width: 100%;
  max-width: 100%;
}

.layout-shell {
  width: 100%;
  max-width: var(--layout-max-width);
  margin-inline: auto;
}

.app-layout {
  width: 100%;
}

/* =============================================================================
   Header & brand
   ============================================================================= */
.tool-header {
  margin-bottom: clamp(14px, 2.5vw, 22px);
}

.header-inner {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2vw, 14px);
}

.tool-header-wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px 16px;
}

.brand-title {
  font-weight: 700;
  font-size: clamp(1rem, 2vw, 1.2rem);
  letter-spacing: -0.02em;
}

.highlight-w {
  color: var(--accent-brand);
}

.tool-title {
  margin: 0;
  flex: 1 1 auto;
  min-width: min(100%, 12rem);
  font-size: clamp(1.25rem, 4vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.theme-toggle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: clamp(0.875rem, 2vw, 0.95rem);
  color: var(--text-secondary);
}

body.dark .theme-toggle {
  color: var(--text-muted);
}

#themeLabel {
  user-select: none;
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background-color: var(--border-default);
  transition: background var(--transition-fast);
}

.switch .slider::before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  transition: transform var(--transition-fast);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.switch input:focus-visible + .slider {
  outline: 2px solid var(--accent-sky);
  outline-offset: 2px;
}

.switch input:checked + .slider {
  background-color: var(--accent-green);
}

.switch input:checked + .slider::before {
  transform: translateX(24px);
}

.switch .slider.round {
  border-radius: 28px;
}

/* =============================================================================
   Workspace layout (mobile-first → desktop)
   ============================================================================= */
.workspace-grid {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--workspace-gap);
  width: 100%;
  max-width: 100%;
}

.workspace-grid > * {
  min-width: 0;
  max-width: 100%;
}

/* Main tool first on small screens */
.center-workspace {
  order: -1;
}

.sidebar-left,
.sidebar-right {
  order: 0;
}

@media (min-width: 1024px) {
  .workspace-grid {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
  }

  .center-workspace {
    order: 0;
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(
      100% - var(--sidebar-left-width) - var(--sidebar-right-width) - 2 * var(--workspace-gap)
    );
  }

  .sidebar-left {
    flex: 0 0 var(--sidebar-left-width);
    width: var(--sidebar-left-width);
    order: 0;
  }

  .sidebar-right {
    flex: 0 0 var(--sidebar-right-width);
    width: var(--sidebar-right-width);
    order: 0;
  }
}

@media (min-width: 1280px) {
  .sidebar-left {
    flex-basis: 232px;
    width: 232px;
  }

  .sidebar-right {
    flex-basis: 272px;
    width: 272px;
  }

  .center-workspace {
    max-width: calc(100% - 232px - 272px - 2 * var(--workspace-gap));
  }
}

@media (min-width: 1440px) {
  .workspace-grid {
    gap: 22px;
  }
}

/* =============================================================================
   Panels
   ============================================================================= */
.panel {
  background: var(--surface-panel);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-xl);
  padding: var(--space-panel);
  box-shadow: var(--shadow-panel);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), var(--transition-theme);
}

@media (hover: hover) and (pointer: fine) {
  .panel:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-panel-hover);
  }
}

.panel-title {
  margin: 0 0 12px;
  font-size: clamp(1rem, 2.2vw, 1.08rem);
  font-weight: 650;
}

.panel-section {
  margin-top: 16px;
  border-top: 1px solid var(--border-divider);
  padding-top: 14px;
}

.panel-section h3 {
  margin: 0 0 10px;
  font-size: clamp(0.95rem, 2vw, 1.02rem);
}

/* =============================================================================
   Tool surface (center column)
   ============================================================================= */
.tool-surface {
  position: relative;
  background: var(--surface-tool);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-md);
  padding: var(--space-tool);
  transition: var(--transition-theme);
}

.tool-container {
  margin-top: 4px;
}

.fullscreen-btn {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  width: auto;
  margin: 0;
  padding: 8px 12px;
  font-size: 1.1rem;
  line-height: 1;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  background: var(--surface-muted);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.fullscreen-btn:hover {
  background: var(--surface-code);
  transform: none;
}

.input-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: clamp(0.9rem, 2vw, 0.95rem);
  color: var(--text-secondary);
}

body.dark .input-label {
  color: var(--text-muted);
}

textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: clamp(160px, 35vh, 260px);
  padding: clamp(12px, 2.5vw, 16px);
  margin-bottom: clamp(14px, 2vw, 20px);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  font-size: max(16px, 1rem);
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  background: var(--surface-input);
  color: var(--text-primary);
  transition: var(--transition-theme);
}

textarea:focus-visible {
  outline: 2px solid var(--accent-sky);
  outline-offset: 2px;
  border-color: var(--accent-sky);
}

.results-heading {
  margin: clamp(8px, 2vw, 16px) 0 10px;
  font-size: clamp(1.05rem, 2.5vw, 1.2rem);
  font-weight: 650;
}

pre {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface-code);
  color: var(--text-primary);
  padding: clamp(12px, 2.5vw, 18px);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: clamp(0.8rem, 2.4vw, 0.9rem);
  line-height: 1.5;
  transition: var(--transition-theme);
}

/* Risk bars (graph) */
.graph-output {
  width: 100%;
  max-width: 100%;
  margin-top: clamp(10px, 2vw, 16px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.graph-output .bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-height: max(34px, var(--touch-min));
  margin-bottom: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-align: right;
  color: #fff;
  font-weight: 600;
  font-size: clamp(0.68rem, 2.8vw, 0.82rem);
  line-height: 1.25;
  transition: width 0.55s ease, background 0.25s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 600px) {
  .graph-output .bar {
    font-size: clamp(0.75rem, 1.5vw, 0.85rem);
    min-height: 38px;
  }
}

@media (min-width: 1024px) {
  .graph-output .bar {
    min-height: 36px;
  }
}

/* =============================================================================
   Buttons — default CTA strip; sidebars override
   ============================================================================= */
button {
  font-family: inherit;
}

button:not(.close-popup):not(.fullscreen-btn) {
  display: block;
  
  min-height: var(--touch-min);
  padding: 12px 16px;
  font-size: max(16px, 1rem);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  cursor: pointer;
  margin-bottom: 10px;
  transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

button:not(.close-popup):not(.fullscreen-btn):hover {
  transform: translateY(-1px);
}

button:not(.close-popup):not(.fullscreen-btn):active {
  transform: translateY(0);
}

.sidebar-left button:not(.fullscreen-btn) {
  width: 100%;
  display: block;
  padding: 12px 14px;
  margin-bottom: 10px;
  font-size: max(16px, 0.98rem);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent-ink);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.sidebar-left button:not(.fullscreen-btn):hover {
  background: #1f2937;
}

#scanFreeBtn {
  background: linear-gradient(135deg, var(--accent-green), var(--accent-green-dark));
}

#scanFreeBtn:hover {
  background: linear-gradient(135deg, var(--accent-green-dark), #166534);
}

#premiumBtn {
  background: linear-gradient(135deg, #8b5cf6, var(--accent-purple));
}

#premiumBtn:hover {
  background: linear-gradient(135deg, var(--accent-purple), #6d28d9);
}

#exportPdfBtn {
  background: linear-gradient(135deg, #38bdf8, var(--accent-sky));
}

#exportPdfBtn:hover {
  background: linear-gradient(135deg, var(--accent-sky), #0284c7);
}

#copyEmbedBtn,
.embed-box .copy-btn {
  background: linear-gradient(135deg, var(--accent-green), var(--accent-green-dark));
  color: #fff;
  max-width: 120px;
}

#copyEmbedBtn:hover,
.embed-box .copy-btn:hover {
  background: linear-gradient(135deg, var(--accent-green-dark), #166534);
}

.history-actions button:hover {
  background: linear-gradient(135deg, #334155, #1e293b);
}

.clear-history-btn {
  width: auto;
  min-height: 40px;
  margin: 0;
  padding: 8px 14px;
  font-size: max(14px, 0.9rem);
  background: var(--surface-muted);
  color: var(--text-primary);
  border: 1px solid var(--border-soft);
}

.clear-history-btn:hover {
  background: var(--surface-code);
  transform: none;
}

body.dark .clear-history-btn {
  background: var(--surface-input);
  border-color: var(--border-default);
}

.history-actions button {
  margin: 0;
  width: auto;
  flex: 1 1 auto;
  min-width: min(100%, 5.5rem);
  min-height: var(--touch-min);
  padding: 10px 8px;
  font-size: max(14px, 0.9rem);
  background: linear-gradient(135deg, #475569, #334155);
  color: #fff;
  border: none;
}

.copy-btn {
  max-width: 100%;
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: min(100%, 220px);
}

.close-popup {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  margin: 0;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
  color: inherit;
  transition: background var(--transition-fast);
}

.close-popup:hover {
  background: var(--surface-muted);
  transform: none;
}

button.btn-loading {
  cursor: wait;
  opacity: 0.88;
  transform: none;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action-buttons button {
  margin-bottom: 0;
}

/* =============================================================================
   History
   ============================================================================= */
.history-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.history-header .panel-title {
  margin: 0;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(55vh, 520px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-right: 2px;
}

@media (min-width: 1024px) {
  .history-list {
    max-height: min(62vh, 600px);
  }
}

.history-item {
  border: 1px solid var(--border-history);
  border-radius: var(--radius-lg);
  padding: clamp(10px, 2vw, 12px);
  background: var(--surface-history);
  transition: border-color 0.2s ease, background 0.2s ease;
}

@media (hover: hover) {
  .history-item:hover {
    border-color: var(--border-default);
    background: var(--surface-muted);
  }
}

body.dark .history-item:hover {
  border-color: #4b5563;
  background: #1e293b;
}

.history-preview {
  margin: 0 0 8px;
  font-size: max(14px, 0.875rem);
  line-height: 1.45;
  color: var(--text-secondary);
  word-break: break-word;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-empty {
  margin: 8px 0;
  color: var(--text-muted);
  font-size: max(14px, 0.9rem);
}

.history-edit-input {
  width: 100%;
  max-width: 100%;
  min-height: 88px;
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  font-size: max(16px, 1rem);
  font-family: inherit;
  line-height: 1.45;
  resize: vertical;
  background: var(--surface-input);
  color: var(--text-primary);
}

/* =============================================================================
   Payment modal
   ============================================================================= */
.payment-popup {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  margin: 0;
  border: none;
  background: var(--surface-overlay);
  backdrop-filter: blur(4px);
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.payment-popup.payment-popup--open {
  display: flex;
}

@media (min-width: 600px) {
  .payment-popup {
    align-items: center;
  }
}

.payment-content {
  position: relative;
  width: 100%;
  max-width: 500px;
  margin-block: auto;
  background: var(--surface-tool);
  color: var(--text-primary);
  padding: clamp(20px, 4vw, 32px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
  border: 1px solid var(--border-soft);
}

#paypal-button-container {
  width: 100%;
  max-width: 100%;
  min-height: 48px;
  margin-top: 12px;
}

#paymentStatus {
  margin-top: 12px;
  font-size: max(14px, 0.9rem);
  word-break: break-word;
}

/* =============================================================================
   Status & toast
   ============================================================================= */
.app-status {
  min-height: 1.35rem;
  margin: 0 0 12px;
  font-size: max(14px, 0.9rem);
  color: var(--text-muted);
}

.app-status--info {
  color: #2563eb;
}

body.dark .app-status--info {
  color: #93c5fd;
}

.app-status--success {
  color: var(--accent-green);
}

body.dark .app-status--success {
  color: #86efac;
}

.app-status--error {
  color: #dc2626;
}

body.dark .app-status--error {
  color: #fca5a5;
}

.app-toast {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  left: max(12px, env(safe-area-inset-left));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: auto;
  max-width: min(400px, calc(100vw - 24px));
  margin-inline: auto;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: max(14px, 0.9rem);
  line-height: 1.45;
  background: var(--accent-ink);
  color: #f9fafb;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 10000;
}

@media (min-width: 480px) {
  .app-toast {
    left: auto;
    margin-inline: 0;
  }
}

body.dark .app-toast {
  background: #030712;
  color: #e5e7eb;
}

.app-toast--visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.app-toast--success {
  border-left: 4px solid #22c55e;
}

.app-toast--error {
  border-left: 4px solid #ef4444;
}

.app-toast--info {
  border-left: 4px solid #3b82f6;
}

/* =============================================================================
   Below-fold: embed, similar tools, SEO, FAQ, footer
   ============================================================================= */
.below-layout-content {
  width: 100%;
  max-width: var(--layout-max-width);
  margin-inline: auto;
  margin-top: clamp(18px, 3vw, 28px);
  padding-bottom: clamp(8px, 2vw, 16px);
}

.embed-box,
.similar-tools {
  margin-top: clamp(18px, 3vw, 26px);
}

.embed-box h3,
.similar-tools h3 {
  font-size: clamp(1.05rem, 2.5vw, 1.2rem);
  margin: 0 0 10px;
}

.embed-box p {
  margin: 0 0 12px;
  color: var(--text-secondary);
  font-size: max(15px, 0.95rem);
  max-width: 65ch;
}

.embed-code textarea {
  width: 100%;
  max-width: 100%;
  min-height: clamp(120px, 28vh, 180px);
}

.similar-tools ul {
  margin: 0;
  padding-left: 1.25rem;
  max-width: 165ch;
}

.similar-tools li {
  margin-bottom: 8px;
  word-break: break-word;
}

.supporting-content {
  width: 100%;
  max-width: var(--layout-max-width);
  margin-inline: auto;
}

.tool-seo-content,
.tool-faq {
  margin-top: clamp(24px, 4vw, 40px);
  padding: clamp(16px, 3vw, 28px);
  background: var(--surface-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.tool-seo-content h2,
.tool-faq h3 {
  font-size: clamp(1.15rem, 3vw, 1.45rem);
  line-height: 1.3;
  margin: 0 0 12px;
}

.tool-seo-content h3 {
  font-size: clamp(1.02rem, 2.5vw, 1.2rem);
  margin: 1.25em 0 8px;
}

.tool-seo-content p,
.tool-faq p {
  max-width: 65ch;
  color: var(--text-secondary);
  font-size: max(15px, 0.95rem);
}

.tool-seo-content ul,
.tool-seo-content ol,
.tool-faq ul {
  max-width: 65ch;
  padding-left: 1.25rem;
  color: var(--text-secondary);
  font-size: max(15px, 0.95rem);
}

.tool-seo-content li,
.tool-faq li {
  margin-bottom: 6px;
}

.tool-faq h4 {
  font-size: clamp(1rem, 2.2vw, 1.1rem);
  margin: 1.2em 0 6px;
  color: var(--text-primary);
}

.tool-legal {
  margin-top: clamp(22px, 3vw, 32px);
  padding: clamp(14px, 2.5vw, 20px);
  max-width: var(--layout-max-width);
  margin-inline: auto;
  font-size: max(14px, 0.9rem);
  color: var(--text-muted);
  line-height: 1.55;
  border-top: 1px solid var(--border-soft);
}

.tool-legal p {
  margin: 0;
  max-width: 75ch;
}

/* Scroll to top */
.scroll-btn-wrapper {
  display: flex;
  justify-content: center;
  margin-top: clamp(14px, 2.5vw, 22px);
  padding-inline: var(--space-page);
}

#scrollTopBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  max-width: 100%;
  min-width: min(100%, 200px);
  min-height: var(--touch-min);
  padding: 12px 20px;
  margin: 0;
  background: var(--accent-ink);
  color: #fff;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
}

#scrollTopBtn:hover {
  background: #1f2937;
}

.arrow-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: currentcolor;
}

/* =============================================================================
   Breakpoint tuning (320 → 1920): complements fluid clamp() values
   ============================================================================= */
@media (min-width: 360px) {
  :root {
    --space-page: clamp(14px, 3.2vw, 24px);
  }
}

@media (min-width: 390px) {
  .tool-header-wrapper {
    align-items: center;
  }
}

@media (min-width: 480px) {
  .header-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }

  .tool-header-wrapper {
    flex: 1 1 auto;
    min-width: 0;
  }

  .theme-toggle {
    flex-shrink: 0;
  }
}

@media (min-width: 600px) {
  .below-layout-content {
    padding-inline: clamp(0px, 1.5vw, 16px);
  }
}

@media (min-width: 1280px) {
  .tool-seo-content,
  .tool-faq {
    padding: clamp(22px, 2.5vw, 36px);
  }
}

@media (min-width: 1024px) and (max-height: 520px) and (orientation: landscape) {
  .history-list {
    max-height: min(38vh, 420px);
  }

  .graph-output .bar {
    min-height: 32px;
  }
}

/* =============================================================================
   Tablet band (768–1023)
   ============================================================================= */
@media (min-width: 768px) and (max-width: 1023px) {
  .history-actions {
    flex-wrap: nowrap;
  }
}

/* =============================================================================
   Fine typography scaling at very small widths
   ============================================================================= */
@media (max-width: 359px) {
  body {
    font-size: 14px;
  }

  .panel {
    padding: 12px;
  }

  .tool-surface {
    padding: 14px;
  }
}

/* =============================================================================
   Reduced motion
   ============================================================================= */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .graph-output .bar {
    transition: none;
  }
}
