/*
 * Self-contained palette so the tool looks the same inside any theme
 * (same approach as the other EducationalEngine generators).
 */
.ee-ws-app {
	--ee-ws-bg: #ffffff;
	--ee-ws-surface: #f1f5f9;
	--ee-ws-text: #1e293b;
	--ee-ws-muted: #52606d;
	--ee-ws-border: #cbd5e1;
	--ee-ws-accent: #1d4ed8;
	--ee-ws-accent-hover: #1e40af;
	--ee-ws-accent-soft: #eff6ff;
	--ee-ws-danger: #b91c1c;

	max-width: 1000px;
	margin: 0 auto 48px;
	padding: 24px;
	background: var(--ee-ws-bg);
	border: 1px solid var(--ee-ws-border);
	border-radius: 10px;
	box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
	color: var(--ee-ws-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	line-height: 1.55;
}
.ee-ws-app * { box-sizing: border-box; }
.ee-ws-app button, .ee-ws-app input, .ee-ws-app select, .ee-ws-app textarea {
	font-family: inherit; box-shadow: none; text-shadow: none; background-image: none;
}
.ee-ws-app [hidden] { display: none !important; }

.ee-ws-quota-bar {
	display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center;
	background: var(--ee-ws-surface); border: 1px solid var(--ee-ws-border); border-radius: 6px;
	padding: 10px 16px; margin-bottom: 16px; font-size: 0.9em;
}
.ee-ws-quota-label { font-weight: 700; }
.ee-ws-quota-count { color: var(--ee-ws-muted); }
.ee-ws-quota-count a { color: var(--ee-ws-accent); }

.ee-ws-tabs { display: flex; gap: 8px; margin-bottom: 20px; border-bottom: 1px solid var(--ee-ws-border); }
.ee-ws-tab {
	background: transparent !important; border: 0; border-bottom: 3px solid transparent; color: var(--ee-ws-muted) !important;
	padding: 8px 12px; font-weight: 600; cursor: pointer; margin-bottom: -1px;
}
.ee-ws-tab.is-active { color: var(--ee-ws-accent) !important; border-bottom-color: var(--ee-ws-accent); }
.ee-ws-panel { display: none; }
.ee-ws-panel.is-active { display: block; }

.ee-ws-form { max-width: 820px; }
.ee-ws-field { margin-bottom: 14px; flex: 1 1 0; min-width: 0; }
.ee-ws-field label, .ee-ws-label { display: block; font-weight: 600; font-size: 0.9em; margin-bottom: 4px; color: var(--ee-ws-text); }
.ee-ws-field input, .ee-ws-field select, .ee-ws-field textarea {
	width: 100%; padding: 8px 10px; height: auto; min-height: 40px; border: 1px solid var(--ee-ws-border); border-radius: 6px;
	background: #fff !important; color: var(--ee-ws-text) !important; font-size: 0.95em;
}
.ee-ws-row { display: flex; gap: 12px; flex-wrap: wrap; }
.ee-ws-row .ee-ws-field { min-width: 220px; }
.ee-ws-hint { font-size: 0.82em; color: var(--ee-ws-muted); margin: 4px 0 0; }
.ee-ws-hint:empty { display: none; }
.ee-ws-more { margin: 0 0 16px; }
.ee-ws-more summary { cursor: pointer; font-weight: 600; font-size: 0.9em; color: var(--ee-ws-accent); margin-bottom: 10px; }

.ee-ws-btn {
	display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 6px; cursor: pointer;
	border: 1px solid var(--ee-ws-border); background: #fff !important; color: var(--ee-ws-text) !important;
	font-weight: 600; font-size: 0.9em; text-decoration: none !important; line-height: 1.2;
}
.ee-ws-btn:hover { border-color: var(--ee-ws-accent); color: var(--ee-ws-accent) !important; }
.ee-ws-btn:focus-visible { outline: 2px solid var(--ee-ws-accent); outline-offset: 2px; }
.ee-ws-btn-primary { background: var(--ee-ws-accent) !important; border-color: var(--ee-ws-accent); color: #fff !important; padding: 10px 18px; font-size: 1em; }
.ee-ws-btn-primary:hover { background: var(--ee-ws-accent-hover) !important; color: #fff !important; }
.ee-ws-btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.ee-ws-btn-small { padding: 5px 10px; font-size: 0.82em; }
.ee-ws-cost-badge { background: rgba(255, 255, 255, 0.2); border-radius: 999px; padding: 2px 8px; font-size: 0.8em; }
.ee-ws-estimate { font-weight: 600; }

.ee-ws-status { margin: 14px 0 0; font-weight: 600; color: var(--ee-ws-accent); }
.ee-ws-status:empty { display: none; }
.ee-ws-status.is-error { color: var(--ee-ws-danger); }
.ee-ws-status.is-working::before {
	content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px;
	border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: ee-ws-spin 0.9s linear infinite;
}
@keyframes ee-ws-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ee-ws-status.is-working::before { animation: none; } }
.ee-ws-result { margin-top: 18px; }

.ee-ws-list { list-style: none; padding: 0; margin: 0 0 16px; }
.ee-ws-list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--ee-ws-border); }
.ee-ws-view-btn { background: none !important; border: 0; padding: 0; color: var(--ee-ws-accent) !important; font-weight: 600; cursor: pointer; text-align: left; }
.ee-ws-list-meta { color: var(--ee-ws-muted); font-size: 0.85em; }

