/* ==========================================================================
   PureWrite Tools — front-end design system
   --------------------------------------------------------------------------
   Scope: everything lives under `.pw-tool` (the shortcode container) and all
   classes carry the `pw-` prefix, so collisions with any theme are
   impossible. Color/spacing tokens are CSS custom properties on `.pw-tool`.

   Class vocabulary (shared with tools.js — keep names in sync):
   Layout : pw-wrap pw-head pw-eyebrow pw-title pw-sub pw-grid pw-panel
            pw-panel-title
   Input  : pw-textarea pw-input-row pw-counter pw-actions pw-btn
            pw-btn-primary pw-btn-ghost pw-btn-sm pw-chip pw-quota pw-slider
            pw-seg pw-seg-item pw-seg-active pw-select pw-input pw-label
   Output : pw-output pw-empty pw-result pw-gauge pw-verdict
            pw-verdict-human|mixed|ai pw-stats pw-stat pw-stat-num
            pw-sent-list pw-sent pw-sent-low|mid|high pw-reason pw-diff
            pw-del pw-ins pw-tabs pw-tab pw-tab-active pw-issue pw-issue-type
            pw-flag pw-bar pw-bar-fill pw-toast pw-loading pw-dots pw-card
            pw-hub-grid pw-hub-card pw-hub-search pw-faq-item pw-handoff-row
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens & base
   -------------------------------------------------------------------------- */

.pw-tool {
	/* Color tokens (PureWrite brand) */
	--pw-paper: #FAF7F1;
	--pw-surface: #FFFFFF;
	--pw-surface-warm: #F3EEE5;
	--pw-ink: #1B1713;
	--pw-ink-soft: #57504A;
	--pw-ink-faint: #8A817A;
	--pw-line: #E7E0D5;
	--pw-brand: #0C8A5F;
	--pw-brand-deep: #0A6E4C;
	--pw-brand-tint: #E3F2EA;
	--pw-amber: #D98A2B;
	--pw-amber-tint: #FBF0DE;
	--pw-red: #C84B3C;
	--pw-red-tint: #FBE9E6;
	--pw-sky: #3E7C8C;

	/* Typography (Google Fonts loaded via the purewrite-fonts handle) */
	--pw-font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
	--pw-font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
	--pw-font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;

	/* Shape & elevation */
	--pw-radius-card: 16px;
	--pw-radius-ctl: 12px;
	--pw-radius-sm: 8px;
	--pw-shadow-card: 0 1px 2px rgba(27, 23, 19, 0.04), 0 8px 24px -12px rgba(27, 23, 19, 0.12);
	--pw-shadow-hover: 0 2px 4px rgba(27, 23, 19, 0.05), 0 12px 32px -12px rgba(27, 23, 19, 0.18);

	/* Motion */
	--pw-ease: cubic-bezier(0.22, 1, 0.36, 1);
	--pw-dur: 0.3s;

	font-family: var(--pw-font-body);
	font-size: 16px;
	line-height: 1.625;
	color: var(--pw-ink);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

.pw-tool,
.pw-tool *,
.pw-tool *::before,
.pw-tool *::after {
	box-sizing: border-box;
}

.pw-tool h1,
.pw-tool h2,
.pw-tool h3,
.pw-tool h4,
.pw-tool p,
.pw-tool ul,
.pw-tool ol,
.pw-tool figure,
.pw-tool blockquote {
	margin: 0;
	padding: 0;
}

.pw-tool ul,
.pw-tool ol {
	list-style: none;
}

.pw-tool a {
	color: var(--pw-brand);
	text-decoration: none;
}

.pw-tool a:hover {
	color: var(--pw-brand-deep);
	text-decoration: underline;
}

.pw-tool button,
.pw-tool input,
.pw-tool select,
.pw-tool textarea {
	font-family: inherit;
	font-size: inherit;
	color: inherit;
}

.pw-tool img,
.pw-tool svg {
	max-width: 100%;
}

.pw-tool :focus-visible {
	outline: 2px solid var(--pw-brand);
	outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   2. Layout — wrap, header, grid, panels
   -------------------------------------------------------------------------- */

.pw-tool .pw-wrap {
	width: 100%;
	max-width: 1280px;
	margin: 0 auto;
	padding: 40px 0 56px;
}

.pw-tool .pw-head {
	max-width: 720px;
	margin-bottom: 28px;
}

.pw-tool .pw-eyebrow {
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.14em;
	line-height: 16px;
	text-transform: uppercase;
	color: var(--pw-brand);
	margin-bottom: 8px;
}

.pw-tool .pw-title {
	font-family: var(--pw-font-display);
	font-size: clamp(30px, 4.5vw, 44px);
	font-weight: 600;
	line-height: 1.15;
	letter-spacing: -0.02em;
	color: var(--pw-ink);
	margin-bottom: 12px;
}

.pw-tool .pw-sub {
	font-size: 17px;
	line-height: 1.65;
	color: var(--pw-ink-soft);
	max-width: 640px;
}

/* Two-column workspace: input (7) + output (5). Stacks under 860px. */
.pw-tool .pw-grid {
	display: grid;
	grid-template-columns: 7fr 5fr;
	gap: 24px;
	align-items: start;
}

/* Single-column variant (hub, wordcounter, chat…) */
.pw-tool .pw-grid.pw-grid-single {
	grid-template-columns: 1fr;
}

.pw-tool .pw-panel {
	position: relative;
	background: var(--pw-surface);
	border: 1px solid var(--pw-line);
	border-radius: var(--pw-radius-card);
	box-shadow: var(--pw-shadow-card);
	padding: 20px;
	transition: box-shadow var(--pw-dur) var(--pw-ease);
}

.pw-tool .pw-panel-title {
	font-size: 14px;
	font-weight: 600;
	color: var(--pw-ink);
	margin-bottom: 12px;
}

/* --------------------------------------------------------------------------
   3. Input controls — textarea, counter, rows, labels, inputs, selects
   -------------------------------------------------------------------------- */

.pw-tool .pw-label {
	display: block;
	font-size: 13.5px;
	font-weight: 600;
	color: var(--pw-ink);
	margin-bottom: 8px;
}

.pw-tool .pw-textarea {
	display: block;
	width: 100%;
	min-height: 320px;
	resize: vertical;
	background: var(--pw-paper);
	border: 1px solid var(--pw-line);
	border-radius: var(--pw-radius-ctl);
	padding: 16px 16px 40px;
	font-size: 15px;
	line-height: 1.7;
	color: var(--pw-ink);
	transition: border-color 0.2s var(--pw-ease), box-shadow 0.2s var(--pw-ease);
}

.pw-tool .pw-textarea::placeholder {
	color: var(--pw-ink-faint);
}

.pw-tool .pw-textarea:focus {
	outline: none;
	border-color: var(--pw-brand);
	box-shadow: 0 0 0 3px rgba(12, 138, 95, 0.15);
}

/* Compact textarea variant for form-style tools (quiz, flashcards, chat). */
.pw-tool .pw-textarea.pw-textarea-sm {
	min-height: 140px;
	padding-bottom: 16px;
}

.pw-tool .pw-counter {
	display: block;
	margin-top: -30px;
	padding-right: 14px;
	text-align: right;
	font-family: var(--pw-font-mono);
	font-size: 12px;
	font-weight: 400;
	color: var(--pw-ink-faint);
	pointer-events: none;
}

.pw-tool .pw-input-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	margin-top: 14px;
}

.pw-tool .pw-input-row > .pw-label {
	margin-bottom: 0;
}

.pw-tool .pw-input,
.pw-tool .pw-select {
	display: block;
	width: 100%;
	height: 44px;
	background: var(--pw-surface);
	border: 1px solid var(--pw-line);
	border-radius: var(--pw-radius-ctl);
	padding: 0 14px;
	font-size: 14.5px;
	color: var(--pw-ink);
	transition: border-color 0.2s var(--pw-ease), box-shadow 0.2s var(--pw-ease);
}

.pw-tool .pw-input::placeholder {
	color: var(--pw-ink-faint);
}

.pw-tool .pw-input:focus,
.pw-tool .pw-select:focus {
	outline: none;
	border-color: var(--pw-brand);
	box-shadow: 0 0 0 3px rgba(12, 138, 95, 0.15);
}

.pw-tool .pw-select {
	appearance: none;
	-webkit-appearance: none;
	padding-right: 38px;
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%2357504A' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
	cursor: pointer;
}

/* Two/three-up form field rows (citation form, email, writer). */
.pw-tool .pw-fields {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 14px;
	margin-bottom: 14px;
}

/* --------------------------------------------------------------------------
   4. Buttons & action rows
   -------------------------------------------------------------------------- */

.pw-tool .pw-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	margin-top: 16px;
}

