/**
 * CounterWords — word counter workspace.
 * Loaded only on pages that render the tool.
 *
 * ============================================================================
 * RESPONSIVE STRATEGY
 * ============================================================================
 *
 * This file is MOBILE FIRST. Everything below is the phone layout; the wider
 * layouts are layered on in responsive.css using min-width queries.
 *
 * The product is "type text, see numbers". Every layout decision below serves
 * one rule: THE COUNT IS ALWAYS VISIBLE WHILE TYPING.
 *
 * Phone (<768px) — single column
 *   - Toolbar: 3 primary actions (Paste / Copy / Clear) + More + Settings.
 *     Icon above label, so five targets fit on a 360px screen at >=44px each
 *     without a horizontal scroller. Secondary actions live in the More sheet.
 *   - Live bar: sticky under the site header, ABOVE the editor. The on-screen
 *     keyboard covers the bottom ~45% of the viewport, so a count placed below
 *     the editor is hidden at exactly the moment it matters.
 *   - Tabs: one scrollable row with snap points and short labels. Wrapping
 *     five tabs onto two ragged rows reads as broken.
 *   - Panels: below the editor, reached by scrolling or the live bar's jump
 *     button.
 *   - Dialogs: bottom sheets, thumb-reachable, with a grabber affordance.
 *
 * Tablet (768-1023px) — single column, roomier
 *   - Toolbar: all eight actions inline with side-by-side icon+label. There is
 *     width for them, so the More sheet is not needed.
 *   - Live bar stays: still a single column, so the panel is still off-screen
 *     while typing.
 *   - Stat grid goes to 3 columns; rules grid to 2.
 *
 * Desktop (>=1024px) — two columns
 *   - Editor left, analysis right, both visible at once.
 *   - Live bar is removed: it would duplicate the primary stat card sitting
 *     directly to the right of the editor.
 *   - Analysis column becomes sticky so the numbers stay put while scrolling
 *     a long document.
 *
 * ============================================================================
 */

.cw-app {
	max-width: var(--cw-editor-width);
	margin: 0 auto;
}

/* Single column by default; responsive.css promotes this to two at 1024px. */
.cw-workspace {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 16px;
	align-items: start;
}

/* ------------------------------------------------------------------ *
 * Editor column
 * ------------------------------------------------------------------ */

/*
 * No `overflow: hidden` here. It would turn this element into a scroll
 * container and stop the live bar's `position: sticky` from ever engaging.
 * Corners are clipped by the child radii instead.
 */
.cw-editor-col {
	background: var(--cw-color-card);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius);
	box-shadow: var(--cw-shadow);
	display: flex;
	flex-direction: column;
	min-width: 0;
}

/* ---------------- toolbar ---------------- */

.cw-toolbar {
	display: flex;
	gap: 6px;
	padding: 8px;
	border-bottom: 1px solid var(--cw-color-border);
	background: var(--cw-color-bg);
	border-radius: var(--cw-radius) var(--cw-radius) 0 0;
}

/*
 * Phone: stacked icon-over-label. Five of these fit a 360px viewport
 * (5 x 60px + 4 x 6px gap = 324px) while every target clears 44x44.
 */
.cw-tool-btn {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 3px;
	flex: 1 1 0;
	min-width: 0;
	min-height: 52px;
	padding: 6px 4px;
	background: var(--cw-color-card);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius-sm);
	color: var(--cw-color-secondary);
	font: inherit;
	font-size: 0.7rem;
	line-height: 1.2;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: border-color 0.12s ease, color 0.12s ease, background-color 0.12s ease, transform 0.06s ease;
}