.ee-ws-upsells { margin-top: 24px; }
.ee-ws-disclaimer { font-size: 0.8em; color: var(--ee-ws-muted); margin-top: 16px; }

/* Worksheet form. */
.ee-ws-types { border: 0; padding: 0; margin: 0 0 14px; }
.ee-ws-type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 14px; }
.ee-ws-check { display: flex !important; gap: 8px; align-items: flex-start; font-weight: 400 !important; font-size: 0.92em !important; margin: 2px 0 6px; cursor: pointer; }
.ee-ws-check input { width: auto !important; min-height: 0 !important; margin-top: 4px; flex: 0 0 auto; }

/* Worksheet view. */
.ee-ws-item { max-width: 900px; }
.ee-ws-item-header h3 { margin: 0 0 4px; }
.ee-ws-item-meta { color: var(--ee-ws-muted); font-size: 0.88em; margin: 0 0 4px; word-break: break-word; }
.ee-ws-upsell-source-note { font-size: 0.85em; color: var(--ee-ws-accent); margin: 0 0 4px; font-weight: 600; }
.ee-ws-permalink { font-size: 0.85em; margin: 0 0 10px; }

.ee-ws-toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 14px; padding-bottom: 12px; border-bottom: 1px solid var(--ee-ws-border); }
.ee-ws-toolbar-label { font-size: 0.82em; color: var(--ee-ws-muted); margin-left: 8px; }
.ee-ws-export-status { font-size: 0.82em; color: var(--ee-ws-muted); }
.ee-ws-export-status.is-error { color: var(--ee-ws-danger); font-weight: 600; }
.ee-ws-btn-danger:hover { border-color: var(--ee-ws-danger); color: var(--ee-ws-danger) !important; }
.ee-ws-viewswitch { display: inline-flex; margin-right: 8px; }
.ee-ws-viewswitch .ee-ws-btn { border-radius: 0; }
.ee-ws-viewswitch .ee-ws-btn:first-child { border-radius: 6px 0 0 6px; }
.ee-ws-viewswitch .ee-ws-btn:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; }
.ee-ws-viewswitch .ee-ws-btn.is-active { background: var(--ee-ws-accent) !important; border-color: var(--ee-ws-accent); color: #fff !important; }

.ee-ws-draft-box { border: 1px solid var(--ee-ws-accent); background: var(--ee-ws-accent-soft); border-radius: 8px; padding: 12px 14px; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ee-ws-draft-box p { margin: 0; flex: 1 1 260px; }
.ee-ws-continue-status { font-size: 0.85em; color: var(--ee-ws-accent); font-weight: 600; }
.ee-ws-continue-status.is-error { color: var(--ee-ws-danger); }
.ee-ws-continue-status.is-working::before, .ee-ws-section-status.is-working::before {
	content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px;
	border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: ee-ws-spin 0.9s linear infinite;
}

.ee-ws-paper { border: 1px solid var(--ee-ws-border); border-radius: 8px; padding: 18px 20px; background: #fff; }
.ee-ws-namebar { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0 0 12px; font-weight: 600; font-size: 0.92em; }
.ee-ws-namebar span { display: flex; align-items: flex-end; gap: 6px; flex: 1 1 200px; }
.ee-ws-namebar i { flex: 1; border-bottom: 1px solid var(--ee-ws-text); min-width: 80px; height: 1.1em; }
.ee-ws-intro { margin: 0 0 6px; font-style: italic; }
.ee-ws-section { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--ee-ws-border); }
.ee-ws-section-head { margin: 0 0 4px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ee-ws-type-chip { border-radius: 999px; padding: 1px 9px; font-size: 0.72em; font-weight: 700; background: var(--ee-ws-accent-soft); color: var(--ee-ws-accent); }
.ee-ws-instructions { margin: 0 0 8px; color: var(--ee-ws-muted); font-size: 0.93em; }
.ee-ws-items { margin: 0 0 6px; padding-left: 24px; }
.ee-ws-items > li { margin: 0 0 10px; }
.ee-ws-marks { color: var(--ee-ws-muted); font-size: 0.85em; white-space: nowrap; }
.ee-ws-lines { display: block; height: calc(var(--lines, 3) * 1.9em); margin: 4px 0 0; color: var(--ee-ws-muted); font-size: 0.88em;
	background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(1.9em - 1px), #94a3b8 calc(1.9em - 1px), #94a3b8 1.9em) !important; }
.ee-ws-ans { margin: 6px 0 0; padding: 6px 10px; border-left: 3px solid #16a34a; background: #f0fdf4; color: #14532d; font-size: 0.9em; border-radius: 0 6px 6px 0; }
.ee-ws-ans p { margin: 0; }
.ee-ws-steps { margin: 2px 0 4px; padding-left: 20px; }
.ee-ws-blank { display: inline-block; min-width: 7em; border-bottom: 1px solid var(--ee-ws-text); text-align: center; padding: 0 4px; }
.ee-ws-ans-inline { color: #15803d; font-weight: 700; }
.ee-ws-wordbank { border: 1px dashed var(--ee-ws-border); border-radius: 6px; padding: 6px 10px; margin: 0 0 10px; font-size: 0.92em; }
.ee-ws-wordbank b { margin-right: 6px; }
.ee-ws-match { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px 24px; }
.ee-ws-match-options { list-style: none; margin: 0; padding: 0; }
.ee-ws-match-options li, .ee-ws-seq li { margin: 0 0 8px; }
.ee-ws-match-options b, .ee-ws-seq b { display: inline-block; min-width: 1.6em; }
.ee-ws-seq { list-style: none; padding-left: 0; }
.ee-ws-box { display: inline-block; width: 1.6em; height: 1.4em; border: 1px solid var(--ee-ws-text); border-radius: 3px; vertical-align: middle; margin-right: 4px; }
.ee-ws-tf { display: inline-block; margin-left: 8px; font-weight: 600; font-size: 0.85em; color: var(--ee-ws-muted); white-space: nowrap; }
.ee-ws-scenario { background: var(--ee-ws-surface); border-radius: 6px; padding: 8px 12px; margin: 0 0 10px; font-size: 0.95em; }
.ee-ws-scenario p { margin: 0 0 6px; }
.ee-ws-scenario p:last-child { margin: 0; }
.ee-ws-table-wrap { overflow-x: auto; margin: 0 0 6px; }
.ee-ws-table { border-collapse: collapse; width: 100%; font-size: 0.92em; }
.ee-ws-table th, .ee-ws-table td { border: 1px solid var(--ee-ws-border); padding: 6px 8px; text-align: left; vertical-align: top; }
.ee-ws-table thead th { background: var(--ee-ws-surface); }
.ee-ws-table td.is-blank, .ee-ws-table th.is-blank { min-width: 8em; height: 2.6em; }
.ee-ws-planned { opacity: 0.6; }

.ee-ws-section-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.ee-ws-section-tools select, .ee-ws-section-tools input { padding: 4px 6px; border: 1px solid var(--ee-ws-border); border-radius: 6px; font-size: 0.82em; background: #fff !important; color: var(--ee-ws-text) !important; max-width: 100%; }
.ee-ws-section-tools input { flex: 1 1 160px; min-width: 0; }
.ee-ws-add-tools { margin-top: 14px; padding: 10px 12px; border: 1px dashed var(--ee-ws-border); border-radius: 8px; }
.ee-ws-add-tools > label:first-child { font-weight: 600; font-size: 0.88em; }
.ee-ws-section-status { font-size: 0.82em; color: var(--ee-ws-accent); }
.ee-ws-section-status.is-error { color: var(--ee-ws-danger); font-weight: 600; }
.ee-ws-btn-small .ee-ws-cost-badge { background: var(--ee-ws-surface); }
.ee-ws-section.is-new { box-shadow: 0 0 0 2px var(--ee-ws-accent-soft); border-radius: 6px; }

.ee-ws-notes { margin: 18px 0 0; }
.ee-ws-notes h4 { margin: 0 0 6px; }
.ee-ws-notes ul { margin: 0; padding-left: 22px; }

/* Student view: answers hidden, writing space shown. */
.ee-ws-student-only { display: none; }
.ee-ws-item.is-student .ee-ws-student-only { display: block; }
.ee-ws-item.is-student .ee-ws-ans, .ee-ws-item.is-student .ee-ws-teacher-only { display: none !important; }
.ee-ws-item.is-student .ee-ws-ans-inline { visibility: hidden; }

/* Editor. */
.ee-ws-editor { border: 1px solid var(--ee-ws-accent); border-radius: 8px; padding: 14px; background: var(--ee-ws-surface); }
.ee-ws-edit-sections { list-style: none; padding: 0; margin: 12px 0; }
.ee-ws-edit-section { background: #fff; border: 1px solid var(--ee-ws-border); border-radius: 8px; padding: 12px; margin: 0 0 12px; }
.ee-ws-edit-section > .ee-ws-edit-type { font-weight: 700; font-size: 0.8em; color: var(--ee-ws-accent); margin: 0 0 6px; }
.ee-ws-edit-items { list-style: decimal; padding-left: 24px; margin: 8px 0; }
.ee-ws-edit-item { border-top: 1px dashed var(--ee-ws-border); padding: 8px 0 4px; }
.ee-ws-edit-item .ee-ws-field { margin-bottom: 6px; }
.ee-ws-edit-item .ee-ws-row .ee-ws-field { min-width: 120px; }
.ee-ws-edit-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.ee-ws-editor-footer { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.ee-ws-editor-status { font-size: 0.85em; color: var(--ee-ws-muted); }
.ee-ws-editor-status.is-error { color: var(--ee-ws-danger); font-weight: 600; }
.ee-ws-small-field { flex: 0 1 110px !important; min-width: 90px !important; }

.ee-ws-app .screen-reader-text {
	border: 0; clip: rect(1px, 1px, 1px, 1px); clip-path: inset(50%); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; word-wrap: normal !important;
}

@media (max-width: 600px) {
	.ee-ws-app { padding: 16px; }
	.ee-ws-row .ee-ws-field, .ee-ws-edit-item .ee-ws-row .ee-ws-field { min-width: 100%; }
	.ee-ws-paper { padding: 14px 12px; }
	.ee-ws-match { grid-template-columns: minmax(0, 1fr); }
	.ee-ws-viewswitch { width: 100%; margin: 0 0 4px; }
	.ee-ws-viewswitch .ee-ws-btn { flex: 1; justify-content: center; }
	.ee-ws-items { padding-left: 20px; }
}