.pw-tool .pw-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 44px;
	padding: 0 22px;
	border: 1px solid transparent;
	border-radius: var(--pw-radius-ctl);
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	white-space: nowrap;
	text-decoration: none;
	transition: background-color 0.2s var(--pw-ease), color 0.2s var(--pw-ease),
		border-color 0.2s var(--pw-ease), transform 0.1s var(--pw-ease),
		box-shadow 0.2s var(--pw-ease);
}

.pw-tool .pw-btn:active {
	transform: scale(0.97);
}

.pw-tool .pw-btn:disabled,
.pw-tool .pw-btn[disabled] {
	opacity: 0.45;
	cursor: not-allowed;
	transform: none;
}

/* Full-width primary action inside the input panel. */
.pw-tool .pw-btn-block {
	display: flex;
	width: 100%;
	min-height: 48px;
	margin-top: 16px;
}

.pw-tool .pw-btn-primary {
	background: var(--pw-brand);
	border-color: var(--pw-brand);
	color: #fff;
}

.pw-tool .pw-btn-primary:hover:not(:disabled) {
	background: var(--pw-brand-deep);
	border-color: var(--pw-brand-deep);
	color: #fff;
}

.pw-tool .pw-btn-ghost {
	background: transparent;
	border-color: transparent;
	color: var(--pw-ink-soft);
}

.pw-tool .pw-btn-ghost:hover:not(:disabled) {
	background: var(--pw-surface-warm);
	color: var(--pw-ink);
}

/* Bordered secondary ghost (results actions: copy / download / re-run). */
.pw-tool .pw-btn-outline {
	background: var(--pw-surface);
	border-color: var(--pw-line);
	color: var(--pw-ink-soft);
}

.pw-tool .pw-btn-outline:hover:not(:disabled) {
	background: var(--pw-surface-warm);
	border-color: var(--pw-line);
	color: var(--pw-ink);
}