.cw-tool-btn .cw-tool-label {
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Press feedback within the 80-150ms window; touch has no hover to rely on. */
.cw-tool-btn:active {
	transform: scale(0.96);
	background: var(--cw-color-bg);
}

@media (hover: hover) {
	.cw-tool-btn:hover {
		border-color: var(--cw-color-primary);
		color: var(--cw-color-primary);
	}
	.cw-tool-btn--danger:hover {
		border-color: var(--cw-color-danger);
		color: var(--cw-color-danger);
	}
}

/* Secondary actions are sheet-only on phones. */
.cw-tool-btn--secondary { display: none; }
.cw-tool-btn--more { display: flex; }

/* ---------------- live count bar ---------------- */

/*
 * Sticky directly beneath the site header. --cw-sticky-top resolves to the
 * header height only when the header is actually sticky (body class), so this
 * does not leave a gap when the admin turns the sticky header off.
 */
.cw-livebar {
	position: sticky;
	top: var(--cw-sticky-top);
	z-index: 20;
	display: flex;
	align-items: stretch;
	gap: 2px;
	min-height: var(--cw-livebar-height);
	padding: 6px 8px;
	background: var(--cw-color-card);
	border-bottom: 1px solid var(--cw-color-border);
}

.cw-livebar-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	flex: 1 1 0;
	min-width: 0;
	padding: 2px 4px;
	border-radius: var(--cw-radius-sm);
}

.cw-livebar-value {
	font-size: 1.05rem;
	font-weight: 800;
	color: var(--cw-color-heading);
	line-height: 1.1;
	/* Tabular figures stop the row from jittering as digits change. */
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum" 1;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}

.cw-livebar-label {
	font-size: 0.66rem;
	color: var(--cw-color-muted);
	margin-top: 1px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}

/* The page's own primary metric is emphasized. */
.cw-livebar-item.is-primary {
	background: var(--cw-color-primary);
}
.cw-livebar-item.is-primary .cw-livebar-value,
.cw-livebar-item.is-primary .cw-livebar-label {
	color: var(--cw-color-on-primary);
}

.cw-livebar-jump {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: var(--cw-tap);
	min-height: var(--cw-tap);
	margin-left: 2px;
	border-radius: var(--cw-radius-sm);
	color: var(--cw-color-muted);
	border: 1px solid var(--cw-color-border);
}
.cw-livebar-jump:hover,
.cw-livebar-jump:focus {
	color: var(--cw-color-primary);
	border-color: var(--cw-color-primary);
	text-decoration: none;
}

/* ---------------- editor ---------------- */

.cw-editor-wrap {
	position: relative;
	background: var(--cw-color-editor-bg);
	min-width: 0;
}

/* Editor and highlight backdrop must share identical box metrics. */
.cw-editor,
.cw-highlight-backdrop {
	font-family: var(--cw-font-body);
	/*
	 * Never below 16px: iOS Safari zooms the whole page when a field with a
	 * smaller font receives focus, which then breaks the sticky live bar.
	 */
	font-size: 1rem;
	line-height: 1.7;
	padding: 16px;
	border: 0;
	width: 100%;
	box-sizing: border-box;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: break-word;
	tab-size: 4;
}

.cw-editor {
	position: relative;
	display: block;
	/*
	 * Tall enough to write in, short enough that the analysis panel is a
	 * single flick away. Full screen exists for long-form work.
	 */
	min-height: clamp(200px, 34vh, 320px);
	resize: vertical;
	background: transparent;
	color: var(--cw-color-editor-text);
	z-index: 2;
	outline: none;
	overflow: auto;
}
.cw-editor::placeholder { color: var(--cw-color-muted); opacity: 0.85; }

.cw-highlight-backdrop {
	position: absolute;
	inset: 0;
	z-index: 1;
	pointer-events: none;
	color: transparent;
	overflow: auto;
	opacity: 0;
}
.cw-highlight-backdrop.is-active { opacity: 1; }
.cw-highlight-content mark {
	background: var(--cw-color-highlight);
	color: transparent;
	border-radius: 2px;
}

/* ---------------- notices under the editor ---------------- */

.cw-privacy-notice {
	margin: 0;
	padding: 10px 16px;
	font-size: 0.82rem;
	color: var(--cw-color-muted);
	background: var(--cw-color-bg);
	border-top: 1px solid var(--cw-color-border);
	display: flex;
	align-items: center;
	gap: 8px;
}
.cw-privacy-notice .cw-icon { color: var(--cw-color-success); }

.cw-status {
	margin: 0;
	padding: 6px 16px;
	min-height: 30px;
	font-size: 0.8rem;
	color: var(--cw-color-success);
	background: var(--cw-color-bg);
	border-radius: 0 0 var(--cw-radius) var(--cw-radius);
}

.cw-noscript p,
.cw-noscript {
	margin: 0;
	padding: 14px 16px;
	background: var(--cw-color-warning-bg);
	color: var(--cw-color-warning);
	font-size: 0.9rem;
}

/* ---------------- occurrence navigation ---------------- */

.cw-occ-nav {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 12px;
	background: var(--cw-color-bg);
	border-top: 1px solid var(--cw-color-border);
	flex-wrap: wrap;
}
.cw-occ-count {
	font-size: 0.85rem;
	color: var(--cw-color-muted);
	font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ *
 * Stats / analysis column
 * ------------------------------------------------------------------ */

.cw-stats-col {
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-width: 0;
}
.cw-stats-col:focus { outline: none; }

/* The deeper, tabbed analysis. A sibling of the metrics rail so the desktop
   grid can give it the full width. */
.cw-analysis {
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-width: 0;
}

/* Overview metrics: always visible, never behind a tab. */
.cw-metrics {
	background: var(--cw-color-card);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius);
	padding: 16px;
	min-width: 0;
}

.cw-primary-stat {
	background: var(--cw-color-primary);
	color: var(--cw-color-on-primary);
	border-radius: var(--cw-radius);
	padding: 16px 20px;
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 10px;
}
.cw-primary-value {
	font-size: 2.1rem;
	font-weight: 800;
	line-height: 1;
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum" 1;
}
.cw-primary-label {
	font-size: 0.98rem;
	opacity: 0.92;
}

/* ---------------- tabs ---------------- */

/*
 * Phone: a single scrollable row. The wrapper masks both edges so a partially
 * visible tab signals "there is more this way" without needing arrows.
 */
.cw-tabs-wrap {
	position: relative;
	background: var(--cw-color-card);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius);
	padding: 5px;
}

