Spaces:
Sleeping
Sleeping
Download static/index.html from theJamess/text-declanker: direct link, hf CLI and curl.
- Browser
- Download file 107 kB
-
https://huggingface.co/spaces/theJamess/text-declanker/resolve/main/static/index.html
- Command line
-
hf download hf://spaces/theJamess/text-declanker/static/index.html
-
curl -L -o index.html https://huggingface.co/spaces/theJamess/text-declanker/resolve/main/static/index.html
107 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Text DeClanker β AI Authorship Analysis</title>
<script src="https://cdn.plot.ly/plotly-2.27.0.min.js"
integrity="sha384-Hl48Kq2HifOWdXEjMsKo6qxqvRLTYqIGbvlENBmkHAxZKIGCXv43H6W1jA671RzC"
crossorigin="anonymous"></script>
<style>
/* @j2aq/theme-engine β GENERATED by scripts/build-css.mjs. Do not edit by hand. */
/* Edit src/palettes.js (colors) or src/styles/_base.css (semantic layer) and rebuild. */
/* ============ Base16 palettes (generated from src/palettes.js) ============ */
[data-theme="light"],
:root {
--base00: #f8f9fa;
--base01: #ffffff;
--base02: #e5e7eb;
--base03: #9ca3af;
--base04: #6b7280;
--base05: #1f2937;
--base06: #111827;
--base07: #030712;
--base08: #dc2626;
--base09: #ea580c;
--base0A: #ca8a04;
--base0B: #16a34a;
--base0C: #0891b2;
--base0D: #2563eb;
--base0E: #9333ea;
--base0F: #a16207;
}
[data-theme="dark"] {
--base00: #111827;
--base01: #1f2937;
--base02: #374151;
--base03: #6b7280;
--base04: #9ca3af;
--base05: #e5e7eb;
--base06: #f3f4f6;
--base07: #f9fafb;
--base08: #f87171;
--base09: #fb923c;
--base0A: #fbbf24;
--base0B: #34d399;
--base0C: #22d3ee;
--base0D: #60a5fa;
--base0E: #c084fc;
--base0F: #f97316;
}
[data-theme="renkin-light"] {
--base00: #fafbfc;
--base01: #ffffff;
--base02: #e8f4f8;
--base03: #94a3b8;
--base04: #5a9aae;
--base05: #1a6b7d;
--base06: #0d5566;
--base07: #094555;
--base08: #dc2626;
--base09: #ea580c;
--base0A: #d97706;
--base0B: #00e68a;
--base0C: #00c8ff;
--base0D: #00b8d4;
--base0E: #8b5cf6;
--base0F: #06b6d4;
--chat-user-bg: #7c3aed;
--chat-user-text: #ffffff;
}
[data-theme="renkin-dark"] {
--base00: #05070d;
--base01: #0d1117;
--base02: #161b22;
--base03: #6e7681;
--base04: #8dd4e8;
--base05: #c5f5ff;
--base06: #e0ffff;
--base07: #ffffff;
--base08: #ff3b3b;
--base09: #ff9500;
--base0A: #ffea00;
--base0B: #00ff88;
--base0C: #00e1ff;
--base0D: #00ffcc;
--base0E: #c77dff;
--base0F: #00ffa3;
--chat-user-bg: #7c3aed;
--chat-user-text: #ffffff;
}
[data-theme="high-contrast-light"] {
--base00: #ffffff;
--base01: #f5f5f5;
--base02: #e0e0e0;
--base03: #757575;
--base04: #424242;
--base05: #000000;
--base06: #000000;
--base07: #000000;
--base08: #b71c1c;
--base09: #e65100;
--base0A: #f57f17;
--base0B: #1b5e20;
--base0C: #006064;
--base0D: #0d47a1;
--base0E: #4a148c;
--base0F: #bf360c;
}
[data-theme="high-contrast-dark"] {
--base00: #000000;
--base01: #0d0d0d;
--base02: #1a1a1a;
--base03: #666666;
--base04: #b3b3b3;
--base05: #ffffff;
--base06: #ffffff;
--base07: #ffffff;
--base08: #ff6b6b;
--base09: #ffa94d;
--base0A: #ffd43b;
--base0B: #69db7c;
--base0C: #66d9e8;
--base0D: #74c0fc;
--base0E: #da77f2;
--base0F: #ffa94d;
}
[data-theme="gruvbox-dark"] {
--base00: #282828;
--base01: #3c3836;
--base02: #504945;
--base03: #665c54;
--base04: #bdae93;
--base05: #d5c4a1;
--base06: #ebdbb2;
--base07: #fbf1c7;
--base08: #fb4934;
--base09: #fe8019;
--base0A: #fabd2f;
--base0B: #b8bb26;
--base0C: #8ec07c;
--base0D: #83a598;
--base0E: #d3869b;
--base0F: #d65d0e;
}
[data-theme="gruvbox-light"] {
--base00: #fbf1c7;
--base01: #ebdbb2;
--base02: #d5c4a1;
--base03: #bdae93;
--base04: #665c54;
--base05: #504945;
--base06: #3c3836;
--base07: #282828;
--base08: #9d0006;
--base09: #af3a03;
--base0A: #b57614;
--base0B: #79740e;
--base0C: #427b58;
--base0D: #076678;
--base0E: #8f3f71;
--base0F: #d65d0e;
}
[data-theme="dracula"] {
--base00: #282a36;
--base01: #44475a;
--base02: #44475a;
--base03: #6272a4;
--base04: #f8f8f2;
--base05: #f8f8f2;
--base06: #f8f8f2;
--base07: #ffffff;
--base08: #ff5555;
--base09: #ffb86c;
--base0A: #f1fa8c;
--base0B: #50fa7b;
--base0C: #8be9fd;
--base0D: #bd93f9;
--base0E: #ff79c6;
--base0F: #ffb86c;
}
[data-theme="nord"] {
--base00: #2e3440;
--base01: #3b4252;
--base02: #434c5e;
--base03: #4c566a;
--base04: #d8dee9;
--base05: #e5e9f0;
--base06: #eceff4;
--base07: #ffffff;
--base08: #bf616a;
--base09: #d08770;
--base0A: #ebcb8b;
--base0B: #a3be8c;
--base0C: #88c0d0;
--base0D: #81a1c1;
--base0E: #b48ead;
--base0F: #5e81ac;
}
[data-theme="solarized-dark"] {
--base00: #002b36;
--base01: #073642;
--base02: #586e75;
--base03: #657b83;
--base04: #839496;
--base05: #93a1a1;
--base06: #eee8d5;
--base07: #fdf6e3;
--base08: #dc322f;
--base09: #cb4b16;
--base0A: #b58900;
--base0B: #859900;
--base0C: #2aa198;
--base0D: #268bd2;
--base0E: #6c71c4;
--base0F: #d33682;
}
[data-theme="solarized-light"] {
--base00: #fdf6e3;
--base01: #eee8d5;
--base02: #93a1a1;
--base03: #839496;
--base04: #657b83;
--base05: #586e75;
--base06: #073642;
--base07: #002b36;
--base08: #dc322f;
--base09: #cb4b16;
--base0A: #b58900;
--base0B: #859900;
--base0C: #2aa198;
--base0D: #268bd2;
--base0E: #6c71c4;
--base0F: #d33682;
}
[data-theme="one-dark"] {
--base00: #282c34;
--base01: #353b45;
--base02: #3e4451;
--base03: #545862;
--base04: #565c64;
--base05: #abb2bf;
--base06: #b6bdca;
--base07: #c8ccd4;
--base08: #e06c75;
--base09: #d19a66;
--base0A: #e5c07b;
--base0B: #98c379;
--base0C: #56b6c2;
--base0D: #61afef;
--base0E: #c678dd;
--base0F: #be5046;
}
[data-theme="monokai"] {
--base00: #272822;
--base01: #383830;
--base02: #49483e;
--base03: #75715e;
--base04: #a59f85;
--base05: #f8f8f2;
--base06: #f5f4f1;
--base07: #f9f8f5;
--base08: #f92672;
--base09: #fd971f;
--base0A: #f4bf75;
--base0B: #a6e22e;
--base0C: #a1efe4;
--base0D: #66d9ef;
--base0E: #ae81ff;
--base0F: #cc6633;
}
[data-theme="tokyo-night"] {
--base00: #1a1b26;
--base01: #16161e;
--base02: #2f3549;
--base03: #444b6a;
--base04: #787c99;
--base05: #a9b1d6;
--base06: #cbccd1;
--base07: #d5d6db;
--base08: #f7768e;
--base09: #ff9e64;
--base0A: #e0af68;
--base0B: #9ece6a;
--base0C: #7dcfff;
--base0D: #7aa2f7;
--base0E: #bb9af7;
--base0F: #db4b4b;
}
/* ============ Semantic layer (src/styles/_base.css) ============ */
/*
* Base16 Theming System - Semantic Aliases
*
* This file defines semantic CSS variables that map to Base16 primitives.
* Each theme file (light.css, dark.css, etc.) defines the 16 base colors,
* and this file maps them to meaningful UI roles.
*
* Components should use these semantic variables, NOT the base## primitives directly.
*
* NOTE: We use a mixin-like approach where each theme selector includes
* both the base colors AND the semantic mappings to ensure proper cascading.
*/
/* Default/Light theme semantic mappings */
:root,
[data-theme="light"] {
/* Backgrounds */
--bg-primary: var(--base00);
--bg-secondary: var(--base01);
--bg-tertiary: var(--base02);
--bg-highlight: color-mix(in srgb, var(--base0D) 10%, var(--base01));
--bg-hover: var(--base02);
--bg-active: color-mix(in srgb, var(--base0D) 15%, var(--base01));
--bg-selected: color-mix(in srgb, var(--base0D) 20%, var(--base01));
/* Text */
--text-primary: var(--base05);
--text-secondary: var(--base04);
--text-muted: var(--base03);
--text-inverted: var(--base00);
--text-disabled: var(--base03);
/* Borders */
--border-default: var(--base02);
--border-subtle: color-mix(in srgb, var(--base02) 50%, var(--base01));
--border-strong: var(--base03);
--border-focus: var(--base0D);
/* Primary Action (Blue) */
--primary: var(--base0D);
--primary-hover: color-mix(in srgb, var(--base0D) 85%, var(--base07));
--primary-active: color-mix(in srgb, var(--base0D) 70%, var(--base07));
--primary-subtle: color-mix(in srgb, var(--base0D) 10%, var(--base01));
--primary-text: var(--base07);
/* Semantic Colors */
--success: var(--base0B);
--success-subtle: color-mix(in srgb, var(--base0B) 10%, var(--base01));
--success-text: var(--base07);
--warning: var(--base0A);
--warning-subtle: color-mix(in srgb, var(--base0A) 10%, var(--base01));
--warning-text: var(--base00);
--danger: var(--base08);
--danger-subtle: color-mix(in srgb, var(--base08) 10%, var(--base01));
--danger-text: var(--base07);
--info: var(--base0C);
--info-subtle: color-mix(in srgb, var(--base0C) 10%, var(--base01));
--info-text: var(--base07);
/* Accent Colors */
--accent-purple: var(--base0E);
--accent-purple-subtle: color-mix(in srgb, var(--base0E) 10%, var(--base01));
--accent-orange: var(--base09);
--accent-orange-subtle: color-mix(in srgb, var(--base09) 10%, var(--base01));
--accent-brown: var(--base0F);
/* Shadows */
--shadow-color: var(--base06);
--shadow-sm: 0 1px 2px color-mix(in srgb, var(--shadow-color) 5%, transparent);
--shadow-md: 0 4px 6px color-mix(in srgb, var(--shadow-color) 10%, transparent);
--shadow-lg: 0 10px 15px color-mix(in srgb, var(--shadow-color) 15%, transparent);
/* Focus Ring */
--focus-ring: 0 0 0 2px var(--bg-secondary), 0 0 0 4px var(--primary);
/* Scrollbar */
--scrollbar-track: var(--base01);
--scrollbar-thumb: var(--base03);
--scrollbar-thumb-hover: var(--base04);
/* Code/Syntax (for code blocks, formulas, etc.) */
--code-bg: var(--base01);
--code-text: var(--base05);
--code-keyword: var(--base0E);
--code-string: var(--base0B);
--code-number: var(--base09);
--code-function: var(--base0D);
--code-comment: var(--base03);
--code-variable: var(--base08);
/* Status Colors (for cells, indicators) */
--status-pending: var(--base0A);
--status-processing: var(--base0D);
--status-complete: var(--base0B);
--status-error: var(--base08);
--status-skipped: var(--base03);
/* Diff Colors */
--diff-added-bg: color-mix(in srgb, var(--base0B) 15%, var(--base01));
--diff-added-text: var(--base0B);
--diff-removed-bg: color-mix(in srgb, var(--base08) 15%, var(--base01));
--diff-removed-text: var(--base08);
--diff-changed-bg: color-mix(in srgb, var(--base0A) 15%, var(--base01));
--diff-changed-text: var(--base0A);
}
/* Dark theme semantic mappings */
[data-theme="dark"] {
/* Backgrounds */
--bg-primary: var(--base00);
--bg-secondary: var(--base01);
--bg-tertiary: var(--base02);
--bg-highlight: color-mix(in srgb, var(--base0D) 10%, var(--base01));
--bg-hover: var(--base02);
--bg-active: color-mix(in srgb, var(--base0D) 15%, var(--base01));
--bg-selected: color-mix(in srgb, var(--base0D) 20%, var(--base01));
/* Text */
--text-primary: var(--base05);
--text-secondary: var(--base04);
--text-muted: var(--base03);
--text-inverted: var(--base00);
--text-disabled: var(--base03);
/* Borders */
--border-default: var(--base02);
--border-subtle: color-mix(in srgb, var(--base02) 50%, var(--base01));
--border-strong: var(--base03);
--border-focus: var(--base0D);
/* Primary Action (Blue) */
--primary: var(--base0D);
--primary-hover: color-mix(in srgb, var(--base0D) 85%, var(--base07));
--primary-active: color-mix(in srgb, var(--base0D) 70%, var(--base07));
--primary-subtle: color-mix(in srgb, var(--base0D) 10%, var(--base01));
--primary-text: var(--base07);
/* Semantic Colors */
--success: var(--base0B);
--success-subtle: color-mix(in srgb, var(--base0B) 10%, var(--base01));
--success-text: var(--base07);
--warning: var(--base0A);
--warning-subtle: color-mix(in srgb, var(--base0A) 10%, var(--base01));
--warning-text: var(--base00);
--danger: var(--base08);
--danger-subtle: color-mix(in srgb, var(--base08) 10%, var(--base01));
--danger-text: var(--base07);
--info: var(--base0C);
--info-subtle: color-mix(in srgb, var(--base0C) 10%, var(--base01));
--info-text: var(--base07);
/* Accent Colors */
--accent-purple: var(--base0E);
--accent-purple-subtle: color-mix(in srgb, var(--base0E) 10%, var(--base01));
--accent-orange: var(--base09);
--accent-orange-subtle: color-mix(in srgb, var(--base09) 10%, var(--base01));
--accent-brown: var(--base0F);
/* Shadows */
--shadow-color: var(--base06);
--shadow-sm: 0 1px 2px color-mix(in srgb, var(--shadow-color) 5%, transparent);
--shadow-md: 0 4px 6px color-mix(in srgb, var(--shadow-color) 10%, transparent);
--shadow-lg: 0 10px 15px color-mix(in srgb, var(--shadow-color) 15%, transparent);
/* Focus Ring */
--focus-ring: 0 0 0 2px var(--bg-secondary), 0 0 0 4px var(--primary);
/* Scrollbar */
--scrollbar-track: var(--base01);
--scrollbar-thumb: var(--base03);
--scrollbar-thumb-hover: var(--base04);
/* Code/Syntax */
--code-bg: var(--base01);
--code-text: var(--base05);
--code-keyword: var(--base0E);
--code-string: var(--base0B);
--code-number: var(--base09);
--code-function: var(--base0D);
--code-comment: var(--base03);
--code-variable: var(--base08);
/* Status Colors */
--status-pending: var(--base0A);
--status-processing: var(--base0D);
--status-complete: var(--base0B);
--status-error: var(--base08);
--status-skipped: var(--base03);
/* Diff Colors */
--diff-added-bg: color-mix(in srgb, var(--base0B) 15%, var(--base01));
--diff-added-text: var(--base0B);
--diff-removed-bg: color-mix(in srgb, var(--base08) 15%, var(--base01));
--diff-removed-text: var(--base08);
--diff-changed-bg: color-mix(in srgb, var(--base0A) 15%, var(--base01));
--diff-changed-text: var(--base0A);
}
/* High Contrast Dark theme semantic mappings */
[data-theme="high-contrast-dark"] {
/* Backgrounds */
--bg-primary: var(--base00);
--bg-secondary: var(--base01);
--bg-tertiary: var(--base02);
--bg-highlight: color-mix(in srgb, var(--base0D) 15%, var(--base01));
--bg-hover: var(--base02);
--bg-active: color-mix(in srgb, var(--base0D) 20%, var(--base01));
--bg-selected: color-mix(in srgb, var(--base0D) 25%, var(--base01));
/* Text */
--text-primary: var(--base05);
--text-secondary: var(--base04);
--text-muted: var(--base03);
--text-inverted: var(--base00);
--text-disabled: var(--base03);
/* Borders */
--border-default: var(--base02);
--border-subtle: var(--base02);
--border-strong: var(--base03);
--border-focus: var(--base0D);
/* Primary Action */
--primary: var(--base0D);
--primary-hover: color-mix(in srgb, var(--base0D) 85%, var(--base07));
--primary-active: color-mix(in srgb, var(--base0D) 70%, var(--base07));
--primary-subtle: color-mix(in srgb, var(--base0D) 15%, var(--base01));
--primary-text: var(--base00);
/* Semantic Colors */
--success: var(--base0B);
--success-subtle: color-mix(in srgb, var(--base0B) 15%, var(--base01));
--success-text: var(--base00);
--warning: var(--base0A);
--warning-subtle: color-mix(in srgb, var(--base0A) 15%, var(--base01));
--warning-text: var(--base00);
--danger: var(--base08);
--danger-subtle: color-mix(in srgb, var(--base08) 15%, var(--base01));
--danger-text: var(--base00);
--info: var(--base0C);
--info-subtle: color-mix(in srgb, var(--base0C) 15%, var(--base01));
--info-text: var(--base00);
/* Accent Colors */
--accent-purple: var(--base0E);
--accent-purple-subtle: color-mix(in srgb, var(--base0E) 15%, var(--base01));
--accent-orange: var(--base09);
--accent-orange-subtle: color-mix(in srgb, var(--base09) 15%, var(--base01));
--accent-brown: var(--base0F);
/* Shadows */
--shadow-color: var(--base07);
--shadow-sm: 0 1px 2px color-mix(in srgb, var(--shadow-color) 10%, transparent);
--shadow-md: 0 4px 6px color-mix(in srgb, var(--shadow-color) 15%, transparent);
--shadow-lg: 0 10px 15px color-mix(in srgb, var(--shadow-color) 20%, transparent);
/* Focus Ring */
--focus-ring: 0 0 0 3px var(--bg-secondary), 0 0 0 5px var(--primary);
/* Scrollbar */
--scrollbar-track: var(--base01);
--scrollbar-thumb: var(--base03);
--scrollbar-thumb-hover: var(--base04);
/* Code/Syntax */
--code-bg: var(--base01);
--code-text: var(--base05);
--code-keyword: var(--base0E);
--code-string: var(--base0B);
--code-number: var(--base09);
--code-function: var(--base0D);
--code-comment: var(--base03);
--code-variable: var(--base08);
/* Status Colors */
--status-pending: var(--base0A);
--status-processing: var(--base0D);
--status-complete: var(--base0B);
--status-error: var(--base08);
--status-skipped: var(--base03);
/* Diff Colors */
--diff-added-bg: color-mix(in srgb, var(--base0B) 20%, var(--base01));
--diff-added-text: var(--base0B);
--diff-removed-bg: color-mix(in srgb, var(--base08) 20%, var(--base01));
--diff-removed-text: var(--base08);
--diff-changed-bg: color-mix(in srgb, var(--base0A) 20%, var(--base01));
--diff-changed-text: var(--base0A);
}
/* High Contrast Light theme semantic mappings */
[data-theme="high-contrast-light"] {
/* Backgrounds */
--bg-primary: var(--base00);
--bg-secondary: var(--base01);
--bg-tertiary: var(--base02);
--bg-highlight: color-mix(in srgb, var(--base0D) 15%, var(--base01));
--bg-hover: var(--base02);
--bg-active: color-mix(in srgb, var(--base0D) 20%, var(--base01));
--bg-selected: color-mix(in srgb, var(--base0D) 25%, var(--base01));
/* Text */
--text-primary: var(--base05);
--text-secondary: var(--base04);
--text-muted: var(--base03);
--text-inverted: var(--base00);
--text-disabled: var(--base03);
/* Borders */
--border-default: var(--base02);
--border-subtle: var(--base02);
--border-strong: var(--base03);
--border-focus: var(--base0D);
/* Primary Action */
--primary: var(--base0D);
--primary-hover: color-mix(in srgb, var(--base0D) 85%, var(--base00));
--primary-active: color-mix(in srgb, var(--base0D) 70%, var(--base00));
--primary-subtle: color-mix(in srgb, var(--base0D) 15%, var(--base01));
--primary-text: var(--base00);
/* Semantic Colors */
--success: var(--base0B);
--success-subtle: color-mix(in srgb, var(--base0B) 15%, var(--base01));
--success-text: var(--base00);
--warning: var(--base0A);
--warning-subtle: color-mix(in srgb, var(--base0A) 15%, var(--base01));
--warning-text: var(--base00);
--danger: var(--base08);
--danger-subtle: color-mix(in srgb, var(--base08) 15%, var(--base01));
--danger-text: var(--base00);
--info: var(--base0C);
--info-subtle: color-mix(in srgb, var(--base0C) 15%, var(--base01));
--info-text: var(--base00);
/* Accent Colors */
--accent-purple: var(--base0E);
--accent-purple-subtle: color-mix(in srgb, var(--base0E) 15%, var(--base01));
--accent-orange: var(--base09);
--accent-orange-subtle: color-mix(in srgb, var(--base09) 15%, var(--base01));
--accent-brown: var(--base0F);
/* Shadows */
--shadow-color: var(--base05);
--shadow-sm: 0 1px 2px color-mix(in srgb, var(--shadow-color) 10%, transparent);
--shadow-md: 0 4px 6px color-mix(in srgb, var(--shadow-color) 15%, transparent);
--shadow-lg: 0 10px 15px color-mix(in srgb, var(--shadow-color) 20%, transparent);
/* Focus Ring */
--focus-ring: 0 0 0 3px var(--bg-secondary), 0 0 0 5px var(--primary);
/* Scrollbar */
--scrollbar-track: var(--base01);
--scrollbar-thumb: var(--base03);
--scrollbar-thumb-hover: var(--base04);
/* Code/Syntax */
--code-bg: var(--base01);
--code-text: var(--base05);
--code-keyword: var(--base0E);
--code-string: var(--base0B);
--code-number: var(--base09);
--code-function: var(--base0D);
--code-comment: var(--base03);
--code-variable: var(--base08);
/* Status Colors */
--status-pending: var(--base0A);
--status-processing: var(--base0D);
--status-complete: var(--base0B);
--status-error: var(--base08);
--status-skipped: var(--base03);
/* Diff Colors */
--diff-added-bg: color-mix(in srgb, var(--base0B) 20%, var(--base01));
--diff-added-text: var(--base0B);
--diff-removed-bg: color-mix(in srgb, var(--base08) 20%, var(--base01));
--diff-removed-text: var(--base08);
--diff-changed-bg: color-mix(in srgb, var(--base0A) 20%, var(--base01));
--diff-changed-text: var(--base0A);
}
/* Apply theme to body */
body {
background-color: var(--bg-primary);
color: var(--text-primary);
transition: background-color 0.2s ease, color 0.2s ease;
}
/* Scrollbar styling */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
background: var(--scrollbar-thumb);
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--scrollbar-thumb-hover);
}
/* βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
POPULAR BASE16 THEMES - Semantic Mappings
All themes use the same semantic structure, just different palettes
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
/* Dark themes semantic mappings */
[data-theme="gruvbox-dark"],
[data-theme="dracula"],
[data-theme="nord"],
[data-theme="solarized-dark"],
[data-theme="one-dark"],
[data-theme="monokai"],
[data-theme="tokyo-night"],
[data-theme="renkin-dark"] {
/* Backgrounds */
--bg-primary: var(--base00);
--bg-secondary: var(--base01);
--bg-tertiary: var(--base02);
--bg-highlight: color-mix(in srgb, var(--base0D) 10%, var(--base01));
--bg-hover: var(--base02);
--bg-active: color-mix(in srgb, var(--base0D) 15%, var(--base01));
--bg-selected: color-mix(in srgb, var(--base0D) 20%, var(--base01));
/* Text */
--text-primary: var(--base05);
--text-secondary: var(--base04);
--text-muted: var(--base03);
--text-inverted: var(--base00);
--text-disabled: var(--base03);
/* Borders */
--border-default: var(--base02);
--border-subtle: color-mix(in srgb, var(--base02) 50%, var(--base01));
--border-strong: var(--base03);
--border-focus: var(--base0D);
/* Primary Action */
--primary: var(--base0D);
--primary-hover: color-mix(in srgb, var(--base0D) 85%, var(--base07));
--primary-active: color-mix(in srgb, var(--base0D) 70%, var(--base07));
--primary-subtle: color-mix(in srgb, var(--base0D) 10%, var(--base01));
--primary-text: var(--base07);
/* Semantic Colors */
--success: var(--base0B);
--success-subtle: color-mix(in srgb, var(--base0B) 10%, var(--base01));
--success-text: var(--base07);
--warning: var(--base0A);
--warning-subtle: color-mix(in srgb, var(--base0A) 10%, var(--base01));
--warning-text: var(--base00);
--danger: var(--base08);
--danger-subtle: color-mix(in srgb, var(--base08) 10%, var(--base01));
--danger-text: var(--base07);
--info: var(--base0C);
--info-subtle: color-mix(in srgb, var(--base0C) 10%, var(--base01));
--info-text: var(--base07);
/* Accent Colors */
--accent-purple: var(--base0E);
--accent-purple-subtle: color-mix(in srgb, var(--base0E) 10%, var(--base01));
--accent-orange: var(--base09);
--accent-orange-subtle: color-mix(in srgb, var(--base09) 10%, var(--base01));
--accent-brown: var(--base0F);
/* Shadows */
--shadow-color: var(--base00);
--shadow-sm: 0 1px 2px color-mix(in srgb, var(--shadow-color) 20%, transparent);
--shadow-md: 0 4px 6px color-mix(in srgb, var(--shadow-color) 30%, transparent);
--shadow-lg: 0 10px 15px color-mix(in srgb, var(--shadow-color) 40%, transparent);
/* Focus Ring */
--focus-ring: 0 0 0 2px var(--bg-secondary), 0 0 0 4px var(--primary);
/* Scrollbar */
--scrollbar-track: var(--base01);
--scrollbar-thumb: var(--base03);
--scrollbar-thumb-hover: var(--base04);
/* Code/Syntax */
--code-bg: var(--base01);
--code-text: var(--base05);
--code-keyword: var(--base0E);
--code-string: var(--base0B);
--code-number: var(--base09);
--code-function: var(--base0D);
--code-comment: var(--base03);
--code-variable: var(--base08);
/* Status Colors */
--status-pending: var(--base0A);
--status-processing: var(--base0D);
--status-complete: var(--base0B);
--status-error: var(--base08);
--status-skipped: var(--base03);
/* Diff Colors */
--diff-added-bg: color-mix(in srgb, var(--base0B) 15%, var(--base01));
--diff-added-text: var(--base0B);
--diff-removed-bg: color-mix(in srgb, var(--base08) 15%, var(--base01));
--diff-removed-text: var(--base08);
--diff-changed-bg: color-mix(in srgb, var(--base0A) 15%, var(--base01));
--diff-changed-text: var(--base0A);
/* Chat Colors - User message bubble */
--chat-user-bg: #3b82f6;
--chat-user-text: #ffffff;
}
/* Renkin Dark - High contrast button text overrides */
[data-theme="renkin-dark"] {
/* Override button text colors for maximum contrast on neon buttons */
--primary-text: #05070d; /* Dark navy on bright teal buttons */
--success-text: #05070d; /* Dark navy on bright green buttons */
--info-text: #05070d; /* Dark navy on bright cyan buttons */
--warning-text: #05070d; /* Dark navy on bright yellow buttons */
--danger-text: #ffffff; /* White on red buttons (red is darker) */
}
/* Light themes semantic mappings */
[data-theme="gruvbox-light"],
[data-theme="solarized-light"],
[data-theme="renkin-light"] {
/* Backgrounds */
--bg-primary: var(--base00);
--bg-secondary: var(--base01);
--bg-tertiary: var(--base02);
--bg-highlight: color-mix(in srgb, var(--base0D) 10%, var(--base01));
--bg-hover: var(--base02);
--bg-active: color-mix(in srgb, var(--base0D) 15%, var(--base01));
--bg-selected: color-mix(in srgb, var(--base0D) 20%, var(--base01));
/* Text */
--text-primary: var(--base05);
--text-secondary: var(--base04);
--text-muted: var(--base03);
--text-inverted: var(--base00);
--text-disabled: var(--base03);
/* Borders */
--border-default: var(--base02);
--border-subtle: color-mix(in srgb, var(--base02) 50%, var(--base01));
--border-strong: var(--base03);
--border-focus: var(--base0D);
/* Primary Action */
--primary: var(--base0D);
--primary-hover: color-mix(in srgb, var(--base0D) 85%, var(--base07));
--primary-active: color-mix(in srgb, var(--base0D) 70%, var(--base07));
--primary-subtle: color-mix(in srgb, var(--base0D) 10%, var(--base01));
--primary-text: var(--base00);
/* Semantic Colors */
--success: var(--base0B);
--success-subtle: color-mix(in srgb, var(--base0B) 10%, var(--base01));
--success-text: var(--base00);
--warning: var(--base0A);
--warning-subtle: color-mix(in srgb, var(--base0A) 10%, var(--base01));
--warning-text: var(--base00);
--danger: var(--base08);
--danger-subtle: color-mix(in srgb, var(--base08) 10%, var(--base01));
--danger-text: var(--base00);
--info: var(--base0C);
--info-subtle: color-mix(in srgb, var(--base0C) 10%, var(--base01));
--info-text: var(--base00);
/* Accent Colors */
--accent-purple: var(--base0E);
--accent-purple-subtle: color-mix(in srgb, var(--base0E) 10%, var(--base01));
--accent-orange: var(--base09);
--accent-orange-subtle: color-mix(in srgb, var(--base09) 10%, var(--base01));
--accent-brown: var(--base0F);
/* Shadows */
--shadow-color: var(--base03);
--shadow-sm: 0 1px 2px color-mix(in srgb, var(--shadow-color) 10%, transparent);
--shadow-md: 0 4px 6px color-mix(in srgb, var(--shadow-color) 15%, transparent);
--shadow-lg: 0 10px 15px color-mix(in srgb, var(--shadow-color) 20%, transparent);
/* Focus Ring */
--focus-ring: 0 0 0 2px var(--bg-secondary), 0 0 0 4px var(--primary);
/* Scrollbar */
--scrollbar-track: var(--base01);
--scrollbar-thumb: var(--base03);
--scrollbar-thumb-hover: var(--base04);
/* Code/Syntax */
--code-bg: var(--base01);
--code-text: var(--base05);
--code-keyword: var(--base0E);
--code-string: var(--base0B);
--code-number: var(--base09);
--code-function: var(--base0D);
--code-comment: var(--base03);
--code-variable: var(--base08);
/* Status Colors */
--status-pending: var(--base0A);
--status-processing: var(--base0D);
--status-complete: var(--base0B);
--status-error: var(--base08);
--status-skipped: var(--base03);
/* Diff Colors */
--diff-added-bg: color-mix(in srgb, var(--base0B) 15%, var(--base01));
--diff-added-text: var(--base0B);
--diff-removed-bg: color-mix(in srgb, var(--base08) 15%, var(--base01));
--diff-removed-text: var(--base08);
--diff-changed-bg: color-mix(in srgb, var(--base0A) 15%, var(--base01));
--diff-changed-text: var(--base0A);
/* Chat Colors - User message bubble */
--chat-user-bg: #3b82f6;
--chat-user-text: #ffffff;
}
/* Custom themes - base colors injected via JS on :root */
[data-theme="custom"] {
--bg-primary: var(--base00);
--bg-secondary: var(--base01);
--bg-tertiary: var(--base02);
--bg-highlight: color-mix(in srgb, var(--base0D) 10%, var(--base01));
--bg-hover: var(--base02);
--bg-active: color-mix(in srgb, var(--base0D) 15%, var(--base01));
--bg-selected: color-mix(in srgb, var(--base0D) 20%, var(--base01));
--text-primary: var(--base05);
--text-secondary: var(--base04);
--text-muted: var(--base03);
--text-inverted: var(--base00);
--text-disabled: var(--base03);
--border-default: var(--base02);
--border-subtle: color-mix(in srgb, var(--base02) 50%, var(--base01));
--border-strong: var(--base03);
--border-focus: var(--base0D);
--primary: var(--base0D);
--primary-hover: color-mix(in srgb, var(--base0D) 85%, var(--base07));
--primary-active: color-mix(in srgb, var(--base0D) 70%, var(--base07));
--primary-subtle: color-mix(in srgb, var(--base0D) 10%, var(--base01));
--primary-text: var(--base07);
--success: var(--base0B);
--success-subtle: color-mix(in srgb, var(--base0B) 10%, var(--base01));
--success-text: var(--base07);
--warning: var(--base0A);
--warning-subtle: color-mix(in srgb, var(--base0A) 10%, var(--base01));
--warning-text: var(--base00);
--danger: var(--base08);
--danger-subtle: color-mix(in srgb, var(--base08) 10%, var(--base01));
--danger-text: var(--base07);
--info: var(--base0C);
--info-subtle: color-mix(in srgb, var(--base0C) 10%, var(--base01));
--info-text: var(--base07);
--accent-purple: var(--base0E);
--accent-purple-subtle: color-mix(in srgb, var(--base0E) 10%, var(--base01));
--accent-orange: var(--base09);
--accent-orange-subtle: color-mix(in srgb, var(--base09) 10%, var(--base01));
--accent-brown: var(--base0F);
--shadow-color: var(--base00);
--shadow-sm: 0 1px 2px color-mix(in srgb, var(--shadow-color) 20%, transparent);
--shadow-md: 0 4px 6px color-mix(in srgb, var(--shadow-color) 30%, transparent);
--shadow-lg: 0 10px 15px color-mix(in srgb, var(--shadow-color) 40%, transparent);
--focus-ring: 0 0 0 2px var(--bg-secondary), 0 0 0 4px var(--primary);
--scrollbar-track: var(--base01);
--scrollbar-thumb: var(--base03);
--scrollbar-thumb-hover: var(--base04);
--code-bg: var(--base01);
--code-text: var(--base05);
--code-keyword: var(--base0E);
--code-string: var(--base0B);
--code-number: var(--base09);
--code-function: var(--base0D);
--code-comment: var(--base03);
--code-variable: var(--base08);
--status-pending: var(--base0A);
--status-processing: var(--base0D);
--status-complete: var(--base0B);
--status-error: var(--base08);
--status-skipped: var(--base03);
--diff-added-bg: color-mix(in srgb, var(--base0B) 15%, var(--base01));
--diff-added-text: var(--base0B);
--diff-removed-bg: color-mix(in srgb, var(--base08) 15%, var(--base01));
--diff-removed-text: var(--base08);
--diff-changed-bg: color-mix(in srgb, var(--base0A) 15%, var(--base01));
--diff-changed-text: var(--base0A);
}
</style>
<script>
/* Apply theme before body renders to avoid FOUC */
(function() {
var saved = localStorage.getItem('storyscope-theme');
var theme = saved || 'dark';
document.documentElement.setAttribute('data-theme', theme);
})();
</script>
<style>
/* StoryScope aliases β map app vars to theme-engine semantic layer */
:root, [data-theme] {
--bg: var(--bg-primary);
--panel: var(--bg-secondary);
--card: color-mix(in srgb, var(--bg-primary) 40%, var(--bg-secondary));
--border: var(--border-default);
--text: var(--text-primary);
--text-dim: var(--text-muted);
--accent: var(--accent-purple);
--human: var(--accent-orange);
--ai: var(--primary);
--green: var(--success);
--red: var(--danger);
--yellow: var(--warning);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: 'Inter', system-ui, sans-serif; font-size: 14px; min-height: 100vh; }
/* HEADER */
header { background: var(--panel); border-bottom: 1px solid var(--border); padding: 12px 24px; display: flex; align-items: center; gap: 16px; }
header h1 { font-size: 20px; font-weight: 700; color: var(--accent); }
header p { color: var(--text-dim); font-size: 12px; }
.paper-link { margin-left: auto; font-size: 11px; color: var(--text-dim); }
.paper-link a { color: var(--accent); text-decoration: none; }
.theme-picker { background: var(--card); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 4px 8px; font-size: 11px; cursor: pointer; }
/* API KEY BANNER */
.key-banner { background: var(--panel); border-bottom: 1px solid var(--border); padding: 8px 20px; display: flex; align-items: center; gap: 10px; font-size: 12px; }
.key-banner.has-key { border-bottom-color: color-mix(in srgb, var(--success) 30%, transparent); background: color-mix(in srgb, var(--success) 4%, transparent); }
.key-input { flex: 1; max-width: 340px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; color: var(--text); font-size: 12px; font-family: monospace; }
.key-input:focus { outline: none; border-color: var(--accent); }
.key-status { font-size: 11px; white-space: nowrap; }
/* LAYOUT */
.app { display: grid; grid-template-columns: 380px 1fr; height: calc(100vh - 86px); }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.main { overflow-y: auto; padding: 20px; }
/* SIDEBAR */
.sidebar-top { padding: 14px; flex: 1; display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
textarea { background: var(--card); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 10px; font-size: 13px; font-family: inherit; resize: vertical; outline: none; }
textarea:focus { border-color: var(--accent); }
textarea#inputText { flex: 1; min-height: 160px; max-height: 340px; }
.word-count { color: var(--text-dim); font-size: 11px; text-align: right; }
.warning-box { background: var(--warning-subtle); border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent); border-radius: 6px; padding: 6px 10px; font-size: 11px; color: var(--yellow); display: none; }
/* BUTTONS */
.btn { padding: 8px 16px; border-radius: 7px; border: none; cursor: pointer; font-weight: 600; font-size: 13px; transition: all 0.15s; }
.btn-primary { background: var(--accent); color: var(--text-inverted); width: 100%; }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 80%, var(--text-primary)); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-xs { padding: 3px 8px; font-size: 10px; font-weight: 600; }
/* MODE + MODEL CONTROLS */
.ctrl-row { display: flex; gap: 8px; align-items: center; }
.ctrl-row label { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.ctrl-row select { flex: 1; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 5px 8px; font-size: 11px; }
.sample-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.sample-btn { font-size: 10px; padding: 3px 8px; background: var(--accent-purple-subtle); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 4px; color: var(--accent); cursor: pointer; }
.sample-btn:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
/* LOADING */
.loading { display: none; text-align: center; padding: 14px; color: var(--text-dim); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-detail { font-size: 11px; margin-top: 3px; color: var(--text-dim); }
/* TABS */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab { padding: 7px 14px; cursor: pointer; border-radius: 6px 6px 0 0; color: var(--text-dim); font-size: 12px; border: 1px solid transparent; border-bottom: none; transition: all 0.15s; }
.tab:hover { color: var(--text); background: var(--card); }
.tab.active { color: var(--accent); border-color: var(--border); background: var(--panel); margin-bottom: -1px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
/* CARDS */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.card-title { font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
/* SCORES */
.score-big { font-size: 40px; font-weight: 800; text-align: center; line-height: 1; }
.score-label { font-size: 11px; color: var(--text-dim); text-align: center; margin-top: 4px; }
.meter-bar { height: 7px; background: var(--border); border-radius: 4px; overflow: hidden; margin: 5px 0; }
.meter-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.source-badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.conf-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.conf-label { width: 72px; font-size: 11px; color: var(--text-dim); }
.conf-bar { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.conf-fill { height: 100%; border-radius: 3px; }
.conf-pct { width: 36px; text-align: right; font-size: 11px; }
/* FEATURE TABLE */
.feat-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.feat-table th { color: var(--text-dim); font-weight: 600; text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--border); }
.feat-table td { padding: 4px 8px; border-bottom: 1px solid var(--panel); vertical-align: middle; }
.feat-table tr:hover td { background: var(--bg-hover); }
.feat-name-link { cursor: pointer; color: var(--text); text-decoration: underline dotted; text-underline-offset: 2px; }
.feat-name-link:hover { color: var(--accent); }
.feat-group-row td { font-size: 10px; color: var(--text-dim); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; padding: 7px 8px 3px; background: var(--bg-hover); }
.tag { display: inline-block; padding: 1px 6px; border-radius: 8px; font-size: 10px; font-weight: 600; }
.tag-ai { background: var(--accent-purple-subtle); color: var(--accent-purple); border: 1px solid color-mix(in srgb, var(--accent-purple) 30%, transparent); }
.tag-human { background: var(--accent-orange-subtle); color: var(--accent-orange); border: 1px solid color-mix(in srgb, var(--accent-orange) 30%, transparent); }
.tag-neutral { background: color-mix(in srgb, var(--text-muted) 15%, transparent); color: var(--text-muted); border: 1px solid color-mix(in srgb, var(--text-muted) 20%, transparent); }
/* PROGRESS STEPS */
.progress-bar-track { height: 4px; background: var(--border); border-radius: 2px; margin: 6px 0 8px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.4s ease; }
.progress-steps { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.progress-step { font-size: 10px; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--border); color: var(--text-dim); transition: background 0.3s, color 0.3s, border-color 0.3s; }
.progress-step.done { background: color-mix(in srgb, var(--green) 20%, transparent); color: var(--green); border-color: var(--green); }
.progress-step.active { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); border-color: var(--accent); animation: pill-glow 1.1s ease-in-out infinite; }
@keyframes pill-glow {
0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); }
50% { box-shadow: 0 0 8px 2px color-mix(in srgb, var(--accent) 50%, transparent); }
}
/* PLOTS */
.plot-container { min-height: 360px; background: var(--card); border-radius: 8px; border: 1px solid var(--border); position: relative; }
.plot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
/* TRANSFORM */
.diff-view { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.text-box { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-size: 12px; line-height: 1.6; max-height: 380px; overflow-y: auto; white-space: pre-wrap; }
.changes-list { list-style: none; }
.changes-list li { padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.changes-list li::before { content: "β "; color: var(--accent); }
/* IN-FLIGHT */
.strategy-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.strategy-title { font-weight: 600; color: var(--accent); margin-bottom: 5px; }
.strategy-eff { font-size: 11px; color: var(--text-dim); margin-bottom: 6px; }
.prompt-box { background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px; font-size: 11px; font-family: 'Courier New', monospace; color: var(--text-secondary); white-space: pre-wrap; }
.constraint-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.constraint-item { display: flex; align-items: flex-start; gap: 6px; padding: 7px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.constraint-item input { margin-top: 2px; accent-color: var(--accent); }
.constraint-label { font-size: 11px; font-weight: 600; }
.constraint-prompt { font-size: 10px; color: var(--text-dim); margin-top: 2px; }
/* MODAL */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; max-width: 560px; width: 90%; }
.modal h3 { color: var(--accent); margin-bottom: 10px; }
.modal-meta { font-size: 11px; color: var(--text-dim); margin-bottom: 8px; }
.modal p { font-size: 13px; line-height: 1.6; color: var(--text); }
.modal-close { float: right; cursor: pointer; font-size: 18px; color: var(--text-dim); border: none; background: none; line-height: 1; }
.modal-rubric { background: var(--code-bg); border-radius: 6px; padding: 10px; font-size: 12px; color: var(--text-secondary); margin-top: 10px; line-height: 1.5; }
/* SIDEBAR RESULTS */
#sidebarResults { border-top: 1px solid var(--border); padding: 14px; }
/* ERROR / EMPTY */
.error-box { background: var(--danger-subtle); border: 1px solid var(--red); border-radius: 8px; padding: 10px; color: var(--red); margin-bottom: 12px; font-size: 13px; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-dim); }
.empty-state .icon { font-size: 44px; margin-bottom: 10px; }
.empty-state h3 { color: var(--text); margin-bottom: 6px; }
@media (max-width: 900px) {
.app { grid-template-columns: 1fr; height: auto; }
.main { padding: 12px; }
.plot-grid, .diff-view, .grid2, .grid3, .constraint-grid { grid-template-columns: 1fr; }
}
</style>
</head>
<body>
<header>
<div>
<h1>Text DeClanker</h1>
<p>Discourse-level AI authorship analysis & humanization</p>
</div>
<div class="paper-link">Based on <a href="https://github.com/jenna-russell/storyscope" target="_blank" rel="noopener">StoryScope</a> by Jenna Russell et al. · <a href="https://arxiv.org/abs/2604.03136" target="_blank" rel="noopener">arXiv:2604.03136</a></div>
<select id="themePicker" class="theme-picker" title="Choose theme" onchange="setTheme(this.value)">
<optgroup label="Dark">
<option value="dark">Dark</option>
<option value="one-dark">One Dark</option>
<option value="tokyo-night">Tokyo Night</option>
<option value="dracula">Dracula</option>
<option value="monokai">Monokai</option>
<option value="nord">Nord</option>
<option value="gruvbox-dark">Gruvbox Dark</option>
<option value="solarized-dark">Solarized Dark</option>
<option value="high-contrast-dark">High Contrast Dark</option>
</optgroup>
<optgroup label="Light">
<option value="gruvbox-light">Gruvbox Light</option>
<option value="light">Light</option>
<option value="solarized-light">Solarized Light</option>
<option value="high-contrast-light">High Contrast Light</option>
</optgroup>
</select>
</header>
<!-- API KEY BANNER -->
<div id="keyBanner" class="key-banner">
<span style="color:var(--text-dim);white-space:nowrap;font-size:11px;">Anthropic key:</span>
<input class="key-input" id="keyInput" type="password" placeholder="sk-ant-api03-..." autocomplete="off"
oninput="onKeyInput()" onkeydown="if(event.key==='Enter')saveKey()">
<button class="btn btn-secondary btn-sm" onclick="saveKey()">Save</button>
<span class="key-status" id="keyStatus" style="color:var(--text-dim);">No key set. Auto mode requires a key.</span>
<button class="btn btn-secondary btn-sm" id="keyClearBtn" style="display:none;" onclick="clearKey()">Clear</button>
<span style="font-size:10px;color:var(--text-dim);margin-left:6px;display:flex;align-items:center;gap:4px;"><svg width="11" height="12" viewBox="0 0 11 12" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><rect x="1" y="5" width="9" height="7" rx="1.5"/><path d="M3 5V3.5a2.5 2.5 0 0 1 5 0V5"/></svg> Stored in browser session only, never sent to this server.</span>
<button class="btn btn-secondary btn-xs" style="margin-left:auto;" onclick="document.getElementById('privacyModal').classList.add('open')">Privacy & Terms</button>
</div>
<div class="app">
<!-- SIDEBAR -->
<aside class="sidebar">
<div class="sidebar-top">
<!-- AUTO PANEL -->
<div id="autoPanel" style="display:flex;flex-direction:column;gap:10px;flex:1;overflow:hidden;">
<div style="display:flex;flex-direction:column;gap:6px;flex:1;overflow:hidden;">
<div class="ctrl-row">
<label>Mode:</label>
<select id="extractionMode" title="Quick: top 30 features by discriminating power, 1 call. Full: all 304 NarraBench features, 10 calls (one per dimension).">
<option value="quick">Quick: 30 features (1 call)</option>
<option value="full">Full: 304 features, 10 calls (all NarraBench dimensions)</option>
</select>
</div>
<div class="ctrl-row">
<label>Model:</label>
<select id="modelSelect">
<option value="claude-haiku-4-5-20251001">Haiku (fast, cheap)</option>
<option value="claude-sonnet-4-6" selected>Sonnet</option>
<option value="claude-opus-4-8">Opus (most accurate)</option>
</select>
</div>
<div class="sample-btns">
<span style="font-size:10px;color:var(--text-dim);">Sample:</span>
<button class="sample-btn" onclick="loadSample('human')">Human fiction</button>
<button class="sample-btn" onclick="loadSample('claude')">Claude-like</button>
<button class="sample-btn" onclick="loadSample('gpt')">GPT-like</button>
</div>
<label style="font-size:11px;color:var(--text-dim);">Paste text to analyze (50+ words)</label>
<textarea id="inputText" placeholder="Paste a story, essay, or any creative text here..."></textarea>
<div class="word-count"><span id="wordCount">0</span> words</div>
<div class="warning-box" id="truncWarning">Text >6000 words will be truncated to 6000 for extraction.</div>
</div>
<button class="btn btn-primary" id="analyzeBtn" onclick="runAnalysis()">Analyze Text</button>
<div class="loading" id="loadingIndicator">
<div class="spinner"></div>
<div id="loadingLabel">Extracting narrative features via LLM...</div>
<div class="loading-detail" id="loadingDetail">This takes 10β20s (Quick) or 60β90s (Full)</div>
</div>
</div>
</div>
<!-- Sidebar mini-results -->
<div id="sidebarResults" style="display:none;">
<div style="margin-bottom:10px;">
<div class="score-big" id="humannessBig">β</div>
<div class="score-label">Humanness Score</div>
</div>
<div style="margin-bottom:8px;">
<div style="font-size:10px;color:var(--text-dim);margin-bottom:4px;">PREDICTED SOURCE</div>
<div id="predictedSource" class="source-badge">β</div>
</div>
<div>
<div style="font-size:10px;color:var(--text-dim);margin-bottom:5px;">SOURCE CONFIDENCE</div>
<div id="miniConfidences"></div>
</div>
</div>
</aside>
<!-- MAIN -->
<main class="main">
<div id="errorBox" class="error-box" style="display:none;"></div>
<div id="progressWrap" style="display:none;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);z-index:1000;background:var(--card);border:1px solid var(--border);border-radius:14px;padding:28px 32px;min-width:360px;max-width:520px;box-shadow:0 8px 32px rgba(0,0,0,0.4);">
<div style="text-align:center;margin-bottom:18px;">
<div id="loadingLabelMain" style="font-size:15px;font-weight:700;color:var(--text);margin-bottom:6px;">Analyzing...</div>
<div style="font-size:12px;color:var(--text-dim);">10 LLM calls, one per NarraBench dimension</div>
</div>
<div class="progress-bar-track" style="margin-bottom:16px;height:6px;"><div class="progress-bar-fill" id="progressBarFill" style="width:0%"></div></div>
<div class="progress-steps" id="progressSteps"></div>
</div>
<div id="emptyState" class="empty-state">
<div class="icon"><svg width="40" height="40" viewBox="0 0 40 40" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M6 8h11a3 3 0 0 1 3 3v20a3 3 0 0 0-3-3H6V8z"/><path d="M34 8H23a3 3 0 0 0-3 3v20a3 3 0 0 1 3-3h11V8z"/><line x1="10" y1="14" x2="16" y2="14"/><line x1="10" y1="19" x2="16" y2="19"/><line x1="24" y1="14" x2="30" y2="14"/><line x1="24" y1="19" x2="30" y2="19"/></svg></div>
<h3>Narrative Feature Analysis</h3>
<p>Paste a story or creative text on the left and click Analyze.</p>
<br>
<p style="font-size:12px;">Based on 30+ discourse-level features: temporal structure, thematic explicitness, moral ambiguity, reader engagement, and more. Uses the NarraBench taxonomy from the StoryScope paper by Russell et al. (2026).</p>
</div>
<div id="results" style="display:none;">
<div class="tabs">
<div class="tab active" onclick="switchTab('overview')">Overview</div>
<div class="tab" onclick="switchTab('space')">Narrative Space</div>
<div class="tab" onclick="switchTab('features')">Features</div>
<div class="tab" onclick="switchTab('humanize')">Humanize</div>
<div class="tab" onclick="switchTab('inflight')">In-Flight Guide</div>
</div>
<!-- ββ OVERVIEW ββ -->
<div id="tab-overview" class="tab-panel active">
<div class="grid3">
<div class="card">
<div class="card-title">Humanness Score</div>
<div class="score-big" id="humannessPct">β</div>
<div class="meter-bar"><div class="meter-fill" id="humannessMeter" style="width:0%"></div></div>
<div style="display:flex;justify-content:space-between;font-size:10px;color:var(--text-dim)"><span>AI</span><span>Human</span></div>
</div>
<div class="card">
<div class="card-title">Predicted Source</div>
<div class="score-big" id="sourceDisplay" style="font-size:28px;">β</div>
<div id="sourceSub" style="text-align:center;font-size:11px;color:var(--text-dim);margin-top:4px;"></div>
</div>
<div class="card">
<div class="card-title">LD Coordinates</div>
<div id="ldCoords" style="text-align:center;padding:6px 0;"></div>
<div style="font-size:10px;color:var(--text-dim);text-align:center;margin-top:4px;">Humanββ4, AIβ+1.5</div>
</div>
</div>
<div class="grid2">
<div class="card">
<div class="card-title">Source Confidence</div>
<div id="confidenceBars"></div>
</div>
<div class="card">
<div class="card-title">Top AI-Like Features</div>
<div id="topAiFeatures"></div>
</div>
</div>
<div class="grid2">
<div class="card">
<div class="card-title">Top Human-Like Features</div>
<div id="topHumanFeatures"></div>
</div>
<div class="card">
<div class="card-title">Key Findings</div>
<div id="keyFindings" style="font-size:13px;line-height:1.7;"></div>
</div>
</div>
<div class="card" style="padding:6px 16px;">
<div id="plot-overview-space" class="plot-container" style="min-height:300px;"></div>
</div>
</div>
<!-- ββ NARRATIVE SPACE ββ -->
<div id="tab-space" class="tab-panel">
<div class="card" style="padding:8px;">
<div class="card-title" style="padding:0 8px;">
Narrative Feature Space
<button class="btn btn-secondary btn-xs" onclick="downloadPlot('plot-narrative-space','narrative_space')">Save PNG</button>
</div>
<div id="plot-narrative-space" class="plot-container"></div>
</div>
<div class="card" style="padding:8px;">
<div class="card-title" style="padding:0 8px;">
Rarity Distribution
<button class="btn btn-secondary btn-xs" onclick="downloadPlot('plot-rarity','rarity_violin')">Save PNG</button>
</div>
<div id="plot-rarity" class="plot-container"></div>
</div>
<div class="card">
<div class="card-title">How to Read These Plots</div>
<div style="font-size:12px;line-height:1.7;color:var(--text-dim);">
<p><strong style="color:var(--text)">Narrative Space:</strong> Approximates Figure 2 from the paper. LD1 separates human (left, negative) from AI (right, positive). Your text (β
) is plotted based on extracted feature scores against the background of 200 synthetic points per source calibrated to the paper's reported centroids.</p>
<br>
<p><strong style="color:var(--text)">Rarity Violin:</strong> Approximates Figure 5. Human stories occupy less-crowded regions of narrative space (mean rarity 0.71 vs 0.49 for AI). The dashed line shows your text's estimated rarity percentile.</p>
</div>
</div>
</div>
<!-- ββ FEATURES ββ -->
<div id="tab-features" class="tab-panel">
<div class="plot-grid">
<div class="card" style="padding:8px;">
<div class="card-title" style="padding:0 8px;">
Feature Radar
<button class="btn btn-secondary btn-xs" onclick="downloadPlot('plot-radar','feature_radar')">Save PNG</button>
</div>
<div id="plot-radar" class="plot-container" style="min-height:420px;"></div>
</div>
<div class="card" style="padding:8px;">
<div class="card-title" style="padding:0 8px;">
Per-Feature Humanness
<button class="btn btn-secondary btn-xs" onclick="downloadPlot('plot-bars','feature_bars')">Save PNG</button>
</div>
<div id="plot-bars" class="plot-container" style="min-height:420px;"></div>
</div>
</div>
<div class="card">
<div class="card-title">
All Features
<button class="btn btn-secondary btn-xs" onclick="exportJSON()">Export JSON</button>
</div>
<table class="feat-table">
<thead>
<tr>
<th>Feature</th><th>Value</th><th>Human</th><th>AI</th><th>Humanness</th><th>Signal</th>
</tr>
</thead>
<tbody id="featureTableBody"></tbody>
</table>
</div>
</div>
<!-- ββ HUMANIZE ββ -->
<div id="tab-humanize" class="tab-panel">
<div class="card">
<div class="card-title">Transform Toward Human-Like Patterns</div>
<p style="font-size:12px;color:var(--text-dim);margin-bottom:10px;">
Rewrites the text targeting its most AI-elevated narrative features: structural choices, not just surface style.
Re-analyzes after to show movement in narrative space.
</p>
<div id="humanizeTargets" style="margin-bottom:12px;"></div>
<div class="ctrl-row" style="margin-bottom:10px;">
<label>Model:</label>
<select id="humanizeModel" style="max-width:200px;background:var(--bg);border:1px solid var(--border);color:var(--text);border-radius:6px;padding:5px 8px;font-size:11px;">
<option value="claude-haiku-4-5-20251001">Haiku (fast, cheap)</option>
<option value="claude-sonnet-4-6" selected>Sonnet</option>
<option value="claude-opus-4-8">Opus (best)</option>
</select>
</div>
<button class="btn btn-primary" id="humanizeBtn" onclick="runHumanize()" style="max-width:280px;">
Humanize Text
</button>
<div class="loading" id="humanizeLoading">
<div class="spinner"></div>
<div>Rewriting and re-analyzing (30β60s)...</div>
</div>
</div>
<div id="humanizeResults" style="display:none;">
<div class="grid2" style="margin-bottom:14px;">
<div class="card">
<div class="card-title">Before</div>
<div id="beforeScores"></div>
</div>
<div class="card">
<div class="card-title">After Humanization</div>
<div id="afterScores"></div>
</div>
</div>
<div class="card" style="padding:8px;">
<div class="card-title" style="padding:0 8px;">
Movement in Narrative Space
<button class="btn btn-secondary btn-xs" onclick="downloadPlot('plot-compare-space','comparison')">Save PNG</button>
</div>
<div id="plot-compare-space" class="plot-container"></div>
</div>
<div class="diff-view">
<div class="card">
<div class="card-title">Original Text</div>
<div class="text-box" id="originalTextDisplay"></div>
</div>
<div class="card">
<div class="card-title">Humanized Text
<button class="btn btn-secondary btn-xs" onclick="copyHumanized()">Copy</button>
</div>
<div class="text-box" id="transformedTextDisplay"></div>
</div>
</div>
<div class="card">
<div class="card-title">Changes Made</div>
<ul class="changes-list" id="changesList"></ul>
</div>
<div class="card" style="padding:8px;">
<div class="card-title" style="padding:0 8px;">
Feature Comparison
<button class="btn btn-secondary btn-xs" onclick="downloadPlot('plot-compare-bars','feature_comparison')">Save PNG</button>
</div>
<div id="plot-compare-bars" class="plot-container"></div>
</div>
</div>
</div>
<!-- ββ IN-FLIGHT GUIDE ββ -->
<div id="tab-inflight" class="tab-panel">
<div class="card">
<div class="card-title">
Humanizing System Prompt
<button class="btn btn-secondary btn-xs" onclick="copySystemPrompt()">Copy</button>
</div>
<p style="font-size:11px;color:var(--text-dim);margin-bottom:8px;">Paste as system prompt to steer AI generation toward human-like patterns.</p>
<div class="prompt-box" id="systemPromptBox">Loading...</div>
</div>
<div class="card">
<div class="card-title">Constraint Builder</div>
<p style="font-size:11px;color:var(--text-dim);margin-bottom:8px;">Select constraints, then build a prompt snippet to prepend.</p>
<div class="constraint-grid" id="constraintGrid"></div>
<button class="btn btn-secondary btn-sm" style="margin-top:8px;" onclick="buildConstraintPrompt()">Build Selected</button>
<div id="builtPrompt" style="display:none;margin-top:8px;">
<div class="prompt-box" id="constraintPromptBox"></div>
<button class="btn btn-secondary btn-xs" style="margin-top:6px;" onclick="copyConstraintPrompt()">Copy</button>
</div>
</div>
<div class="card">
<div class="card-title">Strategy Reference</div>
<div id="strategiesContainer"></div>
</div>
<div class="card">
<div class="card-title">Key Findings from the Paper</div>
<div style="font-size:12px;line-height:1.8;color:var(--text-dim);">
<p><strong style="color:var(--text)">Why surface rewrites fail:</strong> The LAMP framework (span-level surface editing) drops detection accuracy by only 1.6pp (93.9% vs 95.5%). Surface edits don't change the underlying structural choices that drive detection.</p>
<br>
<p><strong style="color:var(--text)">5 strongest AI signals (largest gap):</strong></p>
<ol style="margin-left:18px;margin-top:4px;">
<li>Emotional expression via embodied metaphors (AI=81%, Human=38%)</li>
<li>Thematic explicitness & moralizing (AI=3.94, Human=3.28)</li>
<li>Setting as psychological mirror (AI=4.07, Human=3.58)</li>
<li>Moral/philosophical weighting (AI=3.68, Human=3.26)</li>
<li>Environmental emphasis (AI=3.21, Human=2.83)</li>
</ol>
<br>
<p><strong style="color:var(--text)">5 strongest human signals:</strong></p>
<ol style="margin-left:18px;margin-top:4px;">
<li>Moral polarity β ambivalent (Human=59%, AI=38%)</li>
<li>Intertextual named references (Human=47%, AI=24%)</li>
<li>Fourth-wall permeability (Human=0.67, AI=0.39)</li>
<li>Depth of recontextualization after surprise (Human=3.28, AI=2.95)</li>
<li>Chronological discontinuity (Human=2.40, AI=2.12)</li>
</ol>
<br>
<p><strong style="color:var(--text)">Model fingerprints:</strong> Claude β flat escalation + epilogues. GPT β gossip/dreams + retrospective narrator. Gemini β protagonist social expansion. DeepSeek β interleaved backstory. Kimi β in medias res.</p>
</div>
</div>
</div>
</div>
</main>
</div>
<!-- PRIVACY & TERMS MODAL -->
<div class="modal-overlay" id="privacyModal" onclick="if(event.target===this)this.classList.remove('open')">
<div class="modal" style="max-width:480px;">
<button class="modal-close" onclick="document.getElementById('privacyModal').classList.remove('open')">β</button>
<h3 style="margin-bottom:12px;">Privacy & Terms</h3>
<div style="font-size:13px;line-height:1.8;color:var(--text-dim);">
<p><strong style="color:var(--text);">API Key</strong><br>
Your Anthropic API key is stored only in your browser's <code>sessionStorage</code> and is cleared when you close the tab. It is sent directly to Anthropic's servers with each analysis request via the <code>X-Api-Key</code> header. It is never logged, stored, or transmitted to any other party by this server.</p>
<br>
<p><strong style="color:var(--text);">Text You Analyze</strong><br>
The story or passage you submit is sent to Anthropic's API for feature extraction and (if used) humanization rewriting. This server does not log, store, or retain your text in any form. However, Anthropic processes your text under their own <a href="https://www.anthropic.com/privacy" target="_blank" rel="noopener" style="color:var(--accent);">Privacy Policy</a> β do not submit text containing personal information, confidential content, or anything you would not share with a third-party AI provider.</p>
<br>
<p><strong style="color:var(--text);">No Tracking</strong><br>
No analytics, cookies, or telemetry are collected. No account is required.</p>
<br>
<p><strong style="color:var(--text);">Use at Your Own Risk</strong><br>
This tool is provided for research and educational purposes only, as a demonstration of the StoryScope methodology. Results are probabilistic and should not be used as definitive evidence of authorship. The authors make no warranties of accuracy or fitness for any purpose. Use is at your own risk.</p>
<br>
<p><strong style="color:var(--text);">Attribution & License</strong><br>
Text DeClanker is built on the <a href="https://github.com/jenna-russell/storyscope" target="_blank" rel="noopener" style="color:var(--accent);">StoryScope</a> codebase and NarraBench taxonomy data, used under the MIT License:<br>
<span style="font-size:11px;font-family:monospace;">Copyright (c) 2026 Jenna Russell</span><br><br>
Full citation: Russell et al. (2026) "StoryScope: Investigating idiosyncrasies in AI fiction," <a href="https://arxiv.org/abs/2604.03136" target="_blank" rel="noopener" style="color:var(--accent);">arXiv:2604.03136</a></p>
</div>
</div>
</div>
<!-- FEATURE RUBRIC MODAL -->
<div class="modal-overlay" id="modalOverlay" onclick="closeModal(event)">
<div class="modal">
<button class="modal-close" onclick="closeModal(null)">β</button>
<h3 id="modalTitle">Feature</h3>
<div class="modal-meta" id="modalMeta"></div>
<p id="modalQuestion" style="margin-bottom:8px;"></p>
<div class="modal-rubric" id="modalRubric"></div>
</div>
</div>
<script>
// βββ Theme βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
function setTheme(id) {
document.documentElement.setAttribute('data-theme', id);
localStorage.setItem('storyscope-theme', id);
document.getElementById('themePicker').value = id;
}
// βββ State βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
let currentAnalysis = null;
let inflightData = null;
// βββ API Key βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
function getKey() { return sessionStorage.getItem('anthropic_api_key') || ''; }
function saveKey() {
const val = document.getElementById('keyInput').value.trim().replace(/[^\x20-\x7E]/g, '');
if (!val) return;
sessionStorage.setItem('anthropic_api_key', val);
updateKeyUI(true);
}
function clearKey() {
sessionStorage.removeItem('anthropic_api_key');
document.getElementById('keyInput').value = '';
updateKeyUI(false);
}
function onKeyInput() {
const val = document.getElementById('keyInput').value.trim();
if (val.startsWith('sk-')) saveKey();
}
function updateKeyUI(hasKey) {
const banner = document.getElementById('keyBanner');
const status = document.getElementById('keyStatus');
const clearBtn = document.getElementById('keyClearBtn');
if (hasKey) {
banner.classList.add('has-key');
status.textContent = 'Key saved for this session';
status.style.color = 'var(--green)';
clearBtn.style.display = '';
document.getElementById('keyInput').value = 'β’β’β’β’β’β’β’β’β’β’β’β’β’β’β’β’';
} else {
banner.classList.remove('has-key');
status.textContent = 'No key set. Auto mode requires a key.';
status.style.color = 'var(--text-dim)';
clearBtn.style.display = 'none';
}
}
function apiHeaders() {
const h = {'Content-Type': 'application/json'};
const k = getKey().replace(/[^\x20-\x7E]/g, '');
if (k) h['X-Api-Key'] = k;
return h;
}
function promptForKey() {
clearKey();
document.getElementById('keyInput').focus();
showError('API key required. Paste your Anthropic API key in the bar above and try again.');
}
updateKeyUI(!!getKey());
// Sync theme picker to active theme (set before body rendered in <head> script)
(function() {
var t = document.documentElement.getAttribute('data-theme') || 'dark';
document.getElementById('themePicker').value = t;
})();
// βββ Input persistence βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
(function() {
const saved = sessionStorage.getItem('storyscope-input');
if (saved) {
const el = document.getElementById('inputText');
el.value = saved;
const words = saved.trim().split(/\s+/).filter(w => w).length;
document.getElementById('wordCount').textContent = words;
document.getElementById('truncWarning').style.display = words > 6000 ? 'block' : 'none';
}
})();
// βββ Word count + truncation warning ββββββββββββββββββββββββββββββββββββββββββ
document.getElementById('inputText').addEventListener('input', function () {
const words = this.value.trim().split(/\s+/).filter(w => w).length;
document.getElementById('wordCount').textContent = words;
document.getElementById('truncWarning').style.display = words > 6000 ? 'block' : 'none';
sessionStorage.setItem('storyscope-input', this.value);
});
// βββ Sample texts ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const SAMPLE_TEXTS = {
human: `My grandmother kept her grief in the flour tin. After Grandpa died she'd take down the blue tin from the shelfβthe same one she'd used to store cooking flour for forty yearsβand just sit there with it. She never opened it in front of us. My mother told me later that inside was a single photograph, a dance card from 1958, and two ticket stubs from a film neither of them could remember the name of.
I thought about that tin when Marcus left. Not because the situations were comparable, but because I suddenly understood the impulse to make loss small and containable. To put it somewhere with a lid.
The apartment we'd shared for six years looked smaller without his things in it. Or maybe larger. I kept confusing the two. On the third day I found his copy of Herzog on the nightstand, a bookmark still wedged at page 211. I moved it to the shelf but couldn't bring myself to remove the bookmark.
My friend Dana came over Thursday. She brought wine she knew I wouldn't drink and ordered Thai food that arrived cold. We sat on the floor because the couch was where Marcus always sat, and neither of us mentioned that.
"Do you want to talk about it?" she said, finally, around eleven.
"Not even a little," I said.
She nodded like this was the correct answer. Outside, the neighbor's dog kept barking at something only it could see. We listened to it for a while.
In my grandmother's tin there was apparently also a small stone, smoothed by a river. Nobody knows where it came from. My mother asked once and my grandmother said, "Some things you keep because you forget why you started keeping them, and then it's too late to stop."
I have the Herzog now. I still haven't moved the bookmark.`,
claude: `The moment Elena stepped into the sunlit courtyard of the orphanage, she understood with crystalline clarity that her life's purpose had led her here. The children's laughter, bright as morning bells, echoed off ancient stone wallsβwalls that had witnessed generations of joy and sorrow, hope and despair. She felt the weight of her mission settle upon her shoulders like a mantle of sacred responsibility.
"You must be the new volunteer," said Sister Agnes, a woman whose face bore the serene geography of a life devoted to others. Her eyes held the particular warmth of someone who had made peace with suffering by transforming it into service.
Elena nodded, her throat tight with emotion. "I want to make a difference," she said, and meant it with every fiber of her being.
The children ranged in age from toddlers who could barely walk to teenagers on the cusp of adulthood, each carrying their invisible burdens with a resilience that humbled her. She thought of her own comfortable upbringing, the privileges she had taken for granted, and felt the familiar sting of guilt transform into renewed determination.
That evening, as the sun painted the courtyard in shades of amber and rose, she sat with a small boy named Marco who refused to speak to the other children. He pressed a faded photograph into her handsβhis parents, she realized, gone to illness three years prior.
"They're still with you," she said softly. "In here." She touched her chest above her heart.
Marco studied her face as though trying to determine if she could be trusted with the truth of his longing. Then, slowly, he leaned against her shoulder. Outside the courtyard walls, the city continued its indifferent bustle, but here, in this small circle of understanding, something essential had passed between them: the acknowledgment that grief, shared, becomes bearable; that connection is the only antidote to loss; that love, given freely, transforms both the giver and the receiver.
Elena knew she had found her purpose. The journey ahead would be difficult, but it would be meaningful. And meaning, she had come to understand, was everything.`,
gpt: `This is a story my mother told me years later, after enough time had passed that she could laugh about parts of itβnot the important parts, but the peripheral ones, the way you can eventually laugh about anything that didn't kill you.
She had been told about the inheritance by her cousin Rosalie at a family gathering in 1987, which meant everyone knew before she did, which was how things worked in our family: information traveled through cousins and aunts the way rumors spread in a small town, with accretions and embellishments, so that by the time it reached you it had the character of myth.
"Your grandmother left you the house," Rosalie said, not looking up from the deviled eggs she was arranging.
The house was in Pawtucket, which my mother had not visited since she was seven. She remembered it as a place of perpetual shadow and the smell of camphor, a Victorian that leaned slightly to the left as if exhausted by its own history. Her grandmotherβmy great-grandmother Estelleβhad lived there alone for twenty-three years after her husband died, during which time she had apparently accumulated seven cats, an inexplicable number of porcelain thimbles, and a reputation among the neighbors for walking to the mailbox at two in the morning.
What Rosalie did not mention, and what my mother discovered only when she finally drove out to Pawtucket in October with her friend Barbara, who had a truck and strong opinions about Victorian architecture, was that the house also contained Estelle's journals. Fourteen of them, Mead composition notebooks with the black-and-white marble covers, stacked in the bedroom closet beneath a hat that still held the shape of a head.
My mother read them over three weekends while Barbara sorted through the thimbles. I was not born yet. But my mother sometimes says that those weekends were when she first understood that she had come from somewhere specificβthat she was not, as she had sometimes felt, simply arriving into the world without context, but was rather part of a particular ongoing story, with its own logic and recurring themes and unresolved questions that would continue beyond her.
She never told me what was in the journals. I've stopped asking.`
};
function loadSample(key) {
const text = SAMPLE_TEXTS[key];
document.getElementById('inputText').value = text;
const words = text.trim().split(/\s+/).filter(w => w).length;
document.getElementById('wordCount').textContent = words;
sessionStorage.setItem('storyscope-input', text);
}
// βββ Tab switching βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
function switchTab(name) {
const tabs = ['overview', 'space', 'features', 'humanize', 'inflight'];
document.querySelectorAll('.tab').forEach((t, i) => t.classList.toggle('active', tabs[i] === name));
document.querySelectorAll('.tab-panel').forEach(p => p.classList.remove('active'));
document.getElementById(`tab-${name}`).classList.add('active');
if (name === 'space' && currentAnalysis) { renderPlot('plot-narrative-space', currentAnalysis.plots.narrative_space); renderPlot('plot-rarity', currentAnalysis.plots.rarity_violin); }
if (name === 'features' && currentAnalysis) { renderPlot('plot-radar', currentAnalysis.plots.feature_radar); renderPlot('plot-bars', currentAnalysis.plots.feature_bars); }
if (name === 'inflight') loadInflight();
}
// βββ Analysis ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
async function runAnalysis() {
const text = document.getElementById('inputText').value.trim();
if (!text) return;
const extraction_mode = document.getElementById('extractionMode').value;
const model = document.getElementById('modelSelect').value;
setLoading(true, extraction_mode === 'full');
hideError();
document.getElementById('humanizeResults').style.display = 'none';
if (extraction_mode === 'full') {
// Show checklist immediately β don't wait for SSE events the proxy may buffer
const DIMS = ['Revelation','Events','Perspective','Plot','Setting',
'Style','Situatedness','Temporal Structure','Agents','Social Networks'];
document.getElementById('progressSteps').innerHTML =
DIMS.map((l, i) => `<span class="progress-step" id="pstep-${i}">${l}</span>`).join('');
document.getElementById('progressBarFill').style.width = '0%';
document.getElementById('loadingLabelMain').textContent = 'Analyzing...';
document.getElementById('progressWrap').style.display = 'block';
}
try {
if (extraction_mode === 'full') {
await runAnalysisFull(text, model);
} else {
const resp = await fetch('api/analyze', {
method: 'POST', headers: apiHeaders(),
body: JSON.stringify({text, extraction_mode, model}),
});
if (resp.status === 401) { promptForKey(); return; }
if (!resp.ok) { const e = await resp.json(); throw new Error(_errStr(e.detail) || 'Analysis failed'); }
currentAnalysis = await resp.json();
renderResults(currentAnalysis);
}
} catch (e) {
showError(e.message);
document.getElementById('progressWrap').style.display = 'none';
if (!currentAnalysis) document.getElementById('emptyState').style.display = 'block';
else document.getElementById('results').style.display = 'block';
} finally {
setLoading(false);
}
}
async function runAnalysisFull(text, model) {
// Proxy buffers SSE until stream closes, so we use a polling sidecar for live pill updates.
// The SSE response still delivers the final result β we just don't rely on it for chip state.
const jobId = crypto.randomUUID();
const wordCount = text.split(/\s+/).length;
// Fetch avg expected duration so we can animate the progress bar in real time
let avgSecs = 60;
try {
const sr = await fetch(`api/stats?text_len=${wordCount}`);
if (sr.ok) { const sd = await sr.json(); avgSecs = sd.avg_seconds || 60; }
} catch {}
// Animate progress bar from 0 β 95% over avgSecs, then snap to 100% on completion
const barStart = Date.now();
let barDone = false;
function animateBar() {
if (barDone) return;
const pct = Math.min(95, ((Date.now() - barStart) / 1000 / avgSecs) * 100);
document.getElementById('progressBarFill').style.width = pct + '%';
requestAnimationFrame(animateBar);
}
requestAnimationFrame(animateBar);
// Poll /api/progress every 500ms and update pills
let pollTimer = null;
let pollActive = true;
function stopPolling() {
pollActive = false;
if (pollTimer) { clearTimeout(pollTimer); pollTimer = null; }
}
async function poll() {
if (!pollActive) return;
try {
const r = await fetch(`api/progress/${jobId}`);
if (r.ok) {
const st = await r.json();
const doneCount = st.dims_done.length;
// Label: show completion count
if (doneCount < st.total) {
document.getElementById('loadingLabelMain').textContent =
`${doneCount} / ${st.total} dimensions complete`;
}
// Update pill states
st.dim_order.forEach((dim, i) => {
const pill = document.getElementById(`pstep-${i}`);
if (!pill) return;
if (st.dims_done.includes(dim)) {
pill.classList.remove('active'); pill.classList.add('done');
} else if (st.dims_active.includes(dim) && !pill.classList.contains('done')) {
pill.classList.add('active');
}
});
}
} catch {}
if (pollActive) pollTimer = setTimeout(poll, 500);
}
// Light up all chips immediately β parallel mode activates all at once
document.querySelectorAll('.progress-step').forEach(el => el.classList.add('active'));
// Start polling after a 300ms grace period so the job is registered on the backend
pollTimer = setTimeout(poll, 300);
// Fire the SSE stream β job_id in body (proxy strips query params from POST)
const resp = await fetch('api/analyze/stream', {
method: 'POST', headers: apiHeaders(),
body: JSON.stringify({text, extraction_mode: 'full', model, job_id: jobId}),
});
if (resp.status === 401) { stopPolling(); promptForKey(); throw new Error('API key required'); }
if (!resp.ok) { stopPolling(); const e = await resp.json(); throw new Error(_errStr(e.detail) || 'Analysis failed'); }
const reader = resp.body.getReader();
const decoder = new TextDecoder();
let buf = '';
let resultEvt = null;
while (true) {
const {done, value} = await reader.read();
if (done) break;
buf += decoder.decode(value, {stream: true});
const parts = buf.split('\n\n');
buf = parts.pop();
for (const part of parts) {
if (!part.startsWith('data: ')) continue;
let evt;
try { evt = JSON.parse(part.slice(6)); } catch { continue; }
if (evt.type === 'result') { resultEvt = evt; }
else if (evt.type === 'error') { stopPolling(); throw new Error(evt.message); }
}
}
stopPolling();
barDone = true;
if (!resultEvt) throw new Error('Analysis failed. Please try again.');
// All done β snap chips and bar to 100%
document.querySelectorAll('.progress-step').forEach(el => {
el.classList.remove('active'); el.classList.add('done');
});
document.getElementById('progressBarFill').style.width = '100%';
currentAnalysis = resultEvt.data;
renderResults(currentAnalysis);
}
function setLoading(on, isFull = false) {
document.getElementById('loadingIndicator').style.display = on ? 'block' : 'none';
document.getElementById('analyzeBtn').disabled = on;
document.getElementById('loadingDetail').textContent =
isFull && on ? 'Starting 10 dimension calls...' : 'This takes 10β20s (Quick) or 60β90s (Full)';
document.getElementById('loadingLabel').textContent = 'Extracting narrative features via LLM...';
if (!on || !isFull) {
document.getElementById('progressWrap').style.display = 'none';
document.getElementById('progressSteps').innerHTML = '';
document.getElementById('progressBarFill').style.width = '0%';
}
}
function _errStr(v) {
if (v == null) return 'Unknown error';
if (typeof v === 'string') return v;
if (Array.isArray(v)) return v.map(e => e.msg || JSON.stringify(e)).join('; ');
return JSON.stringify(v);
}
function showError(msg) {
const el = document.getElementById('errorBox');
el.textContent = `Error: ${_errStr(msg)}`;
el.style.display = 'block';
}
function hideError() { document.getElementById('errorBox').style.display = 'none'; }
// βββ Result persistence ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
function saveResult(data) {
try { sessionStorage.setItem('storyscope-result', JSON.stringify(data)); } catch {}
}
function clearResult() {
sessionStorage.removeItem('storyscope-result');
}
// βββ Render results ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
function renderResults(data) {
document.getElementById('results').style.display = 'block';
document.getElementById('emptyState').style.display = 'none';
if (!data.is_demo) { const b = document.getElementById('demoBanner'); if (b) b.remove(); clearResult(); }
const h = data.scores.overall_humanness;
const cls = data.classification;
const ranked = data.ranked_features;
// Sidebar
document.getElementById('sidebarResults').style.display = 'block';
document.getElementById('humannessBig').textContent = pct(h);
document.getElementById('humannessBig').style.color = humanColor(h);
const src = cls.predicted_source;
const sb = document.getElementById('predictedSource');
sb.textContent = src || 'β';
sb.style.cssText = src ? `background:${sourceColor(src,0.2)};color:${sourceColor(src,1)};border:1px solid ${sourceColor(src,0.4)};` : '';
document.getElementById('miniConfidences').innerHTML = src ? renderConfBars(cls.confidences, true) : '<span style="font-size:10px;color:var(--text-dim)">Full mode required</span>';
// Overview
document.getElementById('humannessPct').textContent = pct(h);
document.getElementById('humannessPct').style.color = humanColor(h);
document.getElementById('humannessMeter').style.width = (h*100)+'%';
document.getElementById('humannessMeter').style.background = humanColor(h);
document.getElementById('sourceDisplay').textContent = src || 'β';
document.getElementById('sourceDisplay').style.color = src ? sourceColor(src, 1) : 'var(--text-dim)';
document.getElementById('sourceSub').textContent = src ? `${pct(cls.human_probability)} human probability` : 'Run Full mode for source attribution';
const ld = data.ld_coordinates;
document.getElementById('ldCoords').innerHTML =
`<span style="font-size:22px;font-weight:800;">LD1: ${ld.ld1>0?'+':''}${ld.ld1.toFixed(2)}</span><br>`+
`<span style="font-size:12px;color:var(--text-dim)">LD2: ${ld.ld2>0?'+':''}${ld.ld2.toFixed(2)}</span>`;
document.getElementById('confidenceBars').innerHTML = src ? renderConfBars(cls.confidences, false) : '<span style="font-size:11px;color:var(--text-dim)">Source attribution requires Full mode (all 304 features).</span>';
document.getElementById('topAiFeatures').innerHTML = renderFeatureList(ranked.slice(0,5),'ai');
document.getElementById('topHumanFeatures').innerHTML = renderFeatureList([...ranked].reverse().slice(0,5),'human');
document.getElementById('keyFindings').innerHTML = buildFindings(data);
// Overview mini-map
setTimeout(() => renderPlot('plot-overview-space', data.plots.narrative_space), 50);
// Feature table
renderFeatureTable(data);
// Humanize targets
const aiFeats = ranked.filter(f => (f.humanness||1) < 0.45).slice(0,6);
document.getElementById('humanizeTargets').innerHTML = aiFeats.length
? `<div style="font-size:11px;color:var(--text-dim);margin-bottom:5px;">Will target:</div>`+
aiFeats.map(f=>`<span class="tag tag-ai" style="margin:2px;">${f.name}</span>`).join('')
: '<div style="font-size:11px;color:var(--green);">No strongly AI-elevated features found.</div>';
saveResult(data);
}
function renderFeatureTable(data) {
const tbody = document.getElementById('featureTableBody');
const perFeat = data.scores.per_feature;
const groups = {};
for (const [id, info] of Object.entries(perFeat)) {
const g = info.dimension ? info.dimension.replace(/_/g,' ') : 'Other';
if (!groups[g]) groups[g] = [];
groups[g].push({id, ...info});
}
let html = '';
for (const [group, feats] of Object.entries(groups)) {
html += `<tr class="feat-group-row"><td colspan="6">${group}</td></tr>`;
feats.sort((a,b) => (a.humanness??0.5) - (b.humanness??0.5));
for (const f of feats) {
const h = f.humanness;
const hStr = h != null ? pct(h) : 'β';
const hColor = h != null ? humanColor(h) : 'var(--text-dim)';
const tag = h == null ? '' : h < 0.4
? '<span class="tag tag-ai">AI</span>'
: h > 0.6 ? '<span class="tag tag-human">Human</span>'
: '<span class="tag tag-neutral">β</span>';
const hMean = f.human_mean != null ? f.human_mean.toFixed(2) : 'β';
const aiMean = f.ai_mean != null ? f.ai_mean.toFixed(2) : 'β';
html += `<tr>
<td><span class="feat-name-link" data-fid="${f.id}" onclick="showModal(this.dataset.fid)">${f.name}</span></td>
<td><code style="background:rgba(255,255,255,0.05);padding:1px 4px;border-radius:3px;font-size:10px;">${formatVal(f.value)}</code></td>
<td style="color:var(--human);font-size:11px;">${hMean}</td>
<td style="color:var(--ai);font-size:11px;">${aiMean}</td>
<td><span style="color:${hColor};font-weight:700;font-size:11px;">${hStr}</span></td>
<td>${tag}</td>
</tr>`;
}
}
tbody.innerHTML = html;
}
// βββ Plots βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
function renderPlot(divId, figData) {
const el = document.getElementById(divId);
if (!el || !figData) return;
Plotly.react(divId, figData.data, figData.layout, {responsive:true, displayModeBar:false});
}
function downloadPlot(divId, name) {
Plotly.downloadImage(divId, {format:'png', filename:`storyscope_${name}`, width:1200, height:700});
}
// βββ Helpers βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
function pct(v) { return v!=null ? Math.round(v*100)+'%' : 'β'; }
function humanColor(h) { return h>0.6?'var(--green)':h<0.4?'var(--red)':'var(--yellow)'; }
const SRC_COLORS = {Human:'#8B6655',Claude:'#E6634A',GPT:'#2CA02C',DeepSeek:'#9467BD',Gemini:'#1F77B4',Kimi:'#FF7F0E'};
function sourceColor(src, alpha) {
const hex = SRC_COLORS[src]||'#888';
const r=parseInt(hex.slice(1,3),16),g=parseInt(hex.slice(3,5),16),b=parseInt(hex.slice(5,7),16);
return alpha===1 ? hex : `rgba(${r},${g},${b},${alpha})`;
}
function renderConfBars(confs, mini) {
return Object.entries(confs).sort((a,b)=>b[1]-a[1]).slice(0, mini?4:6).map(([s,p])=>
`<div class="conf-row">
<span class="conf-label">${s}</span>
<div class="conf-bar"><div class="conf-fill" style="width:${p*100}%;background:${sourceColor(s,1)};height:6px;"></div></div>
<span class="conf-pct">${pct(p)}</span>
</div>`).join('');
}
function renderFeatureList(feats, side) {
return feats.map(f=>{
const h=f.humanness??0.5, c=side==='ai'?'var(--red)':'var(--green)';
return `<div style="padding:4px 0;border-bottom:1px solid var(--border);font-size:11px;">
<span style="color:${c}">β </span><span style="margin-left:5px;">${f.name}</span>
<span style="float:right;color:${c};font-weight:700;">${pct(h)}</span>
</div>`;
}).join('');
}
function buildFindings(data) {
const cls=data.classification, h=data.scores.overall_humanness, ranked=data.ranked_features;
const topAi=ranked.slice(0,3), topHum=[...ranked].reverse().slice(0,2);
const srcLine = cls.predicted_source
? `, closest to <strong style="color:${sourceColor(cls.predicted_source,1)}">${cls.predicted_source}</strong>`
: '';
return `<p>Scores <strong style="color:${humanColor(h)}">${pct(h)} human-like</strong>${srcLine}.</p><br>`
+ (topAi.length?`<p><strong>Most AI-like:</strong> ${topAi.map(f=>`<em>${f.name}</em>`).join(', ')}.</p><br>`:'')
+ (topHum.length?`<p><strong>Most human-like:</strong> ${topHum.map(f=>`<em>${f.name}</em>`).join(', ')}.</p>`:'')
+ (data.extraction_mode==='full'?`<br><p style="font-size:11px;color:var(--text-dim);">Extracted with Full mode (304 NarraBench features, 10 calls).</p>`:'')
+ (data.extraction_mode==='quick'?`<br><p style="font-size:11px;color:var(--text-dim);">Quick mode: top 30 features only. Run Full mode for source attribution.</p>`:'');
}
function formatVal(v) { return v==null?'β':String(v).replace(/_/g,' '); }
// βββ Export ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
function exportJSON() {
if (!currentAnalysis) return;
const data = {
feature_values: currentAnalysis.feature_values,
scores: {overall_humanness: currentAnalysis.scores.overall_humanness},
classification: currentAnalysis.classification,
ld_coordinates: currentAnalysis.ld_coordinates,
extraction_mode: currentAnalysis.extraction_mode,
model: currentAnalysis.model,
};
const blob = new Blob([JSON.stringify(data, null, 2)], {type:'application/json'});
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url; a.download = 'storyscope_features.json'; a.click();
URL.revokeObjectURL(url);
}
// βββ Humanize ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
async function runHumanize() {
if (!currentAnalysis) return;
const text = document.getElementById('inputText').value.trim();
if (!text) { showError('No text to humanize.'); return; }
const model = document.getElementById('humanizeModel').value;
const loadingDetail = document.getElementById('humanizeLoading').querySelector('div:not(.spinner)');
document.getElementById('humanizeLoading').style.display = 'block';
document.getElementById('humanizeBtn').disabled = true;
if (loadingDetail) loadingDetail.textContent = 'Rewriting text toward human-like patterns...';
try {
const resp = await fetch('api/transform/stream', {
method: 'POST', headers: apiHeaders(),
body: JSON.stringify({
text,
feature_values: currentAnalysis.feature_values,
ranked_features: currentAnalysis.ranked_features,
before_ld: currentAnalysis.ld_coordinates,
before_source: currentAnalysis.classification.predicted_source || null,
model,
}),
});
if (resp.status === 401) { promptForKey(); return; }
if (!resp.ok) { const e = await resp.json(); throw new Error(_errStr(e.detail) || 'Transform failed'); }
const reader = resp.body.getReader();
const decoder = new TextDecoder();
let buf = '';
while (true) {
const {done, value} = await reader.read();
if (done) break;
buf += decoder.decode(value, {stream: true});
const parts = buf.split('\n\n');
buf = parts.pop();
for (const part of parts) {
if (!part.startsWith('data: ')) continue;
let evt;
try { evt = JSON.parse(part.slice(6)); } catch { continue; }
if (evt.type === 'progress') {
if (loadingDetail) loadingDetail.textContent = evt.message;
} else if (evt.type === 'result') {
renderHumanizeResults(evt.data, text, currentAnalysis.scores, currentAnalysis.classification);
} else if (evt.type === 'error') {
throw new Error(evt.message);
}
}
}
} catch (e) {
showError(e.message);
} finally {
document.getElementById('humanizeLoading').style.display = 'none';
document.getElementById('humanizeBtn').disabled = false;
}
}
function renderHumanizeResults(result, origText, beforeScores, beforeCls) {
document.getElementById('humanizeResults').style.display = 'block';
// Use Quick-mode re-score of original features as baseline so delta is Quick-vs-Quick.
// Falls back to original overall_humanness when before_scores_quick is absent.
const bh = result.before_scores_quick?.overall_humanness ?? beforeScores.overall_humanness;
const ah = result.after_scores?.overall_humanness ?? bh;
const delta = ah - bh;
const deltaStr = (delta>=0?'+':'')+Math.round(delta*100)+'pp';
const bSrc = beforeCls.predicted_source;
const aSrc = result.after_classification?.predicted_source;
document.getElementById('beforeScores').innerHTML =
`<div class="score-big" style="color:${humanColor(bh)}">${pct(bh)}</div>
<div class="score-label">${bSrc || 'Quick mode'}</div>`;
document.getElementById('afterScores').innerHTML =
`<div class="score-big" style="color:${humanColor(ah)}">${pct(ah)}</div>
<div class="score-label">${aSrc || 'β'}</div>
<div style="font-size:13px;color:${delta>=0?'var(--green)':'var(--red)'};text-align:center;margin-top:6px;font-weight:700;">${deltaStr}</div>`;
document.getElementById('originalTextDisplay').textContent = origText.slice(0,3000)+(origText.length>3000?'...':'');
document.getElementById('transformedTextDisplay').textContent = result.transformed_text||'(no output)';
const changes = result.changes_made||[];
document.getElementById('changesList').innerHTML = changes.map(c=>`<li>${c}</li>`).join('')||'<li>No changes recorded</li>';
if (result.after_plots?.narrative_space_comparison) {
setTimeout(() => renderPlot('plot-compare-space', result.after_plots.narrative_space_comparison), 50);
}
if (result.after_plots?.feature_bars) {
setTimeout(() => renderPlot('plot-compare-bars', result.after_plots.feature_bars), 50);
}
}
function copyHumanized() {
const text = document.getElementById('transformedTextDisplay').textContent;
navigator.clipboard.writeText(text);
}
// βββ In-Flight Guide βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
async function loadInflight() {
if (inflightData) { renderInflight(inflightData); return; }
try {
const resp = await fetch('api/inflight-strategies');
inflightData = await resp.json();
renderInflight(inflightData);
} catch(e) { console.error(e); }
}
function renderInflight(data) {
document.getElementById('systemPromptBox').textContent = data.system_prompt;
document.getElementById('strategiesContainer').innerHTML = data.strategies.map(s=>`
<div class="strategy-card">
<div class="strategy-title">${s.name}</div>
<div class="strategy-eff">Effectiveness: ${s.effectiveness}</div>
<div style="font-size:12px;color:var(--text-dim);margin-bottom:6px;">${s.description}</div>
${s.steps?`<ol style="font-size:11px;color:var(--text-dim);margin-left:16px;">${s.steps.map(x=>`<li>${x}</li>`).join('')}</ol>`:''}
${s.prompt_addition?`<div style="margin-top:6px;"><div style="font-size:10px;color:var(--text-dim);margin-bottom:3px;">ADD TO PROMPT:</div><div class="prompt-box">${s.prompt_addition}</div></div>`:''}
${s.patterns_to_catch?`<div style="margin-top:6px;">${s.patterns_to_catch.map(p=>`<div style="padding:3px 0;border-bottom:1px solid var(--border);font-size:11px;"><code style="color:var(--red);">"${p.pattern}"</code> β <span style="color:var(--text-dim);">${p.replacement}</span></div>`).join('')}</div>`:''}
</div>`).join('');
document.getElementById('constraintGrid').innerHTML = data.constraints_menu.map(c=>`
<label class="constraint-item">
<input type="checkbox" value="${c.id}" data-prompt="${c.prompt}">
<div>
<div class="constraint-label">${c.label}</div>
<div class="constraint-prompt">${c.prompt.slice(0,70)}...</div>
</div>
</label>`).join('');
}
function buildConstraintPrompt() {
const checked = document.querySelectorAll('#constraintGrid input:checked');
if (!checked.length) return;
const built = 'CONSTRAINTS:\n'+Array.from(checked).map((el,i)=>`${i+1}. ${el.dataset.prompt}`).join('\n');
document.getElementById('constraintPromptBox').textContent = built;
document.getElementById('builtPrompt').style.display = 'block';
}
function copySystemPrompt() { navigator.clipboard.writeText(document.getElementById('systemPromptBox').textContent); }
function copyConstraintPrompt() { navigator.clipboard.writeText(document.getElementById('constraintPromptBox').textContent); }
// βββ Feature Rubric Modal ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
function showModal(featureId) {
if (!currentAnalysis?.scores?.per_feature?.[featureId]) return;
const pf = currentAnalysis.scores.per_feature[featureId];
const feat = {id:featureId, name:pf.name, question:pf.question, detection_method:pf.detection_method||'',
dimension:pf.dimension||'', aspect:pf.aspect||'', type:pf.type||'', values:pf.values||[]};
document.getElementById('modalTitle').textContent = feat.name;
const vals = (feat.values||[]).slice(0,8).join(', ') + ((feat.values||[]).length>8?'β¦':'');
document.getElementById('modalMeta').textContent =
[feat.dimension&&`Dimension: ${feat.dimension.replace(/_/g,' ')}`,
feat.aspect&&`Aspect: ${feat.aspect}`,
feat.type&&`Type: ${feat.type}`,
vals&&`Values: ${vals}`].filter(Boolean).join(' | ') || 'β';
document.getElementById('modalQuestion').textContent = feat.question||'';
document.getElementById('modalRubric').textContent = feat.detection_method||'No rubric available for this feature.';
document.getElementById('modalOverlay').classList.add('open');
}
function closeModal(e) {
if (!e || e.target===document.getElementById('modalOverlay') || e===null) {
document.getElementById('modalOverlay').classList.remove('open');
}
}
// βββ Result persistence + demo loader βββββββββββββββββββββββββββββββββββββββββ
(function() {
try {
const saved = sessionStorage.getItem('storyscope-result');
if (saved) {
currentAnalysis = JSON.parse(saved);
renderResults(currentAnalysis);
return;
}
} catch {}
// First visit with no saved result: load demo so all tabs are populated
fetch('api/demo').then(r => r.ok ? r.json() : null).then(data => {
if (!data || currentAnalysis) return;
currentAnalysis = data;
renderResults(data);
// Pre-fill the textarea with the demo text
const ta = document.getElementById('inputText');
if (ta && !ta.value.trim()) {
ta.value = "The morning light fell through the rain-slicked glass like a benediction, each drop catching the pale winter sun before surrendering to gravity's persistent demand. Elara pressed her palm against the cold window, feeling the ghost of warmth that lingered in the pane β a warmth that had nothing to do with the sun and everything to do with memory. Her mother had stood here too, seventeen years ago, watching the same street with the same expression: that particular amalgamation of hope and resignation that only the very tired know how to wear.\n\nShe had been avoiding the letters for three weeks. They sat on the kitchen table in a neat pile β her sister's handwriting on the top envelope, blue ink pressed hard into cream paper as if urgency could be transferred through the page itself. The house smelled of coffee and old wood, and beneath that, the faint chemical sweetness of the medication she had started taking on the advice of someone whose name she was already beginning to forget.";
try { sessionStorage.setItem('storyscope-input', ta.value); } catch {}
}
// Show a subtle demo banner
const banner = document.createElement('div');
banner.id = 'demoBanner';
banner.style.cssText = 'background:var(--card);border:1px solid var(--border);border-radius:6px;padding:8px 14px;font-size:11px;color:var(--text-dim);text-align:center;margin:8px 0;';
banner.innerHTML = 'β¬ Demo result β enter your Anthropic API key and click Analyze to run on your own text';
const resultsEl = document.getElementById('results');
if (resultsEl) resultsEl.insertBefore(banner, resultsEl.firstChild);
}).catch(() => {});
})();
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Text DeClanker β AI Authorship Analysis</title>
<script src="https://cdn.plot.ly/plotly-2.27.0.min.js"
integrity="sha384-Hl48Kq2HifOWdXEjMsKo6qxqvRLTYqIGbvlENBmkHAxZKIGCXv43H6W1jA671RzC"
crossorigin="anonymous"></script>
<style>
/* @j2aq/theme-engine β GENERATED by scripts/build-css.mjs. Do not edit by hand. */
/* Edit src/palettes.js (colors) or src/styles/_base.css (semantic layer) and rebuild. */
/* ============ Base16 palettes (generated from src/palettes.js) ============ */
[data-theme="light"],
:root {
--base00: #f8f9fa;
--base01: #ffffff;
--base02: #e5e7eb;
--base03: #9ca3af;
--base04: #6b7280;
--base05: #1f2937;
--base06: #111827;
--base07: #030712;
--base08: #dc2626;
--base09: #ea580c;
--base0A: #ca8a04;
--base0B: #16a34a;
--base0C: #0891b2;
--base0D: #2563eb;
--base0E: #9333ea;
--base0F: #a16207;
}
[data-theme="dark"] {
--base00: #111827;
--base01: #1f2937;
--base02: #374151;
--base03: #6b7280;
--base04: #9ca3af;
--base05: #e5e7eb;
--base06: #f3f4f6;
--base07: #f9fafb;
--base08: #f87171;
--base09: #fb923c;
--base0A: #fbbf24;
--base0B: #34d399;
--base0C: #22d3ee;
--base0D: #60a5fa;
--base0E: #c084fc;
--base0F: #f97316;
}
[data-theme="renkin-light"] {
--base00: #fafbfc;
--base01: #ffffff;
--base02: #e8f4f8;
--base03: #94a3b8;
--base04: #5a9aae;
--base05: #1a6b7d;
--base06: #0d5566;
--base07: #094555;
--base08: #dc2626;
--base09: #ea580c;
--base0A: #d97706;
--base0B: #00e68a;
--base0C: #00c8ff;
--base0D: #00b8d4;
--base0E: #8b5cf6;
--base0F: #06b6d4;
--chat-user-bg: #7c3aed;
--chat-user-text: #ffffff;
}
[data-theme="renkin-dark"] {
--base00: #05070d;
--base01: #0d1117;
--base02: #161b22;
--base03: #6e7681;
--base04: #8dd4e8;
--base05: #c5f5ff;
--base06: #e0ffff;
--base07: #ffffff;
--base08: #ff3b3b;
--base09: #ff9500;
--base0A: #ffea00;
--base0B: #00ff88;
--base0C: #00e1ff;
--base0D: #00ffcc;
--base0E: #c77dff;
--base0F: #00ffa3;
--chat-user-bg: #7c3aed;
--chat-user-text: #ffffff;
}
[data-theme="high-contrast-light"] {
--base00: #ffffff;
--base01: #f5f5f5;
--base02: #e0e0e0;