.pw-tool .pw-btn-sm {
	min-height: 32px;
	padding: 0 12px;
	border-radius: var(--pw-radius-sm);
	font-size: 13px;
	font-weight: 600;
}

.pw-tool .pw-btn svg {
	flex: none;
}

/* --------------------------------------------------------------------------
   5. Chips, quota pill, demo badge
   -------------------------------------------------------------------------- */

.pw-tool .pw-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 12px;
	border-radius: 999px;
	background: var(--pw-brand-tint);
	color: var(--pw-brand-deep);
	font-family: var(--pw-font-mono);
	font-size: 12px;
	font-weight: 500;
	line-height: 1.5;
	white-space: nowrap;
}

.pw-tool .pw-chip[data-tone='amber'] {
	background: var(--pw-amber-tint);
	color: var(--pw-amber);
}

.pw-tool .pw-chip[data-tone='red'] {
	background: var(--pw-red-tint);
	color: var(--pw-red);
}

.pw-tool .pw-chip[data-tone='sky'] {
	background: rgba(62, 124, 140, 0.14);
	color: var(--pw-sky);
}

.pw-tool .pw-chip[data-tone='warm'] {
	background: var(--pw-surface-warm);
	color: var(--pw-ink-soft);
}

/* Free-uses quota pill — pinned top-right of the workspace panel. */
.pw-tool .pw-quota {
	position: absolute;
	top: 16px;
	right: 16px;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 12px;
	border-radius: 999px;
	background: var(--pw-surface-warm);
	color: var(--pw-ink-soft);
	font-family: var(--pw-font-mono);
	font-size: 12px;
	font-weight: 500;
	line-height: 1.5;
	white-space: nowrap;
}

.pw-tool .pw-quota[data-empty='true'],
.pw-tool .pw-quota.pw-quota-empty {
	background: var(--pw-amber-tint);
	color: var(--pw-amber);
}

/* --------------------------------------------------------------------------
   6. Segmented control (paraphraser modes, citation styles)
   -------------------------------------------------------------------------- */

.pw-tool .pw-seg {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 4px;
	padding: 4px;
	background: var(--pw-surface-warm);
	border-radius: 999px;
}

.pw-tool .pw-seg-item {
	appearance: none;
	border: none;
	background: transparent;
	border-radius: 999px;
	padding: 8px 16px;
	font-size: 13.5px;
	font-weight: 600;
	color: var(--pw-ink-soft);
	cursor: pointer;
	transition: background-color 0.2s var(--pw-ease), color 0.2s var(--pw-ease),
		box-shadow 0.2s var(--pw-ease);
}

.pw-tool .pw-seg-item:hover {
	color: var(--pw-ink);
}

.pw-tool .pw-seg-item.pw-seg-active {
	background: var(--pw-surface);
	color: var(--pw-ink);
	box-shadow: 0 1px 3px rgba(27, 23, 19, 0.12);
}

/* --------------------------------------------------------------------------
   7. Custom slider (humanizer intensity, summarizer ratio)
   --------------------------------------------------------------------------
   JS may set `--pw-pos` (0–100%) to paint the filled portion of the track;
   the track falls back to a flat warm fill when unset.
   -------------------------------------------------------------------------- */

.pw-tool .pw-slider {
	appearance: none;
	-webkit-appearance: none;
	display: block;
	width: 100%;
	height: 28px;
	margin: 4px 0 2px;
	background: transparent;
	cursor: pointer;
}

.pw-tool .pw-slider::-webkit-slider-runnable-track {
	height: 6px;
	border-radius: 999px;
	background: linear-gradient(
		to right,
		var(--pw-brand) 0%,
		var(--pw-brand) var(--pw-pos, 50%),
		var(--pw-surface-warm) var(--pw-pos, 50%),
		var(--pw-surface-warm) 100%
	);
}

.pw-tool .pw-slider::-webkit-slider-thumb {
	appearance: none;
	-webkit-appearance: none;
	width: 20px;
	height: 20px;
	margin-top: -7px;
	border-radius: 50%;
	background: var(--pw-surface);
	border: 2px solid var(--pw-brand);
	box-shadow: 0 1px 4px rgba(27, 23, 19, 0.2);
	transition: transform 0.15s var(--pw-ease);
}

.pw-tool .pw-slider::-webkit-slider-thumb:hover {
	transform: scale(1.15);
}

.pw-tool .pw-slider::-moz-range-track {
	height: 6px;
	border-radius: 999px;
	background: var(--pw-surface-warm);
}

.pw-tool .pw-slider::-moz-range-progress {
	height: 6px;
	border-radius: 999px;
	background: var(--pw-brand);
}

.pw-tool .pw-slider::-moz-range-thumb {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--pw-surface);
	border: 2px solid var(--pw-brand);
	box-shadow: 0 1px 4px rgba(27, 23, 19, 0.2);
	transition: transform 0.15s var(--pw-ease);
}

.pw-tool .pw-slider::-moz-range-thumb:hover {
	transform: scale(1.15);
}

/* Tick labels under the slider (Light / Moderate / Aggressive, 10%…50%). */
.pw-tool .pw-slider-ticks {
	display: flex;
	justify-content: space-between;
	margin-top: 4px;
	font-size: 12px;
	font-weight: 500;
	color: var(--pw-ink-faint);
}

.pw-tool .pw-slider-ticks .pw-slider-tick-active {
	color: var(--pw-brand-deep);
	font-weight: 700;
}