.cw-tabs {
	display: flex;
	gap: 4px;
	overflow-x: auto;
	scroll-snap-type: x proximity;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
	scroll-padding-inline: 8px;

	/*
	 * Scroll affordance. Two pairs of gradients: the `local` pair are opaque
	 * covers that travel with the content, the `scroll` pair are shadows
	 * pinned to the box. When the strip is scrolled to an end, the cover slides
	 * over that shadow and hides it — so a shadow is only visible on the side
	 * that still has tabs left to reach. No JavaScript, and it disappears
	 * entirely when everything already fits.
	 */
	background:
		linear-gradient(var(--cw-color-card), var(--cw-color-card)) left center / 16px 100% no-repeat local,
		linear-gradient(var(--cw-color-card), var(--cw-color-card)) right center / 16px 100% no-repeat local,
		radial-gradient(farthest-side at 0 50%, rgba(17, 24, 39, 0.17), rgba(17, 24, 39, 0)) left center / 14px 100% no-repeat scroll,
		radial-gradient(farthest-side at 100% 50%, rgba(17, 24, 39, 0.17), rgba(17, 24, 39, 0)) right center / 14px 100% no-repeat scroll;
}
.cw-tabs::-webkit-scrollbar { display: none; }

.cw-tab {
	flex: 0 0 auto;
	scroll-snap-align: start;
	min-height: var(--cw-tap);
	padding: 10px 14px;
	background: transparent;
	border: 0;
	border-radius: var(--cw-radius-sm);
	color: var(--cw-color-secondary);
	font: inherit;
	font-size: 0.86rem;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
	-webkit-tap-highlight-color: transparent;
	/*
	 * Deliberately NOT transitioning background-color/color here.
	 *
	 * Both resolve from theme custom properties, and animating a property
	 * whose value comes from a custom property is exactly where engines drop
	 * the re-resolution: a tab could stay painted in the previous palette
	 * after a light/dark switch. Selection should read as instant anyway;
	 * :active below still gives press feedback.
	 */
}
.cw-tab:active { background: var(--cw-color-bg); }
@media (hover: hover) {
	.cw-tab:hover { background: var(--cw-color-bg); }
}
.cw-tab.is-active {
	background: var(--cw-color-primary);
	color: var(--cw-color-on-primary);
}