/* --------------------------------------------------------------------------
   8. Output panel — result wrapper & empty state
   -------------------------------------------------------------------------- */

.pw-tool .pw-output {
	min-height: 320px;
}

.pw-tool .pw-result {
	animation: pw-fade-up 0.35s var(--pw-ease) both;
}

/* Result prose (humanizer output, summaries, generated content…). */
.pw-tool .pw-result-text {
	background: var(--pw-paper);
	border: 1px solid var(--pw-line);
	border-radius: var(--pw-radius-ctl);
	padding: 16px 18px;
	font-size: 15px;
	line-height: 1.75;
	color: var(--pw-ink);
	white-space: pre-wrap;
	word-break: break-word;
}

.pw-tool .pw-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 320px;
	padding: 32px;
	text-align: center;
	background: var(--pw-paper);
	border: 2px dashed var(--pw-line);
	border-radius: var(--pw-radius-ctl);
}

.pw-tool .pw-empty svg,
.pw-tool .pw-empty .pw-empty-icon {
	width: 40px;
	height: 40px;
	color: var(--pw-ink-faint);
	opacity: 0.9;
	margin-bottom: 14px;
}

.pw-tool .pw-empty-title {
	font-size: 14px;
	font-weight: 600;
	color: var(--pw-ink-soft);
}

.pw-tool .pw-empty-hint {
	margin-top: 4px;
	max-width: 300px;
	font-size: 13px;
	line-height: 1.6;
	color: var(--pw-ink-faint);
}

/* --------------------------------------------------------------------------
   9. Score gauge (detector) — SVG arc + center numeral/label
   -------------------------------------------------------------------------- */

.pw-tool .pw-gauge {
	width: 168px;
	margin: 4px auto 16px;
	text-align: center;
}

.pw-tool .pw-gauge svg {
	display: block;
	width: 100%;
	height: auto;
	overflow: visible;
}

.pw-tool .pw-gauge .pw-gauge-track {
	stroke: var(--pw-surface-warm);
}

.pw-tool .pw-gauge .pw-gauge-fill {
	stroke: var(--pw-brand);
	stroke-linecap: round;
	transition: stroke-dashoffset 1.2s var(--pw-ease), stroke 0.4s var(--pw-ease);
}

/* Score-band tinting: 0–30 green, 31–70 amber, 71–100 red. */
.pw-tool .pw-gauge[data-band='mid'] .pw-gauge-fill {
	stroke: var(--pw-amber);
}

.pw-tool .pw-gauge[data-band='high'] .pw-gauge-fill {
	stroke: var(--pw-red);
}

.pw-tool .pw-gauge text {
	font-family: var(--pw-font-mono);
	fill: var(--pw-ink);
}

/* Center numeral (score 0–100) and the caption beneath it. */
.pw-tool .pw-gauge .pw-gauge-num {
	font-size: 40px;
	font-weight: 700;
	line-height: 1;
}

.pw-tool .pw-gauge .pw-gauge-label {
	font-family: var(--pw-font-body);
	font-size: 10.5px;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	fill: var(--pw-ink-faint);
}

/* --------------------------------------------------------------------------
   10. Verdict chips (human / mixed / ai)
   -------------------------------------------------------------------------- */

.pw-tool .pw-verdict {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 6px 16px;
	border-radius: 999px;
	font-size: 13.5px;
	font-weight: 700;
	line-height: 1.4;
}

.pw-tool .pw-verdict::before {
	content: '';
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: currentColor;
}

.pw-tool .pw-verdict-human {
	background: var(--pw-brand-tint);
	color: var(--pw-brand-deep);
}

.pw-tool .pw-verdict-mixed {
	background: var(--pw-amber-tint);
	color: var(--pw-amber);
}

.pw-tool .pw-verdict-ai {
	background: var(--pw-red-tint);
	color: var(--pw-red);
}

/* --------------------------------------------------------------------------
   11. Stats grid — mono numerals
   -------------------------------------------------------------------------- */

.pw-tool .pw-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
	gap: 12px;
	margin-top: 16px;
}

.pw-tool .pw-stat {
	background: var(--pw-surface-warm);
	border: 1px solid var(--pw-line);
	border-radius: var(--pw-radius-ctl);
	padding: 12px 14px;
	min-width: 0;
}

.pw-tool .pw-stat-num {
	display: block;
	font-family: var(--pw-font-mono);
	font-size: 26px;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: -0.01em;
	color: var(--pw-ink);
	font-variant-numeric: tabular-nums;
	word-break: break-word;
}

.pw-tool .pw-stat-label {
	display: block;
	margin-top: 2px;
	font-size: 11.5px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--pw-ink-faint);
}

/* --------------------------------------------------------------------------
   12. Sentence highlight list (detector) — scaleX sweep animation
   -------------------------------------------------------------------------- */

.pw-tool .pw-sent-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: 16px;
}

.pw-tool .pw-sent {
	position: relative;
	isolation: isolate;
	padding: 10px 14px;
	border-radius: var(--pw-radius-sm);
	font-size: 14.5px;
	line-height: 1.65;
	color: var(--pw-ink);
}

/* Tint layer sweeps in left → right; staggered by JS via animation-delay. */
.pw-tool .pw-sent::before {
	content: '';
	position: absolute;
	inset: 0;
	z-index: -1;
	border-radius: inherit;
	background: var(--pw-surface-warm);
	transform: scaleX(0);
	transform-origin: left center;
	animation: pw-sweep 0.6s var(--pw-ease) forwards;
}