/* Short label on phones, full label from 560px up (responsive.css). */
.cw-tab-text { display: none; }
.cw-tab-text-short { display: inline; }

/* ---------------- panels ---------------- */

.cw-panel {
	background: var(--cw-color-card);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius);
	padding: 16px;
	min-width: 0;
}
.cw-panel[hidden] { display: none; }
.cw-panel:focus { outline: none; }

.cw-stat-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
}
.cw-stat {
	background: var(--cw-color-bg);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius-sm);
	padding: 12px 8px;
	text-align: center;
	min-width: 0;
}
.cw-stat-value {
	display: block;
	font-size: 1.3rem;
	font-weight: 800;
	color: var(--cw-color-heading);
	line-height: 1.1;
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum" 1;
	overflow-wrap: anywhere;
}
.cw-stat-label {
	display: block;
	font-size: 0.74rem;
	color: var(--cw-color-muted);
	margin-top: 4px;
}

.cw-subhead {
	font-size: 0.98rem;
	margin: 22px 0 10px;
	color: var(--cw-color-heading);
}
.cw-subhead:first-child { margin-top: 0; }

.cw-stat-list { list-style: none; margin: 0; padding: 0; }
.cw-stat-list li {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 12px;
	padding: 10px 0;
	border-bottom: 1px solid var(--cw-color-border);
}
.cw-stat-list li:last-child { border-bottom: 0; }
.cw-li-label { color: var(--cw-color-muted); font-size: 0.88rem; }
.cw-li-value {
	font-weight: 700;
	color: var(--cw-color-heading);
	text-align: right;
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum" 1;
}

/*
 * "Longest word / sentence / paragraph" are free text, not figures. Stacking
 * them and letting them wrap beats the old single-line ellipsis, which on a
 * phone truncated the value to nothing useful.
 */
.cw-stat-list--stacked li {
	display: block;
}
.cw-stat-list--stacked .cw-li-label {
	display: block;
	margin-bottom: 2px;
}
.cw-li-value--text {
	display: block;
	text-align: left;
	font-weight: 600;
	font-size: 0.92rem;
	font-variant-numeric: normal;
	overflow-wrap: anywhere;
}

.cw-rule-summary,
.cw-note,
.cw-panel-intro {
	font-size: 0.84rem;
	color: var(--cw-color-muted);
	margin-top: 14px;
}
.cw-note { font-style: italic; }
.cw-panel-intro { margin-top: 0; margin-bottom: 14px; }
.cw-empty { color: var(--cw-color-muted); font-size: 0.9rem; margin: 0; }

/* ---------------- checkboxes ---------------- */

/*
 * The label is the target, not just the box, so the whole row is tappable and
 * comfortably clears 44px.
 */
.cw-check {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	cursor: pointer;
	font-size: 0.92rem;
	padding: 10px 0;
	min-height: var(--cw-tap);
	-webkit-tap-highlight-color: transparent;
}
.cw-check input {
	margin-top: 1px;
	width: 22px;
	height: 22px;
	accent-color: var(--cw-color-primary);
	flex: 0 0 auto;
}

/* ---------------- selection ---------------- */

.cw-selection-actions {
	margin-top: 14px;
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
}

/* ---------------- repetition ---------------- */

.cw-panel-controls { margin-bottom: 8px; }

.cw-subtabs {
	display: flex;
	gap: 6px;
	margin-bottom: 12px;
}
.cw-subtab {
	flex: 1 1 auto;
	padding: 8px 12px;
	min-height: var(--cw-tap);
	background: var(--cw-color-bg);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius-sm);
	color: var(--cw-color-secondary);
	font: inherit;
	font-size: 0.85rem;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}
.cw-subtab.is-active {
	background: var(--cw-color-primary);
	color: var(--cw-color-on-primary);
	border-color: var(--cw-color-primary);
}

/* Long phrases must scroll inside their own box, never the page. */
.cw-table-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.cw-freq-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9rem;
}
.cw-freq-table th {
	text-align: left;
	padding: 8px;
	color: var(--cw-color-muted);
	font-weight: 600;
	border-bottom: 2px solid var(--cw-color-border);
	font-size: 0.78rem;
	white-space: nowrap;
}
.cw-freq-table td {
	padding: 2px 8px;
	border-bottom: 1px solid var(--cw-color-border);
}
.cw-freq-table th:not(:first-child),
.cw-freq-table td:not(:first-child) {
	text-align: right;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

/* Tapping a word highlights it in the editor, so it needs a real target. */
.cw-word-link {
	display: block;
	width: 100%;
	background: none;
	border: 0;
	padding: 11px 0;
	min-height: var(--cw-tap);
	color: var(--cw-color-primary);
	font: inherit;
	cursor: pointer;
	text-align: left;
	overflow-wrap: anywhere;
	-webkit-tap-highlight-color: transparent;
}
.cw-word-link:hover { text-decoration: underline; }

.cw-plain-list { list-style: none; margin: 0; padding: 0; }
.cw-plain-list li {
	padding: 10px 0;
	border-bottom: 1px solid var(--cw-color-border);
	font-size: 0.9rem;
	overflow-wrap: anywhere;
}
.cw-plain-list li:last-child { border-bottom: 0; }
.cw-tag { font-weight: 700; color: var(--cw-color-heading); }

/* ---------------- warnings ---------------- */

.cw-warnings { display: flex; flex-direction: column; gap: 8px; }
.cw-warning {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	background: var(--cw-color-warning-bg);
	color: var(--cw-color-warning);
	border: 1px solid transparent;
	border-radius: var(--cw-radius-sm);
	padding: 10px 12px;
	font-size: 0.88rem;
}
.cw-warning-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cw-warning-dismiss {
	flex: 0 0 auto;
	width: var(--cw-tap);
	height: var(--cw-tap);
	margin: -8px -8px -8px 0;
	background: none;
	border: 0;
	color: inherit;
	font-size: 1.3rem;
	line-height: 1;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

/* ---------------- distribution bars ---------------- */

.cw-dist { display: flex; flex-direction: column; gap: 10px; }

/*
 * Phone: label above the bar. A three-column row squeezes the track to
 * roughly 90px, at which point the fill is unreadable as a proportion.
 */
.cw-bar-row {
	display: grid;
	grid-template-columns: 1fr auto;
	grid-template-areas:
		"label value"
		"track track";
	gap: 4px 10px;
	align-items: center;
	font-size: 0.82rem;
}
.cw-bar-label { grid-area: label; color: var(--cw-color-muted); }
.cw-bar-value {
	grid-area: value;
	text-align: right;
	font-weight: 700;
	color: var(--cw-color-heading);
	font-variant-numeric: tabular-nums;
}
.cw-bar-track {
	grid-area: track;
	background: var(--cw-color-bg);
	border: 1px solid var(--cw-color-border);
	border-radius: 999px;
	height: 12px;
	overflow: hidden;
}
.cw-bar-fill {
	display: block;
	height: 100%;
	background: var(--cw-color-primary);
	border-radius: 999px;
	transition: width 0.3s ease;
}

/* ---------------- count rules ---------------- */

.cw-rules-grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0 18px;
	margin-bottom: 14px;
}

/* ------------------------------------------------------------------ *
 * Sheets and dialogs
 *
 * One component serves both the More sheet and the Settings dialog. On phones
 * it is a bottom sheet: reachable by thumb, with a grabber and a large close
 * target. responsive.css turns it into a centered modal from 768px up.
 * ------------------------------------------------------------------ */

.cw-sheet {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: flex;
	align-items: flex-end;
	justify-content: center;
}
.cw-sheet[hidden] { display: none; }

.cw-sheet-scrim {
	position: absolute;
	inset: 0;
	/* 55% scrim: within the 40-60% band that reads as "behind is inactive". */
	background: rgba(15, 23, 42, 0.55);
	animation: cw-fade-in 0.2s ease;
}

.cw-sheet-panel {
	position: relative;
	z-index: 1;
	width: 100%;
	max-height: 85dvh;
	display: flex;
	flex-direction: column;
	background: var(--cw-color-card);
	border-radius: 16px 16px 0 0;
	box-shadow: var(--cw-shadow-lg);
	padding-bottom: var(--cw-safe-bottom);
	animation: cw-sheet-up 0.24s cubic-bezier(0.2, 0, 0, 1);
}

.cw-sheet-grabber {
	width: 40px;
	height: 4px;
	border-radius: 999px;
	background: var(--cw-color-border);
	margin: 8px auto 0;
	flex: 0 0 auto;
}

.cw-sheet-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 16px;
	border-bottom: 1px solid var(--cw-color-border);
	flex: 0 0 auto;
}
.cw-sheet-head h2 { margin: 0; font-size: 1.1rem; }