/* low = likely human (green), mid = mixed (amber), high = likely AI (red). */
.pw-tool .pw-sent-low::before {
	background: var(--pw-brand-tint);
}

.pw-tool .pw-sent-mid::before {
	background: var(--pw-amber-tint);
}

.pw-tool .pw-sent-high::before {
	background: var(--pw-red-tint);
}

/* Per-sentence score badge. */
.pw-tool .pw-sent .pw-sent-score {
	float: right;
	margin-left: 12px;
	font-family: var(--pw-font-mono);
	font-size: 12px;
	font-weight: 700;
	color: var(--pw-ink-soft);
}

.pw-tool .pw-sent-low .pw-sent-score {
	color: var(--pw-brand-deep);
}

.pw-tool .pw-sent-mid .pw-sent-score {
	color: var(--pw-amber);
}

.pw-tool .pw-sent-high .pw-sent-score {
	color: var(--pw-red);
}

/* Reason chips under a flagged sentence. */
.pw-tool .pw-reason {
	display: inline-block;
	margin: 8px 6px 0 0;
	padding: 2px 10px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.7);
	border: 1px solid var(--pw-line);
	font-size: 11.5px;
	font-weight: 500;
	color: var(--pw-ink-soft);
}

/* --------------------------------------------------------------------------
   13. Diff view (humanizer) — word-level del/ins
   -------------------------------------------------------------------------- */

.pw-tool .pw-diff {
	background: var(--pw-paper);
	border: 1px solid var(--pw-line);
	border-radius: var(--pw-radius-ctl);
	padding: 16px 18px;
	font-size: 15px;
	line-height: 1.9;
	color: var(--pw-ink);
	word-break: break-word;
}

.pw-tool .pw-del {
	background: var(--pw-red-tint);
	color: var(--pw-red);
	text-decoration: line-through;
	text-decoration-thickness: 1.5px;
	border-radius: 4px;
	padding: 1px 2px;
}

.pw-tool .pw-ins {
	background: var(--pw-brand-tint);
	color: var(--pw-brand-deep);
	border-radius: 4px;
	padding: 1px 2px;
}

/* --------------------------------------------------------------------------
   14. Tabs (humanizer: Rewritten / Diff / Compare)
   -------------------------------------------------------------------------- */

.pw-tool .pw-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	border-bottom: 1px solid var(--pw-line);
	margin-bottom: 16px;
}

.pw-tool .pw-tab {
	appearance: none;
	position: relative;
	border: none;
	background: transparent;
	padding: 10px 16px;
	font-size: 13.5px;
	font-weight: 600;
	color: var(--pw-ink-soft);
	cursor: pointer;
	transition: color 0.2s var(--pw-ease);
}

.pw-tool .pw-tab::after {
	content: '';
	position: absolute;
	left: 12px;
	right: 12px;
	bottom: -1px;
	height: 2px;
	border-radius: 2px;
	background: transparent;
	transition: background-color 0.2s var(--pw-ease);
}

.pw-tool .pw-tab:hover {
	color: var(--pw-ink);
}

.pw-tool .pw-tab.pw-tab-active {
	color: var(--pw-brand-deep);
}

.pw-tool .pw-tab.pw-tab-active::after {
	background: var(--pw-brand);
}

/* --------------------------------------------------------------------------
   15. Issues list (grammar) & flagged phrases (plagiarism)
   -------------------------------------------------------------------------- */

.pw-tool .pw-issue {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 12px 14px;
	margin-bottom: 10px;
	background: var(--pw-surface);
	border: 1px solid var(--pw-line);
	border-left: 3px solid var(--pw-ink-faint);
	border-radius: var(--pw-radius-sm);
	font-size: 14px;
	line-height: 1.6;
}

.pw-tool .pw-issue[data-type='spelling'] {
	border-left-color: var(--pw-red);
}

.pw-tool .pw-issue[data-type='grammar'] {
	border-left-color: var(--pw-amber);
}

.pw-tool .pw-issue[data-type='punctuation'] {
	border-left-color: var(--pw-sky);
}

.pw-tool .pw-issue[data-type='style'] {
	border-left-color: var(--pw-ink-faint);
}