.cw-sheet-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--cw-tap);
	height: var(--cw-tap);
	flex: 0 0 auto;
	background: none;
	border: 0;
	border-radius: var(--cw-radius-sm);
	cursor: pointer;
	color: var(--cw-color-muted);
	-webkit-tap-highlight-color: transparent;
}
.cw-sheet-close:active { background: var(--cw-color-bg); }

.cw-sheet-body {
	padding: 8px 16px 16px;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	flex: 1 1 auto;
}

/* Full-width action rows inside the More sheet. */
.cw-sheet-item {
	display: flex;
	align-items: center;
	gap: 14px;
	width: 100%;
	min-height: 56px;
	padding: 12px 8px;
	background: none;
	border: 0;
	border-bottom: 1px solid var(--cw-color-border);
	color: var(--cw-color-heading);
	font: inherit;
	text-align: left;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}
.cw-sheet-item:last-child { border-bottom: 0; }
.cw-sheet-item:active { background: var(--cw-color-bg); }
.cw-sheet-item .cw-icon { color: var(--cw-color-primary); }
.cw-sheet-item-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cw-sheet-item-title { font-weight: 600; font-size: 0.98rem; }
.cw-sheet-item-desc { font-size: 0.8rem; color: var(--cw-color-muted); }

/* Settings fields */
.cw-field { margin-bottom: 16px; }
.cw-field label {
	display: block;
	font-weight: 600;
	margin-bottom: 6px;
	font-size: 0.92rem;
}
.cw-field input[type="number"] {
	width: 100%;
	padding: 12px;
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius-sm);
	background: var(--cw-color-card);
	color: var(--cw-color-text);
	/* 16px minimum again: prevents the iOS focus zoom. */
	font: inherit;
	font-size: 1rem;
	min-height: var(--cw-tap);
}
.cw-field-actions { margin: 16px 0; }