/* Small uppercase type chip on an issue row. */
.pw-tool .pw-issue-type {
	display: inline-flex;
	align-self: flex-start;
	align-items: center;
	padding: 2px 10px;
	border-radius: 999px;
	background: var(--pw-surface-warm);
	color: var(--pw-ink-soft);
	font-family: var(--pw-font-mono);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.pw-tool .pw-issue[data-type='spelling'] .pw-issue-type {
	background: var(--pw-red-tint);
	color: var(--pw-red);
}

.pw-tool .pw-issue[data-type='grammar'] .pw-issue-type {
	background: var(--pw-amber-tint);
	color: var(--pw-amber);
}

.pw-tool .pw-issue[data-type='punctuation'] .pw-issue-type {
	background: rgba(62, 124, 140, 0.14);
	color: var(--pw-sky);
}

.pw-tool .pw-issue .pw-issue-original {
	color: var(--pw-red);
	text-decoration: line-through;
}

.pw-tool .pw-issue .pw-issue-suggestion {
	color: var(--pw-brand-deep);
	font-weight: 600;
}

.pw-tool .pw-issue .pw-issue-message {
	color: var(--pw-ink-soft);
	font-size: 13px;
}

/* Flagged phrase rows (plagiarism / fact-check claims). */
.pw-tool .pw-flag {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 12px 14px;
	margin-bottom: 10px;
	background: var(--pw-red-tint);
	border: 1px solid rgba(200, 75, 60, 0.25);
	border-radius: var(--pw-radius-sm);
	font-size: 14px;
	line-height: 1.6;
}

.pw-tool .pw-flag .pw-flag-phrase {
	font-weight: 600;
	color: var(--pw-red);
}

.pw-tool .pw-flag .pw-flag-reason {
	font-size: 13px;
	color: var(--pw-ink-soft);
}

/* --------------------------------------------------------------------------
   16. Uniqueness / progress bar
   -------------------------------------------------------------------------- */

.pw-tool .pw-bar {
	position: relative;
	width: 100%;
	height: 10px;
	border-radius: 999px;
	background: var(--pw-surface-warm);
	overflow: hidden;
}

.pw-tool .pw-bar-fill {
	display: block;
	height: 100%;
	width: 0;
	border-radius: inherit;
	background: var(--pw-brand);
	transition: width 0.9s var(--pw-ease), background-color 0.4s var(--pw-ease);
}

.pw-tool .pw-bar[data-band='mid'] .pw-bar-fill {
	background: var(--pw-amber);
}

.pw-tool .pw-bar[data-band='high'] .pw-bar-fill {
	background: var(--pw-red);
}

/* --------------------------------------------------------------------------
   17. Toast (bottom-center notifications)
   --------------------------------------------------------------------------
   tools.js may mount the toast inside the container or directly on <body>;
   both placements are styled.
   -------------------------------------------------------------------------- */

.pw-tool .pw-toast,
body > .pw-toast {
	position: fixed;
	left: 50%;
	bottom: 28px;
	z-index: 99999;
	transform: translateX(-50%);
	display: flex;
	align-items: center;
	gap: 10px;
	max-width: min(90vw, 420px);
	padding: 12px 20px;
	background: var(--pw-ink, #1B1713);
	color: var(--pw-paper, #FAF7F1);
	border-radius: 12px;
	box-shadow: 0 8px 28px rgba(27, 23, 19, 0.28);
	font-family: var(--pw-font-body, 'Inter', sans-serif);
	font-size: 14px;
	font-weight: 500;
	line-height: 1.4;
	animation: pw-toast-in 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.pw-tool .pw-toast.pw-toast-out,
body > .pw-toast.pw-toast-out {
	animation: pw-toast-out 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* --------------------------------------------------------------------------
   18. Loading — 3-dot pulse (button loading state, busy panels)
   -------------------------------------------------------------------------- */

.pw-tool .pw-loading {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	color: inherit;
}

.pw-tool .pw-dots {
	display: inline-flex;
	align-items: center;
	gap: 5px;
}

.pw-tool .pw-dots::before,
.pw-tool .pw-dots::after,
.pw-tool .pw-dots > span {
	content: '';
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
	animation: pw-dot-pulse 0.9s ease-in-out infinite;
}

.pw-tool .pw-dots::before {
	animation-delay: 0s;
}

.pw-tool .pw-dots > span {
	animation-delay: 0.15s;
}

.pw-tool .pw-dots::after {
	animation-delay: 0.3s;
}

/* --------------------------------------------------------------------------
   19. Cards — generic card + related-tool cards
   -------------------------------------------------------------------------- */

.pw-tool .pw-card {
	display: block;
	background: var(--pw-surface);
	border: 1px solid var(--pw-line);
	border-radius: var(--pw-radius-card);
	box-shadow: var(--pw-shadow-card);
	padding: 20px;
	color: var(--pw-ink);
	text-decoration: none;
	transition: transform 0.25s var(--pw-ease), box-shadow 0.25s var(--pw-ease),
		border-color 0.25s var(--pw-ease);
}

.pw-tool .pw-card:hover {
	transform: translateY(-4px);
	box-shadow: var(--pw-shadow-hover);
	border-color: rgba(12, 138, 95, 0.35);
	text-decoration: none;
}

.pw-tool .pw-card .pw-card-title {
	display: block;
	font-size: 15px;
	font-weight: 600;
	color: var(--pw-ink);
	margin-bottom: 4px;
}

.pw-tool .pw-card .pw-card-text {
	display: block;
	font-size: 13px;
	line-height: 1.55;
	color: var(--pw-ink-soft);
}

/* --------------------------------------------------------------------------
   20. Hub — search, filter chips and the tool grid
   -------------------------------------------------------------------------- */

.pw-tool .pw-hub-search {
	position: relative;
	margin-bottom: 18px;
}

.pw-tool .pw-hub-search .pw-input {
	height: 52px;
	padding-left: 46px;
	font-size: 15px;
	border-radius: 999px;
	background: var(--pw-surface);
	box-shadow: var(--pw-shadow-card);
}

.pw-tool .pw-hub-search svg,
.pw-tool .pw-hub-search .pw-hub-search-icon {
	position: absolute;
	left: 18px;
	top: 50%;
	transform: translateY(-50%);
	width: 18px;
	height: 18px;
	color: var(--pw-ink-faint);
	pointer-events: none;
}

.pw-tool .pw-hub-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 16px;
	margin-top: 18px;
}

.pw-tool .pw-hub-card {
	display: flex;
	flex-direction: column;
	gap: 8px;
	background: var(--pw-surface);
	border: 1px solid var(--pw-line);
	border-radius: var(--pw-radius-card);
	box-shadow: var(--pw-shadow-card);
	padding: 20px;
	color: var(--pw-ink);
	text-decoration: none;
	transition: transform 0.25s var(--pw-ease), box-shadow 0.25s var(--pw-ease),
		border-color 0.25s var(--pw-ease);
}

.pw-tool .pw-hub-card:hover {
	transform: translateY(-4px);
	box-shadow: var(--pw-shadow-hover);
	border-color: rgba(12, 138, 95, 0.35);
	text-decoration: none;
	color: var(--pw-ink);
}

.pw-tool .pw-hub-card .pw-hub-card-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 12px;
	background: var(--pw-brand-tint);
	color: var(--pw-brand-deep);
}

.pw-tool .pw-hub-card .pw-hub-card-icon svg {
	width: 20px;
	height: 20px;
}

.pw-tool .pw-hub-card .pw-hub-card-title {
	font-size: 15.5px;
	font-weight: 600;
	color: var(--pw-ink);
}

.pw-tool .pw-hub-card .pw-hub-card-text {
	flex: 1;
	font-size: 13px;
	line-height: 1.55;
	color: var(--pw-ink-soft);
}

.pw-tool .pw-hub-card .pw-hub-card-link {
	margin-top: 6px;
	font-size: 13px;
	font-weight: 600;
	color: var(--pw-brand);
}

.pw-tool .pw-hub-card:hover .pw-hub-card-link {
	color: var(--pw-brand-deep);
}

/* --------------------------------------------------------------------------
   21. FAQ accordion items
   -------------------------------------------------------------------------- */

.pw-tool .pw-faq-item {
	background: var(--pw-surface);
	border: 1px solid var(--pw-line);
	border-radius: var(--pw-radius-ctl);
	margin-bottom: 10px;
	overflow: hidden;
}

/* Works both for <details class="pw-faq-item"> and JS-toggled divs. */
.pw-tool .pw-faq-item summary,
.pw-tool .pw-faq-item .pw-faq-question {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 16px 18px;
	font-size: 14.5px;
	font-weight: 600;
	color: var(--pw-ink);
	cursor: pointer;
	list-style: none;
}

.pw-tool .pw-faq-item summary::-webkit-details-marker {
	display: none;
}

.pw-tool .pw-faq-item summary::after,
.pw-tool .pw-faq-item .pw-faq-question::after {
	content: '+';
	flex: none;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: var(--pw-surface-warm);
	color: var(--pw-ink-soft);
	font-size: 16px;
	font-weight: 500;
	line-height: 24px;
	text-align: center;
	transition: transform 0.25s var(--pw-ease), background-color 0.25s var(--pw-ease);
}

.pw-tool .pw-faq-item[open] summary::after,
.pw-tool .pw-faq-item.pw-faq-open .pw-faq-question::after {
	content: '−';
	background: var(--pw-brand-tint);
	color: var(--pw-brand-deep);
	transform: rotate(180deg);
}

.pw-tool .pw-faq-item .pw-faq-answer {
	padding: 0 18px 16px;
	font-size: 14px;
	line-height: 1.7;
	color: var(--pw-ink-soft);
}

/* --------------------------------------------------------------------------
   22. Cross-tool handoff row (Send to Humanizer / Verify in Detector)
   -------------------------------------------------------------------------- */

.pw-tool .pw-handoff-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	margin-top: 20px;
	padding-top: 16px;
	border-top: 1px solid var(--pw-line);
}

.pw-tool .pw-handoff-row .pw-handoff-label {
	font-size: 13px;
	font-weight: 600;
	color: var(--pw-ink-faint);
	margin-right: auto;
}

/* Handoff buttons read as friendly brand-tint pills. */
.pw-tool .pw-handoff-row .pw-btn {
	background: var(--pw-brand-tint);
	color: var(--pw-brand-deep);
	border-color: transparent;
}

.pw-tool .pw-handoff-row .pw-btn:hover:not(:disabled) {
	background: var(--pw-brand);
	color: #fff;
}

/* --------------------------------------------------------------------------
   23. Compare view (humanizer: before → after scores)
   -------------------------------------------------------------------------- */

.pw-tool .pw-compare {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 14px;
}

.pw-tool .pw-compare .pw-compare-col {
	background: var(--pw-paper);
	border: 1px solid var(--pw-line);
	border-radius: var(--pw-radius-ctl);
	padding: 16px;
}

.pw-tool .pw-compare .pw-compare-heading {
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--pw-ink-faint);
	margin-bottom: 10px;
}

/* --------------------------------------------------------------------------
   24. Quiz & flashcards helpers (built from the shared vocabulary)
   -------------------------------------------------------------------------- */

.pw-tool .pw-quiz-option {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	text-align: left;
	padding: 12px 16px;
	margin-bottom: 8px;
	background: var(--pw-surface);
	border: 1px solid var(--pw-line);
	border-radius: var(--pw-radius-ctl);
	font-size: 14.5px;
	font-weight: 500;
	color: var(--pw-ink);
	cursor: pointer;
	transition: border-color 0.2s var(--pw-ease), background-color 0.2s var(--pw-ease);
}

.pw-tool .pw-quiz-option:hover {
	border-color: rgba(12, 138, 95, 0.4);
	background: var(--pw-paper);
}

.pw-tool .pw-quiz-option.pw-quiz-correct {
	background: var(--pw-brand-tint);
	border-color: var(--pw-brand);
	color: var(--pw-brand-deep);
}

.pw-tool .pw-quiz-option.pw-quiz-wrong {
	background: var(--pw-red-tint);
	border-color: var(--pw-red);
	color: var(--pw-red);
}

.pw-tool .pw-flashcard {
	perspective: 1200px;
	cursor: pointer;
}

.pw-tool .pw-flashcard-inner {
	position: relative;
	min-height: 180px;
	transition: transform 0.55s var(--pw-ease);
	transform-style: preserve-3d;
}

.pw-tool .pw-flashcard.pw-flipped .pw-flashcard-inner {
	transform: rotateY(180deg);
}

.pw-tool .pw-flashcard-face {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	text-align: center;
	background: var(--pw-surface);
	border: 1px solid var(--pw-line);
	border-radius: var(--pw-radius-card);
	box-shadow: var(--pw-shadow-card);
	font-size: 16px;
	line-height: 1.6;
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
}

.pw-tool .pw-flashcard-face.pw-flashcard-back {
	transform: rotateY(180deg);
	background: var(--pw-brand-tint);
	color: var(--pw-brand-deep);
}

/* Chat bubbles (rule-based assistant). */
.pw-tool .pw-chat-log {
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-height: 420px;
	overflow-y: auto;
	padding: 16px;
	background: var(--pw-paper);
	border: 1px solid var(--pw-line);
	border-radius: var(--pw-radius-ctl);
}

.pw-tool .pw-chat-msg {
	max-width: 82%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.6;
}

.pw-tool .pw-chat-msg.pw-chat-user {
	align-self: flex-end;
	background: var(--pw-brand);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.pw-tool .pw-chat-msg.pw-chat-bot {
	align-self: flex-start;
	background: var(--pw-surface);
	border: 1px solid var(--pw-line);
	color: var(--pw-ink);
	border-bottom-left-radius: 4px;
}

/* Demo-mode ribbon shown on demo tools (plagiarism, translator, factcheck). */
.pw-tool .pw-demo-note {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 16px;
	padding: 10px 14px;
	background: var(--pw-amber-tint);
	border: 1px solid rgba(217, 138, 43, 0.3);
	border-radius: var(--pw-radius-sm);
	font-size: 13px;
	line-height: 1.55;
	color: var(--pw-amber);
}

/* --------------------------------------------------------------------------
   25. Keyframes
   -------------------------------------------------------------------------- */

@keyframes pw-fade-up {
	from {
		opacity: 0;
		transform: translateY(16px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes pw-sweep {
	from {
		transform: scaleX(0);
	}
	to {
		transform: scaleX(1);
	}
}

@keyframes pw-toast-in {
	from {
		opacity: 0;
		transform: translate(-50%, 12px);
	}
	to {
		opacity: 1;
		transform: translate(-50%, 0);
	}
}

@keyframes pw-toast-out {
	from {
		opacity: 1;
		transform: translate(-50%, 0);
	}
	to {
		opacity: 0;
		transform: translate(-50%, 12px);
	}
}

@keyframes pw-dot-pulse {
	0%,
	100% {
		opacity: 0.3;
		transform: translateY(0);
	}
	50% {
		opacity: 1;
		transform: translateY(-3px);
	}
}

/* --------------------------------------------------------------------------
   26. Responsive — stack the workspace under 860px
   -------------------------------------------------------------------------- */

@media (max-width: 860px) {
	.pw-tool .pw-wrap {
		padding: 28px 0 40px;
	}

	.pw-tool .pw-grid {
		grid-template-columns: 1fr;
	}

	.pw-tool .pw-panel {
		padding: 16px;
	}

	.pw-tool .pw-quota {
		position: static;
		margin-bottom: 12px;
	}

	.pw-tool .pw-textarea {
		min-height: 220px;
	}

	.pw-tool .pw-stats {
		grid-template-columns: repeat(2, 1fr);
	}

	.pw-tool .pw-hub-grid {
		grid-template-columns: 1fr;
	}

	.pw-tool .pw-compare {
		grid-template-columns: 1fr;
	}

	.pw-tool .pw-title {
		font-size: 30px;
		line-height: 1.2;
	}
}

/* --------------------------------------------------------------------------
   27. Reduced motion — show end states, no sweeps/pulses
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.pw-tool *,
	.pw-tool *::before,
	.pw-tool *::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}

	.pw-tool .pw-sent::before {
		transform: scaleX(1);
	}
}

/* --------------------------------------------------------------------------
   28. Print — hide interactive chrome, keep results
   -------------------------------------------------------------------------- */

@media print {
	.pw-tool .pw-actions,
	.pw-tool .pw-btn,
	.pw-tool .pw-quota,
	.pw-tool .pw-handoff-row,
	.pw-tool .pw-seg,
	.pw-tool .pw-tabs,
	.pw-tool .pw-hub-search,
	.pw-tool .pw-slider,
	.pw-tool .pw-toast,
	.pw-tool .pw-loading {
		display: none !important;
	}

	.pw-tool .pw-panel,
	.pw-tool .pw-card,
	.pw-tool .pw-hub-card {
		box-shadow: none;
	}
}