@keyframes cw-fade-in {
	from { opacity: 0; }
	to { opacity: 1; }
}
@keyframes cw-sheet-up {
	from { transform: translateY(100%); }
	to { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
	.cw-sheet-panel,
	.cw-sheet-scrim { animation: none; }
	.cw-bar-fill { transition: none; }
}

/* Stop background scroll while a sheet is open. */
body.cw-modal-open,
body.cw-sheet-open {
	overflow: hidden;
	touch-action: none;
}

/* ------------------------------------------------------------------ *
 * Save to history panel
 *
 * Styled here rather than only in account.css. This panel sits inside the
 * tool, and editor.css is guaranteed to be loaded wherever the tool renders,
 * so the field can never fall back to an unstyled browser input.
 * ------------------------------------------------------------------ */

.cw-save-panel {
	background: var(--cw-color-card);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius);
	box-shadow: var(--cw-shadow);
	padding: 20px;
	margin-top: 16px;
}

.cw-save-panel .cw-save-head {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	margin-bottom: 18px;
}
.cw-save-panel .cw-save-head .cw-icon { color: var(--cw-color-primary); margin-top: 2px; }
.cw-save-panel h2 { font-size: 1.1rem; margin: 0 0 4px; }
.cw-save-panel .cw-form-intro { margin: 0; font-size: 0.9rem; color: var(--cw-color-muted); }

.cw-save-panel .cw-save-row {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 14px;
	align-items: start;
}
.cw-save-panel .cw-field { margin: 0; }

.cw-save-panel label {
	display: block;
	font-weight: 600;
	font-size: 0.92rem;
	color: var(--cw-color-heading);
	margin-bottom: 6px;
}

.cw-save-panel input[type="text"] {
	display: block;
	width: 100%;
	padding: 12px;
	min-height: var(--cw-tap);
	border: 1px solid var(--cw-color-border);
	border-radius: var(--cw-radius-sm);
	background: var(--cw-color-card);
	color: var(--cw-color-text);
	font: inherit;
	/* 16px minimum stops iOS zooming the page on focus. */
	font-size: 1rem;
}
.cw-save-panel input[type="text"]:focus-visible { border-color: var(--cw-color-primary); }

.cw-save-panel .cw-field-hint {
	display: block;
	margin-top: 6px;
	font-size: 0.82rem;
	font-weight: 400;
	color: var(--cw-color-muted);
}

.cw-save-panel .cw-save-submit .cw-btn { width: 100%; }

/* The checkbox row is a label too, so it must not inherit the block label
   styling above. */
.cw-save-panel .cw-check {
	display: flex;
	font-weight: 400;
	margin-bottom: 0;
	margin-top: 6px;
}
.cw-save-panel .cw-check span { font-size: 0.92rem; color: var(--cw-color-text); }

@media (min-width: 640px) {
	.cw-save-panel .cw-save-row {
		grid-template-columns: minmax(0, 1fr) minmax(170px, auto);
	}
	/* Line the button up with the input, not with the label above it. */
	.cw-save-panel .cw-save-submit { padding-top: 27px; }
	.cw-save-panel .cw-save-submit .cw-btn { width: auto; }
}

/* ------------------------------------------------------------------ *
 * Full screen mode
 * ------------------------------------------------------------------ */

/*
 * dvh, not vh: on mobile browsers vh is measured against the largest possible
 * viewport, so a 100vh editor sits partly underneath the URL bar.
 */
.cw-app.cw-fullscreen {
	position: fixed;
	inset: 0;
	z-index: 1200;
	background: var(--cw-color-bg);
	max-width: none;
	margin: 0;
	padding: 10px;
	padding-bottom: calc(10px + var(--cw-safe-bottom));
	overflow: auto;
	-webkit-overflow-scrolling: touch;
}
.cw-app.cw-fullscreen .cw-workspace { height: auto; }
.cw-app.cw-fullscreen .cw-editor { min-height: 50dvh; }

/* In full screen the header is gone, so the live bar sticks to the top. */
.cw-app.cw-fullscreen .cw-livebar { top: 0; }

body.cw-fullscreen-lock { overflow: hidden; }
